Hi Jochen, 

Thanks it works. 

I still need advice/recommendations: 
As I said, I want to build a trihedral frame representation (like in CAD 
software): red, green and blue arrows for x,y and z axis respectively. 

So my first idea is: 

- create a red arrow (cone+cylinder) along x 
- copy the red arrow 
- change the color and orientation of the arrow to get a green arrow along y 
- copy the red arrow 
- change the color and orientation of the arrow to get a blue arrow along z 
- aggregate the 3 arrows in one datanode 
- connect the datanode to my tracking device to have my frame foolowing my tool 

However: 
- colors seems to be handled via the datanode properties, so how can I get all 
my colored arrows under the same datanode? 
- what is the recommanded way of working with basic 3D transformations? I tried 
to use the mitk::AffineTransform3D as well as directly accessing the 
vtkMatrix4x4 from mitk::Geometry3D but in practice I couldn't rotate my 
cylinders ... 
I do understand that VTK and also IGT is based on the process pipeline 
principle, so should I always stick to it? 


Thank you in advance from a scene graph guy :) 

Best regards, 

Tangi 


------------------------------------- 
Tangi MEYER 
Virtual and Augmented Reality 
System and Software Engineer 
Leuvensesteenweg 325 
B-1932 Zaventem - Belgium 
Telephone: +32 (0) 2 721 54 84 
Fax: +32 (0) 2 721 54 44 
------------------------------------- 


From: "Neuhaus Jochen" <[email protected]> 
To: "Tangi Meyer" <[email protected]>, "mitk-users" 
<[email protected]> 
Sent: Friday, 21 May, 2010 5:33:14 PM 
Subject: AW: [mitk-users] mitk::BoundingObjectGroup visualisation? 




Hi Tangi, 



As far as I remember, the BoundingObjectGroup class was only intended for the 
CSG operations using its IsInside() method, not for rendering. 



You should use vtkAppendPolyData to combine multiple Polydata objects: 



vtkConeSource* vtkDataRedCone = vtkConeSource::New(); 
[…] 
vtkDataRedCone->Update(); 



vtkConeSource* vtkDataGreenCone = vtkConeSource::New(); 
[…] 
vtkDataGreenCone->Update(); 
[…] 



vtkAppendPolyData * ap = vtkAppendPolyData :: New (); 

ap -> AddInput ( vtkDataRedCone -> GetOutput ()); 

ap -> AddInput ( vtkDataGreenCone -> GetOutput ()); 

ap -> GetOutput ()-> Update (); 

mitk :: Surface :: Pointer dummy = mitk :: Surface :: New (); 

dummy -> SetVtkPolyData ( ap -> GetOutput ()); 

mitk :: DataNode :: Pointer node = mitk :: DataNode :: New (); 

node -> SetData ( dummy ); 

myDataStorage->Add(node); 



As far as I know, there is no real CSG filter to combine multiple vtkPolyDatas, 
but just appending them works quite well for visualization tasks. 



Best Regards, 

Jochen 








Von: Tangi Meyer [mailto:[email protected]] 
Gesendet: Freitag, 21. Mai 2010 17:35 
An: mitk-users 
Betreff: [mitk-users] mitk::BoundingObjectGroup visualisation? 




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

Reply via email to