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());
202 if (zoneBb.contains(centre))
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);
static void addNote(const string ¬e)
Add extra notes for the usage information.
A class for handling file names.
type
Volume classification types.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void noParallel()
Remove the parallel options.
scalar distance(const vector &p1, const vector &p2)
A bounding box defined in terms of min/max extrema points.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
#define forAll(list, i)
Loop across all elements in list.
Helper class to search on triSurface.
Extract command arguments and options from the supplied argc and argv parameters. ...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A location inside the volume.
A location outside the volume.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Input from file stream, using an ISstream.
T get(const label index) const
Get a value from the argument at index.
Non-pointer based hierarchical recursive searching.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
messageStream Info
Information stream (stdout output on master, null elsewhere)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
static const Enum< volumeType::type > names
Names for the classification enumeration.