53 for (i=ts.size()-1; i>=0; i--)
66 for (
label j=i; j>=0; j--)
72 Pout<<
" triSurface::triSurfInstance(const Time& d)" 73 <<
"reading " << foamName
74 <<
" from " << ts[j].
name()/typeName
85 Pout<<
" triSurface::triSurfInstance(const Time& d)" 86 <<
"reading " << foamName
87 <<
" from constant/" <<
endl;
96 const label defaultRegion
103 const face& f = faces[facei];
108 <<
"Face at position " << facei
109 <<
" does not have three vertices:" << f
118 tri.
region() = defaultRegion;
128 const label defaultRegion
135 const triFace& f = faces[facei];
142 tri.
region() = defaultRegion;
151 void Foam::triSurface::printTriangle
160 << pre.c_str() <<
"vertex numbers:" 161 << f[0] <<
' ' << f[1] <<
' ' << f[2] <<
endl 162 << pre.c_str() <<
"vertex coords :" 163 << points[f[0]] <<
' ' << points[f[1]] <<
' ' << points[f[2]]
164 << pre.c_str() <<
"region :" << f.
region() <<
endl 176 while ((line.empty() || line[0] ==
'#') && is.
good());
194 if (f[fp] < 0 || f[fp] > maxPointi)
198 <<
" uses point indices outside point range 0.." 212 bool hasInvalid =
false;
218 if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2]))
221 valid[facei] =
false;
227 <<
"triangle " << facei
228 <<
" does not have three unique vertices:\n";
235 const labelList& fEdges = faceEdges()[facei];
242 const labelList& eFaces = edgeFaces()[fEdges[fp]];
246 label neighbour = eFaces[i];
248 if (neighbour > facei)
255 ((f[0] == n[0]) || (f[0] == n[1]) || (f[0] == n[2]))
256 && ((f[1] == n[0]) || (f[1] == n[1]) || (f[1] == n[2]))
257 && ((f[2] == n[0]) || (f[2] == n[1]) || (f[2] == n[2]))
260 valid[facei] =
false;
266 <<
"triangles share the same vertices:\n" 267 <<
" face 1 :" << facei <<
endl;
273 << neighbour <<
endl;
294 (*this)[newFacei++] =
f;
301 <<
"Removing " << size() - newFacei
302 <<
" illegal faces." <<
endl;
304 (*this).setSize(newFacei);
319 const labelList& myFaces = eFaces[edgeI];
324 <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
325 <<
" has no edgeFaces" 328 else if (myFaces.
size() > 2 && verbose)
331 <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
332 <<
" has more than 2 faces connected to it : " << myFaces
340 bool Foam::triSurface::read(
Istream& is)
342 is >> patches_ >> storedPoints() >> storedFaces();
349 bool Foam::triSurface::read
356 if (check && !
exists(name))
367 return read(unzipName, unzipName.
ext(),
false);
369 else if (ext ==
"ftr")
373 else if (ext ==
"stl")
375 return readSTL(name);
377 else if (ext ==
"stlb")
379 return readSTLBINARY(name);
381 else if (ext ==
"gts")
383 return readGTS(name);
385 else if (ext ==
"obj")
387 return readOBJ(name);
389 else if (ext ==
"off")
391 return readOFF(name);
393 else if (ext ==
"tri")
395 return readTRI(name);
397 else if (ext ==
"ac")
401 else if (ext ==
"nas")
403 return readNAS(name);
405 else if (ext ==
"vtk")
407 return readVTK(name);
412 <<
"unknown file extension " << ext
413 <<
". Supported extensions are '.ftr', '.stl', '.stlb', '.gts'" 414 <<
", '.obj', '.ac', '.off', '.nas', '.tri' and '.vtk'" 423 void Foam::triSurface::write
434 else if (ext ==
"stl")
436 return writeSTLASCII(sort,
OFstream(name)());
438 else if (ext ==
"stlb")
440 ofstream outFile(name.c_str(), std::ios::binary);
442 writeSTLBINARY(outFile);
444 else if (ext ==
"gts")
446 return writeGTS(sort,
OFstream(name)());
448 else if (ext ==
"obj")
452 else if (ext ==
"off")
456 else if (ext ==
"vtk")
460 else if (ext ==
"tri")
464 else if (ext ==
"dx")
468 else if (ext ==
"ac")
472 else if (ext ==
"smesh")
479 <<
"unknown file extension " << ext
480 <<
" for file " << name
481 <<
". Supported extensions are '.ftr', '.stl', '.stlb', " 482 <<
"'.gts', '.obj', '.vtk'" 483 <<
", '.off', '.dx', '.smesh', '.ac' and '.tri'" 496 forAll(sortedRegion, facei)
498 sortedRegion[facei] = operator[](facei).region();
502 faceMap = sortedRegion.
indices();
512 operator[](faceMap.
last()).region()
522 label region = operator[](facei).region();
524 newPatches[region].size()++;
530 label startFacei = 0;
531 forAll(newPatches, newPatchi)
535 newPatch.
index() = newPatchi;
537 label oldPatchi = newPatchi;
540 newPatch.
start() = startFacei;
544 if ((oldPatchi < patches_.size()) && (patches_[oldPatchi].
name() !=
""))
546 newPatch.
name() = patches_[oldPatchi].name();
555 (oldPatchi < patches_.size())
556 && (patches_[oldPatchi].geometricType() !=
"")
559 newPatch.
geometricType() = patches_[oldPatchi].geometricType();
566 startFacei += newPatch.
size();
573 void Foam::triSurface::setDefaultPatches()
581 patches_.setSize(newPatches.
size());
587 patches_[
patchi].geometricType() = newPatches[
patchi].geometricType();
598 sortedEdgeFacesPtr_(NULL),
613 sortedEdgeFacesPtr_(NULL),
628 sortedEdgeFacesPtr_(NULL),
642 sortedEdgeFacesPtr_(NULL),
655 sortedEdgeFacesPtr_(NULL),
668 ParentType(convertToTri(triangles, 0), points),
670 sortedEdgeFacesPtr_(NULL),
681 sortedEdgeFacesPtr_(NULL),
696 sortedEdgeFacesPtr_(NULL),
709 sortedEdgeFacesPtr_(NULL),
727 patches_(ts.patches()),
728 sortedEdgeFacesPtr_(NULL),
768 if (!sortedEdgeFacesPtr_)
770 calcSortedEdgeFaces();
773 return *sortedEdgeFacesPtr_;
784 return *edgeOwnerPtr_;
804 if (scaleFactor > 0 && scaleFactor != 1.0)
821 stitchTriangles(SMALL, verbose);
838 const label currentZone,
852 label facei = changedFaces[i];
858 label edgeI = fEdges[i];
860 if (!borderEdge[edgeI])
866 label nbrFacei = eFaces[j];
868 if (faceZone[nbrFacei] == -1)
870 faceZone[nbrFacei] = currentZone;
871 newChangedFaces.
append(nbrFacei);
873 else if (faceZone[nbrFacei] != currentZone)
876 <<
"Zones " << faceZone[nbrFacei]
877 <<
" at face " << nbrFacei
878 <<
" connects to zone " << currentZone
879 <<
" at face " << facei
887 if (newChangedFaces.empty())
892 changedFaces.
transfer(newChangedFaces);
911 <<
"borderEdge boolList not same size as number of edges" <<
endl 912 <<
"borderEdge:" << borderEdge.
size() <<
endl 919 for (
label startFacei = 0;; zoneI++)
922 for (; startFacei <
size(); startFacei++)
924 if (faceZone[startFacei] == -1)
930 if (startFacei >=
size())
935 faceZone[startFacei] = zoneI;
937 markZone(borderEdge, startFacei, zoneI, faceZone);
964 if (include[oldFacei])
967 faceMap[facei++] = oldFacei;
977 pointHad[labI] =
true;
978 pointMap[pointi++] = labI;
1009 newPoints[pointi] = locPoints[pointMap[pointi]];
1010 oldToNew[pointMap[pointi]] = pointi;
1019 const labelledTri& tri = locFaces[faceMap[facei]];
1021 newTriangles[facei][0] = oldToNew[tri[0]];
1022 newTriangles[facei][1] = oldToNew[tri[1]];
1023 newTriangles[facei][2] = oldToNew[tri[2]];
1024 newTriangles[facei].region() = tri.region();
1032 void Foam::triSurface::write
1035 const bool sortByRegion
1038 write(name, name.
ext(), sortByRegion);
1051 os.
check(
"triSurface::write(Ostream&)");
1055 void Foam::triSurface::write(
const Time& d)
const 1082 label pointi = f[fp];
1083 if (pointIsUsed.
set(pointi, 1))
1092 os <<
"Triangles : " <<
size() <<
endl 1093 <<
"Vertices : " << nPoints <<
endl 1094 <<
"Bounding Box : " << bb <<
endl;
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
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.
void subsetMeshMap(const boolList &include, labelList &pointMap, labelList &faceMap) const
'Create' sub mesh, including only faces for which
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.
label region() const
Return region label.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
const word & geometricType() const
Return the type of the patch.
const point & min() const
Minimum describing the bounding box.
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.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
A list that is sorted upon construction or when explicitly requested with the sort() method...
void writeStats(Ostream &) const
Write some statistics.
const List< labelledTri > & localFaces() const
Return patch faces addressing into local point list.
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.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
bool good() const
Return true if next operation might succeed.
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Field< point > & points() const
Return reference to global points.
const point & max() const
Maximum describing the bounding box.
A bounding box defined in terms of the points at its extremities.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
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.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void movePoints(const pointField &)
Move points.
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
word name() const
Return file name (part beyond last /)
bool read(const char *, int32_t &)
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
vectorField pointField
pointField is a vectorField.
'Patch' on surface as subset of triSurface.
void set(const PackedList< 1 > &)
Set specified bits.
A class for handling words, derived from string.
const geometricSurfacePatchList & patches() const
A triangular face using a FixedList of labels corresponding to mesh vertices.
const labelListList & faceEdges() const
Return face-edge addressing.
virtual const fileName & name() const
Return the name of the stream.
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
void append(const T &)
Append an element at the end of the list.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
const word & constant() const
Return constant name.
Triangle with additional region number.
const word & name() const
Return name.
errorManip< error > abort(error &err)
pointField & storedPoints()
Non-const access to global points.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
prefixOSstream Pout(cout,"Pout")
virtual const fileName & name() const
Return the name of the stream.
defineTypeNameAndDebug(combustionModel, 0)
fileName lessExt() const
Return file name without extension (part before last .)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label size() const
Return the number of elements in the UList.
label start() const
Return start label of this patch in the polyMesh face list.
word name(const complex &)
Return a string representation of a complex.
label nEdges() const
Return number of edges in patch.
void operator=(const UList< T > &)
Assignment from UList operator. Takes linear time.
void setSize(const label)
Reset size of List.
Template functions to aid in the implementation of demand driven data.
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- VGREAT.
triSurface()
Construct null.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
#define WarningInFunction
Report a warning using Foam::Warning.
scalar timeOutputValue() const
Return current time value.
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
Ostream & operator<<(Ostream &, const ensightPart &)
word ext() const
Return file name extension (part after last .)
label size() const
Return size of this patch in the polyMesh face list.
instantList times() const
Search the case for valid time directories.
const labelListList & edgeFaces() const
Return edge-face addressing.
void writeVTK(OFstream &os, const Type &value)
T & last()
Return the last element of the list.
Triangulated surface description with patch information.
fileName path() const
Return path.
void deleteDemandDrivenData(DataPtr &dataPtr)
A class for handling character strings derived from std::string.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
label index() const
Return the index of this patch in the boundaryMesh.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
const Field< point > & localPoints() const
Return pointField of points in patch.
const fileName & caseName() const
Return case name.
ISstream & getLine(string &)
Raw, low-level getline into a string function.