43Foam::face::calcEdgeVectors(
const UList<point>&
points)
const
46 auto& edgeVecs = tedgeVecs.ref();
51 edgeVecs[i].normalise();
58Foam::label Foam::face::mostConcaveAngle
72 const vector& leftEdge = edges[rcIndex(i)];
73 const vector& rightEdge = edges[i];
75 vector edgeNormal = (rightEdge ^ leftEdge);
78 scalar edgeCos = (leftEdge & rightEdge);
79 scalar edgeAngle =
acos(
clamp(edgeCos, -1, 1));
83 if ((edgeNormal &
n) > 0)
106Foam::label Foam::face::split
108 const face::splitMode
mode,
116 const label oldIndices = (triI + quadI);
121 <<
"Serious problem: asked to split a face with < 3 vertices"
124 else if (size() == 3)
127 if (
mode == COUNTTRIANGLE ||
mode == COUNTQUAD)
133 triFaces[triI++] = *
this;
136 else if (size() == 4)
138 if (
mode == COUNTTRIANGLE)
142 if (
mode == COUNTQUAD)
146 else if (
mode == SPLITTRIANGLE)
152 label startIndex = mostConcaveAngle(
points, edges, minAngle);
154 label nextIndex = fcIndex(startIndex);
155 label splitIndex = fcIndex(nextIndex);
159 triFace[0] = operator[](startIndex);
160 triFace[1] = operator[](nextIndex);
161 triFace[2] = operator[](splitIndex);
165 triFace[0] = operator[](splitIndex);
166 triFace[1] = operator[](fcIndex(splitIndex));
167 triFace[2] = operator[](startIndex);
173 quadFaces[quadI++] = *
this;
183 label startIndex = mostConcaveAngle(
points, edges, minAngle);
185 scalar bisectAngle = minAngle/2;
186 const vector& rightEdge = edges[startIndex];
193 label index = fcIndex(fcIndex(startIndex));
195 label minIndex = index;
198 for (label i = 0; i < size() - 3; i++)
203 -
points[
operator[](startIndex)]
205 splitEdge.normalise();
207 const scalar splitCos = splitEdge & rightEdge;
208 const scalar splitAngle =
acos(
clamp(splitCos, -1, 1));
209 const scalar
angleDiff = fabs(splitAngle - bisectAngle);
218 index = fcIndex(index);
228 if (minIndex > startIndex)
230 diff = minIndex - startIndex;
235 diff = minIndex + size() - startIndex;
238 label nPoints1 =
diff + 1;
239 label nPoints2 = size() -
diff + 1;
242 face face1(nPoints1);
245 for (label i = 0; i < nPoints1; i++)
247 face1[i] = operator[](index);
248 index = fcIndex(index);
252 face face2(nPoints2);
255 for (label i = 0; i < nPoints2; i++)
257 face2[i] = operator[](index);
258 index = fcIndex(index);
262 face1.split(
mode,
points, triI, quadI, triFaces, quadFaces);
263 face2.split(
mode,
points, triI, quadI, triFaces, quadFaces);
266 return (triI + quadI - oldIndices);
286 const label sizeA = a.
size();
287 const label sizeB =
b.size();
302 return (a[0] ==
b[0] ? 1 : 0);
311 if (aCirc() == bCirc())
314 bCirc.setFulcrumToIterator();
324 if (!bCirc.circulate())
332 if (*aCirc != *bCirc)
344 if (!aCirc.circulate())
351 aCirc.setIteratorToFulcrum();
352 bCirc.setIteratorToFulcrum();
360 if (*aCirc != *bCirc)
372 if (!aCirc.circulate())
383 const label sizeA = a.size();
384 const label sizeB =
b.size();
394 return (a[0] ==
b[0]);
403 if (a[i] == a[j]) aOcc++;
410 if (a[i] ==
b[j]) bOcc++;
414 if (aOcc != bOcc)
return false;
425 label len =
f.size();
435 return op(
f[0], seed);
440 for (label i = 1; i < len; ++i)
454 seed = op(
f[pivot], seed);
463 seed = op(
f[pivot], seed);
479 for (label i=1; i<size(); i++)
481 if (
operator[](i) !=
operator[](ci))
483 operator[](++ci) = operator[](i);
487 if (
operator[](ci) !=
operator[](0))
501 const label
n = size();
505 for (label i=1; i < (
n+1)/2; ++i)
507 std::swap(
operator[](i),
operator[](
n-i));
545 for (label pI = 0; pI <
nPoints; ++pI)
547 const label nextPti(pI ==
nPoints-1 ? 0 : pI+1);
548 const auto& thisPoint =
points[operator[](pI)];
549 const auto& nextPoint =
points[operator[](nextPti)];
552 const vector ttc(thisPoint + nextPoint + centrePoint);
557 (thisPoint - centrePoint)
558 ^ (nextPoint - centrePoint)
567 return sumAc/(3.0*sumA);
604 for (label pI = 0; pI <
nPoints; ++pI)
606 const label nextPti(pI ==
nPoints-1 ? 0 : pI+1);
607 const auto& thisPoint =
points[operator[](pI)];
608 const auto& nextPoint =
points[operator[](nextPti)];
625 const label len = origFace.
size();
630 newFace[0] = origFace[0];
631 for (label i=1; i < len; ++i)
633 newFace[i] = origFace[len - i];
677 const point centreOldPoint = centre(oldPoints);
678 const point centreNewPoint = centre(newPoints);
688 oldPoints[
operator[](
pi)],
689 oldPoints[
operator[](
pi + 1)]
695 newPoints[
operator[](
pi)],
696 newPoints[
operator[](
pi + 1)]
704 oldPoints[
operator[](
nPoints-1)],
705 oldPoints[
operator[](0)]
711 newPoints[
operator[](
nPoints-1)],
712 newPoints[
operator[](0)]
738 const point ctr = centre(
p);
747 p[
operator[](fcIndex(i))],
759 const label nVerts = verts.
size();
764 theEdges.back().first() = verts.back();
765 theEdges.back().second() = verts.front();
767 for (label verti = 0; verti < nVerts - 1; ++verti)
769 theEdges[verti].first() = verts[verti];
770 theEdges[verti].second() = verts[verti + 1];
780 const label nVerts = verts.
size();
785 theEdges.front().first() = verts.front();
786 theEdges.front().second() = verts.back();
788 for (label verti = 1; verti < nVerts; ++verti)
790 theEdges[verti].first() = verts[nVerts - verti];
791 theEdges[verti].second() = verts[nVerts - verti - 1];
807 if (
e.second() == nextLabel(idx))
812 if (
e.second() == prevLabel(idx))
829 if (
e.second() == nextLabel(idx))
834 if (
e.second() == prevLabel(idx))
861 return split(SPLITTRIANGLE,
points, triI, quadI, triFaces, quadFaces);
875 return split(COUNTQUAD,
points, triI, quadI, triFaces, quadFaces);
888 return split(SPLITQUAD,
points, triI, quadI, triFaces, quadFaces);
895 const label nVerts = verts.
size();
898 label longest = nVerts - 1;
902 for (label edgei = 0; edgei < nVerts - 1; ++edgei)
904 scalar edgeLen =
pts[verts[edgei]].distSqr(
pts[verts[edgei+1]]);
906 if (longestLen < edgeLen)
909 longestLen = edgeLen;
constexpr scalar pi(M_PI)
void setFulcrumToIterator()
Set the fulcrum to the current position of the iterator.
bool circulate(const CirculatorBase::direction dir=CirculatorBase::NONE)
Circulate around the list in the given direction.
void setIteratorToFulcrum()
Set the iterator to the current position of the fulcrum.
Like Foam::Circulator, but with const-access iterators.
const T & first() const noexcept
Access the first element.
const T & second() const noexcept
Access the second element.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
const T & rcValue(const label i) const
Return reverse circular value (ie, previous value in the list).
T & back()
Access last element of the list, position [size()-1].
const T & fcValue(const label i) const
Return forward circular value (ie, next value in the list).
label rcIndex(const label i) const noexcept
T & front()
Access first element of the list, position [0].
label size() const noexcept
void size(const label n)
Older name for setAddressableSize.
label & operator[](const label i)
label find(const label &val) const
label fcIndex(const label i) const noexcept
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
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 triangles(const UList< point > &points, label &triI, faceList &triFaces) const
Split into triangles using existing points.
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
Return the inertia tensor, with optional reference point and density specification.
label find(const Foam::edge &e) const
Find the edge within the face.
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.
point centre(const UList< point > &points) const
Centre point of face.
pointField points(const UList< point > &pts) const
Return the points corresponding to this face.
label nextLabel(const label i) const
Next vertex on face.
label thisLabel(const label i) const
The vertex on face - identical to operator[], but with naming similar to nextLabel(),...
edgeList rcEdges() const
Return list of edges in reverse walk order.
label collapse()
Collapse face by removing duplicate vertex labels.
face reverseFace() const
Return face with reverse direction.
static bool sameVertices(const face &a, const face &b)
True if the faces have all the same vertices.
edgeList edges() const
Return list of edges in forward walk order.
vector areaNormal(const UList< point > &p) const
The area normal - with magnitude equal to area of face.
label nTriangles() const noexcept
Number of triangles after splitting.
constexpr face() noexcept=default
Default construct.
label prevLabel(const label i) const
Previous vertex on face.
static const char *const typeName
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A triangular face using a FixedList of labels corresponding to mesh vertices.
scalar sweptVol(const triangle &t) const
Return swept-volume.
vector areaNormal() const
tensor inertia(PointRef refPt=Zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
static bool split(const std::string &line, std::string &key, std::string &val)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr scalar pi(M_PI)
List< edge > edgeList
List of edge.
List< label > labelList
A List of labels.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
List< face > faceList
List of faces.
double doubleScalar
A typedef for double.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
Vector< double > doubleVector
static scalar angleDiff(scalar angle1, scalar angle2)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
triangle< point, const point & > triPointRef
A triangle using referred points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
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...