Go to the documentation of this file.
33 #include "triSurface.H"
42 #include "treeDataTriSurface.H"
51 int main(
int argc,
char *argv[])
59 Info<<
"Reading dictionary " <<
args[1] <<
" ..." <<
endl;
70 surf1.writeStats(
Info);
76 meshSubsetDict.lookup(
"localPoints")
81 meshSubsetDict.lookup(
"edges")
86 meshSubsetDict.lookup(
"faces")
91 meshSubsetDict.lookup(
"zone")
94 if (markedZone.size() && markedZone.size() != 2)
97 <<
"zone specification should be two points, min and max of "
98 <<
"the boundingbox" <<
endl
99 <<
"zone:" << markedZone
105 meshSubsetDict.lookup(
"addFaceNeighbours")
108 const bool invertSelection =
109 meshSubsetDict.lookupOrDefault(
"invertSelection",
false);
114 boolList facesToSubset(surf1.size(),
false);
121 if (markedPoints.size())
123 Info<<
"Found " << markedPoints.size() <<
" marked point(s)." <<
endl;
127 forAll(markedPoints, pointI)
131 markedPoints[pointI] < 0
132 || markedPoints[pointI] >= surf1.nPoints()
136 <<
"localPoint label " << markedPoints[pointI]
138 <<
" The mesh has got "
139 << surf1.nPoints() <<
" localPoints."
144 surf1.pointFaces()[markedPoints[pointI]];
148 facesToSubset[curFaces[i]] =
true;
159 if (markedEdges.size())
161 Info<<
"Found " << markedEdges.size() <<
" marked edge(s)." <<
endl;
165 forAll(markedEdges, edgeI)
169 markedEdges[edgeI] < 0
170 || markedEdges[edgeI] >= surf1.nEdges()
174 <<
"edge label " << markedEdges[edgeI]
176 <<
" The mesh has got "
177 << surf1.nEdges() <<
" edges."
181 const labelList& curFaces = surf1.edgeFaces()[markedEdges[edgeI]];
185 facesToSubset[curFaces[i]] =
true;
195 if (markedZone.size() == 2)
204 const point centre = surf1[faceI].
centre(surf1.points());
208 (centre.
x() >=
min.x())
209 && (centre.
y() >=
min.y())
210 && (centre.
z() >=
min.z())
211 && (centre.
x() <=
max.x())
212 && (centre.
y() <=
max.y())
213 && (centre.
z() <=
max.z())
216 facesToSubset[faceI] =
true;
226 if (meshSubsetDict.found(
"surface"))
236 Info<<
"Selecting all triangles with centre outside surface "
241 Info<<
"Selecting all triangles with centre inside surface "
256 searchSelectSurf.tree();
259 forAll(facesToSubset, faceI)
261 if (!facesToSubset[faceI])
263 const point fc(surf1[faceI].centre(surf1.points()));
274 facesToSubset[faceI] =
true;
281 if (meshSubsetDict.found(
"plane"))
285 const plane pl(planeDict);
292 forAll(surf1.faceCentres(), faceI)
294 const point& fc = surf1.faceCentres()[faceI];
295 const point& nf = surf1.faceNormals()[faceI];
297 if (pl.distance(fc) <
distance &&
mag(pl.normal() & nf) > cosAngle)
299 facesToSubset[faceI] =
true;
311 label nFaceNeighbours = 0;
313 if (markedFaces.size())
315 Info<<
"Found " << markedFaces.size() <<
" marked face(s)." <<
endl;
318 forAll(markedFaces, faceI)
322 markedFaces[faceI] < 0
323 || markedFaces[faceI] >= surf1.size()
327 <<
"Face label " << markedFaces[faceI] <<
"out of range."
328 <<
" The mesh has got "
329 << surf1.size() <<
" faces."
334 facesToSubset[markedFaces[faceI]] =
true;
337 if (addFaceNeighbours)
340 surf1.faceFaces()[markedFaces[faceI]];
344 label faceI = curFaces[i];
346 if (!facesToSubset[faceI])
348 facesToSubset[faceI] =
true;
356 if (addFaceNeighbours)
358 Info<<
"Added " << nFaceNeighbours
359 <<
" faces because of addFaceNeighbours" <<
endl;
365 Info<<
"Inverting selection." <<
endl;
369 facesToSubset[i] = facesToSubset[i] ? false :
true;
379 surf1.subsetMesh(facesToSubset, pointMap,
faceMap)
383 surf2.writeStats(
Info);
386 Info<<
"Writing surface to " << outFileName <<
endl;
388 surf2.
write(outFileName);
static SLList< string > validArgs
A list of valid (mandatory) arguments.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
A class for handling file names.
#define forAll(list, i)
Loop across all elements in list.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
Helper class to search on triSurface.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
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.
virtual Ostream & write(const token &)=0
Write next token to stream.
Non-pointer based hierarchical recursive searching.
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt > > &) const
Return *this (used for point which is a typedef to Vector<scalar>.
int main(int argc, char *argv[])
A list of keyword definitions, which are a keyword followed by any number of values (e....
scalar distance(const vector &p1, const vector &p2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
volumeType getVolumeType(const label nodeI, const point &) const
Search cached volume type.
static void noParallel()
Remove the parallel options.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Foam::argList args(argc, argv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)