Open CASCADE Technology 7.8.2.dev
|
An abstract class implementing procedure to read OBJ file. More...
#include <RWObj_Reader.hxx>
Data Structures | |
struct | ObjVec3iHasher |
Hasher for 3 ordered integers. More... | |
class | VectorOfVertices |
Auxiliary structure holding vertex data either with single or double floating point precision. More... | |
Public Member Functions | |
RWObj_Reader () | |
Empty constructor. | |
Standard_Boolean | Read (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress) |
Open stream and pass it to Read method Returns true if success, false on error. | |
Standard_Boolean | Read (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress) |
Reads data from OBJ file. Unicode paths can be given in UTF-8 encoding. Returns true if success, false on error or user break. | |
Standard_Boolean | Probe (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress) |
Open stream and pass it to Probe method. | |
Standard_Boolean | Probe (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress) |
Probe data from OBJ file (comments, external references) without actually reading mesh data. Although mesh data will not be collected, the full file content will be parsed, due to OBJ format limitations. | |
const TCollection_AsciiString & | FileComments () const |
Returns file comments (lines starting with # at the beginning of file). | |
const NCollection_IndexedMap< TCollection_AsciiString > & | ExternalFiles () const |
Return the list of external file references. | |
Standard_Integer | NbProbeNodes () const |
Number of probed nodes. | |
Standard_Integer | NbProbeElems () const |
Standard_Size | MemoryLimit () const |
Returns memory limit in bytes; -1 (no limit) by default. | |
void | SetMemoryLimit (Standard_Size theMemLimit) |
Specify memory limit in bytes, so that import will be aborted by specified limit before memory allocation error occurs. | |
const RWMesh_CoordinateSystemConverter & | Transformation () const |
Return transformation from one coordinate system to another; no transformation by default. | |
void | SetTransformation (const RWMesh_CoordinateSystemConverter &theCSConverter) |
Setup transformation from one coordinate system to another. OBJ file might be exported following various coordinate system conventions, so that it might be useful automatically transform data during file reading. | |
Standard_Boolean | IsSinglePrecision () const |
Return single precision flag for reading vertex data (coordinates); FALSE by default. | |
void | SetSinglePrecision (Standard_Boolean theIsSinglePrecision) |
Setup single/double precision flag for reading vertex data (coordinates). | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. | |
virtual | ~Standard_Transient () |
Destructor must be virtual. | |
virtual const opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. | |
Standard_Boolean | IsInstance (const opencascade::handle< Standard_Type > &theType) const |
Returns a true value if this is an instance of Type. | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. | |
Standard_Boolean | IsKind (const opencascade::handle< Standard_Type > &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. | |
Standard_Integer | GetRefCount () const noexcept |
Get the reference counter of this object. | |
void | IncrementRefCounter () noexcept |
Increments the reference counter of this object. | |
Standard_Integer | DecrementRefCounter () noexcept |
Decrements the reference counter of this object; returns the decremented value. | |
virtual void | Delete () const |
Memory deallocator for transient classes. | |
Protected Member Functions | |
Standard_Boolean | read (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const Standard_Boolean theToProbe) |
Reads data from OBJ file. Unicode paths can be given in UTF-8 encoding. Returns true if success, false on error or user break. | |
interface methods which should be implemented by sub-class | |
virtual Standard_Boolean | addMesh (const RWObj_SubMesh &theMesh, const RWObj_SubMeshReason theReason)=0 |
Add new sub-mesh. Basically, this method will be called multiple times for the same group with different reason, so that implementation should decide if previously allocated sub-mesh should be used or new one to be allocated. Sub-mesh command can be skipped if previous sub-mesh is empty, or if the reason is out of interest for particular reader (e.g. if materials are ignored, reader may ignore RWObj_SubMeshReason_NewMaterial reason). | |
virtual gp_Pnt | getNode (Standard_Integer theIndex) const =0 |
Retrieve sub-mesh node position, added by addNode(). | |
virtual Standard_Integer | addNode (const gp_Pnt &thePnt)=0 |
Callback function to be implemented in descendant. Should create new node with specified coordinates in the target model, and return its ID as integer. | |
virtual void | setNodeNormal (const Standard_Integer theIndex, const Graphic3d_Vec3 &theNorm)=0 |
Callback function to be implemented in descendant. Should set normal coordinates for specified node. | |
virtual void | setNodeUV (const Standard_Integer theIndex, const Graphic3d_Vec2 &theUV)=0 |
Callback function to be implemented in descendant. Should set texture coordinates for specified node. | |
virtual void | addElement (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3, Standard_Integer theN4)=0 |
Callback function to be implemented in descendant. Should create new element (triangle or quad if 4th index is != -1) built on specified nodes in the target model. | |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. | |
Static Public Member Functions inherited from Standard_Transient | |
static constexpr const char * | get_type_name () |
Returns a type descriptor about this object. | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. | |
An abstract class implementing procedure to read OBJ file.
This class is not bound to particular data structure and can be used to read the file directly into arbitrary data model. To use it, create descendant class and implement interface methods.
Call method Read() to read the file.
RWObj_Reader::RWObj_Reader | ( | ) |
Empty constructor.
|
protectedpure virtual |
Callback function to be implemented in descendant. Should create new element (triangle or quad if 4th index is != -1) built on specified nodes in the target model.
Implemented in RWObj_TriangulationReader.
|
protectedpure virtual |
Add new sub-mesh. Basically, this method will be called multiple times for the same group with different reason, so that implementation should decide if previously allocated sub-mesh should be used or new one to be allocated. Sub-mesh command can be skipped if previous sub-mesh is empty, or if the reason is out of interest for particular reader (e.g. if materials are ignored, reader may ignore RWObj_SubMeshReason_NewMaterial reason).
theMesh | mesh definition |
theReason | reason to create new sub-mesh |
Implemented in RWObj_TriangulationReader.
|
protectedpure virtual |
Callback function to be implemented in descendant. Should create new node with specified coordinates in the target model, and return its ID as integer.
Implemented in RWObj_TriangulationReader.
|
inline |
Return the list of external file references.
|
inline |
Returns file comments (lines starting with # at the beginning of file).
|
protectedpure virtual |
Retrieve sub-mesh node position, added by addNode().
Implemented in RWObj_TriangulationReader.
|
inline |
Return single precision flag for reading vertex data (coordinates); FALSE by default.
|
inline |
Returns memory limit in bytes; -1 (no limit) by default.
|
inline |
|
inline |
Number of probed nodes.
number of probed polygon elements (of unknown size).
|
inline |
Open stream and pass it to Probe method.
theFile | path to the file |
theProgress | progress indicator |
|
inline |
Probe data from OBJ file (comments, external references) without actually reading mesh data. Although mesh data will not be collected, the full file content will be parsed, due to OBJ format limitations.
theStream | input stream |
theFile | path to the file |
theProgress | progress indicator |
|
inline |
Open stream and pass it to Read method Returns true if success, false on error.
|
inline |
Reads data from OBJ file. Unicode paths can be given in UTF-8 encoding. Returns true if success, false on error or user break.
|
protected |
Reads data from OBJ file. Unicode paths can be given in UTF-8 encoding. Returns true if success, false on error or user break.
|
inline |
Specify memory limit in bytes, so that import will be aborted by specified limit before memory allocation error occurs.
|
protectedpure virtual |
Callback function to be implemented in descendant. Should set normal coordinates for specified node.
theIndex | node ID as returned by addNode() |
theNorm | normal vector |
Implemented in RWObj_TriangulationReader.
|
protectedpure virtual |
Callback function to be implemented in descendant. Should set texture coordinates for specified node.
theIndex | node ID as returned by addNode() |
theUV | UV texture coordinates |
Implemented in RWObj_TriangulationReader.
|
inline |
Setup single/double precision flag for reading vertex data (coordinates).
|
inline |
Setup transformation from one coordinate system to another. OBJ file might be exported following various coordinate system conventions, so that it might be useful automatically transform data during file reading.
|
inline |
Return transformation from one coordinate system to another; no transformation by default.
|
protected |
active sub-mesh definition
|
protected |
coordinate system flipper
|
protected |
indices for the current element
|
protected |
list of external file references
|
protected |
file header comments
|
protected |
folder containing the OBJ file
|
protected |
map of known materials
|
protected |
estimated memory occupation in bytes
|
protected |
memory limit in bytes
|
protected |
number of big elements (polygons with 5+ nodes)
|
protected |
number of parsed lines (e.g. current line)
|
protected |
number of probed elements
|
protected |
number of probed nodes
|
protected |
temporary vector of normals
|
protected |
temporary vector of vertices
|
protected |
temporary vector of UV parameters
|
protected |
list of external file references
|
protected |
flag indicating abort state (e.g. syntax error)