55int 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);
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
const Vector< Cmpt > & centre(const Foam::UList< Vector< Cmpt > > &) const noexcept
Return this (for point which is a typedef to Vector<scalar>).
Extract command arguments and options from the supplied argc and argv parameters.
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
static void noParallel()
Remove the parallel options.
static void addNote(const string ¬e)
Add extra notes for the usage information.
A bounding box defined in terms of min/max extrema points.
const point & max() const noexcept
Maximum describing the bounding box.
const point & min() const noexcept
Minimum describing the bounding box.
bool contains(const point &pt) const
Contains point? (inside or on edge).
bool good() const
Bounding box is non-inverted.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
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...
A class for handling file names.
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
Non-pointer based hierarchical recursive searching.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Helper class to search on triSurface.
Triangulated surface description with patch information.
static const Enum< volumeType::type > names
Names for the classification enumeration.
type
Volume classification types.
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
scalar distance(const vector &p1, const vector &p2)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
MeshedSurface< face > meshedSurface
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.