51 int main(
int argc,
char *argv[])
59 Info<<
"Reading dictionary " <<
args[3] <<
" ..." <<
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)
197 const point& min = markedZone[0];
198 const point& max = markedZone[1];
200 Info<<
"Using zone min:" << min <<
" max:" << max <<
endl;
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);
#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)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
static void noParallel()
Remove the parallel options.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
scalar distance(const vector &p1, const vector &p2)
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Helper class to search on triSurface.
Extract command arguments and options from the supplied argc and argv parameters. ...
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Non-pointer based hierarchical recursive searching.
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual Ostream & write(const token &)=0
Write next token to stream.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.