47 auto& edgeVecs = tedgeVecs.ref();
52 edgeVecs[i].normalise();
59Foam::label Foam::face::mostConcaveAngle
61 const UList<point>&
points,
73 const vector& leftEdge = edges[rcIndex(i)];
74 const vector& rightEdge = edges[i];
76 vector edgeNormal = (rightEdge ^ leftEdge);
79 scalar edgeCos = (leftEdge & rightEdge);
80 scalar edgeAngle =
acos(
max(-1.0,
min(1.0, edgeCos)));
84 if ((edgeNormal &
n) > 0)
107Foam::label Foam::face::split
109 const face::splitMode
mode,
110 const UList<point>&
points,
117 const label oldIndices = (triI + quadI);
122 <<
"Serious problem: asked to split a face with < 3 vertices"
125 else if (size() == 3)
128 if (
mode == COUNTTRIANGLE ||
mode == COUNTQUAD)
134 triFaces[triI++] = *
this;
137 else if (size() == 4)
139 if (
mode == COUNTTRIANGLE)
143 if (
mode == COUNTQUAD)
147 else if (
mode == SPLITTRIANGLE)
153 label startIndex = mostConcaveAngle(
points, edges, minAngle);
155 label nextIndex = fcIndex(startIndex);
156 label splitIndex = fcIndex(nextIndex);
160 triFace[0] = operator[](startIndex);
161 triFace[1] = operator[](nextIndex);
162 triFace[2] = operator[](splitIndex);
166 triFace[0] = operator[](splitIndex);
167 triFace[1] = operator[](fcIndex(splitIndex));
168 triFace[2] = operator[](startIndex);
174 quadFaces[quadI++] = *
this;
184 label startIndex = mostConcaveAngle(
points, edges, minAngle);
186 scalar bisectAngle = minAngle/2;
187 const vector& rightEdge = edges[startIndex];
194 label index = fcIndex(fcIndex(startIndex));
196 label minIndex = index;
199 for (label i = 0; i < size() - 3; i++)
204 -
points[
operator[](startIndex)]
206 splitEdge.normalise();
208 const scalar splitCos = splitEdge & rightEdge;
209 const scalar splitAngle =
acos(
max(-1.0,
min(1.0, splitCos)));
210 const scalar
angleDiff = fabs(splitAngle - bisectAngle);
219 index = fcIndex(index);
229 if (minIndex > startIndex)
231 diff = minIndex - startIndex;
236 diff = minIndex + size() - startIndex;
239 label nPoints1 =
diff + 1;
240 label nPoints2 = size() -
diff + 1;
243 face face1(nPoints1);
246 for (label i = 0; i < nPoints1; i++)
248 face1[i] = operator[](index);
249 index = fcIndex(index);
253 face face2(nPoints2);
256 for (label i = 0; i < nPoints2; i++)
258 face2[i] = operator[](index);
259 index = fcIndex(index);
263 face1.split(
mode,
points, triI, quadI, triFaces, quadFaces);
264 face2.split(
mode,
points, triI, quadI, triFaces, quadFaces);
267 return (triI + quadI - oldIndices);
287 const label sizeA = a.
size();
288 const label sizeB =
b.
size();
303 return (a[0] ==
b[0] ? 1 : 0);
312 if (aCirc() == bCirc())
333 if (*aCirc != *bCirc)
361 if (*aCirc != *bCirc)
384 const label sizeA = a.
size();
385 const label sizeB =
b.
size();
395 return (a[0] ==
b[0]);
404 if (a[i] == a[j]) aOcc++;
411 if (a[i] ==
b[j]) bOcc++;
415 if (aOcc != bOcc)
return false;
426 label len =
f.
size();
436 return op(
f[0], seed);
441 for (label i = 1; i < len; ++i)
455 seed = op(
f[pivot], seed);
464 seed = op(
f[pivot], seed);
480 for (label i=1; i<size(); i++)
482 if (
operator[](i) != operator[](ci))
484 operator[](++ci) = operator[](i);
488 if (
operator[](ci) !=
operator[](0))
502 const label
n = size();
506 for (label i=1; i < (
n+1)/2; ++i)
508 std::swap(
operator[](i),
operator[](
n-i));
535 for (label pI=0; pI<
nPoints; ++pI)
537 centrePoint +=
points[operator[](pI)];
544 for (label pI=0; pI<
nPoints; ++pI)
559 (
points[
operator[](pI)] - centrePoint)
560 ^ (nextPoint - centrePoint)
569 return sumAc/(3.0*sumA);
601 for (pI = 0; pI <
nPoints; ++pI)
603 centrePoint +=
p[operator[](pI)];
609 point nextPoint = centrePoint;
611 for (pI = 0; pI <
nPoints; ++pI)
615 nextPoint =
p[operator[](pI + 1)];
619 nextPoint =
p[operator[](0)];
642 const label len = origFace.
size();
647 newFace[0] = origFace[0];
648 for (label i=1; i < len; ++i)
650 newFace[i] = origFace[len - i];
694 point centreOldPoint = centre(oldPoints);
695 point centreNewPoint = centre(newPoints);
699 for (label pi=0; pi<
nPoints-1; ++pi)
705 oldPoints[
operator[](pi)],
706 oldPoints[
operator[](pi + 1)]
712 newPoints[
operator[](pi)],
713 newPoints[
operator[](pi + 1)]
721 oldPoints[
operator[](
nPoints-1)],
722 oldPoints[
operator[](0)]
728 newPoints[
operator[](
nPoints-1)],
729 newPoints[
operator[](0)]
752 ).inertia(refPt, density);
755 const point ctr = centre(
p);
764 p[
operator[](fcIndex(i))],
766 ).inertia(refPt, density);
776 const label nVerts = verts.
size();
781 theEdges.
last().first() = verts.
last();
782 theEdges.
last().second() = verts[0];
784 for (label verti = 0; verti < nVerts - 1; ++verti)
786 theEdges[verti].
first() = verts[verti];
787 theEdges[verti].second() = verts[verti + 1];
797 const label nVerts = verts.
size();
802 theEdges.
first().first() = verts[0];
803 theEdges.
first().second() = verts.
last();
805 for (label verti = 1; verti < nVerts; ++verti)
807 theEdges[verti].
first() = verts[nVerts - verti];
808 theEdges[verti].second() = verts[nVerts - verti - 1];
817 const label idx = find(
e.
first());
821 if (
e.second() == nextLabel(idx))
return 1;
822 if (
e.second() == prevLabel(idx))
return -1;
845 return split(SPLITTRIANGLE,
points, triI, quadI, triFaces, quadFaces);
859 return split(COUNTQUAD,
points, triI, quadI, triFaces, quadFaces);
872 return split(SPLITQUAD,
points, triI, quadI, triFaces, quadFaces);
879 const label nVerts = verts.
size();
882 label longest = nVerts - 1;
886 for (label edgei = 0; edgei < nVerts - 1; ++edgei)
888 scalar edgeLen =
Foam::edge(verts[edgei], verts[edgei + 1]).
mag(pts);
890 if (longestLen < edgeLen)
893 longestLen = edgeLen;
static bool split(const std::string &line, std::string &key, std::string &val)
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
bool circulate(const CirculatorBase::direction dir=CirculatorBase::NONE)
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
Like Foam::Circulator, but with const-access iterators.
scalar centre() const
Mid-point location, zero for an empty list.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Return the first element of the list.
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list)
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list)
label rcIndex(const label i) const noexcept
label size() const noexcept
The number of elements in the UList.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
label fcIndex(const label i) const noexcept
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
scalar mag(const UList< point > &pts) const
Return scalar magnitude of the edge.
const DynamicList< triPoints > triangles() const
Const access to the triangulation.
A face is a list of labels corresponding to mesh vertices.
label trianglesQuads(const UList< point > &points, label &triI, label &quadI, faceList &triFaces, faceList &quadFaces) const
Split into triangles and quads.
void flip()
Flip the face in-place.
static unsigned symmhash_code(const UList< label > &f, unsigned seed=0)
The symmetric hash value for face.
scalar sweptVol(const UList< point > &oldPoints, const UList< point > &newPoints) const
Return the volume swept out by the face when its points move.
label nTrianglesQuads(const UList< point > &points, label &nTris, label &nQuads) const
Number of triangles and quads after splitting.
static int compare(const face &a, const face &b)
Compare faces.
tensor inertia(const UList< point > &p, const point &refPt=vector::zero, scalar density=1.0) const
int edgeDirection(const Foam::edge &e) const
Test the edge direction on the face.
label longestEdge(const UList< point > &pts) const
Find the longest edge on a face.
label nextLabel(const label i) const
Next vertex on face.
label thisLabel(const label i) const
edgeList rcEdges() const
Return list of edges in reverse walk order.
label collapse()
Collapse face by removing duplicate point labels.
face reverseFace() const
Return face with reverse direction.
label nTriangles() const
Number of triangles after splitting.
static bool sameVertices(const face &a, const face &b)
Return true if the faces have the same vertices.
edgeList edges() const
Return list of edges in forward walk order.
constexpr face() noexcept=default
Default construct.
static const char *const typeName
void calcEdgeVectors() const
Calculate edge vectors.
A class for managing temporary objects.
A triangular face using a FixedList of labels corresponding to mesh vertices.
A triangle primitive used to calculate face normals and swept volumes.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr scalar pi(M_PI)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
triangle< point, const point & > triPointRef
A triangle using referred points.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
static scalar angleDiff(scalar angle1, scalar angle2)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
List< face > faceList
A List of faces.
dimensionedScalar acos(const dimensionedScalar &ds)
points setSize(newPointi)
#define forAll(list, i)
Loop across all elements in list.
Hash function class. The default definition is for primitives. Non-primitives used to hash entries on...