[vtkusers] Help slicing 3D stl model

David Gobbi david.gobbi at gmail.com
Mon Aug 25 10:05:17 EDT 2008


Hi Arnaldo,

To raster the slices you do something completely different.  A few
years ago I added a class called vtkPolyDataToImageStencil that is in
the Hybrid directory.  For best results you should use the version of
this class that is in VTK cvs, but you can try the one in VTK 5.0 to
see if it works for your data.

The best example of how to use this class is here:

Hybrid/Testing/Tcl/TestImageStencilWithPolydata.tcl

It requires template images.  You can just create a bunch of black png
images of the desired resolution, and then with the vtkPNGReader, set
the desired DataSpacing (i.e. voxel size) and DataOrigin (i.e. the
coordinates of the corner of the image).  The PNGReader in the example
is set to load only a single image, but you can use SetDataExtent and
SetFilePattern to make it read multiple images if you want.

Then, replace the vtkSphereSource in the example with a vtkSTLReader,
and change the BackgroundValue of vtkImageStencil to 255.

Finally, replace the vtkImageViewer at the end of the example with a
vtkPNGWriter (or whatever image writer you want to use).

Hopefully this will do what you need.

    David


On Mon, Aug 25, 2008 at 9:50 AM, Arnaldo Luis Lixandrão Filho
<arnaldo.fisica at gmail.com> wrote:
> Thanks for your help, do you know any algorithm to raster the 2d slices?
>
> Arnaldo
>
> On Mon, Aug 25, 2008 at 10:39 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Arnaldo,
>>
>> I re-checked the vtkCutter documentation, and I was wrong about
>> needing multiple cutters.  You just need one vtkCutter, with the
>> vtkPlane at the position of the first slice.  Then do this:
>>
>> for (int i = 0; i < n; i++)
>>  {
>>  cutter->SetValue (i, i*sliceSpacing);
>>  }
>>
>> Or you might need to use SetValue (i, -i*sliceSpacing) depending on
>> the direction of the plane's normal.
>>
>>   David
>>
>>
>> On Mon, Aug 25, 2008 at 9:29 AM, David Gobbi <david.gobbi at gmail.com>
>> wrote:
>> > Hi Arnaldo,
>> >
>> > Use vtkCutter with vtkPlane to cut the data.  You will need a
>> > vtkCutter and a vtkPlane for each slice that you want to generate.
>> > You can use vtkAppendPolyData put the slices together into a single
>> > data set.
>> >
>> >   David
>> >
>> >
>> > On Mon, Aug 25, 2008 at 9:05 AM, Arnaldo Luis Lixandrão Filho
>> > <arnaldo.fisica at gmail.com> wrote:
>> >> I want to slice a stl model in 2D chunks.. Any help is appreciated.
>> >>
>> >> Best Regards.
>> >>
>> >> --
>> >> Arnaldo Luis Lixandrão Filho
>> >> Bacharel em Física - UNICAMP
>> >> arnaldo.fisica at gmail.com
>> >> skype/voipraider: arnaldo.fisica
>> >>
>> >> _______________________________________________
>> >> This is the private VTK discussion list.
>> >> Please keep messages on-topic. Check the FAQ at:
>> >> http://www.vtk.org/Wiki/VTK_FAQ
>> >> Follow this link to subscribe/unsubscribe:
>> >> http://www.vtk.org/mailman/listinfo/vtkusers
>> >>
>> >>
>> >
>
>
>
> --
> Arnaldo Luis Lixandrão Filho
> Bacharel em Física - UNICAMP
> arnaldo.fisica at gmail.com
> skype/voipraider: arnaldo.fisica
>



More information about the vtkusers mailing list