Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Protected Member Functions
RWMesh_CafReader Class Referenceabstract

The general interface for importing mesh data into XDE document. More...

#include <RWMesh_CafReader.hxx>

Inheritance diagram for RWMesh_CafReader:
Inheritance graph
[legend]

Data Structures

struct  CafDocumentTools
 Structure holding tools for filling the document. More...
 

Public Member Functions

 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

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.
 
virtual bool performMesh (std::istream &theStream, const TCollection_AsciiString &theFile, const Message_ProgressRange &theProgress, const bool theToProbe)=0
 Read the mesh from specified file - interface to be implemented by sub-classes.
 

tools for filling XDE document

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
 
virtual void fillDocument ()
 Fill document with new root shapes.
 
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.
 
static TCollection_AsciiString shapeTypeToString (TopAbs_ShapeEnum theType)
 Return shape type as string.
 

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.
 

Detailed Description

The general interface for importing mesh data into XDE document.

The tool implements auxiliary structures for creating an XDE document in two steps: 1) Creating TopoDS_Shape hierarchy (myRootShapes) and Shape attributes (myAttribMap) separately within performMesh(). Attributes include names and styles. 2) Filling XDE document from these auxiliary structures. Named elements are expanded within document structure, while Compounds having no named children will remain collapsed. In addition, unnamed nodes can be filled with generated names like "Face", "Compound" via generateNames() method, and the very root unnamed node can be filled from file name like "MyModel.obj".

Constructor & Destructor Documentation

◆ RWMesh_CafReader()

RWMesh_CafReader::RWMesh_CafReader ( )

Empty constructor.

◆ ~RWMesh_CafReader()

RWMesh_CafReader::~RWMesh_CafReader ( )
override

Destructor.

Member Function Documentation

◆ addShapeIntoDoc()

bool RWMesh_CafReader::addShapeIntoDoc ( CafDocumentTools & theTools,
const TopoDS_Shape & theShape,
const TDF_Label & theLabel,
const TCollection_AsciiString & theParentName )
protected

Append new shape into the document (recursively).

◆ addSubShapeIntoDoc()

bool RWMesh_CafReader::addSubShapeIntoDoc ( CafDocumentTools & theTools,
const TopoDS_Shape & theShape,
const TDF_Label & theParentLabel )
protected

Append new sub-shape into the document (recursively).

◆ CoordinateSystemConverter()

const RWMesh_CoordinateSystemConverter & RWMesh_CafReader::CoordinateSystemConverter ( ) const
inline

Return coordinate system converter.

◆ Document()

const occ::handle< TDocStd_Document > & RWMesh_CafReader::Document ( ) const
inline

Return target document.

◆ ExternalFiles()

const NCollection_IndexedMap< TCollection_AsciiString > & RWMesh_CafReader::ExternalFiles ( ) const
inline

Return the list of complementary files - external references (textures, data, etc.).

◆ ExtraStatus()

int RWMesh_CafReader::ExtraStatus ( ) const
inline

Return extended status flags.

See also
RWMesh_CafReaderStatusEx enumeration.

◆ FileCoordinateSystem()

const gp_Ax3 & RWMesh_CafReader::FileCoordinateSystem ( ) const
inline

Return file origin coordinate system; can be UNDEFINED, which means no conversion will be done.

◆ FileLengthUnit()

double RWMesh_CafReader::FileLengthUnit ( ) const
inline

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.

◆ fillDocument()

virtual void RWMesh_CafReader::fillDocument ( )
protectedvirtual

Fill document with new root shapes.

Reimplemented in RWGltf_CafReader.

◆ generateNames()

void RWMesh_CafReader::generateNames ( const TCollection_AsciiString & theFile,
const int theRootLower,
const bool theWithSubLabels )
protected

Generate names for root labels starting from specified index.

◆ HasFileCoordinateSystem()

bool RWMesh_CafReader::HasFileCoordinateSystem ( ) const
inline

Return TRUE if file origin coordinate system has been defined.

◆ HasSystemCoordinateSystem()

bool RWMesh_CafReader::HasSystemCoordinateSystem ( ) const
inline

Return TRUE if system coordinate system has been defined; FALSE by default.

◆ MemoryLimitMiB()

