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

Creates a scene nodes and its children from input data model objects. More...

#include <cadex/ModelPrs_SceneNodeFactory.hxx>

Inheritance diagram for cadex::ModelPrs_SceneNodeFactory:
cadex::Base_PublicObject

Public Types

typedef cadex::internal::ModelPrs_SceneNodeFactoryImpl ImplType
 

Public Member Functions

 ModelPrs_SceneNodeFactory ()
 Constructor.
 
 ModelPrs_SceneNodeFactory (const ModelPrs_SceneNodeFactoryParameters &theParameters)
 Constructor.
 
ModelPrs_SceneNodeFactoryParametersParameters ()
 Returns factory parameters.
 
const ModelPrs_SceneNodeFactoryParametersParameters () const
 Returns factory parameters.
 
ModelPrs_SceneNode CreateGraph (const ModelData_Model &theModel, ModelData_RepresentationMask theRepresentationMask)
 Creates scene graph using ModelData_Model.
 
ModelPrs_SceneNode CreateGraph (const ModelData_Model &theModel, const Base_UTF16String &theRepresentationName)
 Creates scene graph using ModelData_Model.
 
ModelPrs_SceneNode CreateGraph (const ModelData_BIMModel &theBIMModel, ModelData_RepresentationMask theRepresentationMask)
 Creates scene graph using ModelData_BIMModel.
 
ModelPrs_SceneNode CreateGraph (const ModelData_BIMModel &theBIMModel, const Base_UTF16String &theRepresentationName)
 Creates scene graph using ModelData_BIMModel.
 
ModelPrs_SceneNode CreateGraph (const ModelData_BIMGeometryElement &theBIMGeometryElement, ModelData_RepresentationMask theRepresentationMask)
 Creates scene graph using ModelData_BIMGeometryElement.
 
ModelPrs_SceneNode CreateGraph (const ModelData_BIMGeometryElement &theBIMGeometryElement, const Base_UTF16String &theRepresentationName)
 Creates scene graph using ModelData_BIMGeometryElement.
 
ModelPrs_SceneNode CreateGraph (const ModelData_DrawingSheet &theDrawingSheet)
 Creates scene graph using ModelData_DrawingSheet.
 
ModelPrs_SceneNode CreateNode (const ModelData_DrawingElement &theDrawingElement)
 Creates scene node using ModelData_DrawingElement.
 
ModelPrs_SceneNode CreateNode (const ModelData_SceneGraphElement &theSceneGraphElement)
 Creates scene node using ModelData_SceneGraphElement.
 
ModelPrs_SceneNode CreateNode (const ModelData_BIMBaseObject &theBIMElement)
 Creates scene node using ModelData_BIMBaseObject.
 
ModelPrs_SceneNode CreateNode (const ModelData_Representation &theRepresentation)
 Creates scene node using ModelData_PolyRepresentation or ModelData_BRepRepresentation.
 
ModelPrs_SceneNode CreateNode (const ModelData_PolyVertexSet &thePolyVertexSet)
 Creates scene node using ModelData_PolyVertexSet.
 
ModelPrs_SceneNode CreateNode (const ModelData_Body &theBody, const ModelData_BRepRepresentation &theRep=ModelData_BRepRepresentation())
 Creates scene node using ModelData_Body with optional owning ModelData_BRepRepresentation.
 
ModelPrs_SceneNode CreateNode (const ModelPrs_Measurement &theMeasurement)
 Creates scene node using ModelPrs_Measurement.
 
ModelPrs_SceneNode CreateNode (const ModelData_PMIGraphicalElement &thePMIGraphicalElement)
 Creates scene node using ModelData_PMIGraphicalElement.
 
- Public Member Functions inherited from cadex::Base_PublicObject
void Nullify ()
 Resets reference to implementation object.
 
bool IsNull () const
 Returns true if the object is nullified.
 
 operator bool () const
 Casts the object to the bool type.
 
internal::Base_HandledObject * Impl () const
 Return a handle to backend (reserved for internal use).
 

Additional Inherited Members

- Protected Member Functions inherited from cadex::Base_PublicObject
 Base_PublicObject (const internal::Base_HandledObject *theObject)
 Constructor (reserved for internal use).
 
template<typename T >
T * GetOrCreateImpl ()
 Reserved for internal use.
 

Detailed Description

Creates a scene nodes and its children from input data model objects.

Warning
This class is a part of Visualization Toolkit add-on, which is licensed separately from the base CAD Exchanger SDK.

The factory supports various input types to create scene nodes from:

  • Entire ModelData_Model;
  • Assembly, part or instance;
  • B-Rep or polygonal representation.
  • Individual body inside B-Rep representation;
  • Individual mesh (triangle set, polyline set or point set).

