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;
79 surf1.writeStats(
Info);
85 meshSubsetDict.lookup(
"localPoints")
90 meshSubsetDict.lookup(
"edges")
95 meshSubsetDict.lookup(
"faces")
100 meshSubsetDict.lookup(
"zone")
106 if (markedZone.size())
108 if (markedZone.size() != 2)
111 <<
"zone specification should be two points, min and max of "
112 <<
"the boundingbox" <<
endl
113 <<
"zone:" << markedZone
117 zoneBb.
min() = markedZone[0];
118 zoneBb.
max() = markedZone[1];
123 <<
"Defined zone is invalid: " << zoneBb <<
nl;
128 const bool addFaceNeighbours =
129 meshSubsetDict.get<
bool>(
"addFaceNeighbours");
131 const bool invertSelection =
132 meshSubsetDict.getOrDefault(
"invertSelection",
false);
137 bitSet facesToSubset(surf1.size(),
false);
144 if (markedPoints.size())
146 Info<<
"Found " << markedPoints.size() <<
" marked point(s)." <<
endl;
148 for (
const label pointi : markedPoints)
150 if (pointi < 0 || pointi >= surf1.nPoints())
153 <<
"localPoint label " << pointi <<
"out of range."
154 <<
" Surface has " << surf1.nPoints() <<
" localPoints."
158 const labelList& curFaces = surf1.pointFaces()[pointi];
160 facesToSubset.
set(curFaces);
169 if (markedEdges.size())
171 Info<<
"Found " << markedEdges.size() <<
" marked edge(s)." <<
endl;
173 for (
const label edgei : markedEdges)
175 if (edgei < 0 || edgei >= surf1.nEdges())
178 <<
"edge label " << edgei <<
"out of range."
179 <<
" Surface has " << surf1.nEdges() <<
" edges."
183 const labelList& curFaces = surf1.edgeFaces()[edgei];
185 facesToSubset.
set(curFaces);
196 Info<<
"Using zone " << zoneBb <<
endl;
200 const point centre = surf1[facei].
centre(surf1.points());
204 facesToSubset.set(facei);
214 if (meshSubsetDict.found(
"surface"))
218 const auto surfName(surfDict.
get<
fileName>(
"name"));
227 Info<<
"Selecting faces with centre located "
242 searchSelectSurf.tree();
247 if (!facesToSubset[facei])
249 const point fc(surf1[facei].centre(surf1.points()));
251 if (volType == selectTree.getVolumeType(fc))
253 facesToSubset.set(facei);
260 if (meshSubsetDict.found(
"plane"))
264 const plane pl(planeDict);
265 const scalar
distance(planeDict.
get<scalar>(
"distance"));
266 const scalar cosAngle(planeDict.
get<scalar>(
"cosAngle"));
271 forAll(surf1.faceCentres(), facei)
273 const point& fc = surf1.faceCentres()[facei];
274 const point& nf = surf1.faceNormals()[facei];
276 if (pl.distance(fc) <
distance &&
mag(pl.normal() & nf) > cosAngle)
278 facesToSubset.set(facei);
290 label nFaceNeighbours = 0;
292 if (markedFaces.size())
294 Info<<
"Found " << markedFaces.size() <<
" marked face(s)." <<
endl;
297 for (
const label facei : markedFaces)
299 if (facei < 0 || facei >= surf1.size())
302 <<
"Face label " << facei <<
"out of range."
303 <<
" Surface has " << surf1.size() <<
" faces."
308 facesToSubset.set(facei);
311 if (addFaceNeighbours)
313 const labelList& curFaces = surf1.faceFaces()[facei];
315 for (
const label neiFacei : curFaces)
317 if (facesToSubset.set(neiFacei))
326 if (addFaceNeighbours)
328 Info<<
"Added " << nFaceNeighbours
329 <<
" faces because of addFaceNeighbours" <<
endl;
335 Info<<
"Inverting selection." <<
endl;
337 facesToSubset.flip();
345 surf2.writeStats(
Info);
348 Info<<
"Writing surface to " << outFileName <<
endl;
350 surf2.
write(outFileName);
A class for handling file names.
const point & max() const
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)
Extract command arguments and options from the supplied argc and argv parameters.
Ostream & endl(Ostream &os)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
T get(const label index) const
Helper class to search on triSurface.
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="")
Generic templated field type.
Triangulated surface description with patch information.
static const Enum< volumeType::type > names
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const Vector< Cmpt > & centre(const Foam::List< Vector< Cmpt >> &) const
Non-pointer based hierarchical recursive searching.
const point & min() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write(const token &tok)=0
scalar distance(const vector &p1, const vector &p2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool contains(const point &pt) const
#define FatalErrorInFunction
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
@ INSIDE
A location inside the volume.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bounding box defined in terms of min/max extrema points.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Foam::argList args(argc, argv)
#define WarningInFunction
@ OUTSIDE
A location outside the volume.