int RWMesh_CafReader::MemoryLimitMiB ( ) const
inline

Return memory usage limit in MiB, -1 by default which means no limit.

◆ Metadata()

const NCollection_IndexedDataMap< TCollection_AsciiString, TCollection_AsciiString > & RWMesh_CafReader::Metadata ( ) const
inline

Return metadata map.

◆ Perform() [1/2]

bool RWMesh_CafReader::Perform ( const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress )
inline

Open stream and pass it to Perform method. The Document instance should be set beforehand.

◆ perform() [1/2]

virtual bool RWMesh_CafReader::perform ( const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress,
const bool theToProbe )
protectedvirtual

Open stream and pass it to Perform method.

Parameters
theFilefile to read
optionalprogress indicator
theToProbeflag indicating that mesh data should be skipped and only basing information to be read

◆ Perform() [2/2]

bool RWMesh_CafReader::Perform ( std::istream & theStream,
const Message_ProgressRange & theProgress,
const TCollection_AsciiString & theFile = "" )
inline

Read the data from specified file.

◆ perform() [2/2]

virtual bool RWMesh_CafReader::perform ( std::istream & theStream,
const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress,
const bool theToProbe )
protectedvirtual

Read the data from specified file. Default implementation calls performMesh() and fills XDE document from collected shapes.

Parameters
theStreaminput stream
theFilepath of additional files
optionalprogress indicator
theToProbeflag indicating that mesh data should be skipped and only basing information to be read

◆ performMesh() [1/2]

virtual bool RWMesh_CafReader::performMesh ( const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress,
const bool theToProbe )
inlineprotectedvirtual

Read the mesh from specified file.

◆ performMesh() [2/2]

virtual bool RWMesh_CafReader::performMesh ( std::istream & theStream,
const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress,
const bool theToProbe )
protectedpure virtual

Read the mesh from specified file - interface to be implemented by sub-classes.

Implemented in RWGltf_CafReader, RWObj_CafReader, and VrmlAPI_CafReader.

◆ ProbeHeader() [1/2]

bool RWMesh_CafReader::ProbeHeader ( const TCollection_AsciiString & theFile,
const Message_ProgressRange & theProgress = Message_ProgressRange() )
inline

Open stream and pass it to ProbeHeader method.

◆ ProbeHeader() [2/2]

bool RWMesh_CafReader::ProbeHeader ( std::istream & theStream,
const TCollection_AsciiString & theFile = "",
const Message_ProgressRange & theProgress = Message_ProgressRange() )
inline

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).

◆ RootPrefix()

const TCollection_AsciiString & RWMesh_CafReader::RootPrefix ( ) const
inline

Return prefix for generating root labels names.

◆ SetCoordinateSystemConverter()

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

Set coordinate system converter.

◆ SetDocument()

void RWMesh_CafReader::SetDocument ( const occ::handle< TDocStd_Document > & theDoc)

Set target document. Set system length unit according to the units of the document.

◆ SetFileCoordinateSystem() [1/2]

void RWMesh_CafReader::SetFileCoordinateSystem ( const gp_Ax3 & theCS)
inline

Set (override) file origin coordinate system to perform conversion during read.

◆ SetFileCoordinateSystem() [2/2]

void RWMesh_CafReader::SetFileCoordinateSystem ( RWMesh_CoordinateSystem theCS)
inline

Set (override) file origin coordinate system to perform conversion during read.

◆ SetFileLengthUnit()

void RWMesh_CafReader::SetFileLengthUnit ( double theUnits)
inline

Set (override) file length units to convert from while reading the file, defined as scale factor for m (meters).

◆ SetFillIncompleteDocument()

void RWMesh_CafReader::SetFillIncompleteDocument ( bool theToFillIncomplete)
inline

Set flag allowing partially read file content to be put into the XDE document.

◆ SetMemoryLimitMiB()

void RWMesh_CafReader::SetMemoryLimitMiB ( int theLimitMiB)
inline

Set memory usage limit in MiB; can be ignored by reader implementation!

◆ SetRootPrefix()

void RWMesh_CafReader::SetRootPrefix ( const TCollection_AsciiString & theRootPrefix)
inline

Set prefix for generating root labels names.

◆ setShapeName()

