103 const fileName& fName,
104 const fileName& objectName
110 <<
"Cannot find triSurfaceMesh starting from " 117 bool Foam::triSurfaceMesh::addFaceToEdge
120 EdgeMap<label>& facesPerEdge
124 if (eFnd != facesPerEdge.end())
134 facesPerEdge.insert(e, 1);
140 bool Foam::triSurfaceMesh::isSurfaceClosed()
const 153 EdgeMap<label> facesPerEdge(100);
154 forAll(pointFaces, pointi)
156 const labelList& pFaces = pointFaces[pointi];
158 facesPerEdge.
clear();
170 label nextPointi = f[f.fcIndex(fp)];
172 if (nextPointi > pointi)
174 bool okFace = addFaceToEdge
176 edge(pointi, nextPointi),
186 label prevPointi = f[f.rcIndex(fp)];
188 if (prevPointi > pointi)
190 bool okFace = addFaceToEdge
192 edge(pointi, prevPointi),
246 Foam::triSurfaceMesh::triSurfaceMesh(
const IOobject& io)
294 Foam::triSurfaceMesh::triSurfaceMesh
339 scalar scaleFactor = 0;
343 if (dict.
readIfPresent(
"scale", scaleFactor) && scaleFactor > 0)
355 if (dict.
readIfPresent(
"minQuality", minQuality_) && minQuality_ > 0)
358 <<
" : ignoring triangles with quality < " 359 << minQuality_ <<
" for normals calculation." <<
endl;
413 const point& fc = centres[facei];
416 const point& pt = pts[f[fp]];
438 return !indices.
empty();
453 if (edgeTree_.empty())
473 static_cast<const triSurface&>(*
this),
484 bb = bb.
extend(rndGen, 1e-4);
485 bb.
min() -=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
486 bb.
max() +=
point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
518 if (regions_.
empty())
523 regions_[regionI] =
patches()[regionI].name();
533 if (surfaceClosed_ == -1)
535 if (isSurfaceClosed())
545 return surfaceClosed_ == 1;
643 if (minQuality_ >= 0)
654 label facei = info[i].index();
655 normal[i] = s[facei].normal(pts);
657 scalar qual = s[facei].tri(pts).quality();
659 if (qual < minQuality_)
662 const labelList& fFaces = faceFaces[facei];
666 label nbrI = fFaces[j];
667 scalar nbrQual = s[nbrI].tri(pts).quality();
671 normal[i] = s[nbrI].normal(pts);
676 normal[i] /=
mag(normal[i]) + VSMALL;
691 label facei = info[i].index();
696 normal[i] = s[facei].normal(pts);
697 normal[i] /=
mag(normal[i]) + VSMALL;
731 fldPtr.
ptr()->store();
741 if (foundObject<triSurfaceLabelField>(
"values"))
754 values[i] = fld[info[i].index()];
774 const point& pt = points[pointi];
776 if (!
tree().bb().contains(pt))
779 volType[pointi] =
tree().shapes().getVolumeType(
tree(), pt);
784 volType[pointi] =
tree().getVolumeType(pt);
806 triSurface::write(fullPath);
cachedRandom rndGen(label(0),-1)
const Time & time() const
Return time.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &) const
Get all intersections in order from start to end.
List< labelList > labelListList
A List of labelList.
label nPoints() const
Return number of points supporting patch faces.
Field< label > labelField
Specialisation of Field<T> for label.
fileName objectPath() const
Return complete path + object name.
virtual void boundingSpheres(pointField ¢res, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
#define forAll(list, i)
Loop across all elements in list.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, const labelList ®ionIndices, List< pointIndexHit > &info) const
Find the nearest point on the surface out of the regions.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
const boundBox & bounds() const
Return const reference to boundBox.
void clearOut()
Clear storage.
const objectRegistry & db() const
Return the local objectRegistry.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void clearOut()
Clear storage.
const point & min() const
Minimum describing the bounding box.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
T & operator[](const label)
Return element of UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual ~triSurfaceMesh()
Destructor.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void size(const label)
Override size to be inconsistent with allocated storage.
virtual tmp< pointField > points() const
Get the points that define the surface.
virtual label size() const
Range of local indices that can be returned.
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static scalar & perturbTol()
Get the perturbation tolerance.
const Field< point > & points() const
Return reference to global points.
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
Holds data for octree to work on an edges subset.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
const point & max() const
Maximum describing the bounding box.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
A bounding box defined in terms of the points at its extremities.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines. WIP.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
T * ptr()
Return object pointer for reuse.
writeOption writeOpt() const
Macros for easy insertion into run-time selection tables.
label maxTreeDepth() const
Return max tree depth of octree.
virtual void movePoints(const pointField &)
Move points.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit >> &info) const
Calculate all intersections from start to end.
A list of faces which address into the list of points.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
A List obtained as a section of another List.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
vectorField pointField
pointField is a vectorField.
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
scalar tolerance() const
Return tolerance to use in searches.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
fileName filePath() const
Return complete path + object name if the file exists.
virtual const wordList & regions() const
Names of regions.
void clear()
Clear the list, i.e. set size to zero.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
const geometricSurfacePatchList & patches() const
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
streamFormat
Enumeration for the format of data in the stream.
List< label > labelList
A List of labels.
const fileName & local() const
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Triangle with additional region number.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
Simple random number generator.
compressionType
Enumeration for the format of data in the stream.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
const Field< point > & faceCentres() const
Return face centres for patch.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence 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.
label size() const
Return the number of elements in the UList.
word name(const complex &)
Return a string representation of a complex.
const labelListList & faceFaces() const
Return face-face addressing.
label nEdges() const
Return number of edges in patch.
void setSize(const label)
Reset size of List.
triSurface()
Construct null.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
vector point
Point is a vector.
Non-pointer based hierarchical recursive searching.
label nInternalEdges() const
Number of internal edges.
virtual void movePoints(const pointField &)
Move points.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
readOption readOpt() const
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
A class for managing temporary objects.
Registry of regIOobjects.
friend class iterator
Declare friendship with the iterator.
Triangulated surface description with patch information.
T & ref() const
Return non-const reference or generate a fatal error.
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName path() const
Return directory path name (part before last /)
const fileName & instance() const
const Field< point > & localPoints() const
Return pointField of points in patch.
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
const word & name() const
Return name.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.