Hide menu
Loading...
Searching...
No Matches
cadex::ModelData_ShapeConverter Class Reference

Converts between OCC shapes and CAD Exchanger data model. More...

#include <cadex/ModelData_ShapeConverter.hxx>

Static Public Member Functions

static ModelData_SceneGraphElement Add (const TopoDS_Shape &theSource, ModelData_Model &theTarget, bool theBreakSharing=true)
 Adds the shape to model.
 
static ModelData_SceneGraphElement Add (const TopoDS_Shape &theSource, ModelData_Assembly &theTarget, bool theBreakSharing=true)
 Adds the shape to assembly.
 
static ModelData_Shape Convert (const TopoDS_Shape &theSource)
 Creates CAD Exchanger topological shape from OCC one.
 
static TopoDS_Shape Convert (const ModelData_Model &theSource)
 Creates OCC shape from all parts with B-Rep representations in the model.
 
static TopoDS_Shape Convert (const ModelData_SceneGraphElement &theSource)
 Creates OCC shape from all parts with B-Rep representations in the subtree.
 

Detailed Description

Converts between OCC shapes and CAD Exchanger data model.

Member Function Documentation

◆ Add() [1/2]

ModelData_SceneGraphElement cadex::ModelData_ShapeConverter::Add ( const TopoDS_Shape &  theShape,
ModelData_Assembly theAssembly,
bool  theBreakSharing = true 
)
static

Adds the shape to assembly.

This method can be used to convert input OCC shape to CAD Exchanger data model. Refer to the other overload for description of the mapping algorithm.

If theAssembly is null then initializes it on the fly.

theBreakSharing specifies if the part bodies must be deep-copied prior to adding.

◆ Add() [2/2]

ModelData_SceneGraphElement cadex::ModelData_ShapeConverter::Add ( const TopoDS_Shape &  theShape,
ModelData_Model theModel,
bool  theBreakSharing = true 
)
static

Adds the shape to model.

This method can be used to convert input OCC shape to CAD Exchanger data model. The algorithm will populate the model as follows:

  • a simple shape (from vertex to solid) will map to a part consisting of a single B-Rep representation containing a single body with respective shape;
  • a compound will map to either a part if the compound can be mapped to a single body (e.g. wireframe or sheet) or to an assembly otherwise; children of compound will be recursively added following the algorithm;
  • a shape with attached transformation matrix will map to an instance which will refer to either part or assembly corresponding to a shape without location.

If theModel is null then initializes it on the fly.

theBreakSharing specifies if the part bodies must be deep-copied prior to adding.

◆ Convert() [1/3]

TopoDS_Shape cadex::ModelData_ShapeConverter::Convert ( const ModelData_Model theSource)
static

Creates OCC shape from all parts with B-Rep representations in the model.

In the model contains a single part then creates a shape from its B-Rep representation. Otherwise creates a compound. Respects transformations that are attached to instances in the model.

◆ Convert() [2/3]

TopoDS_Shape cadex::ModelData_ShapeConverter::Convert ( const ModelData_SceneGraphElement theSource)
static

Creates OCC shape from all parts with B-Rep representations in the subtree.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

If the subtree contains a single part then creates a shape from its B-Rep representation. Otherwise creates a compound. Respects transformations that are attached to instances under theSource.

◆ Convert() [3/3]

ModelData_Shape cadex::ModelData_ShapeConverter::Convert ( const TopoDS_Shape &  theSource)
static

Creates CAD Exchanger topological shape from OCC one.

Creates a result as follows:

  • if theSource is a simple shape (vertex to solid) then just creates a respective object (ModelData_Vertex to ModelData_Solid)
  • if theSource is a compound (incl. compsolid) of homogeneous types, i.e. edges and/or wires, or faces and/or shells then creates a body of respective type (e.g. wireframe or sheet body)
  • otherwise creates a body list where each body is created following (recursively) to the above rules.

If a homogeneous compound includes children which are instances of the same shape with different locations (see TopoDS_Shape::IsPartner()) then such a compound is converted to a body list, not a single body.