35 #undef DEBUG_STLBINARY 47 void Foam::fileFormats::STLReader::transfer
49 Detail::STLAsciiParse& parsed
52 sorted_ = parsed.is_sorted();
54 points_.transfer(parsed.points());
59 format_ = STLFormat::ASCII;
65 bool Foam::fileFormats::STLReader::readASCII
67 const fileName& filename
74 return readAsciiRagel(filename);
76 else if (parserType == 2)
78 return readAsciiManual(filename);
80 return readAsciiFlex(filename);
84 bool Foam::fileFormats::STLReader::readBINARY
86 const fileName& filename
90 format_ = STLFormat::UNKNOWN;
93 std::unique_ptr<std::istream> streamPtr
95 readBinaryHeader(filename, nTris)
101 <<
"Error reading file " << filename
102 <<
" or file " << filename +
".gz" 105 auto& is = *streamPtr;
107 #ifdef DEBUG_STLBINARY 108 Info<<
"# " << nTris <<
" facets" <<
endl;
112 points_.setSize(3*nTris);
113 zoneIds_.setSize(nTris);
116 DynamicList<label> dynSizes;
123 STLtriangle stlTri(is);
126 points_[ptI++] = stlTri.a();
127 points_[ptI++] = stlTri.b();
128 points_[ptI++] = stlTri.c();
131 const label origId = stlTri.attrib();
133 auto fnd = lookup.cfind(origId);
144 zoneI = dynSizes.size();
145 lookup.insert(origId, zoneI);
146 dynSizes.push_back(0);
149 zoneIds_[facei] = zoneI;
152 #ifdef DEBUG_STLBINARY 153 if (prevZone != zoneI)
157 Info<<
"endsolid zone" << prevZone <<
nl;
161 Info<<
"solid zone" << prevZone <<
nl;
168 #ifdef DEBUG_STLBINARY 171 Info<<
"endsolid zone" << prevZone <<
nl;
176 sizes_.transfer(dynSizes);
178 format_ = STLFormat::BINARY;
183 bool Foam::fileFormats::STLReader::readFile
185 const fileName& filename,
191 format == STLFormat::UNKNOWN
192 ? detectBinaryHeader(filename)
193 :
format == STLFormat::BINARY
196 return readBINARY(filename);
200 return readASCII(filename);
207 Foam::fileFormats::STLReader::STLReader
217 format_(STLFormat::UNKNOWN)
220 readFile(filename, STLFormat::UNKNOWN);
224 Foam::fileFormats::STLReader::STLReader
226 const fileName& filename,
235 format_(STLFormat::UNKNOWN)
238 readFile(filename,
format);
251 format_ = STLFormat::UNKNOWN;
265 return mergePointsMap
275 const scalar mergeTol,
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
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.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Calculate merge mapping, preserving the original point order. All points closer/equal mergeTol are to...
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
Geometric merging of points. See below.
word format(conversionProperties.get< word >("format"))
constexpr doubleScalar doubleScalarSMALL
messageStream Info
Information stream (stdout output on master, null elsewhere)