Go to the documentation of this file.
55 int main(
int argc,
char *argv[])
59 "A surface analysis tool that subsets the surface to choose a"
60 " region of interest."
69 Info<<
"Reading dictionary " <<
args[1] <<
" ..." <<
endl;
81 surf1.writeStats(
Info);
87 meshSubsetDict.lookup(
"localPoints")
92 meshSubsetDict.lookup(
"edges")
97 meshSubsetDict.lookup(
"faces")
102 meshSubsetDict.lookup(
"zone")
108 if (markedZone.size())
110 if (markedZone.size() != 2)
113 <<
"zone specification should be two points, min and max of "
114 <<
"the boundingbox" <<
endl
115 <<
"zone:" << markedZone
119 zoneBb.min() = markedZone[0];
120 zoneBb.max() = markedZone[1];
125 <<
"Defined zone is invalid: " << zoneBb <<
nl;
130 const bool addFaceNeighbours =
131 meshSubsetDict.get<
bool>(
"addFaceNeighbours");
133 const bool invertSelection =
134 meshSubsetDict.getOrDefault(
"invertSelection",
false);
139 bitSet facesToSubset(surf1.size(),
false);
146 if (markedPoints.size())
148 Info<<
"Found " << markedPoints.size() <<
" marked point(s)." <<
endl;
150 for (
const label pointi : markedPoints)
152 if (pointi < 0 || pointi >= surf1.nPoints())
155 <<
"localPoint label " << pointi <<
"out of range."
156 <<
" Surface has " << surf1.nPoints() <<
" localPoints."
160 const labelList& curFaces = surf1.pointFaces()[pointi];
162 facesToSubset.
set(curFaces);
171 if (markedEdges.size())
173 Info<<
"Found " << markedEdges.size() <<
" marked edge(s)." <<
endl;
175 for (
const label edgei : markedEdges)
177 if (edgei < 0 || edgei >= surf1.nEdges())
180 <<
"edge label " << edgei <<
"out of range."
181 <<
" Surface has " << surf1.nEdges() <<
" edges."
185 const labelList& curFaces = surf1.edgeFaces()[edgei];
187 facesToSubset.
set(curFaces);
198 Info<<
"Using zone " << zoneBb <<
endl;
202 const point centre = surf1[facei].
centre(surf1.points());
204 if (zoneBb.contains(centre))
206 facesToSubset.set(facei);
216 if (meshSubsetDict.found(
"surface"))
229 Info<<
"Selecting faces with centre located "
244 searchSelectSurf.tree();
249 if (!facesToSubset[facei])
251 const point fc(surf1[facei].centre(surf1.points()));
253 if (volType == selectTree.getVolumeType(fc))
255 facesToSubset.set(facei);
262 if (meshSubsetDict.found(
"plane"))
266 const plane pl(planeDict);
267 const scalar
distance(planeDict.
get<scalar>(
"distance"));
268 const scalar cosAngle(planeDict.
get<scalar>(
"cosAngle"));
273 forAll(surf1.faceCentres(), facei)
275 const point& fc = surf1.faceCentres()[facei];
276 const point& nf = surf1.faceNormals()[facei];
278 if (pl.distance(fc) <
distance &&
mag(pl.normal() & nf) > cosAngle)
280 facesToSubset.set(facei);
292 label nFaceNeighbours = 0;
294 if (markedFaces.size())
296 Info<<
"Found " << markedFaces.size() <<
" marked face(s)." <<
endl;
299 for (
const label facei : markedFaces)
301 if (facei < 0 || facei >= surf1.size())
304 <<
"Face label " << facei <<
"out of range."
305 <<
" Surface has " << surf1.size() <<
" faces."
310 facesToSubset.set(facei);
313 if (addFaceNeighbours)
315 const labelList& curFaces = surf1.faceFaces()[facei];
317 for (
const label neiFacei : curFaces)
319 if (facesToSubset.set(neiFacei))
328 if (addFaceNeighbours)
330 Info<<
"Added " << nFaceNeighbours
331 <<
" faces because of addFaceNeighbours" <<
endl;
337 Info<<
"Inverting selection." <<
endl;
339 facesToSubset.flip();
347 surf2.writeStats(
Info);
350 Info<<
"Writing surface to " << outFileName <<
endl;
352 surf2.
write(outFileName);
type
Volume classification types.
A class for handling file names.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Input from file stream, using an ISstream.
static void addNote(const string ¬e)
Add extra notes for the usage information.
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Helper class to search on triSurface.
#define forAll(list, i)
Loop across all elements in list.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Triangulated surface description with patch information.
messageStream Info
Information stream (uses stdout - output is on the master only)
static const Enum< volumeType::type > names
Names for the classification enumeration.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) 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>.
Non-pointer based hierarchical recursive searching.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
scalar distance(const vector &p1, const vector &p2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Input/output from file streams.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A location inside the volume.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
A bounding box defined in terms of min/max extrema points.
static void noParallel()
Remove the parallel options.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Foam::argList args(argc, argv)
#define WarningInFunction
Report a warning using Foam::Warning.
A location outside the volume.