34 void Foam::triSurface::writeSTLASCII(
const bool writeSorted, Ostream& os)
const
48 os <<
"solid " << patch.name() <<
endl;
53 patchFacei < patch.size();
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;
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);
150 label nTris = size();
151 os.write(
reinterpret_cast<char*
>(&nTris),
sizeof(
unsigned int));
157 const labelledTri&
f = (*this)[facei];
160 STLpoint
n(normals[facei]);
165 STLtriangle stlTri(
n, pa, pb, pc,
f.region());
#define forAll(list, i)
Loop across all elements in list.
virtual const fileName & name() const
Return the name of the stream.
label size() const
Return the number of elements in the UList.
const Field< PointType > & points() const
Return reference to global points.
const Field< PointType > & faceNormals() const
Return face normals for patch.
const geometricSurfacePatchList & patches() const
List< label > labelList
A List of labels.
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.
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< surfacePatch > surfacePatchList