47 bool 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);
109 void 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];
150 faceNormals()[facei],
175 label currentPatchi = -1;
178 if (currentPatchi !=
patchIDs[facei])
180 if (currentPatchi != -1)
189 const labelledTri&
f = (*this)[facei];
195 faceNormals()[facei],
202 if (currentPatchi != -1)
209 void Foam::triSurface::writeSTLBINARY(
const fileName& filename)
const 211 std::ofstream
os(filename, std::ios::binary);
218 const labelledTri&
f = (*this)[facei];
223 faceNormals()[facei],
const labelList patchIDs(pbm.indices(polyPatchNames, true))
void size(const label n)
Older name for setAddressableSize.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & name() const noexcept
Return the object name.
constexpr char nl
The newline '\n' character (0x0a)
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelledTri > & storedFaces()
Non-const access to the faces.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
#define forAll(list, i)
Loop across all elements in list.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
void write(std::ostream &os) const
Write to ostream (binary)
void sort(UList< T > &list)
Sort the list.
pointField & storedPoints()
Non-const access to global points.
OBJstream os(runTime.globalPath()/outputName)
bool good() const noexcept
True if next operation might succeed.
const polyBoundaryMesh & patches
const std::string patch
OpenFOAM patch number as a std::string.
List< label > labelList
A List of labels.
List< surfacePatch > surfacePatchList
List of surfacePatch.