[vtkusers] VoxelModeller Exception

Thibault Varacca thibault.varacca at gmail.com
Fri May 3 05:39:54 EDT 2013


Hello,

I try to use the marching cubes algorithm on a .raw  image.
For that i use vtkVoxelModeler to specify the sample dimensions, the bounds
etc ... And i get an exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
vtk.vtkMarchingCubes.VTKInit()J
    at vtk.vtkMarchingCubes.VTKInit(Native Method)
    at vtk.vtkObject.<init>(vtkObject.java:96)
    at vtk.vtkAlgorithm.<init>(vtkAlgorithm.java:765)
    at vtk.vtkPolyDataAlgorithm.<init>(vtkPolyDataAlgorithm.java:163)
    at vtk.vtkMarchingCubes.<init>(vtkMarchingCubes.java:127)
    at fr.cea.v3d.tests.MeshVtk.<clinit>(MeshVtk.java:20)

Here is my code :

import java.lang.reflect.InvocationTargetException;

import javax.swing.SwingUtilities;

import vtk.vtkActor;
import vtk.vtkMarchingCubes;
import vtk.vtkMetaImageReader;
import vtk.vtkPolyDataMapper;
import vtk.vtkRenderWindow;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkRenderer;
import vtk.vtkVoxelModeller;

public class MeshVtk implements Runnable {

    private static String filename = "ressources\\output_piston.xy.mhd";
    private static vtkVoxelModeller voxelModeller  = new vtkVoxelModeller();
    private static vtkMarchingCubes marchingcubes = new vtkMarchingCubes();
    private static vtkRenderer renderer = new vtkRenderer();
    private static vtkRenderWindow renderWindow = new vtkRenderWindow();
    private static vtkRenderWindowInteractor interactor = new
vtkRenderWindowInteractor();
    private static vtkPolyDataMapper mapper = new vtkPolyDataMapper();
    private static vtkActor actor = new vtkActor();
    private static double bounds[];

    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();
        }
    }

    @Override
    public void run() {
        /* reader */
        vtkMetaImageReader reader = new vtkMetaImageReader();
        reader.SetFileName(filename);

        /* voxelModeller */
        reader.GetOutput().GetBounds(bounds); /* bounds */
        for (int i = 0; i < 6; i += 2)
        {
            double range = bounds[i+1] - bounds[i]; /* range
([xmin,xmax],[ymin,ymax],[zmin,zmax])*/
            bounds[i]   = bounds[i] - .1 * range;
            bounds[i+1] = bounds[i+1] + .1 * range;
        }

        voxelModeller.SetSampleDimensions(50, 50, 50);
        voxelModeller.SetModelBounds(bounds);
        voxelModeller.SetScalarTypeToFloat();
        voxelModeller.SetMaximumDistance(.1);

        voxelModeller.SetInputConnection(reader.GetOutputPort());

        /* marching cubes */

        marchingcubes.SetInputConnection(voxelModeller.GetOutputPort());
        marchingcubes.ComputeNormalsOn();
        marchingcubes.SetValue(0, 1);

        renderer.SetBackground(.1, .2, .3);

        renderWindow.AddRenderer(renderer);

        interactor.SetRenderWindow(renderWindow);

        mapper.SetInputConnection(marchingcubes.GetOutputPort());

        actor.SetMapper(mapper);

        renderer.AddActor(actor);

        renderWindow.Render();
        interactor.Start();

    }

}

I hope somebody can help me to fix this.

Thanks !


-- 
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/20130503/4c2945af/attachment.htm>


More information about the vtkusers mailing list