[vtkusers] avoiding/removing non-manifold parts from the result of vtkMarchingCubes

Dr. Roman Grothausmann grothausmann.roman at mh-hannover.de
Fri Aug 2 16:25:35 EDT 2013


On 02/08/13 22:20, Bill Lorensen wrote:
> what level do you use?

Sorry, forgot to mention that: level 127

>
>
>
> On Fri, Aug 2, 2013 at 4:07 PM, Dr. Roman Grothausmann
> <grothausmann.roman at mh-hannover.de <mailto:grothausmann.roman at mh-hannover.de>>
> wrote:
>
>     On 02/08/13 16:06, Bill Lorensen wrote:
>
>         Marching Cubes should not generate non-manifold surfaces. The offending
>         triangle
>         looks suspicious. What does the rest of your pipeline look like?
>
>
>     Thanks Bill for looking into this. I get the very same output using paraview
>     and its contour filter when ticking "Generate Triangles" or using
>     vmtkmarchingcubes (which seems to use only vtkMarchingCubes in
>     vmtkmarchingcubes.py). To check it trice I used the simple program below and
>     got the same output again. Only paraview and its contour filter without
>     ticking "Generate Triangles" yields a different result.
>
>     _____________________________
>
>     #include <vtkSmartPointer.h>
>     #include <vtkMetaImageReader.h>
>     //#include <vtkImageConstantPad.h>
>     #include <vtkMarchingCubes.h>
>     #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
>     #include <vtkCallbackCommand.h>
>     #include <vtkCommand.h>
>
>
>     void ProgressFunction ( vtkObject* caller, long unsigned int eventId, void*
>     clientData, void* callData )
>           {
>
>           vtkAlgorithm *d= static_cast<vtkAlgorithm*>(__caller);
>           fprintf(stderr, "\rFilter progress: %5.1f%%", 100.0 * d->GetProgress());
>           std::cerr.flush();
>
>           }
>
>     int main(int argc, char* argv[]){
>           if( argc != 5 )
>              {
>              std::cerr << "Usage: " << argv[0];
>              std::cerr << " inputImage";
>              std::cerr << " outputMesh";
>              std::cerr << " level normals";
>              std::cerr << std::endl;
>              return EXIT_FAILURE;
>              }
>
>           if(!(strcasestr(argv[1],".mhd"__))) {
>              std::cout << "The input should end with .mhd" << std::endl;
>              return -1;
>              }
>
>           if(!(strcasestr(argv[2],".vtp"__))) {
>              std::cout << "The input should end with .vtp" << std::endl;
>              return -1;
>              }
>
>           vtkSmartPointer<__vtkCallbackCommand> progressCallback =
>     vtkSmartPointer<__vtkCallbackCommand>::New();
>           progressCallback->SetCallback(__ProgressFunction);
>
>           vtkSmartPointer<__vtkMetaImageReader> reader =
>               vtkSmartPointer<__vtkMetaImageReader>::New();
>
>           reader->SetFileName(argv[1]);
>           reader->Update();
>
>           vtkSmartPointer<__vtkMarchingCubes> mc=
>     vtkSmartPointer<__vtkMarchingCubes>::New();
>
>           mc->SetInputConnection(reader-__>GetOutputPort());
>           mc->SetValue(0, atof(argv[3]));
>           //mc->ComputeNormalsOn();
>           mc->SetComputeNormals(atoi(__argv[4]));
>           //mc->ComputeGradientsOn();
>           //mc->ComputeScalarsOn();
>           std::cout << "Executing discrete marching cubes..." << std::endl;
>           mc->AddObserver(vtkCommand::__ProgressEvent, progressCallback);
>           mc->Update();
>           std::cout << std::endl << "done." << std::endl;
>
>           vtkSmartPointer<__vtkXMLPolyDataWriter> Pwriter =
>     vtkSmartPointer<__vtkXMLPolyDataWriter>::New();
>           Pwriter->SetFileName(argv[2]);
>           Pwriter->SetInputConnection(__mc->GetOutputPort());
>
>           Pwriter->Update();
>
>           return EXIT_SUCCESS;
>           }
>
>
>
>
>
>         On Fri, Aug 2, 2013 at 8:23 AM, Dr. Roman Grothausmann
>         <grothausmann.roman at mh-__hannover.de
>         <mailto:grothausmann.roman at mh-hannover.de>
>         <mailto:grothausmann.roman at mh-__hannover.de
>         <mailto:grothausmann.roman at mh-hannover.de>>>
>
>         wrote:
>
>              Dear mailing list members,
>
>
>              Recently, I came across a voxel-dataset that when meshed with
>              vtkMarchingCubes results in a mesh that contains non-manifold edges
>         (magenta
>              line in attached image).
>              How can this be avoided?
>              Using paraview's contour filter and switching off "Generate Triangles"
>              creates a slightly different surface mesh that does not contain
>         non-manifold
>              edges. However vtkMarchingCubes does not seem to have any option
>         concerning
>              triangulation.
>              What filter/option do I have to use to get the same result just
>         with pure VTK?
>
>              As a workaround: Is it possible to split the mesh at non-manifold
>         edges?
>              vtkIntersectionPolyDataFilter sounds promising but seems to need
>         surfaces
>              not just the edges.
>
>              Any help or hints are very much appreciated
>              Roman
>
>
>
>         --
>         Unpaid intern in BillsBasement at noware dot com
>
>
>     --
>     Dr. Roman Grothausmann
>
>     Tomographie und Digitale Bildverarbeitung
>     Tomography and Digital Image Analysis
>
>     Institut für Funktionelle und Angewandte Anatomie, OE 4120
>     Medizinische Hochschule Hannover
>     Carl-Neuberg-Str. 1
>     D-30625 Hannover
>
>     Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>
>     _________________________________________________
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/__opensource/opensource.html
>     <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 <http://www.vtk.org/Wiki/VTK_FAQ>
>
>     Follow this link to subscribe/unsubscribe:
>     http://www.vtk.org/mailman/__listinfo/vtkusers
>     <http://www.vtk.org/mailman/listinfo/vtkusers>
>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com

-- 
Dr. Roman Grothausmann

Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis

Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover

Tel. +49 511 532-9574



More information about the vtkusers mailing list