Open CASCADE Technology 7.8.2.dev
RWObj_CafWriter Class Reference

OBJ writer context from XCAF document. More...

#include <RWObj_CafWriter.hxx>

Inheritance diagram for RWObj_CafWriter:

Public Member Functions

 RWObj_CafWriter (const TCollection_AsciiString &theFile)
 Main constructor.
 
virtual ~RWObj_CafWriter ()
 Destructor.
 
const RWMesh_CoordinateSystemConverterCoordinateSystemConverter () const
 Return transformation from OCCT to OBJ coordinate system.
 
RWMesh_CoordinateSystemConverterChangeCoordinateSystemConverter ()
 Return transformation from OCCT to OBJ coordinate system.
 
void SetCoordinateSystemConverter (const RWMesh_CoordinateSystemConverter &theConverter)
 Set transformation from OCCT to OBJ coordinate system.
 
const XCAFPrs_StyleDefaultStyle () const
 Return default material definition to be used for nodes with only color defined.
 
void SetDefaultStyle (const XCAFPrs_Style &theStyle)
 Set default material definition to be used for nodes with only color defined.
 
virtual bool Perform (const Handle< TDocStd_Document > &theDocument, const TDF_LabelSequence &theRootLabels, const TColStd_MapOfAsciiString *theLabelFilter, const TColStd_IndexedDataMapOfStringString &theFileInfo, const Message_ProgressRange &theProgress)
 Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!
 
