ug4
|
Provides functions to read stl files into user provided arrays. More...
#include <algorithm>
#include <exception>
#include <fstream>
#include <sstream>
#include <vector>
Go to the source code of this file.
Classes | |
struct | stl_reader::stl_reader_impl::CoordWithIndex< number_t, index_t > |
class | stl_reader::StlMesh< TNumber, TIndex > |
convenience mesh class which makes accessing the stl data more easy More... | |
Namespaces | |
stl_reader | |
stl_reader::stl_reader_impl | |
Macros | |
#define | STL_READER_COND_THROW(cond, msg) if(cond){std::stringstream ss; ss << msg; throw(std::runtime_error(ss.str()));} |
Throws an std::runtime_error with the given message, if the given condition evaluates to true. More... | |
#define | STL_READER_THROW(msg) {std::stringstream ss; ss << msg; throw(std::runtime_error(ss.str()));} |
Throws an std::runtime_error with the given message. More... | |
Functions | |
template<class TNumberContainer , class TIndexContainer > | |
bool | stl_reader::ReadStlFile (const char *filename, TNumberContainer &coordsOut, TNumberContainer &normalsOut, TIndexContainer &trisOut, TIndexContainer &solidRangesOut) |
Reads an ASCII or binary stl file into several arrays. More... | |
template<class TNumberContainer , class TIndexContainer > | |
bool | stl_reader::ReadStlFile_ASCII (const char *filename, TNumberContainer &coordsOut, TNumberContainer &normalsOut, TIndexContainer &trisOut, TIndexContainer &solidRangesOut) |
Reads an ASCII stl file into several arrays. More... | |
template<class TNumberContainer , class TIndexContainer > | |
bool | stl_reader::ReadStlFile_BINARY (const char *filename, TNumberContainer &coordsOut, TNumberContainer &normalsOut, TIndexContainer &trisOut, TIndexContainer &solidRangesOut) |
Reads a binary stl file into several arrays. More... | |
template<class TNumberContainer , class TIndexContainer > | |
void | stl_reader::stl_reader_impl::RemoveDoubles (TNumberContainer &uniqueCoordsOut, TIndexContainer &trisInOut, std::vector< CoordWithIndex< typename TNumberContainer::value_type, typename TIndexContainer::value_type > > &coordsWithIndexInOut) |
bool | stl_reader::StlFileHasASCIIFormat (const char *filename) |
Determines whether a stl file has ASCII format. More... | |
Provides functions to read stl files into user provided arrays.
The central function of this file is ReadStlFile(...)
. It automatically recognizes whether an ASCII or a Binary file is to be read. It identifies matching corner coordinates of triangles with each other, so that the resulting coordinate array does not contain the same coordinate-triple multiple times.
The function operates on template container types. Those containers should have similar interfaces as std::vector
and operate on float
or double
types (TNumberContainer
) or on int
or size_t
types (TIndexContainer
).
A conveniance class StlMesh
is also provided, which makes accessing triangle corners and corresponding corner coordinates much more easy. It still provides raw access to the underlying data arrays.
If you do not want to use exceptions, you may define the macro STL_READER_NO_EXCEPTIONS before including 'stl_reader.h'. In that case, functions will return false
if an error occurred.
#define STL_READER_COND_THROW | ( | cond, | |
msg | |||
) | if(cond){std::stringstream ss; ss << msg; throw(std::runtime_error(ss.str()));} |
Throws an std::runtime_error with the given message, if the given condition evaluates to true.
#define STL_READER_THROW | ( | msg | ) | {std::stringstream ss; ss << msg; throw(std::runtime_error(ss.str()));} |
Throws an std::runtime_error with the given message.