Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes
RWGltf_CafReader Class Reference

The glTF (GL Transmission Format) mesh reader into XDE document. More...

#include <RWGltf_CafReader.hxx>

Inheritance diagram for RWGltf_CafReader:
Inheritance graph
[legend]

Public Member Functions

 RWGltf_CafReader ()
 Empty constructor.
 
bool ToParallel () const
 Return TRUE if multithreaded optimizations are allowed; FALSE by default.
 
void SetParallel (bool theToParallel)
 Setup multithreaded execution.
 
bool ToSkipEmptyNodes ()
 Return TRUE if Nodes without Geometry should be ignored, TRUE by default.
 
void SetSkipEmptyNodes (bool theToSkip)
 Set flag to ignore nodes without Geometry.
 
bool ToLoadAllScenes () const
 Return TRUE if all scenes in the document should be loaded, FALSE by default which means only main (default) scene will be loaded.
 
bool ToApplyScale () const
 Return TRUE if non-uniform scaling should be applied directly to the triangulation. FALSE if the average scale should be applied to the transformation matrix.
 
void SetLoadAllScenes (bool theToLoadAll)
 Set flag to flag to load all scenes in the document, FALSE by default which means only main (default) scene will be loaded.
 
bool ToUseMeshNameAsFallback ()
 Set flag to use Mesh name in case if Node name is empty, TRUE by default.
 
void SetMeshNameAsFallback (bool theToFallback)
 Set flag to use Mesh name in case if Node name is empty.
 
bool IsDoublePrecision () const
 Return flag to fill in triangulation using double or single precision; FALSE by default.
 
void SetDoublePrecision (bool theIsDouble)
 Set flag to fill in triangulation using double or single precision.
 
bool ToSkipLateDataLoading ()
 Returns TRUE if data loading should be skipped and can be performed later; FALSE by default.
 
void SetToSkipLateDataLoading (bool theToSkip)
 Sets flag to skip data loading.
 
void SetToApplyScale (bool theToApplyScale)
 Set flag to apply non-uniform scaling directly to the triangulation (modify nodes). TRUE by default. In case of FALSE the average scale is applied to the transformation matrix.
 
bool ToKeepLateData ()
 Returns TRUE if data should be loaded into itself without its transferring to new structure. It allows to keep information about deferred storage to load/unload this data later. TRUE by default.
 
void SetToKeepLateData (bool theToKeep)
 Sets flag to keep information about deferred storage to load/unload data later.
 
bool ToPrintDebugMessages () const
 Returns TRUE if additional debug information should be print; FALSE by default.
 
void SetToPrintDebugMessages (const bool theToPrint)
 Sets flag to print debug information.
 
- Public Member Functions inherited from RWMesh_CafReader
 RWMesh_CafReader ()
 Empty constructor.
 
 ~RWMesh_CafReader () override
 Destructor.
 
const occ::handle< TDocStd_Document > & Document () const
 Return target document.
 
void SetDocument (const occ::handle< TDocStd_Document > &theDoc)
 Set target document. Set system length unit according to the units of the document.
 
const TCollection_AsciiStringRootPrefix () const
 Return prefix for generating root labels names.
 
void SetRootPrefix (const TCollection_AsciiString &theRootPrefix)
 Set prefix for generating root labels names.
 
bool ToFillIncompleteDocument () const
 Flag indicating if partially read file content should be put into the XDE document, TRUE by default.
 
void SetFillIncompleteDocument (bool theToFillIncomplete)
 Set flag allowing partially read file content to be put into the XDE document.
 
int MemoryLimitMiB () const
 Return memory usage limit in MiB, -1 by default which means no limit.
 
void SetMemoryLimitMiB (int theLimitMiB)
 Set memory usage limit in MiB; can be ignored by reader implementation!
 
const RWMesh_CoordinateSystemConverterCoordinateSystemConverter () const
 Return coordinate system converter.
 
void SetCoordinateSystemConverter (const RWMesh_CoordinateSystemConverter &theConverter)
 Set coordinate system converter.
 
double SystemLengthUnit () const
 Return the length unit to convert into while reading the file, defined as scale factor for m (meters); -1.0 by default, which means that NO conversion will be applied.
 
void SetSystemLengthUnit (double theUnits)
 Set system length units to convert into while reading the file, defined as scale factor for m (meters).
 
bool HasSystemCoordinateSystem () const
 Return TRUE if system coordinate system has been defined; FALSE by default.
 
const gp_Ax3SystemCoordinateSystem () const
 Return system coordinate system; UNDEFINED by default, which means that no conversion will be done.
 
void SetSystemCoordinateSystem (const gp_Ax3 &theCS)
 Set system origin coordinate system to perform conversion into during read.
 
