51 int main(
int argc,
char *argv[])
60 Info<<
"Reading dictionary " <<
args[3] <<
" ..." <<
endl;
71 surf1.writeStats(
Info);
77 meshSubsetDict.lookup(
"localPoints")
82 meshSubsetDict.lookup(
"edges")
87 meshSubsetDict.lookup(
"faces")
92 meshSubsetDict.lookup(
"zone")
95 if (markedZone.size() && markedZone.size() != 2)
98 <<
"zone specification should be two points, min and max of "
99 <<
"the boundingbox" <<
endl
100 <<
"zone:" << markedZone
106 meshSubsetDict.lookup(
"addFaceNeighbours")
109 const bool invertSelection =
110 meshSubsetDict.lookupOrDefault(
"invertSelection",
false);
115 boolList facesToSubset(surf1.size(),
false);
122 if (markedPoints.size())
124 Info<<
"Found " << markedPoints.size() <<
" marked point(s)." <<
endl;
128 forAll(markedPoints, pointi)
132 markedPoints[pointi] < 0
133 || markedPoints[pointi] >= surf1.nPoints()
137 <<
"localPoint label " << markedPoints[pointi]
139 <<
" The mesh has got "
140 << surf1.nPoints() <<
" localPoints."
145 surf1.pointFaces()[markedPoints[pointi]];
149 facesToSubset[curFaces[i]] =
true;
160 if (markedEdges.size())
162 Info<<
"Found " << markedEdges.size() <<
" marked edge(s)." <<
endl;
166 forAll(markedEdges, edgeI)
170 markedEdges[edgeI] < 0
171 || markedEdges[edgeI] >= surf1.nEdges()
175 <<
"edge label " << markedEdges[edgeI]
177 <<
" The mesh has got "
178 << surf1.nEdges() <<
" edges."
182 const labelList& curFaces = surf1.edgeFaces()[markedEdges[edgeI]];
186 facesToSubset[curFaces[i]] =
true;
196 if (markedZone.size() == 2)
205 const point centre = surf1[facei].
centre(surf1.points());
209 (centre.
x() >=
min.x())
210 && (centre.
y() >=
min.y())
211 && (centre.
z() >=
min.z())
212 && (centre.
x() <=
max.x())
213 && (centre.
y() <=
max.y())
214 && (centre.
z() <=
max.z())
217 facesToSubset[facei] =
true;
227 if (meshSubsetDict.found(
"surface"))
237 Info<<
"Selecting all triangles with centre outside surface "
242 Info<<
"Selecting all triangles with centre inside surface "
257 searchSelectSurf.tree();
260 forAll(facesToSubset, facei)
262 if (!facesToSubset[facei])
264 const point fc(surf1[facei].centre(surf1.points()));
275 facesToSubset[facei] =
true;
282 if (meshSubsetDict.found(
"plane"))
286 const plane pl(planeDict);
287 const scalar distance(planeDict.
lookup<scalar>(
"distance"));
288 const scalar cosAngle(planeDict.
lookup<scalar>(
"cosAngle"));
293 forAll(surf1.faceCentres(), facei)
295 const point& fc = surf1.faceCentres()[facei];
296 const point& nf = surf1.faceNormals()[facei];
298 if (pl.distance(fc) < distance &&
mag(pl.normal() & nf) > cosAngle)
300 facesToSubset[facei] =
true;
312 label nFaceNeighbours = 0;
314 if (markedFaces.size())
316 Info<<
"Found " << markedFaces.size() <<
" marked face(s)." <<
endl;
319 forAll(markedFaces, facei)
323 markedFaces[facei] < 0
324 || markedFaces[facei] >= surf1.size()
328 <<
"Face label " << markedFaces[facei] <<
"out of range."
329 <<
" The mesh has got "
330 << surf1.size() <<
" faces."
335 facesToSubset[markedFaces[facei]] =
true;
338 if (addFaceNeighbours)
341 surf1.faceFaces()[markedFaces[facei]];
345 label facei = curFaces[i];
347 if (!facesToSubset[facei])
349 facesToSubset[facei] =
true;
357 if (addFaceNeighbours)
359 Info<<
"Added " << nFaceNeighbours
360 <<
" faces because of addFaceNeighbours" <<
endl;
366 Info<<
"Inverting selection." <<
endl;
370 facesToSubset[i] = facesToSubset[i] ? false :
true;
380 surf1.subsetMesh(facesToSubset, pointMap,
faceMap)
384 surf2.writeStats(
Info);
387 Info<<
"Writing surface to " << outFileName <<
endl;
389 surf2.
write(outFileName);
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const char)=0
Write character.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Return *this (used for point which is a typedef to Vector<scalar>.
Extract command arguments and options from the supplied argc and argv parameters.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
A class for handling file names.
Non-pointer based hierarchical recursive searching.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
Helper class to search on triSurface.
Triangulated surface description with patch information.
#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)
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.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Foam::argList args(argc, argv)