102 label fp =
f.find(
e[0]);
103 label fp1 =
f.fcIndex(fp);
104 label fp2 =
f.fcIndex(fp1);
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
183 <<
abort(FatalError);
198static bool insertSorted
207 if (sortedVerts.
found(vertI))
210 <<
" which is already in list of sorted vertices "
211 << sortedVerts <<
abort(FatalError);
214 if (weight <= 0 || weight >= 1)
217 <<
" with illegal weight " << weight
218 <<
" into list of sorted vertices "
219 << sortedVerts <<
abort(FatalError);
223 label insertI = sortedVerts.
size();
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
246 label sz = sortedWeights.
size();
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,
284 triSurfaceTools::oppositeVertex
295 e.line(localPoints).nearestDist
297 localPoints[opposite0]
305 ||
f.tri(surf.
points()).quality() < minQuality
332static void markCollapsedFaces
336 const scalar minQuality,
351 label facei = eFaces[i];
353 bool isCandidate = isSliver(surf, minLen, minQuality, facei, edgeI);
358 if (faceToEdge[facei] != -1)
361 <<
"Cannot collapse face " << facei <<
" since "
362 <<
" is marked to be collapsed both to edge "
363 << faceToEdge[facei] <<
" and " << edgeI
364 <<
abort(FatalError);
367 faceToEdge[facei] = edgeI;
376static void markRegion
385 if (faceToEdge[facei] == -1 || collapseRegion[facei] != -1)
388 <<
"Problem : crossed into uncollapsed/regionized face"
389 <<
abort(FatalError);
392 collapseRegion[facei] = regionI;
400 label edgeI = fEdges[fEdgeI];
406 label nbrFacei = eFaces[i];
408 if (faceToEdge[nbrFacei] != -1)
410 if (collapseRegion[nbrFacei] == -1)
421 else if (collapseRegion[nbrFacei] != regionI)
424 <<
"Edge:" << edgeI <<
" between face " << facei
425 <<
" with region " << regionI
426 <<
" and face " << nbrFacei
427 <<
" with region " << collapseRegion[nbrFacei]
438static label markRegions
449 if (collapseRegion[facei] == -1 && faceToEdge[facei] != -1)
455 markRegion(surf, faceToEdge, regionI++, facei, collapseRegion);
476 bool usesUncollapsed =
false;
477 label usesRegion = -1;
481 label facei = eFaces[i];
483 label region = collapseRegion[facei];
487 usesUncollapsed =
true;
489 else if (usesRegion == -1)
493 else if (usesRegion != region)
505 if (usesRegion == -1)
518 if (usesRegion == -1)
547 label regionI = edgeType(surf, collapseRegion, edgeI);
556 labelList& regionVerts = outsideVerts[regionI];
563 if (!regionVerts.
found(v))
565 label sz = regionVerts.
size();
586 scalar maxDist = -GREAT;
591 label v0 = outsideVerts[i];
593 for (label j = i+1; j < outsideVerts.
size(); j++)
595 label v1 = outsideVerts[j];
597 scalar d =
mag(localPoints[v0] - localPoints[v1]);
613static void projectNonSpanPoints
627 label v = outsideVerts[i];
629 if (v != spanPair[0] && v != spanPair[1])
642 <<
abort(FatalError);
647 insertSorted(v, w, sortedVertices, sortedWeights);
654static void getSplitVerts
668 const label sz = orderedVerts.
size();
670 if (
e[0] == spanPoints[0])
674 if (
e[1] == spanPoints[1])
677 splitVerts = orderedVerts;
678 splitWeights = orderedWeights;
683 label i1 = orderedVerts.
find(
e[1]);
688 else if (
e[0] == spanPoints[1])
692 if (
e[1] == spanPoints[0])
695 splitVerts = orderedVerts;
697 splitWeights = orderedWeights;
704 label i1 = orderedVerts.
find(
e[1]);
711 else if (
e[1] == spanPoints[0])
717 label i0 = orderedVerts.
find(
e[0]);
723 else if (
e[1] == spanPoints[1])
727 label i0 = orderedVerts.
find(
e[0]);
733 label i0 = orderedVerts.
find(
e[0]);
734 label i1 = orderedVerts.
find(
e[1]);
736 if (i0 == -1 || i1 == -1)
739 <<
"Did not find edge in projected vertices." <<
nl
740 <<
"region:" << regionI <<
nl
741 <<
"spanPoints:" << spanPoints
748 <<
"orderedVerts:" << orderedVerts <<
nl
749 <<
abort(FatalError);
772 const scalar minQuality
775 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...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
void setSize(const label n)
Alias for resize()
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & hitPoint() const
Return the hit point. Fatal if not hit.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A List obtained as a section of another List.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
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...
A triFace with additional (region) index.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
Triangulated surface description with patch information.
const geometricSurfacePatchList & patches() const noexcept
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.
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.