<div dir="ltr"><div><div><div><div><div>Hello everybody,<br><br></div>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. <br>
</div>but i have the following error :<br><br># JRE version: 7.0_21-b11<br># Java VM: Java HotSpot(TM) 64-Bit Server VM (23.21-b01 mixed mode windows-amd64 compressed oops)<br># Problematic frame:<br># C  [vtkHybrid.dll+0x5db28]  vtkImageToPolyDataFilter::ProcessImage+0x18<br>
#<br># Failed to write core dump. Minidumps are not enabled by default on client versions of Windows<br>#<br># If you would like to submit a bug report, please visit:<br>#   <a href="http://bugreport.sun.com/bugreport/crash.jsp">http://bugreport.sun.com/bugreport/crash.jsp</a><br>
# The crash happened outside the Java Virtual Machine in native code.<br># See problematic frame for where to report the bug.<br><br></div>Here is my code:<br><br>import java.lang.reflect.InvocationTargetException;<br><br>
import javax.swing.SwingUtilities;<br><br>import vtk.vtkActor;<br>import vtk.vtkImageData;<br>import vtk.vtkImageToPolyDataFilter;<br>import vtk.vtkMarchingCubes;<br>import vtk.vtkMetaImageReader;<br>import vtk.vtkPolyDataMapper;<br>
import vtk.vtkRenderWindow;<br>import vtk.vtkRenderWindowInteractor;<br>import vtk.vtkRenderer;<br>import vtk.vtkSTLWriter;<br>import vtk.vtkVoxelModeller;<br><br>public class MeshVtk implements Runnable {<br><br>    @Override<br>
    public void run() {<br><br>        String filename = &quot;ressources\\output_piston.xy.mhd&quot;;<br>        vtkVoxelModeller voxelModeller = new vtkVoxelModeller();<br>        vtkMarchingCubes marchingcubes = new vtkMarchingCubes();<br>
        vtkRenderer renderer = new vtkRenderer();<br>        vtkRenderWindow renderWindow = new vtkRenderWindow();<br>        vtkRenderWindowInteractor interactor = new vtkRenderWindowInteractor();<br>        vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>
        vtkActor actor = new vtkActor();<br>        double bounds[] = new double[] {};<br><br>        /* reader */<br>        vtkMetaImageReader reader = new vtkMetaImageReader();<br>        reader.SetFileName(filename);<br>
        reader.Update();<br><br>        vtkImageData img = new vtkImageData();<br>        img = reader.GetOutput();<br><br>        vtkImageToPolyDataFilter img2poly = new vtkImageToPolyDataFilter();<br>        img2poly.SetInput(img);<br>
        img2poly.DecimationOn();<br>        img2poly.SetError(0);<br>        img2poly.DecimationOn();<br>        img2poly.SetDecimationError(0.0);<br>        img2poly.Update();<br><br>        bounds = reader.GetOutput().GetBounds(); /* bounds */<br>
<br>        for (int i = 0; i &lt; 6; i += 2) {<br>            double range = bounds[i + 1] - bounds[i];<br>            bounds[i] = bounds[i] - .1 * range;<br>            bounds[i + 1] = bounds[i + 1] + .1 * range;<br>        }<br>
<br>        voxelModeller.SetSampleDimensions(75, 75, 75);<br>        voxelModeller.SetModelBounds(bounds);<br>        voxelModeller.SetScalarTypeToFloat();<br>        voxelModeller.SetMaximumDistance(.1);<br><br>        voxelModeller.SetInput(reader.GetOutput());<br>
<br>        /* marching cubes */<br>        marchingcubes.SetInput(voxelModeller.GetOutput());<br>        marchingcubes.ComputeNormalsOn();<br>        marchingcubes.SetValue(0, 1);<br><br>        renderer.SetBackground(.1, .2, .3);<br>
<br>        renderWindow.AddRenderer(renderer);<br><br>        interactor.SetRenderWindow(renderWindow);<br><br>        mapper.SetInput(marchingcubes.GetOutput());<br><br>        actor.SetMapper(mapper);<br><br>        renderer.AddActor(actor);<br>
        renderWindow.Render();<br>        interactor.Start();<br><br>        vtkSTLWriter writer = new vtkSTLWriter();<br>        writer.SetFileTypeToBinary();<br>        writer.AddInputConnection(marchingcubes.GetOutputPort());<br>
        writer.SetFileName(&quot;ressources\\output_piston.xy.stl&quot;);<br>        writer.Write();<br><br>    }<br><br>    public static void main(String[] args) {<br>        try {<br>            Class.forName(&quot;vtk.vtkPanel&quot;);<br>
        } catch (ClassNotFoundException e) {<br>            e.printStackTrace();<br>        }<br><br>        try {<br>            SwingUtilities.invokeAndWait(new MeshVtk());<br>        } catch (InvocationTargetException | InterruptedException e) {<br>
            e.printStackTrace();<br>        }<br>    }<br><br>}<br><br></div>I hope somebody could help me to fix this.<br><br></div>Regards,<br clear="all"><div><div><div><div><div><div><br>-- <br>Thibault Varacca<br>EFREI Promo 2014<br>
<div>06 60 53 11 35</div>
</div></div></div></div></div></div></div>