/usr/include/psurface/Domains.h is in libpsurface-dev 2.0.0-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #ifndef DOMAINS_H
#define DOMAINS_H
#include "StaticVector.h"
#include <stdexcept>
#include "SurfaceParts.h"
#include "PlaneParam.h"
#include "psurfaceAPI.h"
namespace psurface {
/** A triangle containing a plane triangulation */
template <class ctype>
class PSURFACE_API DomainTriangle : public Triangle,
public PlaneParam<ctype>
{
public:
/// default constructor
DomainTriangle()
{
edgePoints[0].clear();
edgePoints[1].clear();
edgePoints[2].clear();
}
/// creates a domain triangle with an empty parametrization
DomainTriangle(int vertexIdx[3]) : Triangle(vertexIdx), PlaneParam<ctype>() {}
/// creates a domain triangle with an empty parametrization
DomainTriangle(int a, int b, int c) : Triangle(a, b, c), PlaneParam<ctype>() {}
public:
/// creates the identical parametrization
void makeOneTriangle(int a, int b, int c){
PlaneParam<ctype>::makeOneTriangle(a, b, c);
edgePoints[0].resize(2);
edgePoints[0][0] = 0;
edgePoints[0][1] = 1;
edgePoints[1].resize(2);
edgePoints[1][0] = 1;
edgePoints[1][1] = 2;
edgePoints[2].resize(2);
edgePoints[2][0] = 2;
edgePoints[2][1] = 0;
}
/**
* <b> Warning:</b> This routine might not work properly if GHOST_NODEs are present!
*/
void insertExtraEdges();
/**
*
* \bug Crashes if edgePoint array contains less than two entries.
*/
void createPointLocationStructure();
/// inverses orientation
void flip();
/** \brief Turns one third
*
* \todo The transformation of the node-domainPositions is not efficient!
*/
void rotate();
/** \brief Cyclically permute a std::vector */
template <class T>
static void rotate(std::vector<T>& vec, int offset) {
int i, s = vec.size();
T* data = &vec[0];
if (offset<0) {
int n = -offset;
T* tmp = (T*)alloca(n*sizeof(T));
for (i=0; i<n; i++)
tmp[i] = data[i];
for (i=0; i<s-n; i++)
data[i] = data[i+n];
for (i=0; i<n; i++)
data[i+s-n] = tmp[i];
} else if (offset>0) {
int n = offset;
T* tmp = (T*)alloca(n*sizeof(T));
for (i=0; i<n; i++)
tmp[i] = data[s-n+i];
for (i=s-n-1; i>=0; i--)
data[n+i] = data[i];
for (i=0; i<n; i++)
data[i] = tmp[i];
}
}
void updateEdgePoints(int oldNode, int newNode);
///
void adjustTouchingNodes();
void augmentNeighborIdx(int d) {
PlaneParam<ctype>::augmentNeighborIdx(d);
for (int i=0; i<3; i++)
for (size_t j=0; j<edgePoints[i].size(); j++)
edgePoints[i][j] += d;
}
///
int cornerNode(int i) const {
//assert(edgePoints[i][0]->isCORNER_NODE());
return edgePoints[i][0];
}
/** \brief Returns the index of an edge node resp. to its edgePoint array. */
unsigned int getDomainEdgePosition(NodeIdx cN, size_t j) const {
assert(!this->nodes[cN].isINTERIOR_NODE());
if (this->nodes[cN].isTOUCHING_NODE() || this->nodes[cN].isINTERSECTION_NODE())
return this->nodes[cN].getDomainEdgePosition();
if (this->nodes[cN].getCorner()==j)
return 0;
else if (this->nodes[cN].getCorner() == ((j+1)%3))
return edgePoints[j].size()-1;
throw std::runtime_error("domain edge position NOT found!");
}
/** assuming the domain coordinates are given as world coordinates
this routines turns them into barycentric ones. */
void installBarycentricCoordinates(){
const StaticVector<ctype,2> a = this->nodes[cornerNode(0)].domainPos();
const StaticVector<ctype,2> b = this->nodes[cornerNode(1)].domainPos();
const StaticVector<ctype,2> c = this->nodes[cornerNode(2)].domainPos();
PlaneParam<ctype>::installBarycentricCoordinates(a, b, c);
}
/**@name debug code */
//@{
/// prints info about the triangle (to stdout)
void print(bool showEdgePoints=false, bool showParamEdges=false, bool showNodes=false) const;
/// checks the triangle for internal consistency
void checkConsistency(const char* where) const;
//@}
/// a list of all nodes that are located exactly on the boundary of the triangle
std::tr1::array<std::vector<NodeIdx>, 3> edgePoints;
/// the patch number
int patch;
};
} // namespace psurface
#endif
|