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");
147 header.resize(STLheaderSize);
148 os.write(header.c_str(), STLheaderSize);
151 os.write(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
157 const labelledTri& f = (*this)[facei];
160 STLpoint
n(normals[facei]);
161 STLpoint pa(
points()[f[0]]);
162 STLpoint pb(
points()[f[1]]);
163 STLpoint pc(
points()[f[2]]);
165 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
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< PointType > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
const Field< PointType > & faceNormals() const
Return face normals for patch.
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.