50 const Switch& geometricTestOnly
58 Info<< nl <<
"Reading existing feature edges from file " 59 << featureEdgeFile << nl
60 <<
"Selecting edges purely based on geometric tests: " 80 const Switch& geometricTestOnly,
81 const scalar includedAngle
85 <<
"Constructing feature set from included angle " 86 << includedAngle << nl
87 <<
"Selecting edges purely based on geometric tests: " 109 const scalar includedAngle
118 if (dict.
found(
"files"))
122 if (fileNames.found(surfaceFileName))
124 return extractFromFile
126 fileNames[surfaceFileName],
133 return extractFromSurface
143 return extractFromSurface
162 Info<<
"Surface : " << surfaceFileName << nl <<
endl;
173 const Switch featureProximity =
177 Info<< nl <<
"Feature line extraction is only valid on closed manifold " 178 <<
"surfaces." <<
endl;
200 const scalar includedAngle = dict.
lookup<scalar>(
"includedAngle");
216 if (dict.
isDict(
"trimFeatures"))
226 if (minElem > 0 || minLen > 0)
228 Info<<
"Removing features of length < " 230 Info<<
"Removing features with number of edges < " 233 set().trimFeatures(minLen, minElem, includedAngle);
244 if (dict.
isDict(
"subsetFeatures"))
251 if (subsetDict.
found(
"insideBox"))
255 Info<<
"Selecting edges inside bb " << bb;
258 Info <<
" see insideBox.obj";
259 bb.writeOBJ(
"insideBox.obj");
265 else if (subsetDict.
found(
"outsideBox"))
269 Info<<
"Removing all edges inside bb " << bb;
272 Info<<
" see outsideBox.obj" <<
endl;
273 bb.writeOBJ(
"outsideBox.obj");
280 const Switch nonManifoldEdges =
283 if (!nonManifoldEdges)
285 Info<<
"Removing all non-manifold edges" 286 <<
" (edges with > 2 connected faces) unless they" 287 <<
" cross multiple regions" <<
endl;
297 Info<<
"Removing all open edges" 298 <<
" (edges with 1 connected face)" <<
endl;
309 if (subsetDict.
found(
"plane"))
315 Info<<
"Only edges that intersect the plane with normal " 317 <<
" and base point " << cutPlane.refPoint()
318 <<
" will be included as feature edges."<<
endl;
324 newSet.setFromStatus(edgeStat, includedAngle);
327 <<
"Initial feature set:" << nl
328 <<
" feature points : " << newSet.featurePoints().size() << nl
329 <<
" feature edges : " << newSet.featureEdges().size() << nl
331 <<
" region edges : " << newSet.nRegionEdges() << nl
332 <<
" external edges : " << newSet.nExternalEdges() << nl
333 <<
" internal edges : " << newSet.nInternalEdges() << nl
345 if (
findIndex(surfBaffleNames, name) != -1)
347 Info<<
"Adding baffle region " << name <<
endl;
348 surfBaffleRegions[pI] =
true;
357 sFeatFileName +
".extendedFeatureEdgeMesh",
362 if (dict.
isDict(
"addFeatures"))
364 const word addFeName = dict.
subDict(
"addFeatures")[
"name"];
365 Info<<
"Adding (without merging) features from " << addFeName
374 "extendedFeatureEdgeMesh",
380 Info<<
"Read " << addFeMesh.name() <<
nl;
381 addFeMesh.writeStats(
Info);
383 feMesh.add(addFeMesh);
388 <<
"Final feature set:" <<
nl;
389 feMesh.writeStats(
Info);
391 Info<< nl <<
"Writing extendedFeatureEdgeMesh to " 392 << feMesh.relativeObjectPath() <<
endl;
394 mkDir(feMesh.path());
424 Info<< nl <<
"Writing featureEdgeMesh to " 425 << bfeMesh.relativeObjectPath() <<
endl;
427 bfeMesh.regIOobject::write();
431 boolList writeVTKFieldIsPointValues;
432 #define DeclareWriteVTKFieldTypeValues(Type, nullArg) \ 433 PtrList<const Field<Type>> writeVTKField##Type##Values; 435 #undef DeclareWriteVTKFieldTypeValues 438 if (dict.
isDict(
"closeness"))
440 Info<< nl <<
"Extracting internal and external closeness of " 441 <<
"surface." <<
endl;
445 const Switch faceCloseness =
447 const Switch pointCloseness =
450 const scalar internalAngleTolerance
454 "internalAngleTolerance", 80
458 const scalar externalAngleTolerance
462 "externalAngleTolerance", 80
471 sFeatFileName +
".closeness",
483 searchSurf.extractCloseness
485 internalAngleTolerance,
486 externalAngleTolerance
491 << closenessFields.first()->name() <<
endl;
492 closenessFields.first()->
write();
495 << closenessFields.second()->name() <<
endl;
496 closenessFields.second()->
write();
500 writeVTKFieldNames.
append(
"internalCloseness");
501 writeVTKFieldIsPointValues.
append(
false);
502 writeVTKFieldscalarValues.append
507 writeVTKFieldNames.
append(
"externalCloseness");
508 writeVTKFieldIsPointValues.
append(
false);
509 writeVTKFieldscalarValues.append
520 searchSurf.extractPointCloseness
522 internalAngleTolerance,
523 externalAngleTolerance
528 << closenessFields.first()->name() <<
endl;
529 closenessFields.first()->
write();
532 << closenessFields.second()->name() <<
endl;
533 closenessFields.second()->
write();
537 const faceList faces(searchSurf.faces());
538 const Map<label>& meshPointMap = searchSurf.meshPointMap();
541 internalClosenessPointField = closenessFields.
first();
544 externalClosenessPointField = closenessFields.second();
546 scalarField internalCloseness(searchSurf.nPoints(), great);
547 scalarField externalCloseness(searchSurf.nPoints(), great);
551 internalCloseness[
pi] =
552 internalClosenessPointField[meshPointMap[
pi]];
554 externalCloseness[
pi] =
555 externalClosenessPointField[meshPointMap[
pi]];
558 writeVTKFieldNames.
append(
"internalPointCloseness");
559 writeVTKFieldIsPointValues.
append(
true);
560 writeVTKFieldscalarValues.append
565 writeVTKFieldNames.
append(
"externalPointCloseness");
566 writeVTKFieldIsPointValues.
append(
true);
567 writeVTKFieldscalarValues.append
578 Info<< nl <<
"Extracting curvature of surface at the points." 585 sFeatFileName +
".curvature",
599 writeVTKFieldNames.
append(
"curvature");
600 writeVTKFieldIsPointValues.
append(
true);
606 if (featureProximity)
608 Info<< nl <<
"Extracting proximity of close feature points and " 609 <<
"edges to the surface" <<
endl;
611 const scalar searchDistance =
612 dict.
lookup<scalar>(
"maxFeatureProximity");
621 const scalar radiusSqr =
min 629 feMesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList);
630 featureProximity[fi] =
min 632 feMesh.minDisconnectedDist(hitList),
636 feMesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList);
637 featureProximity[fi] =
min 648 sFeatFileName +
".featureProximity",
660 featureProximityField.write();
664 writeVTKFieldNames.
append(
"featureProximity");
665 writeVTKFieldIsPointValues.
append(
false);
666 writeVTKFieldscalarValues.append
675 #define WriteVTKResizeFieldTypeValues(Type, nullArg) \ 676 writeVTKField##Type##Values.resize(writeVTKFieldNames.size()); 678 #undef WriteVTKResizeFieldTypeValues 685 /sFeatFileName +
"Features.vtk",
693 writeVTKFieldIsPointValues,
695 #define WriteVTKFieldTypeValuesParameter(Type, nullArg) \
698 #undef WriteVTKFieldTypeValuesParameter 713 forAll(surfaceFileNames, i)
715 extractFeatures(surfaceFileNames[i], runTime, dict);
723 int main(
int argc,
char *argv[])
727 "extract and write surface features to file" 738 if (dict.
found(
"surfaces"))
751 if (!iter().isDict())
List< labelList > labelListList
A List of labelList.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
A triangle primitive used to calculate face areas and swept volumes.
virtual Ostream & write(const char)=0
Write character.
A class for handling file names.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
void selectCutEdges(const triSurface &surf, const plane &cutPlane, List< surfaceFeatures::edgeStatus > &edgeStat)
Select edges that are intersected by the given plane.
T lookupOrAddDefault(const word &, const T &, bool recursive=false, bool patternMatch=true)
Find and return a T, if not found return the given.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
tmp< scalarField > curvature() const
Return the curvature of surface at the points.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
static void noParallel()
Remove the parallel options.
void selectBox(const triSurface &surf, const boundBox &bb, const bool removeInside, List< surfaceFeatures::edgeStatus > &edgeStat)
Select edges inside or outside bounding box.
label k
Boltzmann constant.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
T & first()
Return the first element of the list.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
scalar minDist(const List< pointIndexHit > &hitList)
bool isDict(const word &) const
Check if entry is a sub-dictionary.
const dimensionSet dimLength
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
A surface geometry formed of discrete facets, e.g. triangles and/or quadrilaterals, defined in a file using formats such as Wavefront OBJ, or stereolithography STL.
void selectManifoldEdges(const triSurface &surf, const scalar tol, const scalar includedAngle, List< surfaceFeatures::edgeStatus > &edgeStat)
Select manifold edges.
stressControl lookup("compactNormalStress") >> compactNormalStress
An ordered pair of two objects of type <T> with first() and second() elements.
void writeStats(Ostream &) const
Write some statistics.
static const word & geometryDir()
Return the geometry directory name.
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void append(const T &)
Append an element at the end of the list.
const word & constant() const
Return constant name.
word name() const
Return file name (part beyond last /)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
const Field< PointType > & points() const
Return reference to global points.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const labelListList & edgeFaces() const
Return edge-face addressing.
List< label > labelList
A List of labels.
scalar circumRadius() const
Return circum-radius.
An STL-conforming hash table.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
IOstream::streamFormat writeFormat() const
Default write format.
const Time & time() const
Return time.
Points connected by edges.
const char * asText() const
Return a text representation of the Switch.
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
const geometricSurfacePatchList & patches() const
Point circumCentre() const
Return circum-centre.
time_t elapsedClockTime() const
Returns wall-clock time from clock instantiation.
double elapsedCpuTime() const
Return CPU time (in seconds) from the start.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
fileName lessExt() const
Return file name without extension (part before last .)
Standard boundBox + extra functionality for use in octree.
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
faceList faces() const
Return the list of triangles as a faceList.
const doubleScalar e
Elementary charge.
static void addNote(const string &)
Add extra notes for the usage information.
Triangulated surface description with patch information.
Foam::argList args(argc, argv)
List< fileName > fileNameList
A List of fileNames.
fileName path() const
Return path.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Holds feature edges/points of surface.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.