36 bool Foam::triSurface::readSTLBINARY(
const fileName& STLfileName)
38 bool compressed =
false;
40 autoPtr<istream> STLfilePtr
42 new ifstream(STLfileName.c_str(), std::ios::binary)
46 if (!STLfilePtr->good() &&
isFile(STLfileName +
".gz",
false,
false))
49 STLfilePtr.reset(
new igzstream((STLfileName +
".gz").c_str()));
51 istream& STLfile = STLfilePtr();
56 <<
"Cannot read file " << STLfileName
57 <<
" or file " << STLfileName +
".gz" 62 char header[STLheaderSize];
63 STLfile.read(header, STLheaderSize);
74 STLfile.read(reinterpret_cast<char*>(&nTris),
sizeof(
unsigned int));
78 if (!STLfile || nTris < 0)
89 if (nTris < dataFileSize/50 || nTris > dataFileSize/25)
98 List<floatVector> STLpoints(3*nTris);
103 for (
label i = 0; i < nTris; i++)
106 STLtriangle stlTri(STLfile);
109 STLpoints[pointi++] = stlTri.a();
110 STLpoints[pointi++] = stlTri.b();
111 STLpoints[pointi++] = stlTri.c();
127 sp.setSize(nUniquePoints);
131 sp[pointMap[pointi]] =
vector #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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
T & operator[](const label)
Return element of UList.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
Vector< scalar > vector
A scalar version of the templated Vector.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
vectorField pointField
pointField is a vectorField.
List< label > labelList
A List of labels.
pointField & storedPoints()
Non-const access to global points.
Vector< float > floatVector
A float version of vector.
void setSize(const label)
Reset size of List.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.