void SetSystemCoordinateSystem (RWMesh_CoordinateSystem theCS)
 Set system origin coordinate system to perform conversion into during read.
 
double FileLengthUnit () const
 Return the length unit to convert from while reading the file, defined as scale factor for m (meters). Can be undefined (-1.0) if file format is unitless.
 
void SetFileLengthUnit (double theUnits)
 Set (override) file length units to convert from while reading the file, defined as scale factor for m (meters).
 
bool HasFileCoordinateSystem () const
 Return TRUE if file origin coordinate system has been defined.
 
const gp_Ax3FileCoordinateSystem () const
 Return file origin coordinate system; can be UNDEFINED, which means no conversion will be done.
 
void SetFileCoordinateSystem (const gp_Ax3 &theCS)
 Set (override) file origin coordinate system to perform conversion during read.
 
void SetFileCoordinateSystem (RWMesh_CoordinateSystem theCS)
 Set (override) file origin coordinate system to perform conversion during read.
 
bool Perform (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress)
 Open stream and pass it to Perform method. The Document instance should be set beforehand.
 
bool Perform (std::istream &theStream, const Message_ProgressRange &theProgress, const TCollection_AsciiString &theFile="")
 Read the data from specified file.
 
int ExtraStatus () const
 Return extended status flags.
 
TopoDS_Shape SingleShape () const
 Return result as a single shape.
 
const NCollection_IndexedMap< TCollection_AsciiString > & ExternalFiles () const
 Return the list of complementary files - external references (textures, data, etc.).
 
const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & Metadata () const
 Return metadata map.
 
bool ProbeHeader (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress=Message_ProgressRange())
 Open stream and pass it to ProbeHeader method.
 
bool ProbeHeader (std::istream &theStream, const TCollection_AsciiString &theFile="", const Message_ProgressRange &theProgress=Message_ProgressRange())
 Read the header data from specified file without reading entire model. The main purpose is collecting metadata and external references - for copying model into a new location, for example. Can be NOT implemented (unsupported by format / reader).
 
- 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 ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool 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.
 
