55 for (i=ts.size()-1; i>=0; i--)
68 for (
label j=i; j>=0; j--)
74 Pout<<
" triSurface::triSurfInstance(const Time& d)" 75 <<
"reading " << foamName
76 <<
" from " << ts[j].
name()/typeName
87 Pout<<
" triSurface::triSurfInstance(const Time& d)" 88 <<
"reading " << foamName
89 <<
" from constant/" <<
endl;
98 const label defaultRegion
105 const face& f = faces[facei];
110 <<
"Face at position " << facei
111 <<
" does not have three vertices:" << f
120 tri.
region() = defaultRegion;
130 const label defaultRegion
137 const triFace& f = faces[facei];
144 tri.
region() = defaultRegion;
153 void Foam::triSurface::printTriangle
162 << pre.c_str() <<
"vertex numbers:" 163 << f[0] <<
' ' << f[1] <<
' ' << f[2] <<
endl 164 << pre.c_str() <<
"vertex coords :" 165 << points[f[0]] <<
' ' << points[f[1]] <<
' ' << points[f[2]]
166 << pre.c_str() <<
"region :" << f.
region() <<
endl 178 while ((line.empty() || line[0] ==
'#') && is.
good());
196 if (f[fp] < 0 || f[fp] > maxPointi)
200 <<
" uses point indices outside point range 0.." 214 bool hasInvalid =
false;
220 if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
223 valid[facei] =
false;
229 <<
"triangle " << facei
230 <<
" does not have three unique vertices:\n";
237 const labelList& fEdges = faceEdges()[facei];
244 const labelList& eFaces = edgeFaces()[fEdges[fp]];
248 label neighbour = eFaces[i];
250 if (neighbour > facei)
257 ((f[0] == n[0]) || (f[0] == n[1]) || (f[0] == n[2]))
258 && ((f[1] == n[0]) || (f[1] == n[1]) || (f[1] == n[2]))
259 && ((f[2] == n[0]) || (f[2] == n[1]) || (f[2] == n[2]))
262 valid[facei] =
false;
268 <<
"triangles share the same vertices:\n" 269 <<
" face 1 :" << facei <<
endl;
275 << neighbour <<
endl;
296 (*this)[newFacei++] =
f;
303 <<
"Removing " << size() - newFacei
304 <<
" illegal faces." <<
endl;
306 (*this).setSize(newFacei);
321 const labelList& myFaces = eFaces[edgeI];
326 <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
327 <<
" has no edgeFaces" 330 else if (myFaces.
size() > 2 && verbose)
333 <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
334 <<
" has more than 2 faces connected to it : " << myFaces
342 bool Foam::triSurface::read(
Istream& is)
344 is >> patches_ >> storedPoints() >> storedFaces();
351 bool Foam::triSurface::read
358 if (check && !
exists(name))
369 return read(unzipName, unzipName.
ext(),
false);
371 else if (ext ==
"ftr")
375 else if (ext ==
"stl")
377 return readSTL(name);
379 else if (ext ==
"stlb")
381 return readSTLBINARY(name);
383 else if (ext ==
"gts")
385 return readGTS(name);
387 else if (ext ==
"obj")
389 return readOBJ(name);
391 else if (ext ==
"off")
393 return readOFF(name);
395 else if (ext ==
"tri")
397 return readTRI(name);
399 else if (ext ==
"ac")
403 else if (ext ==
"nas")
405 return readNAS(name);
407 else if (ext ==
"vtk")
409 return readVTK(name);
414 <<
"unknown file extension " << ext
415 <<
". Supported extensions are '.ftr', '.stl', '.stlb', '.gts'" 416 <<
", '.obj', '.ac', '.off', '.nas', '.tri' and '.vtk'" 425 void Foam::triSurface::write
436 else if (ext ==
"stl")
438 return writeSTLASCII(sort,
OFstream(name)());
440 else if (ext ==
"stlb")
442 ofstream outFile(name.c_str(), std::ios::binary);
444 writeSTLBINARY(outFile);
446 else if (ext ==
"gts")
448 return writeGTS(sort,
OFstream(name)());
450 else if (ext ==
"obj")
454 else if (ext ==
"off")
458 else if (ext ==
"vtk")
462 else if (ext ==
"tri")
466 else if (ext ==
"dx")
470 else if (ext ==
"ac")
474 else if (ext ==
"smesh")
481 <<
"unknown file extension " << ext
482 <<
" for file " << name
483 <<
". Supported extensions are '.ftr', '.stl', '.stlb', " 484 <<
"'.gts', '.obj', '.vtk'" 485 <<
", '.off', '.dx', '.smesh', '.ac' and '.tri'" 498 forAll(sortedRegion, facei)
500 sortedRegion[facei] = operator[](facei).region();
504 faceMap = sortedRegion.
indices();
514 operator[](faceMap.
last()).region()
524 label region = operator[](facei).region();
526 newPatches[region].size()++;
532 label startFacei = 0;
533 forAll(newPatches, newPatchi)
537 newPatch.
index() = newPatchi;
539 label oldPatchi = newPatchi;
542 newPatch.
start() = startFacei;
546 if ((oldPatchi < patches_.size()) && (patches_[oldPatchi].
name() !=
""))
548 newPatch.
name() = patches_[oldPatchi].name();
557 (oldPatchi < patches_.size())
558 && (patches_[oldPatchi].geometricType() !=
"")
561 newPatch.
geometricType() = patches_[oldPatchi].geometricType();
568 startFacei += newPatch.
size();
575 void Foam::triSurface::setDefaultPatches()
583 patches_.setSize(newPatches.
size());
589 patches_[
patchi].geometricType() = newPatches[
patchi].geometricType();
600 sortedEdgeFacesPtr_(nullptr),
601 edgeOwnerPtr_(nullptr)
615 sortedEdgeFacesPtr_(
nullptr),
616 edgeOwnerPtr_(
nullptr)
630 sortedEdgeFacesPtr_(
nullptr),
631 edgeOwnerPtr_(
nullptr)
644 sortedEdgeFacesPtr_(
nullptr),
645 edgeOwnerPtr_(
nullptr)
657 sortedEdgeFacesPtr_(
nullptr),
658 edgeOwnerPtr_(
nullptr)
670 ParentType(convertToTri(triangles, 0), points),
672 sortedEdgeFacesPtr_(
nullptr),
673 edgeOwnerPtr_(
nullptr)
683 sortedEdgeFacesPtr_(nullptr),
684 edgeOwnerPtr_(nullptr)
698 sortedEdgeFacesPtr_(nullptr),
699 edgeOwnerPtr_(nullptr)
711 sortedEdgeFacesPtr_(nullptr),
712 edgeOwnerPtr_(nullptr)
729 patches_(ts.patches()),
730 sortedEdgeFacesPtr_(nullptr),
731 edgeOwnerPtr_(nullptr)
770 if (!sortedEdgeFacesPtr_)
772 calcSortedEdgeFaces();
775 return *sortedEdgeFacesPtr_;
786 return *edgeOwnerPtr_;
806 if (scaleFactor > 0 && scaleFactor != 1.0)
823 stitchTriangles(SMALL, verbose);
840 const label currentZone,
854 label facei = changedFaces[i];
860 label edgeI = fEdges[i];
862 if (!borderEdge[edgeI])
868 label nbrFacei = eFaces[j];
870 if (faceZone[nbrFacei] == -1)
872 faceZone[nbrFacei] = currentZone;
873 newChangedFaces.
append(nbrFacei);
875 else if (faceZone[nbrFacei] != currentZone)
878 <<
"Zones " << faceZone[nbrFacei]
879 <<
" at face " << nbrFacei
880 <<
" connects to zone " << currentZone
881 <<
" at face " << facei
889 if (newChangedFaces.empty())
894 changedFaces.
transfer(newChangedFaces);
913 <<
"borderEdge boolList not same size as number of edges" <<
endl 914 <<
"borderEdge:" << borderEdge.
size() <<
endl 921 for (
label startFacei = 0;; zoneI++)
924 for (; startFacei <
size(); startFacei++)
926 if (faceZone[startFacei] == -1)
932 if (startFacei >=
size())
937 faceZone[startFacei] = zoneI;
939 markZone(borderEdge, startFacei, zoneI, faceZone);
966 if (include[oldFacei])
969 faceMap[facei++] = oldFacei;
979 pointHad[labI] =
true;
980 pointMap[pointi++] = labI;
1011 newPoints[pointi] = locPoints[pointMap[pointi]];
1012 oldToNew[pointMap[pointi]] = pointi;
1021 const labelledTri& tri = locFaces[faceMap[facei]];
1023 newTriangles[facei][0] = oldToNew[tri[0]];
1024 newTriangles[facei][1] = oldToNew[tri[1]];
1025 newTriangles[facei][2] = oldToNew[tri[2]];
1026 newTriangles[facei].region() = tri.region();
1034 void Foam::triSurface::write
1037 const bool sortByRegion
1040 write(name, name.
ext(), sortByRegion);
1053 os.
check(
"triSurface::write(Ostream&)");
1057 void Foam::triSurface::write(
const Time& d)
const 1084 label pointi = f[fp];
1085 if (pointIsUsed.
set(pointi, 1))
1094 os <<
"Triangles : " <<
size() <<
endl 1095 <<
"Vertices : " << nPoints <<
endl 1096 <<
"Bounding Box : " << bb <<
endl;
virtual const fileName & name() const
Return the name of the stream.
A simple container for copying or transferring objects of type <T>.
label nPoints() const
Return number of points supporting patch faces.
void cleanup(const bool verbose)
Remove non-valid triangles.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
fileName path() const
Return path.
label start() const
Return start label of this patch in the polyMesh face list.
virtual void movePoints(const Field< point > &)
Correct patch after moving points.
void sort()
(stable) sort the list (if changed after construction time)
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 word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
void operator=(const triSurface &)
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.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
A list that is sorted upon construction or when explicitly requested with the sort() method...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
const word & geometricType() const
Return the type of the patch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A bounding box defined in terms of the points at its extremities.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
void clearPatchMeshAddr()
void clearPatchMeshAddr()
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool good() const
Return true if next operation might succeed.
word ext() const
Return file name extension (part after last .)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const List< labelledTri > & localFaces() const
Return patch faces addressing into local point list.
virtual void movePoints(const pointField &)
Move points.
label region() const
Return region label.
bool read(const char *, int32_t &)
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
vectorField pointField
pointField is a vectorField.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
'Patch' on surface as subset of triSurface.
void set(const PackedList< 1 > &)
Set specified bits.
void writeStats(Ostream &) const
Write some statistics.
A class for handling words, derived from string.
A triangular face using a FixedList of labels corresponding to mesh vertices.
virtual const fileName & name() const
Return the name of the stream.
const fileName & caseName() const
Return case name.
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
void append(const T &)
Append an element at the end of the list.
const word & constant() const
Return constant name.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.
word name() const
Return file name (part beyond last /)
const Field< point > & points() const
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
Triangle with additional region number.
errorManip< error > abort(error &err)
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
pointField & storedPoints()
Non-const access to global points.
bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const Field< point > & localPoints() const
Return pointField of points in patch.
label nEdges() const
Return number of edges in patch.
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
void operator=(const UList< T > &)
Assignment to UList operator. Takes linear time.
void setSize(const label)
Reset size of List.
Template functions to aid in the implementation of demand driven data.
const point & max() const
Maximum describing the bounding box.
const geometricSurfacePatchList & patches() const
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- VGREAT.
triSurface()
Construct null.
scalar timeOutputValue() const
Return current time value.
label size() const
Return size of this patch in the polyMesh face list.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
void subsetMeshMap(const boolList &include, labelList &pointMap, labelList &faceMap) const
'Create' sub mesh, including only faces for which
instantList times() const
Search the case for valid time directories.
Ostream & operator<<(Ostream &, const ensightPart &)
fileName lessExt() const
Return file name without extension (part before last .)
const labelListList & faceEdges() const
Return face-edge addressing.
label index() const
Return the index of this patch in the boundaryMesh.
const point & min() const
Minimum describing the bounding box.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
void writeVTK(OFstream &os, const Type &value)
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
T & last()
Return the last element of the list.
Triangulated surface description with patch information.
void deleteDemandDrivenData(DataPtr &dataPtr)
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
A class for handling character strings derived from std::string.
label size() const
Return the number of elements in the UList.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
ISstream & getLine(string &)
Raw, low-level getline into a string function.