RWObj
OCCT package RWObj: RWObj, RWObj_CafReader, RWObj_CafWriter, RWObj_IShapeReceiver, and 8 more bound classes.
RWObj
This class provides methods to read and write triangulation from / to the OBJ files.
Constructors(1)
- constructor(): RWObj
Static methods(1)
- ReadFile(theFile: string, aProgress?: Message_ProgressRange): Poly_Triangulation
Read specified OBJ file and returns its content as triangulation. In case of error, returns Null handle.
Parameters (2)theFileaProgress
RWObj_CafReader
The OBJ mesh reader into XDE document.
Constructors(1)
Empty constructor.
Static methods(2)
- get_type_name(): string
Instance methods(3)
- IsSinglePrecision(): boolean
Return single precision flag for reading vertex data (coordinates); FALSE by default.
- SetSinglePrecision(theIsSinglePrecision: boolean): void
Setup single/double precision flag for reading vertex data (coordinates).
Parameters (1)theIsSinglePrecision
RWObj_CafWriter
OBJ writer context from XCAF document.
Constructors(1)
- constructor(theFile: TCollection_AsciiString): RWObj_CafWriter
Main constructor.
Parameters (1)theFile—path to output OBJ file
Static methods(1)
Instance methods(8)
Return transformation from OCCT to OBJ coordinate system.
Return transformation from OCCT to OBJ coordinate system.
- SetCoordinateSystemConverter(theConverter: RWMesh_CoordinateSystemConverter): void
Set transformation from OCCT to OBJ coordinate system.
Parameters (1)theConverter
Return default material definition to be used for nodes with only color defined.
- SetDefaultStyle(theStyle: XCAFPrs_Style): void
Set default material definition to be used for nodes with only color defined.
Parameters (1)theStyle
- Perform(theDocument: TDocStd_Document, theRootLabels: NCollection_Sequence_TDF_Label, theLabelFilter: NCollection_Map_TCollection_AsciiString, theFileInfo: any, theProgress: Message_ProgressRange): boolean
Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!
Parameters (5)theDocument—input documenttheRootLabels—list of root shapes to exporttheLabelFilter—optional filter with document nodes to export, with keys defined byXCAFPrs_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 ignoredtheFileInfo—map with file metadata to put into OBJ header sectiontheProgress—optional progress indicator
ReturnsFALSE on file writing failure
- Perform(theDocument: TDocStd_Document, theFileInfo: any, theProgress: Message_ProgressRange): boolean
Write OBJ file and associated MTL material file. Triangulation data should be precomputed within shapes!
Parameters (3)theDocument—input documenttheFileInfo—map with file metadata to put into glTF header sectiontheProgress—optional progress indicator
ReturnsFALSE on file writing failure
RWObj_IShapeReceiver
Interface to store shape attributes into document.
Instance methods(1)
- BindNamedShape(theShape: TopoDS_Shape, theName: TCollection_AsciiString, theMaterial: RWObj_Material, theIsRootShape: boolean): voidParameters (4)
theShape—shape to registertheName—shape nametheMaterial—shape materialtheIsRootShape—indicates that this is a root object (free shape)
RWObj_Material
Material definition for OBJ file format.
Constructors(1)
Properties(9)
RWObj_MtlReader
Reader of mtl files.
Constructors(1)
- constructor(theMaterials: NCollection_DataMap_TCollection_AsciiString_RWObj_Material): RWObj_MtlReader
Main constructor.
Parameters (1)theMaterials
Instance methods(1)
- Read(theFolder: TCollection_AsciiString, theFile: TCollection_AsciiString): boolean
Read the file.
Parameters (2)theFoldertheFile
RWObj_ObjMaterialMap
Material MTL file writer for OBJ export.
Constructors(1)
Main constructor.
Parameters (1)theFile
Static methods(2)
- get_type_name(): string
Instance methods(3)
- AddMaterial(theStyle: XCAFPrs_Style): TCollection_AsciiString
Add material.
Parameters (1)theStyle
- DefineMaterial(theStyle: XCAFPrs_Style, theKey: TCollection_AsciiString, theName: TCollection_AsciiString): void
Virtual method actually defining the material (e.g. export to the file).
Parameters (3)theStyletheKeytheName
RWObj_ObjWriterContext
Auxiliary low-level tool writing OBJ file.
Constructors(1)
Main constructor.
Parameters (1)theName
Instance methods(11)
- IsOpened(): boolean
Return true if file has been opened.
- Close(): boolean
Correctly close the file.
- HasNormals(): boolean
Return true if normals are defined.
- SetNormals(theHasNormals: boolean): void
Set if normals are defined.
Parameters (1)theHasNormals
- HasTexCoords(): boolean
Return true if normals are defined.
- SetTexCoords(theHasTexCoords: boolean): void
Set if normals are defined.
Parameters (1)theHasTexCoords
- WriteHeader(theNbNodes: number, theNbElems: number, theMatLib: TCollection_AsciiString, theFileInfo: any): boolean
Write the header.
Parameters (4)theNbNodestheNbElemstheMatLibtheFileInfo
Return active material or empty string if not set.
- WriteActiveMaterial(theMaterial: TCollection_AsciiString): boolean
Set active material.
Parameters (1)theMaterial
- WriteGroup(theValue: TCollection_AsciiString): boolean
Writing a group name.
Parameters (1)theValue
- FlushFace(theNbNodes: number): void
Increment indices shift.
Parameters (1)theNbNodes
Properties(1)
RWObj_Reader
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.
Static methods(2)
- get_type_name(): string
Instance methods(13)
- Read(theFile: TCollection_AsciiString, theProgress: Message_ProgressRange): boolean
Open stream and pass it to Read method Returns true if success, false on error.
Parameters (2)theFiletheProgress
- Probe(theFile: TCollection_AsciiString, theProgress: Message_ProgressRange): boolean
Open stream and pass it to Probe method.
Parameters (2)theFile—path to the filetheProgress—progress indicator
ReturnsTRUE if success, FALSE on error or user break.
See alsoFileComments()ExternalFiles()NbProbeNodes()NbProbeElems()
Returns file comments (lines starting with # at the beginning of file).
Return the list of external file references.
- NbProbeNodes(): number
Number of probed nodes.
number of probed polygon elements (of unknown size). - NbProbeElems(): number
- MemoryLimit(): number
Returns memory limit in bytes; -1 (no limit) by default.
- SetMemoryLimit(theMemLimit: number): void
Specify memory limit in bytes, so that import will be aborted by specified limit before memory allocation error occurs.
Parameters (1)theMemLimit
Return transformation from one coordinate system to another; no transformation by default.
- SetTransformation(theCSConverter: RWMesh_CoordinateSystemConverter): void
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.
Parameters (1)theCSConverter
- IsSinglePrecision(): boolean
Return single precision flag for reading vertex data (coordinates); FALSE by default.
- SetSinglePrecision(theIsSinglePrecision: boolean): void
Setup single/double precision flag for reading vertex data (coordinates).
Parameters (1)theIsSinglePrecision
RWObj_SubMesh
Sub-mesh definition for OBJ reader.
Constructors(1)
Properties(4)
RWObj_SubMeshReason
Properties(4)
RWObj_TriangulationReader
RWObj_Reader implementation dumping OBJ file into Poly_Triangulation.
Constructors(1)
Constructor.
Static methods(2)
- get_type_name(): string
Instance methods(5)
- SetCreateShapes(theToCreateShapes: boolean): void
Set flag to create shapes.
Parameters (1)theToCreateShapes
- SetShapeReceiver(theReceiver: RWObj_IShapeReceiver): void
Set shape receiver callback.
Parameters (1)theReceiver
Create
Poly_Triangulationfrom collected data.Return result shape.