47void Foam::fileFormats::STLReader::transfer
49 Detail::STLAsciiParse& parsed
52 sorted_ = parsed.is_sorted();
54 points_.transfer(parsed.points());
55 zoneIds_.transfer(parsed.facets());
56 names_.transfer(parsed.names());
57 sizes_.transfer(parsed.sizes());
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);
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;
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);
207Foam::fileFormats::STLReader::STLReader
224Foam::fileFormats::STLReader::STLReader
235 format_(STLFormat::UNKNOWN)
238 readFile(filename,
format);
265 return mergePointsMap
275 const scalar mergeTol,
A class for handling file names.
#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.
List< label > labelList
A List of labels.
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)
Calculate merge mapping, preserving the original point order. All points closer/equal mergeTol are to...
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
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.