10 for (
unsigned int i = 0; i < size; ++i) {
11 unsigned int iPlusOne = (i + 1) % size;
15 sum += edge[0] * edge[1];
17 if (sum <= 0.0)
return;
27 unsigned int iPlusOne = (i + 1) % numVertices;
28 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
33 double vectorProduct = edge0[0] * edge1[1] - edge0[1] * edge1[0];
35 return (vectorProduct < 0.0);
39 return a[0] * b[1] - a[1] * b[0];
48 return std::abs(r) < 1e-10;
60 unsigned int i,
unsigned int j,
unsigned int k,
unsigned int l)
const {
67 if (numVertices < 5)
return false;
70 unsigned int iPlusOne = (i + 1) % numVertices;
71 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
78 for (
unsigned int j = iPlusOne + 1; j < iPlusOne + numVertices - 3; ++j) {
79 unsigned int k = (j % numVertices);
80 unsigned int kPlusOne = ((k + 1) % numVertices);
100 double angle = std::acos((a[0] * b[0] + a[1] * b[1]) / lengthA / lengthB);
101 if (a[0] * b[1] - a[1] * b[0] < 0.0) angle += M_PI;
110 return edge0[0] * edge1[0] + edge0[1] * edge1[1];
114 return a[0] * b[0] + a[1] * b[1];
118 unsigned int i,
unsigned int j,
unsigned int jPlusOne,
unsigned int jMinusOne)
const {
129 unsigned int iMinusTwo = (i + size - 2) % size;
130 unsigned int iMinusOne = (i + size - 1) % size;
131 unsigned int iPlusOne = (i + 1) % size;
132 unsigned int iPlusTwo = (i + 2) % size;
139 return (convex && isInsideCone1 && isInsideCone2 && notCrossed);
144 std::vector<unsigned int> ears;
146 for (
unsigned int i = 0; i < size; ++i) {
157 unsigned int previous = (i + numVertices - 1) % numVertices;
158 unsigned int next = (i + 1) % numVertices;
167 double angle01 = std::acos(-(edge0[0] * edge1[0] + edge0[1] * edge1[1]) / length0 / length1);
168 double angle12 = std::acos(-(edge1[0] * edge2[0] + edge1[1] * edge2[1]) / length1 / length2);
169 double angle20 = M_PI - angle01 - angle12;
171 return std::min(std::min(angle01, angle12), angle20);
175 unsigned int numEars = ears.size();
178 unsigned int earWithMaxMinAngle = 0;
180 for (
unsigned int i = 1; i < numEars; ++i) {
183 if (angle > maxMinAngle) {
185 earWithMaxMinAngle = i;
189 return ears[earWithMaxMinAngle];
196 while (numVertices > 3) {
199 unsigned int next = (bestEar + 1) % numVertices;
200 unsigned int previous = (bestEar + numVertices - 1) % numVertices;
ippl::Vector< T, Dim > Vector_t
double getAngleBetweenEdges(const Vector_t< double, 3 > &a, const Vector_t< double, 3 > &b)
double dotProduct(const Vector_t< double, 3 > &a, const Vector_t< double, 3 > &b)
std::vector< mslang::Triangle > getTriangles() const
bool isPointInsideCone(unsigned int i, unsigned int j, unsigned int jPlusOne, unsigned int jMinusOne) const
std::vector< Vector_t< double, 3 > > vertices_m
bool isConvex(unsigned int i) const
unsigned int selectBestEar(std::vector< unsigned int > &ears) const
bool lineSegmentTouchesOrCrossesLine(unsigned int i, unsigned int j, unsigned int k, unsigned int l) const
Mesher(std::vector< Vector_t< double, 3 > > &vertices)
std::vector< unsigned int > findAllEars() const
double dotProduct(unsigned int i, unsigned int j, const Vector_t< double, 3 > &pt) const
double computeMinimumAngle(unsigned int i) const
bool isPointOnLine(unsigned int i, unsigned int j, const Vector_t< double, 3 > &pt) const
double crossProduct(const Vector_t< double, 3 > &a, const Vector_t< double, 3 > &b) const
bool isPotentialEdgeIntersected(unsigned int i) const
std::vector< mslang::Triangle > triangles_m
bool isPointRightOfLine(unsigned int i, unsigned int j, const Vector_t< double, 3 > &pt) const
bool isEar(unsigned int i) const
double euclidean_norm2D(Vector_t< double, 3 > v)
Vector_t< double, 3 > center_m
bool doesIntersect(const BoundingBox2D &bb) const
std::vector< Vector_t< double, 3 > > nodes_m