34 void Foam::triSurface::writeSTLASCII(
const bool writeSorted, Ostream& os)
const 48 os <<
"solid " << patch.name() <<
endl;
53 patchFacei < patch.size();
57 const label facei = faceMap[faceIndex++];
61 os <<
" facet normal " 62 << n.x() <<
' ' << n.y() <<
' ' << n.z() <<
nl 63 <<
" outer loop" <<
endl;
65 const labelledTri& f = (*this)[facei];
71 << pa.x() <<
' ' << pa.y() <<
' ' << pa.z() <<
nl 73 << pb.x() <<
' ' << pb.y() <<
' ' << pb.z() <<
nl 75 << pc.x() <<
' ' << pc.y() <<
' ' << pc.z() <<
nl 77 <<
" endfacet" <<
endl;
80 os <<
"endsolid " << patch.
name() <<
endl;
93 patchIDs[faceMap[facei++]] =
patchi;
97 label currentPatchi = -1;
101 if (currentPatchi != patchIDs[facei])
103 if (currentPatchi != -1)
106 os <<
"endsolid " <<
patches[currentPatchi].name()
109 currentPatchi = patchIDs[facei];
110 os <<
"solid " <<
patches[currentPatchi].name() <<
nl;
115 os <<
" facet normal " 116 << n.x() <<
' ' << n.y() <<
' ' << n.z() <<
nl 117 <<
" outer loop" <<
endl;
119 const labelledTri& f = (*this)[facei];
125 << pa.x() <<
' ' << pa.y() <<
' ' << pa.z() <<
nl 127 << pb.x() <<
' ' << pb.y() <<
' ' << pb.z() <<
nl 129 << pc.x() <<
' ' << pc.y() <<
' ' << pc.z() <<
nl 131 <<
" endfacet" <<
endl;
134 if (currentPatchi != -1)
136 os <<
"endsolid " <<
patches[currentPatchi].name()
143 void Foam::triSurface::writeSTLBINARY(std::ostream& os)
const 146 string header(
"Foam binary STL", STLheaderSize);
147 os.write(header.c_str(), STLheaderSize);
150 os.write(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
156 const labelledTri& f = (*this)[facei];
159 STLpoint
n(normals[facei]);
160 STLpoint pa(
points()[f[0]]);
161 STLpoint pb(
points()[f[1]]);
162 STLpoint pc(
points()[f[2]]);
164 STLtriangle stlTri(n, pa, pb, pc, f.region());
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< surfacePatch > surfacePatchList
const Field< point > & faceNormals() const
Return face normals for patch.
Vector< scalar > vector
A scalar version of the templated Vector.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual const fileName & name() const
Return the name of the stream.
const Field< point > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
const geometricSurfacePatchList & patches() const
vector point
Point is a vector.
Field< vector > vectorField
Specialisation of Field<T> for vector.
label size() const
Return the number of elements in the UList.