[vtkusers] giving different colors to various contours drawn through one actor.

Srijan Tiwari srijantiwari1 at gmail.com
Fri Jun 8 05:47:57 EDT 2012


hey christian,

I am also facing similar problem, trying to give different colors
being drawn using one actor.

It will be really helpful if you can tell me how exactly did you solve
that problem.


expecting an early reply


Regards

Quicker(vtkusers Nick)

below is the referenced thread(sorry for the bad font )





* Christian Lackas <lackas at invicro.com
<http://www.vtk.org/mailman/listinfo/vtkusers>> [110222 10:00]:

Hi Everybody,

I finally found the solution to my problem and now everything works as
expected:

    http://www.invicro.com/vtk/vtk-multi-surface-rendering.png

Namely, I had not set a table range for the vtkLookupTable
(SetTableRange), which of course did not help when trying to have values
from 0 to 7 mapped to different colors, and additionally I have to use
(as the manual says) cell and not point data in the mapper
(SetScalarModeToUseCellData), when using vtkDiscreteMarchingCubes.

Is there any interest to put into the example Wiki?
The Medical/GenerateModelsFromLabels does not really show how to
actually visualize results of vtkDiscreteMarchingCubes. And a complete
example would have certainly helped me.

Christian

-- http://www.invicro.com/

>* * Christian Lackas <lackas at invicro.com <http://www.vtk.org/mailman/listinfo/vtkusers>> [110218 20:44]:*>* *>* Hi Everybody,*>* *>* maybe my problem is easier to understand if I show actual code.*>* So here are the cxx/CMakeList file:*>* *>*     http://www.invicro.com/vtk/ROIRendering.zip*>* *>* and an mha file with (unsigned char) values from 0 to 7 for various*>* ROIs:*>* *>*     http://www.invicro.com/vtk/roi.zip*>* *>* and I would like to produce a rendered output such as:*>* *>*     http://www.spect-ct.com/site/site.cgi/dispentry.site?id=135*>* *>* where each ROI is surface rendered in a different color (see below*>* posting for more details).*>* *>* What I do is, load the mha file via vtkMetaImageReader, then use*>* vtkDiscreteMarchingCubes to get the contours:*>* *>*     vtkSmartPointer<vtkDiscreteMarchingCubes> surface = *>*         vtkSmartPointer<vtkDiscreteMarchingCubes>::New();*>*     const int numContours = 7;*>*     surface->SetNumberOfContours(numContours);*>*     surface->GenerateValues(7, 1.0, 7.0);*>*     surface->SetInputConnection(reader->GetOutputPort());*>* *>* Is this the correct way to produce 7 surfaces, one for each discrete*>* value from 1 to 7?*>* *>* After setting up renderer, rendererWindow and rendererWindowInteractor,*>* as well as a vtkLookupTable, I subsequently use a vtkPolyDataMapper to*>* produce graphic primitives:*>* *>*     vtkSmartPointer<vtkPolyDataMapper> mapper =*>*         vtkSmartPointer<vtkPolyDataMapper>::New();*>*     mapper->SetInputConnection( surface->GetOutputPort() );*>*     mapper->SetLookupTable(lut);*>*     mapper->SetScalarModeToUsePointData();*>* *>* However, the lookup table lut, is ignored and I always get a gray*>* rendering for all ROIs.*>* *>* So far, I have only manged to set one color (again for all ROIs), via an*>* actor:*>* *>*     vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();*>*     actor->GetProperty()->SetColor(1,1,1);*>*     actor->SetMapper(mapper);*>* *>* Does this mean I have to produce one actor per ROI I want to show in a*>* different color? How would I do that?*>* *>* The documentation of vtkDiscreteMarchingCubes mentions the use of*>* vtkTreshold, however, this produces an unstructured grid and thus I*>* cannot use the vtkPolyDataMapper anymore.*>* *>* Please let me know if there is any other information I could provide to*>* make my problem easier to understand.*>* *>* Thanks,*>*  Christian*>* *>* -- *>* http://www.invicro.com*>* *>* *>* > Hi Everybody,*>* > *>* > I have a 3D volumetric dataset with distinct values from say 0 to 7*>* > (unsigned chars) that represent voxels of different ROIs. I would like*>* > to produce a surface rendering of these regions in user-selectable*>* > colors, similar to this image here:*>* > *>* >     http://www.spect-ct.com/site/site.cgi/dispentry.site?id=135*>* > *>* > >From what I have read so far, vtkDiscreteMarchingCubes should be a good*>* > starting point to convert the 3D volume into point data. I have also*>* > read the GenerateModelsFromLabels.cxx, which seems to perform exactly*>* > the segmentation I need. However, I don't understand how I can then show*>* > the results on screen, and where to associate ROI values (aka labels)*>* > with different colors.*>* > *>* > So far, I have only succeeded in showing a surface rendering of all ROIs*>* > (i.e. non 0 voxels) together.*>* > *>* > Any further pointers are appreciated...*>* > *>* > Thanks,*>* >  Christian*>* > *>* > -- *>* > http://www.invicro.com*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120608/0f527b3f/attachment.htm>


More information about the vtkusers mailing list