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();
101 patches_[patchi] = geometricSurfacePatch(names[patchi], patchi);
109void Foam::triSurface::writeSTLASCII
111 const fileName& filename,
115 OFstream
os(filename);
119 <<
"Cannot write file " << filename <<
nl
138 label patchFacei = 0;
139 patchFacei <
patch.size();
143 const label facei =
faceMap[faceIndex++];
144 const labelledTri&
f = (*this)[facei];
171 patchIDs[
faceMap[facei++]] = patchi;
175 label currentPatchi = -1;
178 if (currentPatchi != patchIDs[facei])
180 if (currentPatchi != -1)
185 currentPatchi = patchIDs[facei];
189 const labelledTri&
f = (*this)[facei];
202 if (currentPatchi != -1)
209void Foam::triSurface::writeSTLBINARY(
const fileName& filename)
const
211 std::ofstream
os(filename, std::ios::binary);
218 const labelledTri&
f = (*this)[facei];
const word & name() const noexcept
Return the object name.
bool good() const noexcept
True if next operation might succeed.
void setSize(const label n)
Alias for resize()
void size(const label n)
Older name for setAddressableSize.
Ostream & writeBinaryHeader()
Write "C Binary" string for binary files (eg, geometry/measured)
virtual bool write()
Write the output fields.
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
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)
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
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< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< surfacePatch > surfacePatchList
A List of surfacePatch.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.