bool IsKind (const char *const 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.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Protected Member Functions

bool performMesh (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const bool theToProbe) override
 Read the mesh from specified file.
 
void fillDocument () override
 Fill document with new root shapes.
 
bool addShapeIntoDoc (CafDocumentTools &theTools, const TopoDS_Shape &theShape, const TDF_Label &theLabel, const TCollection_AsciiString &theParentName, const bool theHasScale=false, const gp_XYZ &theScale=gp_XYZ(0., 0., 0.))
 Append new shape into the document (recursively).
 
virtual occ::handle< RWMesh_TriangulationReadercreateMeshReaderContext () const
 Create primitive array reader context. Can be overridden by sub-class to read triangulation into application-specific data structures instead of Poly_Triangulation. Default implementation creates RWGltf_TriangulationReader.
 
virtual bool readLateData (NCollection_DynamicArray< TopoDS_Face > &theFaces, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress)
 Read late data from RWGltf_GltfLatePrimitiveArray stored as Poly_Triangulation within faces.
 
void updateLateDataReader (NCollection_DynamicArray< TopoDS_Face > &theFaces, const occ::handle< RWMesh_TriangulationReader > &theReader) const
 Set reader for each late data.
 
- Protected Member Functions inherited from RWMesh_CafReader
virtual bool perform (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const bool theToProbe)
 Open stream and pass it to Perform method.
 
virtual bool perform (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const bool theToProbe)
 Read the data from specified file. Default implementation calls performMesh() and fills XDE document from collected shapes.
 
virtual bool performMesh (const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const bool theToProbe)
 Read the mesh from specified file.
 
bool addShapeIntoDoc (CafDocumentTools &theTools, const TopoDS_Shape &theShape, const TDF_Label &theLabel, const TCollection_AsciiString &theParentName)
 Append new shape into the document (recursively).
 
bool addSubShapeIntoDoc (CafDocumentTools &theTools, const TopoDS_Shape &theShape, const TDF_Label &theParentLabel)
 Append new sub-shape into the document (recursively).
 
void setShapeName (const TDF_Label &theLabel, const TopAbs_ShapeEnum theShapeType, const TCollection_AsciiString &theName, const TDF_Label &theParentLabel, const TCollection_AsciiString &theParentName)
 Put name attribute onto the label.
 
void setShapeStyle (const CafDocumentTools &theTools, const TDF_Label &theLabel, const XCAFPrs_Style &theStyle)
 Put color and material attributes onto the label.
 
void setShapeNamedData (const CafDocumentTools &theTools, const TDF_Label &theLabel, const occ::handle< TDataStd_NamedData > &theNameData)
 Put name data (metadata) attribute onto the label.
 
void generateNames (const TCollection_AsciiString &theFile, const int theRootLower, const bool theWithSubLabels)
 Generate names for root labels starting from specified index.
 

Protected Attributes

bool myToParallel
 flag to use multithreading; FALSE by default
 
bool myToSkipEmptyNodes
 ignore nodes without Geometry; TRUE by default
 
bool myToLoadAllScenes
 flag to load all scenes in the document, FALSE by default
 
bool myUseMeshNameAsFallback
 flag to use Mesh name in case if Node name is empty, TRUE by default
 
bool myIsDoublePrecision
 flag to fill in triangulation using single or double precision
 
bool myToSkipLateDataLoading
 flag to skip triangulation loading
 
bool myToKeepLateData
 flag to keep information about deferred storage to load/unload triangulation later
 
bool myToPrintDebugMessages
 flag to print additional debug information
 
bool myToApplyScale
 flag to apply non-uniform scaling
 
NCollection_DataMap< TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher > * myShapeScaleMap
 map of shapes with non-uniform scalings
 
- Protected Attributes inherited from RWMesh_CafReader
occ::handle< TDocStd_DocumentmyXdeDoc
 target document
 
NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiStringmyMetadata
 metadata map
 
NCollection_IndexedMap< TCollection_AsciiStringmyExternalFiles
 the list of complementary files - external references (textures, data, etc.)
 
TCollection_AsciiString myRootPrefix
 root folder for generating root labels names
 
NCollection_Sequence< TopoDS_ShapemyRootShapes
 sequence of result root shapes
 
NCollection_DataMap< TopoDS_Shape, RWMesh_NodeAttributes, TopTools_ShapeMapHashermyAttribMap
 map of per-shape attributes
 
RWMesh_CoordinateSystemConverter myCoordSysConverter
 coordinate system converter
 
bool myToFillDoc
 fill document from shape sequence
 
bool myToFillIncomplete
 fill the document with partially retrieved data even if reader has failed with error
 
int myMemoryLimitMiB
 memory usage limit
 
int myExtraStatus
 extra status bitmask
 

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 charget_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.
 
- Static Protected Member Functions inherited from RWMesh_CafReader
static TCollection_AsciiString shapeTypeToString (TopAbs_ShapeEnum theType)
 Return shape type as string.
 

Detailed Description

The glTF (GL Transmission Format) mesh reader into XDE document.

Constructor & Destructor Documentation

◆ RWGltf_CafReader()

RWGltf_CafReader::RWGltf_CafReader ( )

Empty constructor.

Member Function Documentation

◆ addShapeIntoDoc()

bool RWGltf_CafReader::addShapeIntoDoc ( CafDocumentTools & theTools,
const TopoDS_Shape & theShape,
const TDF_Label & theLabel,
const TCollection_AsciiString & theParentName,
const bool theHasScale = false,
const gp_XYZ & theScale = gp_XYZ(0., 0., 0.) )
protected

Append new shape into the document (recursively).

◆ createMeshReaderContext()

virtual occ::handle< RWMesh_TriangulationReader > RWGltf_CafReader::createMeshReaderContext ( ) const
protectedvirtual

Create primitive array reader context. Can be overridden by sub-class to read triangulation into application-specific data structures instead of Poly_Triangulation. Default implementation creates RWGltf_TriangulationReader.

◆ fillDocument()

void RWGltf_CafReader::fillDocument ( )
overrideprotectedvirtual

Fill document with new root shapes.

Reimplemented from RWMesh_CafReader.

◆ IsDoublePrecision()

bool RWGltf_CafReader::IsDoublePrecision ( ) const
inline

Return flag to fill in triangulation using double or single precision; FALSE by default.

◆ performMesh()

bool RWGltf_CafReader::performMesh ( std::istream & theStream,
const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress,
const bool theToProbe )
overrideprotectedvirtual

Read the mesh from specified file.

Implements RWMesh_CafReader.

◆ readLateData()

virtual bool RWGltf_CafReader::readLateData ( NCollection_DynamicArray< TopoDS_Face > & theFaces,
const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress )
protectedvirtual

Read late data from RWGltf_GltfLatePrimitiveArray stored as Poly_Triangulation within faces.

◆ SetDoublePrecision()

void RWGltf_CafReader::SetDoublePrecision ( bool theIsDouble)
inline

Set flag to fill in triangulation using double or single precision.

◆ SetLoadAllScenes()

void RWGltf_CafReader::SetLoadAllScenes ( bool theToLoadAll)
inline

Set flag to flag to load all scenes in the document, FALSE by default which means only main (default) scene will be loaded.

◆ SetMeshNameAsFallback()

void RWGltf_CafReader::SetMeshNameAsFallback ( bool theToFallback)
inline

Set flag to use Mesh name in case if Node name is empty.

◆ SetParallel()

void RWGltf_CafReader::SetParallel ( bool theToParallel)
inline

Setup multithreaded execution.

◆ SetSkipEmptyNodes()

void RWGltf_CafReader::SetSkipEmptyNodes ( bool theToSkip)
inline

Set flag to ignore nodes without Geometry.

◆ SetToApplyScale()

void RWGltf_CafReader::SetToApplyScale ( bool theToApplyScale)
inline

Set flag to apply non-uniform scaling directly to the triangulation (modify nodes). TRUE by default. In case of FALSE the average scale is applied to the transformation matrix.

◆ SetToKeepLateData()

void RWGltf_CafReader::SetToKeepLateData ( bool theToKeep)
inline

Sets flag to keep information about deferred storage to load/unload data later.

◆ SetToPrintDebugMessages()

void RWGltf_CafReader::SetToPrintDebugMessages ( const bool theToPrint)
inline

Sets flag to print debug information.

◆ SetToSkipLateDataLoading()

void RWGltf_CafReader::SetToSkipLateDataLoading ( bool theToSkip)
inline

Sets flag to skip data loading.

◆ ToApplyScale()

bool RWGltf_CafReader::ToApplyScale ( ) const
inline

Return TRUE if non-uniform scaling should be applied directly to the triangulation. FALSE if the average scale should be applied to the transformation matrix.

◆ ToKeepLateData()

bool RWGltf_CafReader::ToKeepLateData ( )
inline

Returns TRUE if data should be loaded into itself without its transferring to new structure. It allows to keep information about deferred storage to load/unload this data later. TRUE by default.

◆ ToLoadAllScenes()

bool RWGltf_CafReader::ToLoadAllScenes ( ) const
inline

Return TRUE if all scenes in the document should be loaded, FALSE by default which means only main (default) scene will be loaded.

◆ ToParallel()

bool RWGltf_CafReader::ToParallel ( ) const
inline

Return TRUE if multithreaded optimizations are allowed; FALSE by default.

◆ ToPrintDebugMessages()

bool RWGltf_CafReader::ToPrintDebugMessages ( ) const
inline

Returns TRUE if additional debug information should be print; FALSE by default.

◆ ToSkipEmptyNodes()

bool RWGltf_CafReader::ToSkipEmptyNodes ( )
inline

Return TRUE if Nodes without Geometry should be ignored, TRUE by default.

◆ ToSkipLateDataLoading()

bool RWGltf_CafReader::ToSkipLateDataLoading ( )
inline

Returns TRUE if data loading should be skipped and can be performed later; FALSE by default.

◆ ToUseMeshNameAsFallback()

bool RWGltf_CafReader::ToUseMeshNameAsFallback ( )
inline

Set flag to use Mesh name in case if Node name is empty, TRUE by default.

◆ updateLateDataReader()

void RWGltf_CafReader::updateLateDataReader ( NCollection_DynamicArray< TopoDS_Face > & theFaces,
const occ::handle< RWMesh_TriangulationReader > & theReader ) const
protected

Set reader for each late data.

Field Documentation

◆ myIsDoublePrecision

bool RWGltf_CafReader::myIsDoublePrecision
protected

flag to fill in triangulation using single or double precision

◆ myShapeScaleMap

NCollection_DataMap<TopoDS_Shape, gp_XYZ, TopTools_ShapeMapHasher>* RWGltf_CafReader::myShapeScaleMap
protected

map of shapes with non-uniform scalings

◆ myToApplyScale

bool RWGltf_CafReader::myToApplyScale
protected

flag to apply non-uniform scaling

◆ myToKeepLateData

bool RWGltf_CafReader::myToKeepLateData
protected

flag to keep information about deferred storage to load/unload triangulation later

◆ myToLoadAllScenes

bool RWGltf_CafReader::myToLoadAllScenes
protected

flag to load all scenes in the document, FALSE by default

◆ myToParallel

bool RWGltf_CafReader::myToParallel
protected

flag to use multithreading; FALSE by default

◆ myToPrintDebugMessages

bool RWGltf_CafReader::myToPrintDebugMessages
protected

flag to print additional debug information

◆ myToSkipEmptyNodes

bool RWGltf_CafReader::myToSkipEmptyNodes
protected

ignore nodes without Geometry; TRUE by default

◆ myToSkipLateDataLoading

bool RWGltf_CafReader::myToSkipLateDataLoading
protected

flag to skip triangulation loading

◆ myUseMeshNameAsFallback

bool RWGltf_CafReader::myUseMeshNameAsFallback
protected

flag to use Mesh name in case if Node name is empty, TRUE by default


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