87 bool intersectSurfaces
93 bool hasMoved =
false;
95 for (
label iter = 0; iter < 10; iter++)
97 Info<<
"Determining intersections of surface edges with itself" <<
endl;
146 Info<<
"Surface has been moved. Writing to " << newFile <<
endl;
156 bool intersectSurfaces
164 bool hasMoved1 =
false;
165 bool hasMoved2 =
false;
167 for (
label iter = 0; iter < 10; iter++)
169 Info<<
"Determining intersections of surf1 edges with surf2"
215 Info<<
"Determining intersections of surf2 edges with surf1"
258 if (nIters1 == 0 && nIters2 == 0)
260 Info<<
"** Resolved all intersections to be proper edge-face pierce"
269 Info<<
"Surface 1 has been moved. Writing to " << newFile
271 surf1.write(newFile);
277 Info<<
"Surface 2 has been moved. Writing to " << newFile
279 surf2.write(newFile);
282 return hasMoved1 || hasMoved2;
286 label calcNormalDirection
289 const vector& otherNormal,
298 vector fC0tofE0 = faceCentre - pointOnEdge;
299 fC0tofE0 /=
mag(fC0tofE0);
301 label nDir = ((
cross & fC0tofE0) > 0.0 ? 1 : -1);
303 nDir *= ((otherNormal & fC0tofE0) > 0.0 ? -1 : 1);
332 Info<<
"Determining intersections of surf1 edges with surf2 faces"
344 Info<<
"Determining intersections of surf2 edges with surf1 faces"
364 label nFeaturePoints = 0;
367 const labelList& pEdges = pointEdges[pI];
369 if (pEdges.
size() == 1)
377 labelList featurePointToCutPoint(nFeaturePoints);
378 labelList featurePointToCutEdge(nFeaturePoints);
383 const labelList& pEdges = pointEdges[pI];
385 if (pEdges.
size() == 1)
387 featurePointToCutPoint[nFeatPts] = pI;
388 featurePointToCutEdge[nFeatPts] = pEdges[0];
395 int main(
int argc,
char *argv[])
405 "Mark surface 1 as a baffle"
411 "Mark surface 2 as a baffle"
417 "Perturb surface points to escape degenerate intersections"
423 "do the surfaces have inverted space orientation, "
424 "i.e. a point at infinity is considered inside. "
425 "This is only sensible for union and intersection."
438 if (!validActions.
found(action))
441 <<
"Unsupported action " << action <<
endl
446 Info<<
"Reading surface " << surf1Name <<
endl;
449 Info<< surf1Name <<
" statistics:" <<
endl;
454 Info<<
"Reading surface " << surf2Name <<
endl;
457 Info<< surf2Name <<
" statistics:" <<
endl;
472 <<
"Inverted space only makes sense for union or intersection."
504 label nFeatEds = inter.cutEdges().size();
517 const label& cutEdgeI = iter();
520 const edge& fE = inter.cutEdges()[cutEdgeI];
528 edgeDirections[cutEdgeI] = fE.
vec(inter.cutPoints());
530 normals.append(norm1);
531 eNormals.
append(normals.size() - 1);
548 edgeDirections[cutEdgeI],
550 inter.cutPoints()[fE.
start()]
555 normals.append(norm2);
556 eNormals.
append(normals.size() - 1);
574 edgeDirections[cutEdgeI],
576 inter.cutPoints()[fE.
start()]
584 normals.append(norm2);
602 edgeDirections[cutEdgeI],
604 inter.cutPoints()[fE.
start()]
609 eNormals.
append(normals.size() - 1);
614 normals.append(norm1);
632 edgeDirections[cutEdgeI],
634 inter.cutPoints()[fE.
start()]
639 eNormals.
append(normals.size() - 1);
644 label internalStart = -1;
651 label nEdNorms = edgeNormals[eI].size();
657 else if (nEdNorms == 2)
659 const vector& n0(normals[edgeNormals[eI][0]]);
660 const vector& n1(normals[edgeNormals[eI][1]]);
671 else if (nEdNorms > 2)
686 internalStart = nIntOrExt;
694 internalStart = nIntOrExt;
705 internalStart = nIntOrExt;
710 <<
"Unsupported booleanSurface:booleanOpType and space "
711 << action <<
" " << invertedSpace
727 edgeNormalsTmp[i] = edgeNormals[i];
730 forAll(normalDirectionsTmp, i)
732 normalDirectionsTmp[i] = normalDirections[i];
735 calcFeaturePoints(inter.cutPoints(), inter.cutEdges());
741 sFeatFileName +
".extendedFeatureEdgeMesh",
743 "extendedFeatureEdgeMesh",
758 nIntOrExt + nFlat + nOpen,
761 normalVolumeTypesTmp,
773 feMesh.writeObj(feMesh.path()/sFeatFileName);
781 sFeatFileName +
".eMesh",
793 Info<<
nl <<
"Writing featureEdgeMesh to "
794 << bfeMesh.relativeObjectPath() <<
endl;
796 bfeMesh.regIOobject::write();
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
An STL-conforming hash table.
List< Key > toc() const
Return the table of contents.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
const Type & second() const
Return second.
const Type & first() const
Return first.
const Field< PointType > & points() const
Return reference to global points.
const Field< PointType > & faceNormals() const
Return face normals for patch.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
const stringList & args() const
Return arguments.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
static scalarField minEdgeLength(const triSurface &surf)
Calculate min edge length for every surface point.
label removeDegenerates(const label nIters, const triSurface &surf1, const triSurfaceSearch &query2, const scalarField &surf1PointTol, pointField &points1)
Resolve ties. Shuffles points so all edge - face intersections.
Points connected by edges.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
vector vec(const pointField &) const
Return the vector (end - start)
label start() const
Return start vertex label.
static scalar cosNormalAngleTol_
Angular closeness tolerance for treating normals as the same.
A class for handling file names.
word name() const
Return file name (part beyond last /)
fileName lessExt() const
Return file name without extension (part before last .)
static const word & geometryDir()
Return the geometry directory name.
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
Helper class to search on triSurface.
Triangulated surface description with patch information.
void writeStats(Ostream &) const
Write some statistics.
virtual void setPoints(const pointField &)
Move points.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
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.
errorManip< error > abort(error &err)
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Foam::argList args(argc, argv)