[vtkusers] Remeshing vtkPolyData with vtkMarchingCubes

Se An seb.an at icloud.com
Tue Mar 28 20:03:33 EDT 2017


Hi everyone,

I’m new with vtk and I’m trying to remesh a vtkPolyData with the vtkMarchingCubes-Algorithm.

To do this I’m using the code described here: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes <http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes>


def marchingCubes(size):

        volume = vtk.vtkImageData()

        bounds = [0.0, 0.0, 0.0 , 0.0, 0.0, 0.0]

        data.GetBounds(bounds)

        iBounds = 0
        while iBounds < 6:
            range = bounds[iBounds+1] - bounds[iBounds]
            bounds[iBounds]   = bounds[iBounds] - .0001 * range
            bounds[iBounds+1] = bounds[iBounds+1] + .0001 * range
            iBounds = iBounds + 2

        voxelModeller = vtk.vtkVoxelModeller()
        voxelModeller.SetSampleDimensions(size,size,size)   #Set cube size
        voxelModeller.SetModelBounds(bounds)
        voxelModeller.SetScalarTypeToFloat()
        voxelModeller.SetMaximumDistance(.1)

        voxelModeller.SetInputData(data)
        voxelModeller.Update()

        isoValue = 0.01 #0.001
        volume.DeepCopy(voxelModeller.GetOutput())

        surface = vtk.vtkMarchingCubes()
        if vtk.VTK_MAJOR_VERSION <= 5:
            surface.SetInput(volume)
        else:
            surface.SetInputData(volume)

        surface.ComputeScalarsOff()
        surface.SetValue(0, isoValue)

        surface.Update()

        data = surface.GetOutput()



Here my problem:
My input has just one Surface/Layer, the output has two layers as you see at the screenshot attached.
Is it possible to create an output with a remeshed polydata with just one layer?

Thanks in advance,
Sebastian


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170329/e6fd3f1d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Input.jpeg
Type: image/jpeg
Size: 174599 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170329/e6fd3f1d/attachment-0002.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Output.jpeg
Type: image/jpeg
Size: 235554 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170329/e6fd3f1d/attachment-0003.jpeg>


More information about the vtkusers mailing list