50 vector vec(nextPt - thisPt);
60 Foam::scalar Foam::face::edgeCos
66 label leftEdgeI = left(index);
67 label rightEdgeI = right(index);
70 return -(edges[leftEdgeI] & edges[rightEdgeI]);
74 Foam::label Foam::face::mostConcaveAngle
88 label leftEdgeI = left(i);
89 label rightEdgeI = right(i);
91 vector edgeNormal = edges[rightEdgeI] ^ edges[leftEdgeI];
93 scalar edgeCos = edges[leftEdgeI] & edges[rightEdgeI];
94 scalar edgeAngle =
acos(
max(-1.0,
min(1.0, edgeCos)));
98 if ((edgeNormal & n) > 0)
110 if (angle > maxAngle)
121 Foam::label Foam::face::split
123 const face::splitMode
mode,
131 label oldIndices = (triI + quadI);
138 "(const face::splitMode, const pointField&, label&, label&"
139 ", faceList&, faceList&)"
141 <<
"Serious problem: asked to split a face with < 3 vertices"
147 if (mode == COUNTTRIANGLE || mode == COUNTQUAD)
153 triFaces[triI++] = *
this;
156 else if (size() == 4)
158 if (mode == COUNTTRIANGLE)
162 if (mode == COUNTQUAD)
166 else if (mode == SPLITTRIANGLE)
172 label startIndex = mostConcaveAngle(points, edges, minAngle);
174 label nextIndex = fcIndex(startIndex);
175 label splitIndex = fcIndex(nextIndex);
179 triFace[0] = operator[](startIndex);
180 triFace[1] = operator[](nextIndex);
181 triFace[2] = operator[](splitIndex);
185 triFace[0] = operator[](splitIndex);
186 triFace[1] = operator[](fcIndex(splitIndex));
187 triFace[2] = operator[](startIndex);
193 quadFaces[quadI++] = *
this;
203 label startIndex = mostConcaveAngle(points, edges, minAngle);
205 scalar bisectAngle = minAngle/2;
206 vector rightEdge = edges[right(startIndex)];
213 label index = fcIndex(fcIndex(startIndex));
215 label minIndex = index;
218 for(label i = 0; i < size() - 3; i++)
222 points[
operator[](index)]
223 - points[
operator[](startIndex)]
225 splitEdge /=
Foam::mag(splitEdge) + VSMALL;
227 const scalar splitCos = splitEdge & rightEdge;
228 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
229 const scalar angleDiff = fabs(splitAngle - bisectAngle);
231 if (angleDiff < minDiff)
238 index = fcIndex(index);
248 if (minIndex > startIndex)
250 diff = minIndex - startIndex;
255 diff = minIndex + size() - startIndex;
258 label nPoints1 = diff + 1;
259 label nPoints2 = size() - diff + 1;
262 face face1(nPoints1);
265 for (label i = 0; i < nPoints1; i++)
267 face1[i] = operator[](index);
268 index = fcIndex(index);
272 face face2(nPoints2);
275 for (label i = 0; i < nPoints2; i++)
277 face2[i] = operator[](index);
278 index = fcIndex(index);
282 face1.split(mode, points, triI, quadI, triFaces, quadFaces);
283 face2.split(mode, points, triI, quadI, triFaces, quadFaces);
286 return (triI + quadI - oldIndices);
312 label sizeA = a.
size();
313 label sizeB = b.
size();
322 const label firstA = a[0];
341 label secondA = a[1];
343 if (sizeA > 1 && (secondA == firstA || firstA == a[sizeA - 1]))
358 if (Bptr == b.
size())
364 if (b[Bptr] == secondA)
381 if (b[Bptr] == secondA)
405 if (Aptr >= a.
size())
411 if (Bptr >= b.
size())
416 if (a[Aptr] != b[Bptr])
427 if (Aptr >= a.
size())
438 if (a[Aptr] != b[Bptr])
458 for (label i=1; i<size(); i++)
460 if (
operator[](i) != operator[](ci))
462 operator[](++ci) = operator[](i);
466 if (
operator[](ci) !=
operator[](0))
489 meshPoints[operator[](0)]
490 + meshPoints[operator[](1)]
491 + meshPoints[operator[](2)]
498 for (
register label pI=0; pI<
nPoints; pI++)
500 centrePoint += meshPoints[operator[](pI)];
507 for (
register label pI=0; pI<
nPoints; pI++)
509 const point& nextPoint = meshPoints[operator[]((pI + 1) % nPoints)];
514 meshPoints[
operator[](pI)]
522 (meshPoints[
operator[](pI)] - centrePoint)
523 ^ (nextPoint - centrePoint)
532 return sumAc/(3*sumA);
565 for (pI = 0; pI <
nPoints; pI++)
567 centrePoint += p[operator[](pI)];
573 point nextPoint = centrePoint;
575 for (pI = 0; pI <
nPoints; pI++)
577 if (pI < nPoints - 1)
579 nextPoint = p[operator[](pI + 1)];
583 nextPoint = p[operator[](0)];
610 for (label pointI = 1; pointI < newList.
size(); pointI++)
612 newList[pointI] = f[size() - pointI];
621 label pointInFace = -1;
626 if (f[i] == globalIndex)
649 point centreOldPoint = centre(oldPoints);
650 point centreNewPoint = centre(newPoints);
654 point nextOldPoint = centreOldPoint;
655 point nextNewPoint = centreNewPoint;
659 for (pI = 0; pI <
nPoints; pI++)
661 if (pI < nPoints - 1)
663 nextOldPoint = oldPoints[operator[](pI + 1)];
664 nextNewPoint = newPoints[operator[](pI + 1)];
668 nextOldPoint = oldPoints[operator[](0)];
669 nextNewPoint = newPoints[operator[](0)];
676 oldPoints[
operator[](pI)],
683 newPoints[
operator[](pI)],
701 for (pointI = 0; pointI < points.
size() - 1; pointI++)
703 e[pointI] =
edge(points[pointI], points[pointI + 1]);
707 e[points.
size() - 1] =
edge(points[points.
size() - 1], points[0]);
717 if (
operator[](i) == e.
start())
719 if (
operator[](rcIndex(i)) == e.
end())
724 else if (
operator[](fcIndex(i)) == e.
end())
733 else if (
operator[](i) == e.
end())
735 if (
operator[](rcIndex(i)) == e.
start())
740 else if (
operator[](fcIndex(i)) == e.
start())
773 return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
787 return split(COUNTQUAD, points, triI, quadI, triFaces, quadFaces);
800 return split(SPLITQUAD, points, triI, quadI, triFaces, quadFaces);