void RWMesh_CafReader::setShapeName ( const TDF_Label & theLabel,
const TopAbs_ShapeEnum theShapeType,
const TCollection_AsciiString & theName,
const TDF_Label & theParentLabel,
const TCollection_AsciiString & theParentName )
protected

Put name attribute onto the label.

◆ setShapeNamedData()

void RWMesh_CafReader::setShapeNamedData ( const CafDocumentTools & theTools,
const TDF_Label & theLabel,
const occ::handle< TDataStd_NamedData > & theNameData )
protected

Put name data (metadata) attribute onto the label.

◆ setShapeStyle()

void RWMesh_CafReader::setShapeStyle ( const CafDocumentTools & theTools,
const TDF_Label & theLabel,
const XCAFPrs_Style & theStyle )
protected

Put color and material attributes onto the label.

◆ SetSystemCoordinateSystem() [1/2]

void RWMesh_CafReader::SetSystemCoordinateSystem ( const gp_Ax3 & theCS)
inline

Set system origin coordinate system to perform conversion into during read.

◆ SetSystemCoordinateSystem() [2/2]

void RWMesh_CafReader::SetSystemCoordinateSystem ( RWMesh_CoordinateSystem theCS)
inline

Set system origin coordinate system to perform conversion into during read.

◆ SetSystemLengthUnit()

void RWMesh_CafReader::SetSystemLengthUnit ( double theUnits)
inline

Set system length units to convert into while reading the file, defined as scale factor for m (meters).

◆ shapeTypeToString()

static TCollection_AsciiString RWMesh_CafReader::shapeTypeToString ( TopAbs_ShapeEnum theType)
inlinestaticprotected

Return shape type as string.

See also
TopAbs::ShapeTypeToString()

◆ SingleShape()

TopoDS_Shape RWMesh_CafReader::SingleShape ( ) const

Return result as a single shape.

◆ SystemCoordinateSystem()

const gp_Ax3 & RWMesh_CafReader::SystemCoordinateSystem ( ) const
inline

Return system coordinate system; UNDEFINED by default, which means that no conversion will be done.

◆ SystemLengthUnit()

double RWMesh_CafReader::SystemLengthUnit ( ) const
inline

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.

◆ ToFillIncompleteDocument()

bool RWMesh_CafReader::ToFillIncompleteDocument ( ) const
inline

Flag indicating if partially read file content should be put into the XDE document, TRUE by default.

Partial read means unexpected end of file, critical parsing syntax errors in the middle of file, or reached memory limit indicated by performMesh() returning FALSE. Partial read allows importing a model even in case of formal reading failure, so that it will be up to user to decide if processed data has any value.

In case of partial read (performMesh() returns FALSE, but there are some data that could be put into document), Perform() will return TRUE and result flag will have failure bit set.

See also
MemoryLimitMiB(), ExtraStatus().

Field Documentation

◆ myAttribMap

map of per-shape attributes

◆ myCoordSysConverter

RWMesh_CoordinateSystemConverter RWMesh_CafReader::myCoordSysConverter
protected

coordinate system converter

◆ myExternalFiles

NCollection_IndexedMap<TCollection_AsciiString> RWMesh_CafReader::myExternalFiles
protected

the list of complementary files - external references (textures, data, etc.)

◆ myExtraStatus

int RWMesh_CafReader::myExtraStatus
protected

extra status bitmask

◆ myMemoryLimitMiB

int RWMesh_CafReader::myMemoryLimitMiB
protected

memory usage limit

◆ myMetadata

metadata map

◆ myRootPrefix

TCollection_AsciiString RWMesh_CafReader::myRootPrefix
protected

root folder for generating root labels names

◆ myRootShapes

NCollection_Sequence<TopoDS_Shape> RWMesh_CafReader::myRootShapes
protected

sequence of result root shapes

◆ myToFillDoc

bool RWMesh_CafReader::myToFillDoc
protected

fill document from shape sequence

◆ myToFillIncomplete

bool RWMesh_CafReader::myToFillIncomplete
protected

fill the document with partially retrieved data even if reader has failed with error

◆ myXdeDoc

occ::handle<TDocStd_Document> RWMesh_CafReader::myXdeDoc
protected

target document


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