54 typedef uint8_t BINARY_UINT8;
55 typedef uint16_t BINARY_UINT16;
56 typedef uint32_t BINARY_UINT32;
57 typedef float BINARY_REAL32;
59 static const std::size_t BINARY_HEADER_SIZE;
60 static const std::size_t BINARY_MINIMUM_SIZE;
61 static const std::size_t BINARY_FACET_SIZE;
63 static const std::string ASCII_SOLID_BEGIN;
64 static const std::string ASCII_SOLID_END;
65 static const std::string ASCII_FACET_BEGIN;
66 static const std::string ASCII_FACET_END;
67 static const std::string ASCII_FILE_BEGIN;
68 static const std::string ASCII_FILE_END;
69 static const std::size_t ASCII_MINIMUM_SIZE;
71 STLBase(
const std::string &filename);
72 STLBase(
const std::string &filename, Format format);
78 std::string m_filename;
102 static Format
detectFormat(
const std::string &filename);
104 STLReader(
const std::string &filename, Format format = FormatUnknown);
112 int readSolid(std::string *name, std::size_t *nV, std::size_t *nT,
113 std::vector<std::array<double, 3>> *V, std::vector<std::array<double, 3>> *N,
114 std::vector<std::array<std::size_t, 3>> *T);
116 int readSolid(
const std::string &solid, std::string *name, std::size_t *nV, std::size_t *nT,
117 std::vector<std::array<double, 3>> *V, std::vector<std::array<double, 3>> *N,
118 std::vector<std::array<std::size_t, 3>> *T);
120 int readHeader(std::string *name, std::size_t *nT);
121 int readHeader(
const std::string &solid, std::string *name, std::size_t *nT);
126 int readFacet(std::array<double, 3> *V0, std::array<double, 3> *V1,
127 std::array<double, 3> *V2, std::array<double, 3> *N);
130 std::ifstream m_fileHandle;
135 int inspectSolidASCII(std::size_t *nFactes, std::array<bool, 6> *errors);
136 int inspectFacetASCII(std::array<bool, 6> *errors);
140 int readHeaderASCII(
const std::string &solid, std::string *name, std::size_t *nT);
142 int readFooterASCII(
const std::string &solid);
144 int readFacetASCII(std::array<double, 3> *V0, std::array<double, 3> *V1,
145 std::array<double, 3> *V2, std::array<double, 3> *N);
147 int readHeaderBinary(std::string *name, std::size_t *nT);
149 int readFooterBinary();
151 int readFacetBinary(std::array<double, 3> *V0, std::array<double, 3> *V1,
152 std::array<double, 3> *V2, std::array<double, 3> *N);
164 STLWriter(
const std::string &filename, Format format);
166 int writeBegin(WriteMode writeMode,
bool partialWrite =
false);
169 int writeSolid(
const std::string &name, std::size_t nV, std::size_t nT,
170 const std::vector<std::vector<double>> &V,
const std::vector<std::vector<double>> &N,
171 const std::vector<std::vector<std::size_t>> &T);
173 int writeSolid(
const std::string &name, std::size_t nV, std::size_t nT,
174 const std::vector<std::array<double, 3>> &V,
const std::vector<std::array<double, 3>> &N,
175 const std::vector<std::array<std::size_t, 3>> &T);
177 int writeHeader(
const std::string &name, std::size_t nT);
181 int writeFacet(
const std::array<double, 3> &V0,
const std::array<double, 3> &V1,
182 const std::array<double, 3> &V2,
const std::array<double, 3> &N);
185 std::ofstream m_fileHandle;
187 int writeHeaderASCII(
const std::string &name, std::size_t nT);
189 int writeFooterASCII(
const std::string &name);
191 int writeFacetASCII(
const std::array<double, 3> &V0,
const std::array<double, 3> &V1,
192 const std::array<double, 3> &V2,
const std::array<double, 3> &N);
194 int writeHeaderBinary(
const std::string &name, std::size_t nT);
196 int writeFooterBinary(
const std::string &name);
198 int writeFacetBinary(
const std::array<double, 3> &V0,
const std::array<double, 3> &V1,
199 const std::array<double, 3> &V2,
const std::array<double, 3> &N);
int readFacet(std::array< double, 3 > *V0, std::array< double, 3 > *V1, std::array< double, 3 > *V2, std::array< double, 3 > *N)
int readSolid(std::string *name, std::size_t *nV, std::size_t *nT, std::vector< std::array< double, 3 > > *V, std::vector< std::array< double, 3 > > *N, std::vector< std::array< std::size_t, 3 > > *T)
int writeFacet(const std::array< double, 3 > &V0, const std::array< double, 3 > &V1, const std::array< double, 3 > &V2, const std::array< double, 3 > &N)