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." 497 surf1Name.lessExt().name()
499 + surf2Name.lessExt().name()
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;
652 label nEdNorms = edgeNormals[eI].size();
658 else if (nEdNorms == 2)
660 const vector& n0(normals[edgeNormals[eI][0]]);
661 const vector& n1(normals[edgeNormals[eI][1]]);
672 else if (nEdNorms > 2)
688 internalStart = nIntOrExt;
696 internalStart = nIntOrExt;
707 internalStart = nIntOrExt;
712 <<
"Unsupported booleanSurface:booleanOpType and space " 713 << action <<
" " << invertedSpace
729 edgeNormalsTmp[i] = edgeNormals[i];
732 forAll(normalDirectionsTmp, i)
734 normalDirectionsTmp[i] = normalDirections[i];
737 calcFeaturePoints(inter.cutPoints(), inter.cutEdges());
743 sFeatFileName +
".extendedFeatureEdgeMesh",
745 "extendedFeatureEdgeMesh",
760 nIntOrExt + nFlat + nOpen,
763 normalVolumeTypesTmp,
775 feMesh.writeObj(feMesh.path()/sFeatFileName);
783 sFeatFileName +
".eMesh",
795 Info<<
nl <<
"Writing featureEdgeMesh to " 796 << bfeMesh.objectPath() <<
endl;
798 bfeMesh.regIOobject::write();
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const double e
Elementary charge.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void writeStats(Ostream &) const
Write some statistics.
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
void size(const label)
Override size to be inconsistent with allocated storage.
const Type & second() const
Return second.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Field< PointType > & points() const
Return reference to global points.
static void noParallel()
Remove the parallel options.
const Type & first() const
Return first.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
virtual void movePoints(const pointField &)
Move points.
Helper class to search on triSurface.
static scalarField minEdgeLength(const triSurface &surf)
Calculate min edge length for every surface point.
const stringList & args() const
Return arguments.
An ordered pair of two objects of type <T> with first() and second() elements.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
bool optionFound(const word &opt) const
Return true if the named option is found.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling words, derived from string.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
An STL-conforming hash table.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
static scalar cosNormalAngleTol_
Angular closeness tolerance for treating normals as the same.
label start() const
Return start vertex label.
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.
A normal distribution model.
const Field< PointType > & faceNormals() const
Return face normals for patch.
vector vec(const pointField &) const
Return the vector (end - start)
virtual bool write() const
Write using setting from DB.
dimensioned< scalar > mag(const dimensioned< Type > &)
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...