39bool Foam::fileFormats::GTSsurfaceFormat<Face>::checkIfTriangulated
41 const UList<Face>& faceLst
46 if (!faceTraits<Face>::isTri())
48 for (
const auto&
f : faceLst)
60 <<
"Surface has " << nNonTris <<
'/' << faceLst.size()
61 <<
" non-triangulated faces - not writing!" <<
endl;
96 <<
"Cannot read file " << filename <<
nl
101 string line = this->getLineNoComment(is);
114 auto& pointLst = this->storedPoints();
115 auto& faceLst = this->storedFaces();
116 auto& zoneIds = this->storedZoneIds();
119 faceLst.resize(nElems);
120 zoneIds.resize(nElems);
126 line = this->getLineNoComment(is);
128 IStringStream lineStream(line);
133 pointLst[pointi] =
point(
x,
y, z);
141 line = this->getLineNoComment(is);
143 IStringStream lineStream(line);
147 edges[edgei] = edge(beg - 1, end - 1);
155 label e0Label, e1Label, e2Label;
158 line = this->getLineNoComment(is);
160 IStringStream lineStream(line);
162 >> e0Label >> e1Label >> e2Label;
169 if (!lineStream.bad())
184 const edge& e0 = edges[e0Label - 1];
185 const edge& e1 = edges[e1Label - 1];
186 const edge& e2 = edges[e2Label - 1];
188 label common01 = e0.commonVertex(e1);
192 <<
"Edges 0 and 1 of triangle " << facei
193 <<
" do not share a point.\n"
194 <<
" edge0:" << e0 <<
nl
199 const label e0Far = e0.otherVertex(common01);
200 const label e1Far = e1.otherVertex(common01);
202 const label common12 = e1.commonVertex(e2);
206 <<
"Edges 1 and 2 of triangle " << facei
207 <<
" do not share a point.\n"
208 <<
" edge1:" << e1 <<
nl
212 const label e2Far = e2.otherVertex(common12);
215 if (common12 != e1Far || e2Far != e0Far)
218 <<
"Edges of triangle " << facei
219 <<
" reference more than three points.\n"
220 <<
" edge0:" << e0 <<
nl
221 <<
" edge1:" << e1 <<
nl
222 <<
" edge2:" << e2 <<
nl
226 faceLst[facei] = Face{e0Far, common01, e1Far};
227 zoneIds[facei] = zoneI;
231 List<surfZoneIdentifier> newZones(maxZone+1);
234 newZones[zonei] = surfZoneIdentifier
236 surfZoneIdentifier::defaultName(zonei),
241 this->storedZoneToc().transfer(newZones);
270 checkIfTriangulated(faceLst);
276 <<
"Cannot write file " << filename <<
nl
282 os <<
"# GTS file" <<
nl
287 os <<
"# " << zonei <<
" "
288 << zones[zonei].name() <<
nl;
292 os <<
"# nPoints nEdges nTriangles" << nl
293 << pointLst.
size() <<
' ' << surf.
nEdges() <<
' '
294 << surf.
size() << nl;
298 for (
const point& pt : pointLst)
300 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() << nl;
309 for (
const edge&
e : es)
311 os << meshPts[
e.start()] + 1 <<
' '
312 << meshPts[
e.end()] + 1 <<
nl;
321 for (
const surfZone& zone : zones)
323 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
325 const label facei = faceIndex;
329 os << fEdges[0] + 1 <<
' '
330 << fEdges[1] + 1 <<
' '
331 << fEdges[2] + 1 <<
' '
357 checkIfTriangulated(faceLst);
363 <<
"Cannot write file " << filename <<
nl
369 os <<
"# GTS file" << nl
374 os <<
"# " << zonei <<
" "
375 << zoneToc[zonei].name() << nl;
379 os <<
"# nPoints nEdges nTriangles" <<
nl
380 << pointLst.
size() <<
' ' << surf.
nEdges() <<
' '
385 for (
const point& pt : pointLst)
387 os << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
nl;
396 for (
const edge&
e : es)
398 os << meshPts[
e.start()] + 1 <<
' '
399 << meshPts[
e.end()] + 1 <<
nl;
409 os << fEdges[0] + 1 <<
' '
410 << fEdges[1] + 1 <<
' '
411 << fEdges[2] + 1 <<
' '
412 << zoneIds[facei] <<
nl;
Input/output from string buffers.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
bool good() const noexcept
True if next operation might succeed.
bool bad() const noexcept
True if stream is corrupted.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
const surfZoneList & surfZones() const
Const access to the surface zones.
pointField & storedPoints()
Non-const access to global points.
label size() const
The surface size is the number of faces.
const List< Face > & surfFaces() const
Return const access to the faces.
List< Face > & storedFaces()
Non-const access to the faces.
bool addZonesToFaces()
Propagate zone information on face regions.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
const edgeList & edges() const
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const labelListList & faceEdges() const
Return face-edge addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
A surface geometry mesh, in which the surface zone information is conveyed by the 'zoneId' associated...
virtual const labelList & zoneIds() const
Return const access to the zone ids.
labelList & storedZoneIds()
Return non-const access to the zone Ids.
label size() const
The surface size is the number of faces.
List< surfZoneIdentifier > & storedZoneToc()
Return non-const access to the zone table-of-contents.
friend class UnsortedMeshedSurface
friend class MeshedSurface
const List< surfZoneIdentifier > & zoneToc() const
Return const access to the zone table-of-contents.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
label commonVertex(const edge &other) const
Return vertex common with other edge or -1 on failure.
label otherVertex(const label vertex) const
Given one vertex label, return the other one.
A class for handling file names.
Identifies a surface patch/zone by name and index, with optional geometric type.
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
A surface zone on a MeshedSurface.
Base class for mesh zones.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
List< edge > edgeList
List of edge.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
List< surfZone > surfZoneList
List of surfZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.