Dear All,
I have a question regarding BoundingObjectGroup. I want to draw a trihedral,
juste like Gizmo in CAD software. So I decided to assemble it using cones and
cylinders. The BoundingObjectGroup class seems to be what I need but I can't
see anything. So, for testing, I used the IGTToolPair navigation example and
just replaced the CreateConeAsInstrumentVisualization function by the following
code:
mitk::BoundingObjectGroup::Pointer GizmoRepData =
mitk::BoundingObjectGroup::New();
mitk::Cone::Pointer xRedCone = mitk::Cone::New();
vtkConeSource* vtkDataRedCone = vtkConeSource::New();
vtkDataRedCone->SetRadius(3.0);
vtkDataRedCone->SetHeight(6.0);
vtkDataRedCone->SetDirection(1.0, 0.0, 0.0); //(0.0, 0.0, -1.0) for 5DoF
vtkDataRedCone->SetCenter(18.0, 0.0, 0.0);
vtkDataRedCone->SetResolution(20);
vtkDataRedCone->CappingOn();
vtkDataRedCone->Update();
xRedCone->SetVtkPolyData(vtkDataRedCone->GetOutput());
vtkDataRedCone->Delete();
mitk::Cone::Pointer yGreenCone = mitk::Cone::New();
vtkConeSource* vtkDataGreenCone = vtkConeSource::New();
vtkDataGreenCone->SetRadius(3.0);
vtkDataGreenCone->SetHeight(6.0);
vtkDataGreenCone->SetDirection(0.0, 1.0, 0.0); //(0.0, 0.0, -1.0) for 5DoF
vtkDataGreenCone->SetCenter(0.0, 18.0, 0.0);
vtkDataGreenCone->SetResolution(20);
vtkDataGreenCone->CappingOn();
vtkDataGreenCone->Update();
yGreenCone->SetVtkPolyData(vtkDataGreenCone->GetOutput());
vtkDataGreenCone->Delete();
mitk::Cone::Pointer zBlueCone = mitk::Cone::New();
vtkConeSource* vtkDataBlueCone = vtkConeSource::New();
vtkDataBlueCone->SetRadius(3.0);
vtkDataBlueCone->SetHeight(6.0);
vtkDataBlueCone->SetDirection(0.0, 0.0, 1.0); //(0.0, 0.0, -1.0) for 5DoF
vtkDataBlueCone->SetCenter(0.0, 0.0, 18.0);
vtkDataBlueCone->SetResolution(20);
vtkDataBlueCone->CappingOn();
vtkDataBlueCone->Update();
zBlueCone->SetVtkPolyData(vtkDataBlueCone->GetOutput());
vtkDataBlueCone->Delete();
mitk::Cylinder::Pointer xRedCylinder = mitk::Cylinder::New();
vtkCylinderSource* vtkDataRedCylinder = vtkCylinderSource::New();
vtkDataRedCylinder->SetRadius(2.0);
vtkDataRedCylinder->SetHeight(18.0);
vtkDataRedCylinder->SetCenter(0.0, 0.0, 0.0);
vtkDataRedCylinder->SetResolution(20);
vtkDataRedCylinder->CappingOn();
vtkDataRedCylinder->Update();
xRedCylinder->SetVtkPolyData(vtkDataRedCylinder->GetOutput());
vtkDataRedCylinder->Delete();
GizmoRepData->SetCSGMode(mitk::BoundingObjectGroup::CSGMode::Union);
GizmoRepData->AddBoundingObject((mitk::BoundingObject::Pointer)xRedCone);
GizmoRepData->AddBoundingObject((mitk::BoundingObject::Pointer)yGreenCone);
GizmoRepData->AddBoundingObject((mitk::BoundingObject::Pointer)zBlueCone);
GizmoRepData->AddBoundingObject((mitk::BoundingObject::Pointer)xRedCylinder);
GizmoRepData->Expand();
GizmoRepData->Update();
GizmoRepData->Modified();
// Associated node pointer
mitk::DataNode::Pointer associatedNode = mitk::DataNode::New();
associatedNode->SetData(GizmoRepData);
associatedNode->GetPropertyList()->SetProperty("name",
mitk::StringProperty::New ( label ) );
associatedNode->GetPropertyList()->SetProperty("layer",
mitk::IntProperty::New(0));
associatedNode->GetPropertyList()->SetProperty("visible",mitk::BoolProperty::New(true));
//don't display in widget 3 (3D camera view)
associatedNode->SetVisibility(false,
mitk::BaseRenderer::GetInstance(m_MultiWidget->mitkWidget3->GetRenderWindow()));
associatedNode->SetColor(1.0,0.0,0.0);//red
associatedNode->SetOpacity(0.7);
associatedNode->Modified();
return associatedNode;
Without my modification, I can see and manipulate the red cone and the green
sphere using our NDI system but with the above code, only the sphere is
displayed ...
I tried to modify the CSGMode and tried to force the update of the
BoundingObjectGroup with different call but nothing worked.
Do you know what I should use for drawing my object?
Best regards,
Tangi
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users