35 #undef DEBUG_STLBINARY
47 void Foam::fileFormats::STLReader::transfer
49 Detail::STLAsciiParse& parsed
52 sorted_ = parsed.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);
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
235 format_(STLFormat::UNKNOWN)
238 readFile(filename,
format);
251 format_ = STLFormat::UNKNOWN;
265 return mergePointsMap
275 const scalar mergeTol,