33 #undef DEBUG_STLBINARY 43 int Foam::fileFormats::STLsurfaceFormatCore::detectBINARY
45 const fileName& filename
51 istream& is = str().stdStream();
66 is.read(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
89 bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
92 const off_t dataFileSize
105 <<
"problem reading header, perhaps file is not binary " 112 is.read(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
128 <<
"problem reading number of triangles, perhaps file is not binary" 132 #ifdef DEBUG_STLBINARY 133 Info<<
"# " << nTris <<
" facets" <<
endl;
141 DynamicList<label> dynSizes;
148 STLtriangle stlTri(is);
151 points_[ptI++] = stlTri.a();
152 points_[ptI++] = stlTri.b();
153 points_[ptI++] = stlTri.c();
156 const label origId = stlTri.attrib();
159 if (fnd != lookup.end())
170 zoneI = dynSizes.size();
171 lookup.insert(origId, zoneI);
175 zoneIds_[facei] = zoneI;
178 #ifdef DEBUG_STLBINARY 179 if (prevZone != zoneI)
183 Info<<
"endsolid zone" << prevZone <<
nl;
187 Info<<
"solid zone" << prevZone <<
nl;
190 Info<<
" facet normal " << stlTri.normal() <<
nl 191 <<
" outer loop" <<
nl 192 <<
" vertex " << stlTri.a() <<
nl 193 <<
" vertex " << stlTri.b() <<
nl 194 <<
" vertex " << stlTri.c() <<
nl 195 <<
" outer loop" <<
nl 196 <<
" endfacet" <<
endl;
223 if (detectBINARY(filename))
258 sprintf(header,
"STL binary file %u facets", nTris);
261 for (
size_t i = strlen(header); i <
headerSize; ++i)
266 os.write(header, headerSize);
267 os.write(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Ostream & endl(Ostream &os)
Add newline and flush stream.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
stressControl lookup("compactNormalStress") >> compactNormalStress
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.