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,
295 e.line(localPoints).nearestDist
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/regionised 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];
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;
788 markCollapsedFaces(surf, minLen, minQuality, faceToEdge);
797 label nRegions = markRegions(surf, faceToEdge, collapseRegion);
805 getOutsideVerts(surf, collapseRegion, nRegions)
813 forAll(spanPoints, regionI)
815 spanPoints[regionI] = getSpanPoints(surf, outsideVerts[regionI]);
826 outsideVerts[regionI],
828 orderedVertices[regionI],
829 orderedWeights[regionI]
869 const edge&
e = edges[edgeI];
872 label regionI = edgeType(surf, collapseRegion, edgeI);
878 else if (regionI == -1)
896 orderedVertices[regionI],
897 orderedWeights[regionI],
904 if (splitVerts.
size())
927 label facei = eFaces[i];
929 if (!faceHandled[facei] && faceToEdge[facei] == -1)
940 faceHandled[facei] =
true;
950 forAll(faceHandled, facei)
952 if (!faceHandled[facei] && faceToEdge[facei] == -1)
954 newTris.append(localFaces[facei]);
958 Info<<
"collapseBase : collapsing " << nSplit
959 <<
" triangles by splitting their base edge."
962 nTotalSplit += nSplit;
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
const Point & hitPoint() const
Return hit point.
scalar distance() const
Return distance to hit.
bool hit() const
Is there a hit.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< PointType > & points() const
Return reference to global points.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
A List obtained as a section of another List.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
T & last()
Return the last element of the list.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Triangle with additional region number.
label size() const
Return size.
Triangulated surface description with patch information.
const geometricSurfacePatchList & patches() const
Routines collapse sliver triangles by splitting the base edge.
label collapseBase(triSurface &surf, const scalar minLen, const scalar minQuality)
Keep collapsing all triangles whose height is < minLen or quality < minQ.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
line< point, const point & > linePointRef
Line using referred points.
errorManip< error > abort(error &err)
const fvMesh & region(const dictionary &dict)
Cast the give dictionary to the corresponding region fvMesh.
void reverse(UList< T > &, const label n)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.