Hi Tangi,

The association is done automatically by the rendering-pipeline. The only thing 
you really have to do is set the scalar-array, as you have already done,
by calling:
                vtkPolyDataObject->GetCellData()->SetScalars( scalars );

Once you have added the DataNode containing this surface to the DataStorage and 
set the LookupTable as well as the remaining properties correctly,
the  colored surface should be visible (and colored).

In order to activate the rendering using scalars, you need to set:
                  node->SetBoolProperty("scalar visibility", true);
  node->SetBoolProperty("color mode", true);

In order to correctly use the LookupTable, you need to set:
                  node->SetProperty( "LookupTable", lookupTableProperty );
  node->SetFloatProperty("ScalarsRangeMaximum", 3);
You can set
node->SetFloatProperty("ScalarsRangeMinimum", 0);
in addition to the rest, although it is the default value.

The last two properties define the bounds of scalars that are actually 
visualized. In this case, only cells with cell-scalars between 0  and 3 will be 
colored using the LookupTable.

I just looked up the vtkAppendPolyData algorithm and saw that cellData is also 
appended if it exists in all vtkPolyDatas that are to be appended.
That makes it easier for you as you can define the CellScalars for each arrow 
before appending. You won’t have to worry about determining which arrow a 
specific Cell belongs to.

Let me know if this solves your problem.

Bests,
Markus


Von: Tangi Meyer [mailto:[email protected]]
Gesendet: Mittwoch, 2. Juni 2010 16:45
An: Engel Markus
Cc: [email protected]
Betreff: [mitk-users] Digest, Vol 48, Issue 13

Hi Markus,

If I understand correctly, the goal is to associate a value (corresponding) to 
a color to each face of the object, then define a LookUpTable difining the 
value association with a rgba color.

So the 4 first points are ok for me but the 5th "Setup node-properties" is not 
clear to me: I do not see where/how the CellScalars are associated with the 
LookUpTable.

I tried to set the CellScalar value:
    output->GetCellData()->SetScalars(scalars);
    output->Update();
but nothing is visible.

How can I "associate" my color face array with the LookUpTable?

Thank you.

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: "Engel Markus" <[email protected]>
To: "[email protected]" <[email protected]>, 
"[email protected]" <[email protected]>
Sent: Monday, 31 May, 2010 10:32:48 AM
Subject: AW: mitk-users Digest, Vol 48, Issue 13


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


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to