[vtkusers] Very simple help required for using abstract class vtkUnstructuredGridToPolyDataFilter

Jonathan.Bailleul Jonathan.Bailleul at greyc.ismra.fr
Thu Aug 7 09:27:46 EDT 2003


Dear all,

I would like to build a polydata file out of the result of a Delaunay3d
filter. It produces an unstructured grid that I might transform into
polydata in using the vtkUnstructuredGridToPolyDataFilter filter. But it
appears to be an abstract class and that the instanciation of the object
I'm attempting to perform is impossible.

What do you suggest me to complete the task? (yes, I'm not very familiar
with C++ object system...)


In advance, thank you for your comments.




#include "vtkPolyData.h"
#include "vtkPolyDataReader.h"
#include "vtkPolyDataWriter.h"
#include "vtkPolyDataNormals.h"
#include "vtkCleanPolyData.h"

#include <vtkDelaunay3D.h> 
#include <vtkUnstructuredGridToPolyDataFilter.h> 
#include <vtkContourGrid.h> 

#include <assert.h>
#include <stdlib.h>



//GLOS (Graphic Library in Open Source), an ANSI Common Lisp OpenGL
subset.
//Copyright (C) 2000 the GLOS development team
(http://glos.sourceforge.net)



static void
usage(int argc, char **argv) 
{
  if ((argc - 1) != 2)
    {
      printf("Infer from given vtk mesh points a new triangulation from
3D Delaunay (VTK)\n");
      printf("Licensed under GPL / Copyright (C) 2000 the GLOS
development team (http://glos.sourceforge.net) \n");
      
      printf("Usage: %s  <input vtk file> <output vtk file> \n",
argv[0]);

      printf("\n");
      exit(1);
    }  
}



int 
main(int argc, char* argv[])
{
  usage(argc, argv);


  vtkPolyDataReader *reader = vtkPolyDataReader::New();
  reader -> SetFileName(argv[1]);
  reader -> Update();
 

  vtkDelaunay3D* delaunay = vtkDelaunay3D::New(); 
  delaunay -> SetInput(reader -> GetOutput());    
  delaunay -> SetTolerance(0.03);
  delaunay -> SetAlpha(0.2);
  delaunay -> BoundingTriangulationOff();
  delaunay -> Update();
  

  //  vtkUnstructuredGridToPolyDataFilter *topoly =
vtkUnstructuredGridToPolyDataFilter::New();
  topoly -> SetInput(delaunay -> GetOutput());
  topoly -> Update();
  
  
  vtkPolyDataWriter *writer = vtkPolyDataWriter::New();
  writer -> SetInput(topoly -> GetOutput());
  writer -> SetFileName(argv[2]);
  writer -> SetFileTypeToASCII();
  writer -> Update();


  return EXIT_SUCCESS;
}


-- 
-----------------------------------
Jonathan BAILLEUL, Doctorant
GREYC Image - Université de Caen 
http://www.greyc.ismra.fr/~bailleul



More information about the vtkusers mailing list