47bool Foam::triSurface::readSTL(
const fileName& filename,
bool forceBinary)
50 fileFormats::STLReader reader
63 const label nUniquePoints = reader.mergePointsMap(pointMap);
65 const auto& readpts = reader.points();
66 const labelList& zoneIds = reader.zoneIds();
72 pointLst.setSize(nUniquePoints);
73 faceLst.setSize(zoneIds.size());
78 pointLst[pointMap[pointi]] = readpts[pointi];
85 auto&
f = faceLst[facei];
87 f[0] = pointMap[pointi++];
88 f[1] = pointMap[pointi++];
89 f[2] = pointMap[pointi++];
90 f.region() = zoneIds[facei];
96 const List<word>&
names = reader.names();
98 patches_.setSize(
names.size());
101 patches_[patchi] = geometricSurfacePatch(
names[patchi], patchi);
109void Foam::triSurface::writeSTLASCII
119 <<
"Cannot write file " << filename <<
nl
138 label patchFacei = 0;
139 patchFacei <
patch.size();
143 const label facei =
faceMap[faceIndex++];
150 faceNormals()[facei],
175 label currentPatchi = -1;
178 if (currentPatchi !=
patchIDs[facei])
180 if (currentPatchi != -1)
195 faceNormals()[facei],
202 if (currentPatchi != -1)
209void Foam::triSurface::writeSTLBINARY(
const fileName& filename)
const
211 std::ofstream
os(filename, std::ios::binary);
223 faceNormals()[facei],
const word & name() const noexcept
Return the object name.
bool good() const noexcept
True if next operation might succeed.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
A triangle representation for STL files.
void write(std::ostream &os) const
Write to ostream (binary).
A class for handling file names.
A triFace with additional (region) index.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
A 'patch' on surface as subset of triSurface.
pointField & storedPoints()
Non-const access to global points.
List< labelledTri > & storedFaces()
Non-const access to the faces.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const std::string patch
OpenFOAM patch number as a std::string.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< surfacePatch > surfacePatchList
List of surfacePatch.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
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).
#define forAll(list, i)
Loop across all elements in list.
static void writeBinaryHeader(ostream &os, uint32_t nTris)
Write STL binary file and number of triangles to stream.