CAD Exchanger SDK
cadex::Base_Reader Class Reference

Base class for reader classes. More...

Inheritance diagram for cadex::Base_Reader:
cadex::A3DS_Reader cadex::ACIS_Reader cadex::BRep_Reader cadex::Collada_Reader cadex::FBX_Reader cadex::IFC_Reader cadex::IGES_Reader cadex::JT_Reader cadex::OBJ_Reader cadex::Para_Reader cadex::Rhino_Reader cadex::SLD_Reader cadex::STEP_Reader cadex::STL_Reader cadex::VRML_Reader

Public Member Functions

 ~Base_Reader ()
 Destructor.
 
bool ReadFile (const Base_UTF16String &theFileName)
 Reads the file into memory. More...
 
bool ReadFile (std::istream &theStream)
 Reads the file into memory. More...
 
bool ReadFile (const std::shared_ptr< Base_IStreamProviderFactory > &theFactory, const Base_UTF16String &theFileName)
 Reads the file into memory. More...
 
bool Transfer (ModelData_Model &theModel)
 Converts read file into a resulting model. More...
 
bool Transfer (TopoDS_Shape &theShape)
 Converts read file into a resulting shape. More...
 
Base_ProgressStatusProgressStatus () const
 Returns a progress status.
 
internal::Base_Reader_Private * Impl () const
 
template<typename T >
T * Impl () const
 Reserved for internal use.
 

Protected Member Functions

 Base_Reader (internal::Base_Reader_Private *theImpl)
 Constructor.
 

Detailed Description

Base class for reader classes.

The reader class provides API for reading (i.e. importing) files in two steps:

  • parsing a file into memory (ReadFile());
  • converting representation in memory into resulting model (Transfer()).

Base_Reader subclasses (e.g. IGES_Reader) must be used following the same pattern:

#include <cadex/IGES_Reader.hxx>
using namespace cadex;
IGES_Reader aReader;
if (aReader.ReadFile ("myfile.igs") && aReader.Transfer (aModel)) {
//OK
} else {
//error during reading the IGES file
}
See also
Base_Writer.

Member Function Documentation

◆ Impl()

internal::Base_Reader_Private* cadex::Base_Reader::Impl ( ) const
inline

Returns the pointer to the implementation object.

Warning
This function is not part of CAD Exchanger API and should not be used.

◆ ReadFile() [1/3]

bool cadex::Base_Reader::ReadFile ( const Base_UTF16String theFileName)

Reads the file into memory.

Returns True if the conversion has been successful and False otherwise.

Exceptions
BaseError_UnsupportedVersion
BaseError_UnexpectedFormat
Note
Please refer to the Base_Reader subclasses' documentation to learn what specific exceptions are thrown by each reader.
Examples:
conversion/import/main.cxx, conversion/transfer/main.cxx, misc/logging/main.cxx, misc/progressindicator/main.cxx, misc/progressindicatorgui/main.cxx, and visualization/qtquick_qml/baseviewer/main.cxx.

◆ ReadFile() [2/3]

bool cadex::Base_Reader::ReadFile ( std::istream &  theStream)

Reads the file into memory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The file is specified in the form of the stream. theStream must be opened and use binary format (the ios::binary flag).

Not all subclasses support this syntax (e.g. STEP_Reader or JT_Reader do not). In this case the method returns False and asserts in debug mode.

Returns True if the conversion has been successful and False otherwise.

Exceptions
BaseError_UnsupportedVersion
BaseError_UnexpectedFormat
Note
Please refer to the Base_Reader subclasses' documentation to learn what specific exceptions are thrown by each reader.

◆ ReadFile() [3/3]

bool cadex::Base_Reader::ReadFile ( const std::shared_ptr< Base_IStreamProviderFactory > &  theFactory,
const Base_UTF16String theFileName 
)

Reads the file into memory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload should be used when parsing files referring to external files (e.g. JT files with external references) residing on specific data storage such as cloud.

theFactory must be an instance of specific subclass of StreamProviderFactory which creates instances of specific subclass(es) of StreamProvider.

Exceptions
BaseError_UnsupportedVersion
BaseError_UnexpectedFormat
Note
Please refer to the Base_Reader subclasses' documentation to learn what specific exceptions are thrown by each reader.
See also
Base_StreamProvider.

◆ Transfer() [1/2]

bool cadex::Base_Reader::Transfer ( ModelData_Model theModel)

Converts read file into a resulting model.

Returns true if the conversion has been successful and false otherwise.

The contents of theModel will be appended.

Sets the base name of the most recently read file (in ReadFile()) to theModel's name unless the model already has a name.

Examples:
conversion/import/main.cxx, conversion/transfer/main.cxx, misc/logging/main.cxx, misc/progressindicator/main.cxx, misc/progressindicatorgui/main.cxx, and visualization/qtquick_qml/baseviewer/main.cxx.

◆ Transfer() [2/2]

bool cadex::Base_Reader::Transfer ( TopoDS_Shape &  theShape)

Converts read file into a resulting shape.

Returns true if the conversion has been successful and false otherwise.