Go to the documentation of this file.
58 #include "triSurface.H"
71 const point& pt = pts[i];
73 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
82 Info<<
"Dumping borderPoints as Lightwave .obj file to " << fName
83 <<
"\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
87 forAll(borderPoint, pointI)
89 if (borderPoint[pointI] != -1)
93 os <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z() <<
endl;
103 Info<<
"Dumping borderEdges as Lightwave .obj file to " << fName
104 <<
"\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
112 if (borderEdge[edgeI])
116 os <<
"l " <<
e.start()+1 <<
' ' <<
e.end()+1 <<
endl;
129 Info<<
"Dumping connectedFaces as Lightwave .obj file to " << fName
130 <<
"\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
138 os <<
"v " << ctr.
x() <<
' ' << ctr.
y() <<
' ' << ctr.
z() <<
endl;
143 void testSortedEdgeFaces(
const triSurface& surf)
150 const labelList& myFaces = edgeFaces[edgeI];
151 const labelList& sortMyFaces = sortedEdgeFaces[edgeI];
155 if (
findIndex(sortMyFaces, myFaces[i]) == -1)
162 if (
findIndex(myFaces, sortMyFaces[i]) == -1)
172 label markBorderEdges
179 label nBorderEdges = 0;
185 if (edgeFaces[edgeI].size() == 4)
187 borderEdge[edgeI] =
true;
195 dumpEdges(surf, borderEdge);
204 label markBorderPoints
216 forAll(pointEdges, pointI)
218 const labelList& pEdges = pointEdges[pointI];
220 label nBorderEdges = 0;
224 if (borderEdge[pEdges[i]])
230 if (nBorderEdges == 2 && borderPoint[pointI] == -1)
232 borderPoint[pointI] =
nPoints++;
240 dumpPoints(surf, borderPoint);
243 return nBorderPoints;
255 scalar minLen = GREAT;
259 label edgeI = pEdges[i];
283 label edgeI = edgeLabels[i];
305 <<
' ' << v1 <<
" in candidates " << edgeLabels
318 const label otherEdgeI,
326 label edgeI = fEdges[i];
345 <<
" connected to point " << pointI
362 const label startFaceI,
363 const label startEdgeI,
364 const label startPointI,
370 label faceI = startFaceI;
371 label edgeI = startEdgeI;
372 label pointI = startPointI;
383 edgeI =
otherEdge(surf, faceI, edgeI, pointI);
385 if (borderEdge[edgeI])
387 if (!faceToEdge.insert(faceI, edgeI))
407 if (eFaces.
size() != 2)
410 <<
"Can only handle edges with 2 or 4 edges for now."
414 if (eFaces[0] == faceI)
418 else if (eFaces[1] == faceI)
434 pointI = surf.
edges()[edgeI].otherVertex(pointI);
436 if (borderPoint[pointI] == -1)
451 const label firstFaceI,
452 const label sharedEdgeI
464 bool edgeOrder = (
f[
f.fcIndex(startIndex)] ==
e.end());
477 return eFaces[eFaces.rcIndex(faceIndex)];
482 return eFaces[eFaces.fcIndex(faceIndex)];
505 const label edgeI = iter();
507 if (!edgeDone[edgeI])
509 edgeDone[edgeI] =
true;
517 const labelList& eFaces = sortedEdgeFaces[edgeI];
521 label faceI = eFaces[i];
523 if (faceToEdge.found(faceI))
529 else if (face1I == -1)
538 if (face0I == -1 && face1I == -1)
540 Info<<
"Writing surface to errorSurf.obj" <<
endl;
542 surf.
write(
"errorSurf.obj");
545 <<
"Cannot find two faces using border edge " << edgeI
546 <<
" verts:" << edges[edgeI]
547 <<
" eFaces:" << eFaces <<
endl
548 <<
"face0I:" << face0I
549 <<
" face1I:" << face1I <<
nl
550 <<
"faceToEdge:" << faceToEdge <<
nl
552 <<
"Written surface to errorSurf.obj"
558 const edge&
e = edges[edgeI];
581 scalar magMidVec =
mag(midVec);
583 if (magMidVec > SMALL)
588 borderPointVec[
e.start()] += midVec;
589 borderPointVec[
e.end()] += midVec;
608 const label faceI = iter.key();
613 if (pointMap[
f[fp]] != -1)
615 newTris[faceI][fp] = pointMap[
f[fp]];
624 bool splitBorderEdges
636 if (borderEdge[edgeI])
640 if (borderPoint[
e.start()] == -1 && borderPoint[
e.end()] == -1)
644 edgesToBeSplit[nSplit++] = edgeI;
648 edgesToBeSplit.
setSize(nSplit);
652 Info<<
"Splitting surface along " << nSplit <<
" borderEdges that don't"
653 <<
" neighbour other borderEdges" <<
nl <<
endl;
669 int main(
int argc,
char *argv[])
673 "split multiply connected surface edges by duplicating points"
681 "add debugging output"
690 Info<<
"Reading surface from " << inSurfName <<
endl;
695 testSortedEdgeFaces(surf);
699 markBorderEdges(debug, surf, borderEdge);
705 markBorderPoints(debug, surf, borderEdge, borderPoint);
708 splitBorderEdges(surf, borderEdge, borderPoint);
711 Info<<
"Writing split surface to " << outSurfName <<
nl <<
endl;
712 surf.
write(outSurfName);
713 Info<<
"Finished writing surface to " << outSurfName <<
nl <<
endl;
717 label nOldBorderEdges = -1;
718 label nOldBorderPoints = -1;
727 label nBorderEdges = markBorderEdges(debug, surf, borderEdge);
729 if (nBorderEdges == 0)
731 Info<<
"Found no border edges. Exiting." <<
nl <<
nl;
739 label nBorderPoints =
748 if (nBorderPoints == 0)
750 Info<<
"Found no border points. Exiting." <<
nl <<
nl;
756 <<
" border edges :" << nBorderEdges <<
nl
757 <<
" border points:" << nBorderPoints <<
nl
762 nBorderPoints == nOldBorderPoints
763 && nBorderEdges == nOldBorderEdges
766 Info<<
"Stopping since number of border edges and point is same"
767 <<
" as in previous iteration" <<
nl <<
endl;
777 label startEdgeI = -1;
778 label startPointI = -1;
782 if (borderEdge[edgeI])
786 if ((borderPoint[
e[0]] != -1) && (borderPoint[
e[1]] == -1))
793 else if ((borderPoint[
e[0]] == -1) && (borderPoint[
e[1]] != -1))
803 if (startEdgeI == -1)
805 Info<<
"Cannot find starting point of splitLine\n" <<
endl;
813 label firstFaceI = eFaces[0];
817 label secondFaceI = sharedFace(surf, firstFaceI, startEdgeI);
819 Info<<
"Starting local walk from:" <<
endl
820 <<
" edge :" << startEdgeI <<
endl
821 <<
" point:" << startPointI <<
endl
822 <<
" face0:" << firstFaceI <<
endl
823 <<
" face1:" << secondFaceI <<
endl
831 faceToEdge.insert(firstFaceI, startEdgeI);
847 faceToEdge.insert(secondFaceI, startEdgeI);
863 Info<<
"Finished local walk and visited" <<
nl
864 <<
" border edges :" << faceToEdge.size() <<
nl
865 <<
" border points(but not edges):" <<
faceToPoint.size() <<
nl
870 dumpFaces(
"faceToEdge.obj", surf, faceToEdge);
883 calcPointVecs(surf, faceToEdge,
faceToPoint, borderPointVec);
888 newPoints.setSize(newPoints.size() + nBorderPoints);
890 forAll(borderPoint, pointI)
892 label newPointI = borderPoint[pointI];
896 scalar minLen = minEdgeLen(surf, pointI);
898 vector n = borderPointVec[pointI];
901 newPoints[newPointI] = newPoints[pointI] + 0.1 * minLen *
n;
916 newTris[faceI].region() = surf[faceI].region();
920 renumberFaces(surf, borderPoint, faceToEdge, newTris);
922 renumberFaces(surf, borderPoint,
faceToPoint, newTris);
932 const point& pt = newPoints[
f[fp]];
934 if (
mag(pt) >= GREAT/2)
936 Info<<
"newTri:" << faceI <<
" verts:" <<
f
937 <<
" vert:" <<
f[fp] <<
" point:" << pt <<
endl;
945 if (debug || (iteration != 0 && (iteration % 20) == 0))
947 Info<<
"Writing surface to " << outSurfName <<
nl <<
endl;
949 surf.
write(outSurfName);
951 Info<<
"Finished writing surface to " << outSurfName <<
nl <<
endl;
955 nOldBorderEdges = nBorderEdges;
956 nOldBorderPoints = nBorderPoints;
962 Info<<
"Writing final surface to " << outSurfName <<
nl <<
endl;
964 surf.
write(outSurfName);
static SLList< string > validArgs
A list of valid (mandatory) arguments.
const labelListList & edgeFaces() const
Return edge-face addressing.
A class for handling file names.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
static void addNote(const string &)
Add extra notes for the usage information.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
label nEdges() const
Return number of edges in patch.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelListList & faceEdges() const
Return face-edge addressing.
dimensioned< scalar > mag(const dimensioned< Type > &)
const geometricSurfacePatchList & patches() const
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
Triangulated surface description with patch information.
const labelListList & pointEdges() const
Return point-edge addressing.
int main(int argc, char *argv[])
label nPoints() const
Return number of points supporting patch faces.
errorManip< error > abort(error &err)
const double e
Elementary charge.
void setSize(const label)
Reset size of List.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool optionFound(const word &opt) const
Return true if the named option is found.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
Various functions to operate on Lists.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static void noParallel()
Remove the parallel options.
void write(const fileName &, const word &ext, const bool sort) const
Generic write routine. Chooses writer based on extension.
Foam::argList args(argc, argv)
A topoSetSource to select points based on usage in faces.