<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I worked it out, here my solution:</div><div class=""><br class=""></div><div class="">data is the input as vtkPolyData, for example a sphere.</div><div class=""><br class=""></div><div class="">def marchingCubes(size):</div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>whiteImage = vtk.vtkImageData()</div><div class=""> bounds = [0]*6</div><div class=""> data.GetBounds(bounds)</div><div class=""> spacing = [0]*3 # desired volume spacing</div><div class=""> spacing[0] = size</div><div class=""> spacing[1] = size</div><div class=""> spacing[2] = size</div><div class=""><br class=""></div><div class=""> whiteImage.SetSpacing(spacing)</div><div class=""><br class=""></div><div class=""> dim = [0]*3</div><div class=""> for i in range(3):</div><div class=""> dim[i] = int(math.ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i])) + 1</div><div class=""> if (dim[i] < 1):</div><div class=""> dim[i] = 1</div><div class=""> whiteImage.SetDimensions(dim)</div><div class=""> whiteImage.SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1)</div><div class=""> origin = [0]*3</div><div class=""> origin[0] = bounds[0]</div><div class=""> origin[1] = bounds[2]</div><div class=""> origin[2] = bounds[4]</div><div class=""> whiteImage.SetOrigin(origin)</div><div class=""><br class=""></div><div class=""> whiteImage.AllocateScalars(vtk.VTK_UNSIGNED_CHAR,1)</div><div class=""><br class=""></div><div class=""> inval = 255</div><div class=""> outval = 0</div><div class=""><br class=""></div><div class=""> count = whiteImage.GetNumberOfPoints()</div><div class=""> i = 0</div><div class=""> while i < count:</div><div class=""> whiteImage.GetPointData().GetScalars().SetTuple1(i, inval)</div><div class=""> i = i + 1</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> pol2stenc = vtk.vtkPolyDataToImageStencil()</div><div class=""> pol2stenc.SetInputData(data)</div><div class=""><br class=""></div><div class=""> pol2stenc.SetOutputOrigin(origin)</div><div class=""> pol2stenc.SetOutputSpacing(spacing)</div><div class=""> pol2stenc.SetOutputWholeExtent(whiteImage.GetExtent())</div><div class=""> pol2stenc.Update()</div><div class=""><br class=""></div><div class=""> imgstenc = vtk.vtkImageStencil()</div><div class=""> imgstenc.SetInputData(whiteImage)</div><div class=""> imgstenc.SetStencilConnection(pol2stenc.GetOutputPort())</div><div class=""> imgstenc.ReverseStencilOff()</div><div class=""> imgstenc.SetBackgroundValue(outval)</div><div class=""> imgstenc.Update()</div><div class=""><br class=""></div><div class=""> cf = vtk.vtkMarchingCubes()</div><div class=""> cf.SetInputData(imgstenc.GetOutput())</div><div class=""> cf.GenerateValues(1,10,10)</div><div class=""> cf.Update()</div><div class=""><br class=""></div><div class=""> reverse = vtk.vtkReverseSense()</div><div class=""> reverse.SetInputConnection(cf.GetOutputPort())</div><div class=""> reverse.ReverseCellsOn()</div><div class=""> reverse.ReverseNormalsOn()</div><div class=""><br class=""></div><div class=""> reverse.Update()</div><div class=""><br class=""></div><div class=""> data = reverse.GetOutput()</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Hope it helps anyone.</div><div class="">Cheers!</div><div class=""><br class=""></div><br class=""><div><div class="">Am 29.03.2017 um 02:03 schrieb Se An <<a href="mailto:seb.an@icloud.com" class="">seb.an@icloud.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi everyone,<div class=""><br class=""></div><div class="">I’m new with vtk and I’m trying to remesh a vtkPolyData with the vtkMarchingCubes-Algorithm.</div><div class=""><br class=""></div><div class="">To do this I’m using the code described here: <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes" class="">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Modelling/MarchingCubes</a></div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class="">def marchingCubes(size):</div><div class=""><br class=""></div><div class=""> volume = vtk.vtkImageData()</div><div class=""><br class=""></div><div class=""> bounds = [0.0, 0.0, 0.0 , 0.0, 0.0, 0.0]</div><div class=""><br class=""></div><div class=""> data.GetBounds(bounds)</div><div class=""><br class=""></div><div class=""> iBounds = 0</div><div class=""> while iBounds < 6:</div><div class=""> range = bounds[iBounds+1] - bounds[iBounds]</div><div class=""> bounds[iBounds] = bounds[iBounds] - .0001 * range</div><div class=""> bounds[iBounds+1] = bounds[iBounds+1] + .0001 * range</div><div class=""> iBounds = iBounds + 2</div><div class=""><br class=""></div><div class=""> voxelModeller = vtk.vtkVoxelModeller()</div><div class=""> voxelModeller.SetSampleDimensions(size,size,size) #Set cube size</div><div class=""> voxelModeller.SetModelBounds(bounds)</div><div class=""> voxelModeller.SetScalarTypeToFloat()</div><div class=""> voxelModeller.SetMaximumDistance(.1)</div><div class=""><br class=""></div><div class=""> voxelModeller.SetInputData(data)</div><div class=""> voxelModeller.Update()</div><div class=""><br class=""></div><div class=""> isoValue = 0.01 #0.001</div><div class=""> volume.DeepCopy(voxelModeller.GetOutput())</div><div class=""><br class=""></div><div class=""> surface = vtk.vtkMarchingCubes()</div><div class=""> if vtk.VTK_MAJOR_VERSION <= 5:</div><div class=""> surface.SetInput(volume)</div><div class=""> else:</div><div class=""> surface.SetInputData(volume)</div><div class=""><br class=""></div><div class=""> surface.ComputeScalarsOff()</div><div class=""> surface.SetValue(0, isoValue)</div><div class=""><br class=""></div><div class=""> surface.Update()</div><div class=""><br class=""></div><div class=""> data = surface.GetOutput()</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Here my problem:</div><div class="">My input has just one Surface/Layer, the output has two layers as you see at the screenshot attached.</div><div class="">Is it possible to create an output with a remeshed polydata with just one layer?</div><div class=""><br class=""></div><div class="">Thanks in advance,</div><div class="">Sebastian</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span id="cid:DCF2C3DA-2C62-4322-85A3-D93A5F1747A1@fritz.box"><Input.jpeg></span><span id="cid:A38ADC09-A487-46EE-BC38-A210E43B4635@fritz.box"><Output.jpeg></span></div></div>_______________________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" class="">http://www.vtk.org/Wiki/VTK_FAQ</a><br class=""><br class="">Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" class="">http://markmail.org/search/?q=vtkusers</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="http://public.kitware.com/mailman/listinfo/vtkusers" class="">http://public.kitware.com/mailman/listinfo/vtkusers</a><br class=""></div></div><br class=""></body></html>