ASCII and Binary Stereo Lithography File readers. More...
#include <ReadSTL.hpp>
Classes | |
struct | Point |
struct | Triangle |
Public Types | |
enum | ByteOrder { STL_BIG_ENDIAN , STL_LITTLE_ENDIAN , STL_UNKNOWN_BYTE_ORDER } |
Public Member Functions | |
ErrorCode | load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0) |
Generic file loading code for both binary and ASCII readers. Calls reader-specific read_triangles function to do actual I/O. More... | |
ErrorCode | read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0) |
Read tag values from a file. More... | |
ReadSTL (Interface *impl=NULL) | |
Constructor. More... | |
virtual | ~ReadSTL () |
Destructor. More... | |
Public Member Functions inherited from moab::ReaderIface | |
virtual | ~ReaderIface () |
Static Public Member Functions | |
static ReaderIface * | factory (Interface *) |
factory method for STL reader More... | |
Protected Member Functions | |
ErrorCode | ascii_read_triangles (const char *file_name, std::vector< Triangle > &tris_out) |
ErrorCode | binary_read_triangles (const char *file_name, ByteOrder byte_order, std::vector< Triangle > &tris_out) |
Protected Attributes | |
ReadUtilIface * | readMeshIface |
Interface * | mdbImpl |
interface instance More... | |
ASCII and Binary Stereo Lithography File readers.
STL files contain no connectivity infomration. Each triangle is specified as by three sets of single-precision coordinate triples. This reader does not use ANY tolerance when comparing vertex locations to recover connectivity. The points must be EXACTLY equal (including the sign on zero values.) If the file was written by an application which represented connectivity explicitly, there is no reason for the vertex coordinates to be anything other than exactly equal.
For binary STL files, the defacto standard is that they be written with a little-endian byte order. The reader will attempt to determine the byte order automatically, and if it is ambiguous, will default to little-endian. The byte ordering may be forced by by creating an integer tag named "__STL_BYTE_ORDER" and setting a global/mesh value for the tag as 1 for big-endian or 0 for little-endian.
For binary files, this reader relies on the file size to determine the validity of the file and may use it in guessing the byte order. This should not be an issue, as the file size can be determined exactly from the number of triangles for a valid file. However, if for some reason the file is readable even though it is invalid (e.g. it is some hybrid file with STL data in the beginning and some app- specific data appended to the end of the file) the check on the file size can be disabled by giving the reader a something other than a regular file to read from. For example, on Unix-like systems, have the reader read from a FIFO instead of a file: mkfifo /tmp/fifo.stlb cat my_binary_file.stlb > /tmp/fifo.stlb and instruct the MOAB-based application to read from /tmp/fifo.stlb
Definition at line 63 of file ReadSTL.hpp.
Enumerator | |
---|---|
STL_BIG_ENDIAN | |
STL_LITTLE_ENDIAN | |
STL_UNKNOWN_BYTE_ORDER |
Definition at line 103 of file ReadSTL.hpp.
ReadSTL::ReadSTL | ( | Interface * | impl = NULL | ) |
Constructor.
Definition at line 40 of file ReadSTL.cpp.
References mdbImpl, moab::Interface::query_interface(), and readMeshIface.
Referenced by factory().
|
virtual |
Destructor.
Definition at line 45 of file ReadSTL.cpp.
References mdbImpl, readMeshIface, and moab::Interface::release_interface().
|
protected |
Definition at line 184 of file ReadSTL.cpp.
References moab::ReadSTL::Point::coords, moab::FileTokenizer::get_floats(), moab::FileTokenizer::match_token(), MB_FILE_DOES_NOT_EXIST, MB_FILE_WRITE_ERROR, MB_SUCCESS, moab::ReadSTL::Triangle::points, and readMeshIface.
Referenced by load_file().
|
protected |
Definition at line 265 of file ReadSTL.cpp.
References moab::SysUtil::byteswap(), moab::BinaryTri::coords, moab::BinaryHeader::count, moab::SysUtil::filesize(), moab::SysUtil::little_endian(), MB_FILE_DOES_NOT_EXIST, MB_FILE_WRITE_ERROR, MB_SUCCESS, STL_BIG_ENDIAN, STL_UNKNOWN_BYTE_ORDER, and moab::SysUtil::swap_bytes().
Referenced by load_file().
|
static |
factory method for STL reader
Definition at line 352 of file ReadSTL.cpp.
References iface, and ReadSTL().
Referenced by moab::ReaderWriterSet::ReaderWriterSet().
|
virtual |
Generic file loading code for both binary and ASCII readers. Calls reader-specific read_triangles function to do actual I/O.
Implements moab::ReaderIface.
Definition at line 72 of file ReadSTL.cpp.
References ascii_read_triangles(), moab::ReadUtilIface::assign_ids(), moab::SysUtil::big_endian(), binary_read_triangles(), ErrorCode, moab::ReadUtilIface::get_element_connect(), moab::ReadUtilIface::get_node_coords(), moab::FileOptions::get_null_option(), moab::SysUtil::little_endian(), MB_SET_ERR, MB_START_ID, MB_SUCCESS, MB_UNSUPPORTED_OPERATION, MBTRI, readMeshIface, STL_BIG_ENDIAN, STL_LITTLE_ENDIAN, STL_UNKNOWN_BYTE_ORDER, and moab::ReadUtilIface::update_adjacencies().
|
virtual |
Read tag values from a file.
Read the list if all integer tag values from the file for a tag that is a single integer value per entity.
file_name | The file to read. |
tag_name | The tag for which to read values |
tag_values_out | Output: The list of tag values. |
subset_list | An array of tag name and value sets specifying the subset of the file to read. If multiple tags are specified, the sets that match all tags (intersection) should be read. |
subset_list_length | The length of the 'subset_list' array. |
Implements moab::ReaderIface.
Definition at line 60 of file ReadSTL.cpp.
References MB_NOT_IMPLEMENTED.
|
protected |
interface instance
Definition at line 120 of file ReadSTL.hpp.
Referenced by ReadSTL(), and ~ReadSTL().
|
protected |
Definition at line 117 of file ReadSTL.hpp.
Referenced by ascii_read_triangles(), load_file(), ReadSTL(), and ~ReadSTL().