[vtkusers] Surface rendering of multiple objects
Christian Lackas
lackas at invicro.com
Tue Feb 22 04:00:38 EST 2011
* Christian Lackas <lackas at invicro.com> [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
More information about the vtkusers
mailing list