[vtkusers] How to write a collection of vtkSphereSource on a .vtk file?

David Doria daviddoria at gmail.com
Fri Jul 15 07:41:02 EDT 2011


On Fri, Jul 15, 2011 at 4:42 AM, Massimiliano Folco <
massimiliano.folco at gmail.com> wrote:

> Hi to all,
>
> I am an Italian student of Bioengineering and I have to complete a project
> for the last exam before my Master Degree.
>
> I'm working in C++ to render a certain number of electrodes, each one
> composed by a certain number of contacts, in the right position into a
> volume rendered after having read it from a .nifti file, deriving from a MRI
> of the head of a patient suffering from epilepsy.
>
> I have created two different classes, one for electrodes and and one for
> contacts...
> every electrode is represented by an instance of the corresponding class
> and has, as class member,  one vector<contact>  (C++ object) containing
> instances of contact class, corresponding to the contacts forming the real
> electrode. Every contact contains a vtkSphereSource, used for rendering
> every contact like a sphere with desired radius and color, in the right
> position.
>
> I have obtained the result expected by adding to the same renderer a
> vtkVolume representing the MRI and one vtkActor for every contact, after
> having modified the center of the vtkSphereSource to adapt it to the
> internal coordinates of the vtkVolume (contact_pos_mri = mri_origin +
> contact_pos*mri_spacing) : in this way, I have obtained the right position
> for the contacts system into the MRI.
>
> Now,I would write a .vtk file for every electrode, or better, for the
> collection of vtkSphereSource that is contained into the electrode instance,
> so that these files can be opened by another visualization program,like
> 3Dslicer, and used for other elaboration and analysis.
>
> Could anyone of you tell me how to do this?
> I read documentation about vtkWriter, vtkImageWriter adn vtkPolydatawriter,
> but I don't think that these could be useful for my purposes, or better, i
> don't understand how to use them to reach my goal.
>
> Thanks
>
> Massimiliano
>

To write all of the spheres to one file, you'll want to use:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filters/CombinePolydata

followed by:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/WriteVTP

I don't know anything about Slicer, but you can view them in Paraview.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110715/5c35d271/attachment.htm>


More information about the vtkusers mailing list