virtual bool Perform (const Handle< TDocStd_Document > &theDocument, const TColStd_IndexedDataMapOfStringString &theFileInfo, const Message_ProgressRange &theProgress)
 Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (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_TransientThis () 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

virtual Standard_Boolean toSkipFaceMesh (const RWMesh_FaceIterator &theFaceIter)
 Return TRUE if face mesh should be skipped (e.g. because it is invalid or empty).
 
virtual void addFaceInfo (const RWMesh_FaceIterator &theFace, Standard_Integer &theNbNodes, Standard_Integer &theNbElems, Standard_Real &theNbProgressSteps, Standard_Boolean &theToCreateMatFile)
 Collect face triangulation info.
 
virtual bool writeShape (RWObj_ObjWriterContext &theWriter, RWObj_ObjMaterialMap &theMatMgr, Message_LazyProgressScope &thePSentry, const TDF_Label &theLabel, const TopLoc_Location &theParentTrsf, const XCAFPrs_Style &theParentStyle, const TCollection_AsciiString &theName)
 Write the shape.
 
virtual bool writePositions (RWObj_ObjWriterContext &theWriter, Message_LazyProgressScope &thePSentry, const RWMesh_FaceIterator &theFace)
 Write face triangle vertex positions.
 
virtual bool writeNormals (RWObj_ObjWriterContext &theWriter, Message_LazyProgressScope &thePSentry, const RWMesh_FaceIterator &theFace)
 Write face triangle vertex normals.
 
virtual bool writeTextCoords (RWObj_ObjWriterContext &theWriter, Message_LazyProgressScope &thePSentry, const RWMesh_FaceIterator &theFace)
 Write face triangle vertex texture coordinates.
 
virtual bool writeIndices (RWObj_ObjWriterContext &theWriter, Message_LazyProgressScope &thePSentry, const RWMesh_FaceIterator &theFace)
 Write face triangles indices.
 

Protected Attributes

TCollection_AsciiString myFile
 output OBJ file
 
RWMesh_CoordinateSystemConverter myCSTrsf
 transformation from OCCT to OBJ coordinate system
 
XCAFPrs_Style myDefaultStyle
 default material definition to be used for nodes with only color defined
 

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.
 

Detailed Description

OBJ writer context from XCAF document.

Constructor & Destructor Documentation

◆ RWObj_CafWriter()

RWObj_CafWriter::RWObj_CafWriter ( const TCollection_AsciiString & theFile)

Main constructor.

Parameters
theFile[in] path to output OBJ file

◆ ~RWObj_CafWriter()

virtual RWObj_CafWriter::~RWObj_CafWriter ( )
virtual

Destructor.

Member Function Documentation

◆ addFaceInfo()

virtual void RWObj_CafWriter::addFaceInfo ( const RWMesh_FaceIterator & theFace,
Standard_Integer & theNbNodes,
Standard_Integer & theNbElems,
Standard_Real & theNbProgressSteps,
Standard_Boolean & theToCreateMatFile )
protectedvirtual

Collect face triangulation info.

Parameters
theFace[in] face to process
theNbNodes[in] [out] overall number of triangulation nodes (should be appended)
theNbElems[in] [out] overall number of triangulation elements (should be appended)
theNbProgressSteps[in] [out] overall number of progress steps (should be appended)
theToCreateMatFile[in] [out] flag to create material file or not (should be appended)

◆ ChangeCoordinateSystemConverter()

RWMesh_CoordinateSystemConverter & RWObj_CafWriter::ChangeCoordinateSystemConverter ( )
inline

Return transformation from OCCT to OBJ coordinate system.

◆ CoordinateSystemConverter()

const RWMesh_CoordinateSystemConverter & RWObj_CafWriter::CoordinateSystemConverter ( ) const
inline

Return transformation from OCCT to OBJ coordinate system.

◆ DefaultStyle()

const XCAFPrs_Style & RWObj_CafWriter::DefaultStyle ( ) const
inline

Return default material definition to be used for nodes with only color defined.

◆ Perform() [1/2]

virtual bool RWObj_CafWriter::Perform ( const Handle< TDocStd_Document > & theDocument,
const TColStd_IndexedDataMapOfStringString & theFileInfo,
const Message_ProgressRange & theProgress )
virtual

Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!

Parameters
theDocument[in] input document
theFileInfo[in] map with file metadata to put into glTF header section
theProgress[in] optional progress indicator
Returns
FALSE on file writing failure

◆ Perform() [2/2]

virtual bool RWObj_CafWriter::Perform ( const Handle< TDocStd_Document > & theDocument,
const TDF_LabelSequence & theRootLabels,
const TColStd_MapOfAsciiString * theLabelFilter,
const TColStd_IndexedDataMapOfStringString & theFileInfo,
const Message_ProgressRange & theProgress )
virtual

Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!

Parameters
theDocument[in] input document
theRootLabels[in] list of root shapes to export
theLabelFilter[in] optional filter with document nodes to export, with keys defined by XCAFPrs_DocumentExplorer::DefineChildId() and filled recursively (leaves and parent assembly nodes at all levels); when not NULL, all nodes not included into the map will be ignored
theFileInfo[in] map with file metadata to put into OBJ header section
theProgress[in] optional progress indicator
Returns
FALSE on file writing failure

◆ SetCoordinateSystemConverter()

void RWObj_CafWriter::SetCoordinateSystemConverter ( const RWMesh_CoordinateSystemConverter & theConverter)
inline

Set transformation from OCCT to OBJ coordinate system.

◆ SetDefaultStyle()

void RWObj_CafWriter::SetDefaultStyle ( const XCAFPrs_Style & theStyle)
inline

Set default material definition to be used for nodes with only color defined.

◆ toSkipFaceMesh()

virtual Standard_Boolean RWObj_CafWriter::toSkipFaceMesh ( const RWMesh_FaceIterator & theFaceIter)
protectedvirtual

Return TRUE if face mesh should be skipped (e.g. because it is invalid or empty).

◆ writeIndices()

virtual bool RWObj_CafWriter::writeIndices ( RWObj_ObjWriterContext & theWriter,
Message_LazyProgressScope & thePSentry,
const RWMesh_FaceIterator & theFace )
protectedvirtual

Write face triangles indices.

Parameters
theWriter[in] OBJ writer context
thePSentry[in] progress sentry
theFace[in] current face
Returns
FALSE on writing file error

◆ writeNormals()

virtual bool RWObj_CafWriter::writeNormals ( RWObj_ObjWriterContext & theWriter,
Message_LazyProgressScope & thePSentry,
const RWMesh_FaceIterator & theFace )
protectedvirtual

Write face triangle vertex normals.

Parameters
theWriter[in] OBJ writer context
thePSentry[in] progress sentry
theFace[in] current face
Returns
FALSE on writing file error

◆ writePositions()

virtual bool RWObj_CafWriter::writePositions ( RWObj_ObjWriterContext & theWriter,
Message_LazyProgressScope & thePSentry,
const RWMesh_FaceIterator & theFace )
protectedvirtual

Write face triangle vertex positions.

Parameters
theWriter[in] OBJ writer context
thePSentry[in] progress sentry
theFace[in] current face
Returns
FALSE on writing file error

◆ writeShape()

virtual bool RWObj_CafWriter::writeShape ( RWObj_ObjWriterContext & theWriter,
RWObj_ObjMaterialMap & theMatMgr,
Message_LazyProgressScope & thePSentry,
const TDF_Label & theLabel,
const TopLoc_Location & theParentTrsf,
const XCAFPrs_Style & theParentStyle,
const TCollection_AsciiString & theName )
protectedvirtual

Write the shape.

Parameters
theWriter[in] OBJ writer context
theMatMgr[in] OBJ material map
thePSentry[in] progress sentry
theLabel[in] document label to process
theParentTrsf[in] parent node transformation
theParentStyle[in] parent node style
theName[in] node name

◆ writeTextCoords()

virtual bool RWObj_CafWriter::writeTextCoords ( RWObj_ObjWriterContext & theWriter,
Message_LazyProgressScope & thePSentry,
const RWMesh_FaceIterator & theFace )
protectedvirtual

Write face triangle vertex texture coordinates.

Parameters
theWriter[in] OBJ writer context
thePSentry[in] progress sentry
theFace[in] current face
Returns
FALSE on writing file error

Field Documentation

◆ myCSTrsf

RWMesh_CoordinateSystemConverter RWObj_CafWriter::myCSTrsf
protected

transformation from OCCT to OBJ coordinate system

◆ myDefaultStyle

XCAFPrs_Style RWObj_CafWriter::myDefaultStyle
protected

default material definition to be used for nodes with only color defined

◆ myFile

TCollection_AsciiString RWObj_CafWriter::myFile
protected

output OBJ file


The documentation for this class was generated from the following file: