Go to the documentation of this file.
53 for (i = ts.
size() - 1; i >= 0; i--)
66 for (
label j = i; j >= 0; j--)
68 if (
isFile(d.
path()/ts[j].name()/typeName/foamName))
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;
97 const label defaultRegion
104 const face&
f = faces[faceI];
110 "triSurface::convertToTri"
111 "(const faceList&, const label)"
112 ) <<
"Face at position " << faceI
113 <<
" does not have three vertices:" <<
f
122 tri.
region() = defaultRegion;
132 const label defaultRegion
146 tri.
region() = defaultRegion;
163 os << pre.c_str() <<
"vertex numbers:"
164 <<
f[0] <<
' ' <<
f[1] <<
' ' <<
f[2] <<
endl
165 << pre.c_str() <<
"vertex coords :"
167 << pre.c_str() <<
"region :" <<
f.region() <<
endl
197 (
f[0] < 0) || (
f[0] > maxPointI)
198 || (
f[1] < 0) || (
f[1] > maxPointI)
199 || (
f[2] < 0) || (
f[2] > maxPointI)
204 <<
" uses point indices outside point range 0.."
217 bool hasInvalid =
false;
225 if ((
f[0] ==
f[1]) || (
f[0] ==
f[2]) || (
f[1] ==
f[2]))
228 valid[faceI] =
false;
235 "triSurface::checkTriangles(bool verbose)"
236 ) <<
"triangle " << faceI
237 <<
" does not have three unique vertices:\n";
244 const labelList& neighbours = fFaces[faceI];
248 forAll (neighbours, neighbourI)
250 if (neighbours[neighbourI] <= faceI)
260 ((
f[0] ==
n[0]) || (
f[0] ==
n[1]) || (
f[0] ==
n[2]))
261 && ((
f[1] ==
n[0]) || (
f[1] ==
n[1]) || (
f[1] ==
n[2]))
262 && ((
f[2] ==
n[0]) || (
f[2] ==
n[1]) || (
f[2] ==
n[2]))
265 valid[faceI] =
false;
272 "triSurface::checkTriangles(bool verbose)"
273 ) <<
"triangles share the same vertices:\n"
274 <<
" face 1 :" << faceI <<
endl;
280 << neighbours[neighbourI] <<
endl;
299 (*this)[newFaceI++] =
f;
307 "triSurface::checkTriangles(bool verbose)"
308 ) <<
"Removing " << size() - newFaceI
309 <<
" illegal faces." <<
endl;
311 (*this).setSize(newFaceI);
326 const labelList& myFaces = eFaces[edgeI];
331 <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
332 <<
" has no edgeFaces"
335 else if (myFaces.
size() > 2)
339 "triSurface::checkEdges(bool verbose)"
340 ) <<
"Edge " << edgeI <<
" with vertices " << edges()[edgeI]
341 <<
" has more than 2 faces connected to it : " << myFaces
351 is >> patches_ >> storedPoints() >> storedFaces();
369 "triSurface::read(const fileName&, const word&, const bool)"
378 return read(unzipName, unzipName.
ext(),
false);
380 else if (ext ==
"ftr")
384 else if (ext ==
"stl")
386 return readSTL(
name);
388 else if (ext ==
"stlb")
390 return readSTL(
name);
392 else if (ext ==
"gts")
394 return readGTS(
name);
396 else if (ext ==
"obj")
398 return readOBJ(
name);
400 else if (ext ==
"off")
402 return readOFF(
name);
404 else if (ext ==
"tri")
406 return readTRI(
name);
408 else if (ext ==
"ac")
412 else if (ext ==
"nas")
414 return readNAS(
name);
420 "triSurface::read(const fileName&, const word&)"
421 ) <<
"unknown file extension " << ext
422 <<
". Supported extensions are '.ftr', '.stl', '.stlb', '.gts'"
423 <<
", '.obj', '.ac', '.off', '.nas' and '.tri'"
443 else if (ext ==
"stl")
447 else if (ext ==
"stlb")
449 ofstream outFile(
name.c_str(), std::ios::binary);
451 writeSTLBINARY(outFile);
453 else if (ext ==
"gts")
457 else if (ext ==
"obj")
461 else if (ext ==
"off")
465 else if (ext ==
"vtk")
469 else if (ext ==
"tri")
473 else if (ext ==
"dx")
477 else if (ext ==
"ac")
481 else if (ext ==
"smesh")
489 "triSurface::write(const fileName&, const word&, const bool)"
490 ) <<
"unknown file extension " << ext
491 <<
". Supported extensions are '.ftr', '.stl', '.stlb', "
492 <<
"'.gts', '.obj', '.vtk'"
493 <<
", '.off', '.dx', '.smesh', '.ac' and '.tri'"
506 forAll (sortedRegion, faceI)
508 sortedRegion[faceI] = operator[](faceI).region();
532 label region = operator[](faceI).region();
534 newPatches[region].
size()++;
540 label startFaceI = 0;
541 forAll (newPatches, newPatchI)
545 newPatch.
index() = newPatchI;
547 label oldPatchI = newPatchI;
550 newPatch.
start() = startFaceI;
556 (oldPatchI < patches_.size())
557 && (patches_[oldPatchI].name() !=
"")
560 newPatch.
name() = patches_[oldPatchI].name();
569 (oldPatchI < patches_.size())
570 && (patches_[oldPatchI].geometricType() !=
"")
573 newPatch.
geometricType() = patches_[oldPatchI].geometricType();
580 startFaceI += newPatch.
size();
595 patches_.setSize(newPatches.
size());
597 forAll (newPatches, patchI)
599 patches_[patchI].index() = patchI;
600 patches_[patchI].name() = newPatches[patchI].name();
601 patches_[patchI].geometricType() = newPatches[patchI].geometricType();
612 sortedEdgeFacesPtr_(NULL),
627 sortedEdgeFacesPtr_(NULL),
642 sortedEdgeFacesPtr_(NULL),
655 sortedEdgeFacesPtr_(NULL),
670 sortedEdgeFacesPtr_(NULL),
681 sortedEdgeFacesPtr_(NULL),
696 sortedEdgeFacesPtr_(NULL),
709 sortedEdgeFacesPtr_(NULL),
728 sortedEdgeFacesPtr_(NULL),
745 ParentType::clearTopology();
753 ParentType::clearPatchMeshAddr();
759 ParentType::clearOut();
762 clearPatchMeshAddr();
768 if (!sortedEdgeFacesPtr_)
770 calcSortedEdgeFaces();
773 return *sortedEdgeFacesPtr_;
784 return *edgeOwnerPtr_;
795 ParentType::movePoints(newPoints);
798 storedPoints() = newPoints;
806 if (scaleFactor > 0 && scaleFactor != 1.0)
814 storedPoints() *= scaleFactor;
823 stitchTriangles(
points(), SMALL, verbose);
828 checkTriangles(verbose);
840 const label currentZone,
850 dynamicLabelList newChangedFaces(2*changedFaces.
size());
854 label faceI = changedFaces[i];
856 const labelList& fEdges = faceEdges()[faceI];
860 label edgeI = fEdges[i];
862 if (!borderEdge[edgeI])
864 const labelList& eFaces = edgeFaces()[edgeI];
868 label nbrFaceI = eFaces[j];
873 newChangedFaces.
append(nbrFaceI);
875 else if (
faceZone[nbrFaceI] != currentZone)
879 "triSurface::markZone(const boolList&,"
880 "const label, const label, labelList&) const"
883 <<
" at face " << nbrFaceI
884 <<
" connects to zone " << currentZone
885 <<
" at face " << faceI
893 if (newChangedFaces.empty())
898 changedFaces.
transfer(newChangedFaces);
914 if (borderEdge.
size() != nEdges())
918 "triSurface::markZones"
919 "(const boolList&, labelList&)"
921 <<
"borderEdge boolList not same size as number of edges" <<
endl
922 <<
"borderEdge:" << borderEdge.
size() <<
endl
923 <<
"nEdges :" << nEdges()
929 for (
label startFaceI = 0;; zoneI++)
932 for (; startFaceI < size(); startFaceI++)
940 if (startFaceI >= size())
947 markZone(borderEdge, startFaceI, zoneI,
faceZone);
972 forAll (include, oldFacei)
974 if (include[oldFacei])
986 pointMap[pointI++] = a;
993 pointMap[pointI++] =
b;
1000 pointMap[pointI++] =
c;
1023 subsetMeshMap(include, pointMap,
faceMap);
1029 forAll (pointMap, pointi)
1031 newPoints[pointi] = locPoints[pointMap[pointi]];
1032 oldToNew[pointMap[pointi]] = pointi;
1043 newTriangles[facei][0] = oldToNew[tri[0]];
1044 newTriangles[facei][1] = oldToNew[tri[1]];
1045 newTriangles[facei][2] = oldToNew[tri[2]];
1046 newTriangles[facei].region() = tri.region();
1057 const bool sortByRegion
1073 os.
check(
"triSurface::write(Ostream&)");
1081 fileName foamPath(d.
path()/triSurfInstance(d)/typeName/foamFile);
1105 if (pointIsUsed.
set(pointI, 1))
1114 os <<
"Triangles : " << size() <<
endl
1116 <<
"Bounding Box : " << bb <<
endl;
1126 storedPoints() = ts.
points();
vectorField pointField
pointField is a vectorField.
scalar timeOutputValue() const
Return current time value.
label index() const
Return the index of this patch in the boundaryMesh.
static List< labelledTri > convertToTri(const faceList &, const label defaultRegion=0)
Convert faces to labelledTri. All get same region.
void subsetMeshMap(const boolList &include, labelList &pointMap, labelList &faceMap) const
'Create' sub mesh, including only faces for which
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)
label size() const
Return size of this patch in the polyMesh face list.
const Field< PointType > & points() const
Return reference to global points.
void clearOut()
Clear all data.
void writeStats(Ostream &) const
Write some statistics.
A class for handling words, derived from string.
A class for handling file names.
bool exists(const fileName &, const bool checkGzip=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
const point & max() const
Maximum describing the bounding box.
void checkTriangles(const bool verbose=false)
Check/remove duplicate/degenerate triangles.
void sort()
(stable) sort the list (if changed after construction time)
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
const fileName & caseName() const
Return case name.
bool read(Istream &)
Read in Foam format.
instantList times() const
Search the case for valid time directories.
Template functions to aid in the implementation of demand driven data.
bool read(const char *, int32_t &)
static const boundBox invertedBox
A very large inverted boundBox: min/max == +/- VGREAT.
void set(const PackedList< 1 > &)
Set specified bits.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
defineTypeNameAndDebug(Foam::triSurface, 0)
label start() const
Return start label of this patch in the polyMesh face list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A class for handling character strings derived from std::string.
void clearPatchMeshAddr()
Clear patch addressing.
const geometricSurfacePatchList & patches() const
void operator=(const UList< T > &)
Assignment from UList operator. Takes linear time.
void writeVTK(OFstream &os, const Type &value)
virtual void movePoints(const pointField &)
Move points.
void deleteDemandDrivenData(DataPtr &dataPtr)
void cleanup(const bool verbose=false)
Remove non-valid triangles.
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pre-declare SubField and related Field type.
const word & geometricType() const
Return the type of the patch.
Triangulated surface description with patch information.
A subset of mesh faces organised as a primitive patch.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void append(const T &)
Append an element at the end of the list.
ISstream & getLine(string &)
Raw, low-level getline into a string function.
void markZone(const boolList &borderEdge, const label faceI, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
void operator=(const triSurface &)
triSurface()
Construct null.
const point & min() const
Minimum describing the bounding box.
Ostream & operator<<(Ostream &, const edgeMesh &)
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.
void clearTopology()
Clear topology.
word ext() const
Return file name extension (part after last .)
'Patch' on surface as subset of triSurface.
errorManip< error > abort(error &err)
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
errorManipArg< error, int > exit(error &err, const int errNo=1)
surfacePatchList calcPatches(labelList &faceMap) const
Sort faces according to region. Returns patch list.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setDefaultPatches()
Sets default values for patches.
void setSize(const label)
Reset size of List.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
void checkEdges(const bool verbose=false)
Check triply (or more) connected edges.
fileName path() const
Return path.
virtual void scalePoints(const scalar &)
Scale points. A non-positive factor is ignored.
A triangular face using a FixedList of labels corresponding to mesh vertices.
label region() const
Return region label.
prefixOSstream Pout(cout, "Pout")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const word & constant() const
Return constant name.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
Triangle with additional region number.
A bounding box defined in terms of the points at its extremities.
const dimensionedScalar c
Speed of light in a vacuum.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A face is a list of labels corresponding to mesh vertices.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
bool good() const
Return true if next operation might succeed.
void write(const fileName &, const word &ext, const bool sort) const
Generic write routine. Chooses writer based on extension.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const word & name() const
Return name.
static string getLineNoComment(IFstream &)
Read non-comment line.
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
word name(const complex &)
Return a string representation of a complex.
static void printTriangle(Ostream &, const Foam::string &pre, const labelledTri &, const pointField &)
Helper function to print triangle info.
A list of faces which address into the list of points.