36inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
39 const UList<point>&
pts,
45 triPointRef::unitNormal(
pts[
f[0]],
pts[
f[1]],
pts[
f[2]]);
51 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
53 const label fp2 =
f.fcIndex(fp1);
69inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
72 const UList<point>&
pts,
79 triPointRef::unitNormal(
pts[
f[0]],
pts[
f[1]],
pts[
f[2]]);
85 for (label fp1 = 1; fp1 <
f.size() - 1; ++fp1)
87 const label fp2 =
f.fcIndex(fp1);
131 const label nUniquePoints = reader.mergePointsMap(pointMap);
133 const auto& readpts = reader.points();
137 pointLst.
setSize(nUniquePoints);
140 pointLst[pointMap[pointi]] = readpts[pointi];
151 if (reader.is_sorted())
156 const label startPt = 3*facei;
157 faceLst[facei] = Face
174 const label startPt = 3*
faceMap[facei];
175 faceLst[facei] = Face
186 this->storedFaces().transfer(faceLst);
190 this->addZones(sizes,
names);
194 this->addZones(sizes);
214 <<
"Cannot write file " << filename <<
nl
225 ? surfaceFormatsCore::oneZone(faceLst)
229 const bool useFaceMap = (surf.
useFaceMap() && zones.size() > 1);
236 for (label nLocal =
zone.
size(); nLocal--; ++faceIndex)
239 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
241 const Face&
f = faceLst[facei];
243 writeShell(
os, pointLst,
f);
253 const fileName& filename,
254 const MeshedSurfaceProxy<Face>& surf
257 std::ofstream
os(filename, std::ios::binary);
261 <<
"Cannot write file " << filename << nl
265 const UList<point>& pointLst = surf.points();
266 const UList<Face>& faceLst = surf.surfFaces();
267 const UList<label>&
faceMap = surf.faceMap();
271 surf.surfZones().size() > 1
273 : surfaceFormatsCore::oneZone(faceLst)
276 const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1);
279 unsigned int nTris = surf.nTriangles();
280 STLCore::writeBinaryHeader(
os, nTris);
284 for (
const surfZone& zone : zones)
286 for (label nLocal = zone.size(); nLocal--; ++faceIndex)
289 (useFaceMap ?
faceMap[faceIndex] : faceIndex);
291 const Face&
f = faceLst[facei];
293 writeShell(
os, pointLst,
f, zoneIndex);
319 <<
"Cannot write file " << filename <<
nl
323 os <<
"solid " << surf.
zoneToc()[0].name() << nl;
324 for (
const Face&
f : faceLst)
326 writeShell(
os, pointLst,
f);
328 os <<
"endsolid " << surf.
zoneToc()[0].name() <<
nl;
333 List<surfZone> zoneLst = surf.
sortedZones(faceMap);
338 MeshedSurfaceProxy<Face>
358 std::ofstream
os(filename, std::ios::binary);
362 <<
"Cannot write file " << filename <<
nl
366 const pointField& pointLst = surf.
points();
367 const UList<Face>& faceLst = surf.
surfFaces();
368 const UList<label>& zoneIds = surf.
zoneIds();
372 STLCore::writeBinaryHeader(
os, nTris);
401 || STLCore::isBinaryName(filename, STLCore::UNKNOWN)
404 writeBinary(filename, surf);
422 if (STLCore::isBinaryName(filename,
format))
424 writeBinary(filename, surf);
446 || STLCore::isBinaryName(filename, STLCore::UNKNOWN)
449 writeBinary(filename, surf);
467 if (STLCore::isBinaryName(filename,
format))
469 writeBinary(filename, surf);
473 writeAscii(filename, surf, comp);
Various functions to operate on Lists.
A simple container for options an IOstream can normally have.
compressionType compression() const noexcept
Get the stream compression.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED).
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats.
const UList< surfZone > & surfZones() const noexcept
Const access to the surface zones.
const UList< Face > & surfFaces() const noexcept
Return const access to the faces.
const labelUList & faceMap() const noexcept
Const access to the faceMap, zero-sized when unused.
const pointField & points() const noexcept
Return const access to the points.
label nTriangles() const
Count number of triangles.
bool useFaceMap() const noexcept
Can/should use faceMap?
pointField & storedPoints()
Non-const access to global points.
virtual void addZones(const UList< surfZone > &, const bool cullEmpty=false)
Add surface zones.
const List< Face > & surfFaces() const
Return const access to the faces.
virtual label nTriangles() const
Count number of triangles.
List< Face > & storedFaces()
Non-const access to the faces.
friend class UnsortedMeshedSurface
bool addZonesToFaces()
Propagate zone information on face regions.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
const Field< point_type > & points() const noexcept
Return reference to global points.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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...
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
virtual const labelList & zoneIds() const
Return const access to the zone ids.
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,...
A class for handling file names.
A surface zone on a MeshedSurface.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const word & name() const noexcept
The zone name.
Base class for mesh zones.
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
List< surfZone > surfZoneList
List of surfZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
word format(conversionProperties.get< word >("format"))
#define forAll(list, i)
Loop across all elements in list.