111 for (
label i = 1; i < splitPoints.
size(); i++)
136 else if (f[fp2] == e[1])
151 for (
label i = splitPoints.
size()-1; i > 0; --i)
179 <<
"Edge " << e <<
" not part of triangle " << f
198 static bool insertSorted
210 <<
" which is already in list of sorted vertices " 214 if (weight <= 0 || weight >= 1)
217 <<
" with illegal weight " << weight
218 <<
" into list of sorted vertices " 225 forAll(sortedVerts, sortedI)
227 scalar w = sortedWeights[sortedI];
229 if (
mag(w - weight) < SMALL)
232 <<
"Trying to insert weight " << weight <<
" which is close to" 233 <<
" existing weight " << w <<
" in " << sortedWeights
254 for (
label i = sz-1; i >= insertI; --i)
256 sortedWeights[i+1] = sortedWeights[i];
257 sortedVerts[i+1] = sortedVerts[i];
259 sortedWeights[insertI] = weight;
260 sortedVerts[insertI] = vertI;
271 const scalar minQuality,
297 localPoints[opposite0]
305 || f.
tri(surf.
points()).quality() < minQuality
334 static void markCollapsedFaces
338 const scalar minQuality,
353 label facei = eFaces[i];
355 bool isCandidate = isSliver(surf, minLen, minQuality, facei, edgeI);
360 if (faceToEdge[facei] != -1)
363 <<
"Cannot collapse face " << facei <<
" since " 364 <<
" is marked to be collapsed both to edge " 365 << faceToEdge[facei] <<
" and " << edgeI
369 faceToEdge[facei] = edgeI;
378 static void markRegion
387 if (faceToEdge[facei] == -1 || collapseRegion[facei] != -1)
390 <<
"Problem : crossed into uncollapsed/regionized face" 394 collapseRegion[facei] = regionI;
402 label edgeI = fEdges[fEdgeI];
408 label nbrFacei = eFaces[i];
410 if (faceToEdge[nbrFacei] != -1)
412 if (collapseRegion[nbrFacei] == -1)
423 else if (collapseRegion[nbrFacei] != regionI)
426 <<
"Edge:" << edgeI <<
" between face " << facei
427 <<
" with region " << regionI
428 <<
" and face " << nbrFacei
429 <<
" with region " << collapseRegion[nbrFacei]
440 static label markRegions
451 if (collapseRegion[facei] == -1 && faceToEdge[facei] != -1)
457 markRegion(surf, faceToEdge, regionI++, facei, collapseRegion);
468 static label edgeType
478 bool usesUncollapsed =
false;
479 label usesRegion = -1;
483 label facei = eFaces[i];
485 label region = collapseRegion[facei];
489 usesUncollapsed =
true;
491 else if (usesRegion == -1)
495 else if (usesRegion != region)
507 if (usesRegion == -1)
520 if (usesRegion == -1)
549 label regionI = edgeType(surf, collapseRegion, edgeI);
558 labelList& regionVerts = outsideVerts[regionI];
588 scalar maxDist = -GREAT;
593 label v0 = outsideVerts[i];
595 for (
label j = i+1; j < outsideVerts.
size(); j++)
597 label v1 = outsideVerts[j];
599 scalar d =
mag(localPoints[v0] - localPoints[v1]);
615 static void projectNonSpanPoints
629 label v = outsideVerts[i];
631 if (v != spanPair[0] && v != spanPair[1])
649 insertSorted(v, w, sortedVertices, sortedWeights);
656 static void getSplitVerts
672 if (e[0] == spanPoints[0])
676 if (e[1] == spanPoints[1])
679 splitVerts = orderedVerts;
680 splitWeights = orderedWeights;
690 else if (e[0] == spanPoints[1])
694 if (e[1] == spanPoints[0])
697 splitVerts = orderedVerts;
699 splitWeights = orderedWeights;
713 else if (e[1] == spanPoints[0])
725 else if (e[1] == spanPoints[1])
738 if (i0 == -1 || i1 == -1)
741 <<
"Did not find edge in projected vertices." <<
nl 742 <<
"region:" << regionI <<
nl 743 <<
"spanPoints:" << spanPoints
750 <<
"orderedVerts:" << orderedVerts <<
nl 774 const scalar minQuality
777 label nTotalSplit = 0;
790 markCollapsedFaces(surf, minLen, minQuality, faceToEdge);
799 label nRegions = markRegions(surf, faceToEdge, collapseRegion);
807 getOutsideVerts(surf, collapseRegion, nRegions)
815 forAll(spanPoints, regionI)
817 spanPoints[regionI] = getSpanPoints(surf, outsideVerts[regionI]);
828 outsideVerts[regionI],
830 orderedVertices[regionI],
831 orderedWeights[regionI]
871 const edge& e = edges[edgeI];
874 label regionI = edgeType(surf, collapseRegion, edgeI);
880 else if (regionI == -1)
898 orderedVertices[regionI],
899 orderedWeights[regionI],
906 if (splitVerts.
size())
929 label facei = eFaces[i];
931 if (!faceHandled[facei] && faceToEdge[facei] == -1)
942 faceHandled[facei] =
true;
952 forAll(faceHandled, facei)
954 if (!faceHandled[facei] && faceToEdge[facei] == -1)
956 newTris.append(localFaces[facei]);
960 Info<<
"collapseBase : collapsing " << nSplit
961 <<
" triangles by splitting their base edge." 964 nTotalSplit += nSplit;
linePointRef line(const pointField &) const
Return edge line.
#define forAll(list, i)
Loop across all elements in list.
label collapseBase(triSurface &surf, const scalar minLen, const scalar minQuality)
Keep collapsing all triangles whose height is < minLen or quality < minQ.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label region() const
Return region label.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Field< PointType > & points() const
Return reference to global points.
Routines collapse sliver triangles by splitting the base edge.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A List obtained as a section of another List.
scalar distance() const
Return distance to hit.
An ordered pair of two objects of type <T> with first() and second() elements.
line< point, const point & > linePointRef
Line using referred points.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const geometricSurfacePatchList & patches() const
const labelListList & faceEdges() const
Return face-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Triangle with additional region number.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
errorManip< error > abort(error &err)
void reverse(UList< T > &, const label n)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
triPointRef tri(const pointField &) const
Return the triangle.
const Point & hitPoint() const
Return hit point.
dimensioned< scalar > mag(const dimensioned< Type > &)
const labelListList & edgeFaces() const
Return edge-face addressing.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
bool hit() const
Is there a hit.
T & last()
Return the last element of the list.
Triangulated surface description with patch information.
const Field< PointType > & localPoints() const
Return pointField of points in patch.