There are two ways to create scene nodes:

  • The first is to use CreateGraph that traverses a model entirely, creates scene nodes and their children. This prevents you from influencing the creation of the scene nodes. Therefore, it is more suitable for simply displaying the entire model. For example, to take screenshots. sdk_examples_offscreen
  • The second is to use CreateNode that creates a single scene node. It gives you the ability to process each scene node and manually create a scene graph. For example, to create items for tree view and add a relation to scene nodes. sdk_examples_selectionhandling

The following example demonstrates creating a scene from the entire model. Note that if the model has multiple roots then resulting scene nodes will be children of a single root scene node:

ModelData_Model aModel = ...;
ModelPrs_SceneNodeFactory aFactory ({ModelData_RM_BRep});
ModelPrs_SceneNode aRootNode = aFactory.CreateGraph (aModel);
aScene.AddRoot (aRootNode);
aScene.Update();
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Provides CAD Exchanger visualization structure.
Definition: ModelPrs_Scene.hxx:39
void AddRoot(ModelPrs_SceneNode &theNode)
Adds a root scene node.
Definition: ModelPrs_Scene.cxx:138
void Update(const Base_ProgressStatus &theProgressStatus=Base_ProgressStatus())
Applies changes of attached Scene Nodes.
Definition: ModelPrs_Scene.cxx:188
Creates a scene nodes and its children from input data model objects.
Definition: ModelPrs_SceneNodeFactory.hxx:53
Represents a node in the visual scene graph.
Definition: ModelPrs_SceneNode.hxx:44

The following example demonstrates creating a scene node for a single B-Rep solid:

ModelPrs_Scene aBodyNode = aFactory.CreateNode (aBody);
static ModelData_Solid CreateSphere(double theRadius, double theU=2 *M_PI, double theVmin=-M_PI_2, double theVmax=M_PI_2)
Creates a sphere.
Definition: ModelAlgo_TopoPrimitives.cxx:148
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
static ModelData_Body Create(const ModelData_Shape &theShape)
Creates a body from an arbitrary shape.
Definition: ModelData_Body.cxx:223
Defines a topological solid.
Definition: ModelData_Solid.hxx:31

Scene nodes for B-Rep shapes

Given that B-Rep sub-shapes may only refer to meta-data (such as visual appearances) in the context of B-Rep representation that own them, specifying that owning B-Rep representation is important when creating a node. Consider an example of a B-Rep solid with three colored faces:

auto aF1 = anIt.Next();
auto aF2 = anIt.Next();
auto aF3 = anIt.Next();
aBRep.SetAppearance (aF1, ModelData_Color (1.f, 0.f, 0.f);
aBRep.SetAppearance (aF2, ModelData_Color (0.f, 1.f, 0.f);
aBRep.SetAppearance (aF3, ModelData_Color (0.f, 0.f, 1.f);
static ModelData_Solid CreateBox(double theDx, double theDy, double theDz)
Creates a box.
Definition: ModelAlgo_TopoPrimitives.cxx:86
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
Defines an RGBA color (with alpha channel).
Definition: ModelData_Color.hxx:34
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41

In order to transmit these attributes to the scene nodes the owning B-Rep representation must be specified:

auto aNode = aFactory.CreateNode (aBody, aBRep);

If the B-Rep representation is not provided then the appearance will be lost:

auto aNode2 = aFactory.CreateNode (aBody);

The results are shown on the following screenshots:

Body with owning B-Rep
td
Body without owning B-Rep
td

Of course, to achieve an equivalent correct result the factory could be simply used as follows:

auto aNode = aFactory.CreateNode (aBRep);

A scene node factory contains a shared pointer to its internal implementation, so simple copying an object will just copy a shared pointer. Therefore any modification of the copied object will propagate to original object.

See also
Using pimpl pattern
Examples
MTKConverter/Program.cs, MTKConverter/main.cxx, visualization/offscreen/Program.cs, visualization/offscreen/main.cxx, visualization/qtquick_qml/baseviewer/main.cxx, visualization/qtquick_qml/drawingviewer/main.cxx, visualization/qtquick_qml/measurements/main.cxx, visualization/qtquick_qml/pmiviewer/main.cxx, visualization/qtquick_qml/selectionhandling/main.cxx, visualization/winforms/baseviewer/Program.cs, visualization/wpf/baseviewer/App.xaml.cs, visualization/wpf/pmiviewer/App.xaml.cs, and visualization/wpf/selectionhandling/App.xaml.cs.

Constructor & Destructor Documentation

◆ ModelPrs_SceneNodeFactory() [1/2]

cadex::ModelPrs_SceneNodeFactory::ModelPrs_SceneNodeFactory ( )

Constructor.

Creates factory with default parameters.

◆ ModelPrs_SceneNodeFactory() [2/2]

cadex::ModelPrs_SceneNodeFactory::ModelPrs_SceneNodeFactory ( const ModelPrs_SceneNodeFactoryParameters myParameters)

Constructor.

Creates factory with custom parameters.