[vtkusers] Extract a poligon of Image???

Marcelo Costa Oliveira marcelo at cci.fmrp.usp.br
Mon Jun 4 07:43:08 EDT 2001


Hi users,
I'm new with VTK and i need this for my work.
How can I extract  an image of a poligon with the values of the pixels
within it??

Can VTK  do this ???

Thanks for your  for your help.
I am trying to do this but it doesn't work.

int main ()

{

  int a;

  /*
 vtkSphereSource *sphere = vtkSphereSource :: New();

    sphere -> SetRadius (1);
    sphere -> SetPhiResolution (100);
    sphere -> SetThetaResolution (100);

  */
//****************************************************************************

//****                            LENDO UM ARQUIVO TIFF
//****************************************************************************


 vtkTIFFReader *reader =  vtkTIFFReader :: New();

    reader -> SetFileName("/home/marcelo/vtk.tif");

//****************************************************************************

//****                            CRIANDO OS PONTOS
//****************************************************************************


 vtkPoints *selectionPoints = vtkPoints :: New();

    selectionPoints -> InsertPoint (0, 0.5, 0.5, 0.0);
    selectionPoints -> InsertPoint (1, 0.5, 0.8, 0.0);
    selectionPoints -> InsertPoint (2, 0.8, 0.5, 0.0);
    selectionPoints -> InsertPoint (3, 0.8, 0.8, 0.0);

    /*
 vtkImplicitSelectionLoop *loop = vtkImplicitSelectionLoop :: New();

    loop -> SetLoop (selectionPoints);
    * /


 vtkCellArray *strips = vtkCellArray :: New();

   strips -> InsertNextCell (4);

   strips -> InsertCellPoint (0);

   strips -> InsertCellPoint (1);

   strips -> InsertCellPoint (2);

   strips -> InsertCellPoint (3);


 vtkPolyData *profile = vtkPolyData :: New();

    profile -> SetPoints ( selectionPoints );

    profile -> SetStrips (strips);



 vtkImplicitDataSet *implicitData = vtkImplicitDataSet :: New();

    implicitData -> SetDataSet (profile);



//***********************************************************************************

//****                          EXTRAINDO A GEOMETRIA
//***********************************************************************************


 vtkExtractGeometry *extract = vtkExtractGeometry:: New();

    extract -> SetInput (implicitData  -> GetOutput());
    extract -> SetImplicitFunction (loop);


 vtkConnectivityFilter *connect = vtkConnectivityFilter :: New();

    connect -> SetInput (extract -> GetOutput());
    connect -> SetExtractionModeToClosestPointRegion();
    connect -> SetClosestPoint (selectionPoints -> GetPoint (0));

//****************************************************************************

//****                         MAPEANDO P/ RENDERING
//****************************************************************************




 vtkDataSetMapper *clipMapper = vtkDataSetMapper :: New();

      clipMapper -> SetInput (connect -> GetOutput());


 vtkActor *clipActor = vtkActor :: New();

    clipActor -> SetMapper (clipMapper);


//*****************************************************************************

//****                              RENDERIZANDO
//****************************************************************************



 vtkRenderer *ren1 = vtkRenderer :: New();

 vtkRenderWindow *renWin = vtkRenderWindow :: New();

    renWin -> AddRenderer (ren1);

 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor :: New();

    iren -> SetRenderWindow (renWin);



ren1 -> AddActor (clipActor);
renWin -> SetSize (800,800);
iren -> Start();
renWin -> Render();

cin >>a;

 iren -> Delete();
 renWin -> Delete();
 ren1 -> Delete();
 clipActor -> Delete();
 clipMapper -> Delete();
 connect -> Delete();
 extract -> Delete();
 loop -> Delete();
 selectionPoints -> Delete();
 reader -> Delete();
 quant -> Delete();
strips -> Delete();
profile -> Delete();
implicitData -> Delete();


}






More information about the vtkusers mailing list