Skip to content

Commit

Permalink
Refactor EntityGroupOp in discrete to also handle volome.
Browse files Browse the repository at this point in the history
In ModelBuilder-v3, there is a vtkModelMaterial class and its operator class,
vtkMaterialOperator. Essentially this is a partitioned group, meaning entities
can only belong to one group (in V3, the group is called Domain set, which is
normally associated with material type of attributes). In this commit, we brought
back the vtkMaterialOperator, so that users can create group of volumes (3d) or group
of faces (2d), then associate (material) attribute to them. However, ideally we
should have a univeral group op across all sessions to cluster entities, and then
these groups can be used for attribute associations.
  • Loading branch information
yumin committed Apr 20, 2015
1 parent ea3f284 commit ea23ccb
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 104 deletions.
32 changes: 22 additions & 10 deletions smtk/bridge/discrete/Session.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,14 @@ smtk::model::Group Session::addMaterialToManager(
{
// Add material relations and arrangements
translated |= smtk::model::SESSION_ENTITY_ARRANGED;
if (material->GetNumberOfAssociations(vtkModelRegionType))
{ // Add regions to material
this->addEntities(result, material->NewIterator(vtkModelRegionType), AddEntityToGroupHelper(), relDepth - 1);
}
else if(material->GetNumberOfAssociations(vtkModelFaceType))
{ // Add faces to material group
this->addEntities(result, material->NewIterator(vtkModelFaceType), AddEntityToGroupHelper(), relDepth - 1);
}
}

// Add material properties:
Expand Down Expand Up @@ -1091,20 +1099,24 @@ smtk::model::Volume Session::addVolumeToManager(
smtk::model::ManagerPtr mgr,
int relDepth)
{
if (refVolume && !mgr->findEntity(uid, false))
if (refVolume)
{
smtk::model::Volume result(mgr->insertVolume(uid));
smtk::model::SessionInfoBits translated = smtk::model::SESSION_NOTHING;
if (relDepth >= 0)
smtk::model::Volume result;
// if there is a Volume already for refVolume, return it; otherwise, create one
if(mgr->findEntity(uid, false))
result = smtk::model::Volume(mgr, uid);
else
{
// Add refVolume relations and arrangements
this->addEntities(result, refVolume->NewAdjacentModelFaceIterator(), AddRawRelationHelper(), relDepth - 1);
this->addEntities(result, refVolume->NewIterator(vtkModelShellUseType), AddVolumeUseToVolumeHelper(), relDepth - 1);
result = mgr->insertVolume(uid);
if (relDepth >= 0)
{
// Add refVolume relations and arrangements
this->addEntities(result, refVolume->NewAdjacentModelFaceIterator(), AddRawRelationHelper(), relDepth - 1);
this->addEntities(result, refVolume->NewIterator(vtkModelShellUseType), AddVolumeUseToVolumeHelper(), relDepth - 1);
}
this->addProperties(result, refVolume);
}

this->addProperties(result, refVolume);
translated |= smtk::model::SESSION_PROPERTIES;

return result;
}
return smtk::model::Volume();
Expand Down
Loading

0 comments on commit ea23ccb

Please sign in to comment.