[vtkusers] ImageToPolyDataFilter

Sebastien Jourdain sebastien.jourdain at kitware.com
Mon May 6 12:01:01 EDT 2013


I don't know why ParaView seems faster in your use case.

Seb


On Mon, May 6, 2013 at 10:19 AM, Thibault Varacca <
thibault.varacca at gmail.com> wrote:

> Ok thank you !
> I have another question: when I use the "contour" filter on paraview it is
> very faster than when i code it with vtk.
> Is there a possibility to "parallelize" the execution ? Do you know some
> documentation about it?
> Thanks a lot !
>
>
> 2013/5/6 Sebastien Jourdain <sebastien.jourdain at kitware.com>
>
>> Which version of VTK and do you have the hybrid library inside your set
>> of vtk libraries ?
>>
>> Moreover, instead of calling
>>
>> try {
>>             Class.forName("vtk.vtkPanel");
>>         } catch (ClassNotFoundException e) {
>>             e.printStackTrace();
>>         }
>>
>> You should rely on that instead:
>>
>> vtkNativeLibrary.LoadAllNativeLibraries();
>>
>> Seb
>>
>>
>> On Mon, May 6, 2013 at 8:59 AM, Thibault Varacca <
>> thibault.varacca at gmail.com> wrote:
>>
>>> Hello everybody,
>>>
>>> I have .raw (binary) files which are segmented data. I load it with a
>>> .mhd file and want to convert it to polydata to finally apply the marching
>>> cubes filter.
>>> but i have the following error :
>>>
>>> # JRE version: 7.0_21-b11
>>> # Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode
>>> windows-amd64 compressed oops)
>>> # Problematic frame:
>>> # C  [vtkHybrid.dll+0x5db28]  vtkImageToPolyDataFilter::ProcessImage+0x18
>>> #
>>> # Failed to write core dump. Minidumps are not enabled by default on
>>> client versions of Windows
>>> #
>>> # If you would like to submit a bug report, please visit:
>>> #   http://bugreport.sun.com/bugreport/crash.jsp
>>> # The crash happened outside the Java Virtual Machine in native code.
>>> # See problematic frame for where to report the bug.
>>>
>>> Here is my code:
>>>
>>> import java.lang.reflect.InvocationTargetException;
>>>
>>> import javax.swing.SwingUtilities;
>>>
>>> import vtk.vtkActor;
>>> import vtk.vtkImageData;
>>> import vtk.vtkImageToPolyDataFilter;
>>> import vtk.vtkMarchingCubes;
>>> import vtk.vtkMetaImageReader;
>>> import vtk.vtkPolyDataMapper;
>>> import vtk.vtkRenderWindow;
>>> import vtk.vtkRenderWindowInteractor;
>>> import vtk.vtkRenderer;
>>> import vtk.vtkSTLWriter;
>>> import vtk.vtkVoxelModeller;
>>>
>>> public class MeshVtk implements Runnable {
>>>
>>>     @Override
>>>     public void run() {
>>>
>>>         String filename = "ressources\\output_piston.xy.mhd";
>>>         vtkVoxelModeller voxelModeller = new vtkVoxelModeller();
>>>         vtkMarchingCubes marchingcubes = new vtkMarchingCubes();
>>>         vtkRenderer renderer = new vtkRenderer();
>>>         vtkRenderWindow renderWindow = new vtkRenderWindow();
>>>         vtkRenderWindowInteractor interactor = new
>>> vtkRenderWindowInteractor();
>>>         vtkPolyDataMapper mapper = new vtkPolyDataMapper();
>>>         vtkActor actor = new vtkActor();
>>>         double bounds[] = new double[] {};
>>>
>>>         /* reader */
>>>         vtkMetaImageReader reader = new vtkMetaImageReader();
>>>         reader.SetFileName(filename);
>>>         reader.Update();
>>>
>>>         vtkImageData img = new vtkImageData();
>>>         img = reader.GetOutput();
>>>
>>>         vtkImageToPolyDataFilter img2poly = new
>>> vtkImageToPolyDataFilter();
>>>         img2poly.SetInput(img);
>>>         img2poly.DecimationOn();
>>>         img2poly.SetError(0);
>>>         img2poly.DecimationOn();
>>>         img2poly.SetDecimationError(0.0);
>>>         img2poly.Update();
>>>
>>>         bounds = reader.GetOutput().GetBounds(); /* bounds */
>>>
>>>         for (int i = 0; i < 6; i += 2) {
>>>             double range = bounds[i + 1] - bounds[i];
>>>             bounds[i] = bounds[i] - .1 * range;
>>>             bounds[i + 1] = bounds[i + 1] + .1 * range;
>>>         }
>>>
>>>         voxelModeller.SetSampleDimensions(75, 75, 75);
>>>         voxelModeller.SetModelBounds(bounds);
>>>         voxelModeller.SetScalarTypeToFloat();
>>>         voxelModeller.SetMaximumDistance(.1);
>>>
>>>         voxelModeller.SetInput(reader.GetOutput());
>>>
>>>         /* marching cubes */
>>>         marchingcubes.SetInput(voxelModeller.GetOutput());
>>>         marchingcubes.ComputeNormalsOn();
>>>         marchingcubes.SetValue(0, 1);
>>>
>>>         renderer.SetBackground(.1, .2, .3);
>>>
>>>         renderWindow.AddRenderer(renderer);
>>>
>>>         interactor.SetRenderWindow(renderWindow);
>>>
>>>         mapper.SetInput(marchingcubes.GetOutput());
>>>
>>>         actor.SetMapper(mapper);
>>>
>>>         renderer.AddActor(actor);
>>>         renderWindow.Render();
>>>         interactor.Start();
>>>
>>>         vtkSTLWriter writer = new vtkSTLWriter();
>>>         writer.SetFileTypeToBinary();
>>>         writer.AddInputConnection(marchingcubes.GetOutputPort());
>>>         writer.SetFileName("ressources\\output_piston.xy.stl");
>>>         writer.Write();
>>>
>>>     }
>>>
>>>     public static void main(String[] args) {
>>>         try {
>>>             Class.forName("vtk.vtkPanel");
>>>         } catch (ClassNotFoundException e) {
>>>             e.printStackTrace();
>>>         }
>>>
>>>         try {
>>>             SwingUtilities.invokeAndWait(new MeshVtk());
>>>         } catch (InvocationTargetException | InterruptedException e) {
>>>             e.printStackTrace();
>>>         }
>>>     }
>>>
>>> }
>>>
>>> I hope somebody could help me to fix this.
>>>
>>> Regards,
>>>
>>> --
>>> Thibault Varacca
>>> EFREI Promo 2014
>>> 06 60 53 11 35
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>
>
> --
> Thibault Varacca
> EFREI Promo 2014
> 06 60 53 11 35
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130506/397cb7a4/attachment.htm>


More information about the vtkusers mailing list