Hi Tangi,

If you want to color different parts of your surface with different colors, you 
can use CellScalars and a LookupTable.

1. Create your surface-composition as proposed by Jochen.
2. create a vtkUnsignedCharArray that has as many elements as the surface has 
triangles.

        vtkUnsignedCharArray* scalars = vtkUnsignedCharArray::New();
        scalars->SetNumberOfValues( surfaceComp->GetNUmberOfCells() );

3. For each triangle that belongs to one arrow set one scalar

        - For int i=0; i<size of red arrow; i++
                Scalars->SetValue( id, 0 );

        Same for other two arrows as well. Consider that the Cell-Ids change 
due to the surface-composition!

4. Create LookupTable
        
        vtkLookupTable *vtkLUT = lookupTable->GetVtkLookupTable();
        vtkLUT->SetNumberOfTableValues( 2 );
        vtkLUT->SetRange(0.0, 3.0);
        vtkLUT->SetTableValue( 0, rgb-red );
        vtkLUT->SetTableValue( 1, rgb-blue );
        vtkLUT->SetTableValue( 2, rgb-green );
        vtkLUT->Build();

        mitk::LookupTable::Pointer lookupTable = mitk::LookupTable::New();
        lookupTable->SetVtkLookupTable(vtkLUT);

        mitk::LookupTableProperty* lookupTableProperty = 
mitk::LookupTableProperty::New(lookupTable);


5. Setup node-properties

        
  node->SetProperty( "LookupTable", lookupTableProperty );
  node->SetBoolProperty("scalar visibility", true);
  node->SetFloatProperty("ScalarsRangeMaximum", 3);
  node->SetBoolProperty("color mode", true);
  node->Update();

That should do the trick. You can also set the ScalarType-Property to cellData 
but cellData should be used automatically if nothing else is defined.
I hope this could help you in your attempt.

Bests,

Markus



-----Ursprüngliche Nachricht-----
Von: [email protected] 
[mailto:[email protected]] 
Gesendet: Donnerstag, 27. Mai 2010 14:37
An: [email protected]
Betreff: mitk-users Digest, Vol 48, Issue 13

Send mitk-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/mitk-users
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of mitk-users digest..."


Today's Topics:

   1. Re: display of arbitary image in space (Efthymios Efstathiou)
   2. Re: mitk::BoundingObjectGroup visualisation? (Tangi Meyer)


----------------------------------------------------------------------

Message: 1
Date: Thu, 27 May 2010 13:10:06 +0200
From: Efthymios Efstathiou <[email protected]>
Subject: Re: [mitk-users] display of arbitary image in space
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Dear mitk-users,

I am writing you with regard to my previous email about the "display of 
an arbitary image in space".
I have found out that the ImageMapper2D cannot be used for the mapping 
of 2D images. Therefore I would ask you if there is any way of 
representing  a 2D image as a texture in mitk, in order to be used for 
the mapping of a particular plane in space; more simple: how can a 
surface be mapped with a 2D image in mitk. Since this option is 
available in vtk, it seems that it may also be available in mitk.

I am looking forward to hearing from you. Thank you in advance for any help.

Best regards,
Efthymios

Am 25.05.2010 16:43, schrieb Efthymios Efstathiou:
> Hello,
>
> the problem, that I am facing, concerns the display of an arbitary image
> in space. I already know that there is a similar topic posted in the
> mailing list archive, but it does not lead to a certain working
> solution. The idea, based also on the aforementioned topic, is to create
> a arbitary plane, with the same postition and orientation in space as
> the image, and display the image, as a texture, on top of it.
>
> /*
> QmitkFunctionality* m_View
> mitk::Image::Pointer ImagePointer
> mitk::PlaneGeometry::Pointer ImagePlanePointer
> mitk::DataTreeNode::Pointer ImageDataTreeNodePointer
> mitk::Geometry2DData::Pointer ImagePlaneDataPointer
> mitk::DataTreeNode::Pointer ImagePlaneDataTreeNodePointer
> mitk::VtkPropRenderer* m_Renderer
> mitk::ImageMapper2D::Pointer mapper2D
> mitk::Geometry2DDataVtkMapper3D::Pointer mapper3D
> */
>
> m_Renderer = m_View->m_MultiWidget->GetRenderWindow4()->GetRenderer();        
> ImageDataTreeNodePointer->SetData(ImagePointer);
> ImageDataTreeNodePointer->SetVisibility(true, m_Renderer);
> mapper2D->SetDefaultProperties(ImageDataTreeNodePointer, m_Renderer, true);
> mapper2D->GenerateAllData();
> ImageDataTreeNodePointer->SetMapper(mitk::BaseRenderer::Standard2D,
> mapper2D); //if removed, the result does not change!
> ImageDataTreeNodePointer->Update();
> m_View->GetDataStorage()->Add(ImageDataTreeNodePointer);
>
> ImagePlaneDataPointer->SetGeometry(ImagePlanePointer);
> ImagePlaneDataPointer->Update();
>
> mapper3D->SetDefaultProperties(ImageDataTreeNodePointer, m_Renderer, true);
> //mapper3D->SetDataTreeNode(ImageDataTreeNodePointer); //throws error-
> //exception
> mapper3D->SetDataStorageForTexture(m_View->GetDataStorage());
> //mapper3D->Update(m_Renderer); //throws error-exception
>
>
> ImagePlaneDataTreeNodePointer->SetData(ImagePlaneDataPointer);
> ImagePlaneDataTreeNodePointer->SetMapper(mitk::BaseRenderer::Standard3D,
> mapper3D);
> ImagePlaneDataTreeNodePointer->Update();
> m_View->GetDataStorage()->Add(ImagePlaneDataTreeNodePointer,
> ImageDataTreeNodePointer);
>
> The result of the code is the display of the plane without any texture
> (image) on it. Both objects are added sucessfully in the data storage as
> parent and child nodes and have correct/identical
> positions/orientations. Simple pointers are based on dynamically created
> objects.
>
> Minor changes have been tested with no better results. It seems, the
> mappers are initialized/used in a wrong way.
>
> I am looking forward for your answer. Thank you in advance for the help.
>
> Best regards,
> Efthymios
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> mitk-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mitk-users

-- 
Efthymios Efstathiou
Fraunhofer-Institut f?r Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-73 80
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail   [email protected]
Internet www.iis.fraunhofer.de



------------------------------

Message: 2
Date: Thu, 27 May 2010 14:20:10 +0200 (CEST)
From: Tangi Meyer <[email protected]>
Subject: Re: [mitk-users] mitk::BoundingObjectGroup visualisation?
To: Neuhaus Jochen <[email protected]>
Cc: mitk-users <[email protected]>
Message-ID:
        <30682562.11911.1274962810693.javamail.r...@bizet.spaceapplications.com>
        
Content-Type: text/plain; charset="utf-8"

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 


-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------



------------------------------

_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users


End of mitk-users Digest, Vol 48, Issue 13
******************************************

------------------------------------------------------------------------------

_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to