Hide menu
Loading...
Searching...
No Matches
Configurations

Overview

Configurations allow you to maintain multiple versions of a part or an assembly in a single model. Configurations provide a convenient way to develop and manage families of ModelData_Part or ModelData_Assembly with different dimensions, components, or other parameters.

Conventions on Using Configurations

  • Configuration is a complete scene graph element. For a ModelData_Part, the configuration stores a shallow copy of representations, properties, and PMI. Changing the representation in the configuration will result in a change in the base Part. If you want to change the representation, add a new one. For a ModelData_Assembly, the configuration stores a group of scene graph element with their configurations.
  • Instances should not have own configurations. Such configuration most likely will be ignored by any algorithm (e.g. by an exporter to some target format). Instance points to the configuration of its reference. (see ModelData_Instance::ReferenceConfigurationName())

Multi-configuration model exploration

ModelData_ConfigurationManager is the key class encapsulating the information for a configuration of a ModelData_SceneGraphElement. Configurations are local to ModelData_SceneGraphElement and do not exist for the entire ModelData_Model.

The scene graph configurations can be traversed as follows:

  • with the help of direct search;
  • with the help of iterator;

The following examples demonstrate using each approach:

ModelData_Part aPart = ...;
//find configuration
ModelData_ConfigurationManager aManager = aPart.Configurations();
if (aManager) {
ModelData_SceneGraphElement aConfiguration = aManager.Configuration ("Configuration Name");
...
}
ModelData_ConfigurationManager::ConfigurationIterator anIt (aManager);
while (anIt.HasNext()) {
const ModelData_SceneGraphElement& aConfiguration = anIt.Next();
...
}

Algorithms accepting a ModelData_Model will operate on the base configuration of the root element. For all other configurations, the ModelData_Model for further use will need to be assembled manually.

...
ModelData_Assembly aRootAssembly = ...;
ModelData_ConfigurationManager aManager = aRootAssembly.Configurations();
ModelData_SceneGraphElement aConfiguration = aManager.Configuration ("New Configuration Name");
ModelData_Model aNewModel ("New Configuration Model");
aNewModel.AddRoot (aConfiguration);
ModelAlgo_BRepMesher aMesher;
aMesher.Compute (aNewModel);
...

For algorithms accepting a ModelData_SceneGraphElement you don’t need to build a copy of ModelData_Model. You can get the required configuration of the element like this:

...
ModelData_SceneGraphElement anElement = ...;
ModelData_ConfigurationManager aManager = anElement.Configurations();
ModelData_SceneGraphElement aConfiguration = aManager.Configuration ("New Configuration Name");
ModelData_Box aBox;
ModelAlgo_BoundingBox::Compute (aConfiguration, aBox);
...
static void Compute(const ModelData_Model &theSG, ModelData_Box &theBox, bool theForcedFlush=true)
Returns a bounding box of a scene graph.
Definition: ModelAlgo_BoundingBox.cxx:346

Configuration creation and usage

Method AddConfiguration() returns a shallow copy of the ModelData_SceneGraphElement base configuration. The following code demonstrates creation of a configuration:

ModelData_Part aBolt ("bolt");
ModelData_ConfigurationManager aManager (aBolt);
ModelData_SceneGraphElement aBoltConfiguration = aManager.AddConfiguration ("Configuration");

To change the representation or appearance in the configuration add a new ones. If you want to remove all old representations call the ModelData_Part::RemoveRepresentations().

...
ModelData_SceneGraphElement aBoltConfiguration = aManager.AddConfiguration ("Configuration");
ModelData_Part aPartConfiguration = static_cast <ModelData_Part&> (aBoltConfiguration);
aPartConfiguration.RemoveRepresentations();
ModelData_BRepRepresentation aNewRepresentation = ...;
aPartConfiguration.AddRepresentation (aNewRepresentation);

Once a configuration has been created, it can be used in an assembly. To do this, insert the part in the assembly with an instance, specifying the newly created configuration as the one the instance should reference.

ModelData_Assembly aRoot ("as1");
aModel.AddRoot (aRoot);
ModelData_Part aBolt ("bolt");
ModelData_ConfigurationManager aManager (aBolt);
ModelData_SceneGraphElement aBoltConfiguration = aManager.AddConfiguration ("Configuration");
...
ModelData_Instance anInstance ("bolt_1");
anInstance.SetReference (aBolt);
anInstance.SetReferenceConfigurationName ("Configuration");
aRoot.AddInstance (anInstance);
...

It is also possible to replace the active configuration of a part that is already stored in an assembly (constructed manually or loaded from a model). To do this, we first locate the target part within the product structure. Then, we call SetReferenceConfigurationName() on the instance holding said part and pass the required configuration's name to activate it.

ModelData_Model aModel = ...;
ModelData_Model::ElementIterator anIt (aModel);
while (anIt.HasNext()) {
ModelData_SceneGraphElement aRoot = anIt.Next();
if (aRoot.TypeId() == ModelData_Assembly::GetTypeId()) {
const ModelData_Assembly* aRootAssembly = static_cast <ModelData_Assembly*> (&aRoot);
ModelData_Model::ElementIterator anInstIt (*aRootAssembly);
while (anInstIt.HasNext()) {
ModelData_Instance anInstance = static_cast <ModelData_Instance&> (anIt.Next());
anInstance.SetReferenceConfigurationName ("New Configuration Name");
}
}
}
...