49 Detail::STLAsciiParse& parsed
52 sorted_ = parsed.sorted();
54 points_.transfer(parsed.points());
65bool 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);
84bool 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;
183bool 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);
238 readFile(filename,
format);
251 format_ = STLFormat::UNKNOWN;
265 return mergePointsMap
275 const scalar mergeTol,
void transfer(List< T > &list)
A class for handling file names.
transferModelList & transfer()
Transfer.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Geometric merging of points. See below.
int optimisationSwitch(const char *name, const int deflt=0)
Lookup optimisation switch or add default value.
messageStream Info
Information stream (stdout output on master, null elsewhere)
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr doubleScalar doubleScalarSMALL
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
word format(conversionProperties.get< word >("format"))
#define forAll(list, i)
Loop across all elements in list.