vtkClosePolyData.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkClosePolyData.cxx,v $
00005   Language:  C++
00006   Date:      $Date: 2009/05/14 13:54:34 $
00007   Version:   $Revision: 1.2 $
00008 
00009   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00010   All rights reserved.
00011   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00012 
00013      This software is distributed WITHOUT ANY WARRANTY; without even 
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00015      PURPOSE.  See the above copyright notice for more information.
00016 
00017 =========================================================================*/
00018 #include "vtkClosePolyData.h"
00019 
00020 #include "vtkObjectFactory.h"
00021 #include "vtkPolyData.h"
00022 #include "vtkFeatureEdges.h"
00023 #include "vtkStripper.h"
00024 #include "vtkTriangleFilter.h"
00025 //#include "vtkGLUTesselatorTriangleFilter.h"
00026 #include "vtkAppendPolyData.h"
00027 #include "vtkCleanPolyData.h"
00028 
00029 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.2 $");
00030 vtkStandardNewMacro(vtkClosePolyData);
00031 
00032 //----------------------------------------------------------------------------
00033 vtkClosePolyData::vtkClosePolyData()
00034 {
00035 }
00036 
00037 //----------------------------------------------------------------------------
00038 vtkClosePolyData::~vtkClosePolyData()
00039 {
00040 }
00041 
00042 //----------------------------------------------------------------------------
00043 // This method is much too long, and has to be broken up!
00044 // Furthermore we are loosing the normals !!!
00045 void vtkClosePolyData::Execute()
00046 {
00047   vtkPolyData *input = this->GetInput();
00048   vtkPolyData *output = this->GetOutput();
00049   
00050    //#closing the polydata see : close.py for details
00051   vtkFeatureEdges *boundary = vtkFeatureEdges::New();
00052   boundary->SetInput( input );
00053   boundary->BoundaryEdgesOn ();
00054   boundary->FeatureEdgesOff ();
00055   boundary->NonManifoldEdgesOff ();
00056   boundary->ManifoldEdgesOff ();
00057   //boundary->ColoringOff ();
00058 
00059   vtkStripper *stripper = vtkStripper::New();
00060   stripper->SetInput( boundary->GetOutput() );
00061   stripper->Update(); //important
00062   boundary->Delete();
00063 
00064   vtkPolyData *pd = vtkPolyData::New();
00065   pd->SetPoints ( stripper->GetOutput()->GetPoints() );
00066   pd->SetPolys  ( stripper->GetOutput()->GetLines() );
00067   stripper->Delete();
00068     
00069   //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
00070   vtkTriangleFilter *triangle = vtkTriangleFilter::New();
00071   triangle->SetInput( pd );
00072   pd->Delete();
00073     
00074   vtkAppendPolyData *append = vtkAppendPolyData::New();
00075   append->AddInput( input );
00076   append->AddInput( triangle->GetOutput());
00077   triangle->Delete();
00078       
00079   vtkCleanPolyData *clean = vtkCleanPolyData::New();
00080   clean->SetInput( append->GetOutput());
00081   append->Delete();
00082     
00083   // When all optimizations are complete, this squeeze will be unecessary.
00084   // (But it does not seem to cost much.)
00085   clean->Update();  //important before ShallowCopy
00086   output->ShallowCopy( clean->GetOutput() );
00087   clean->Delete();
00088 }
00089 
00090 //----------------------------------------------------------------------------
00091 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
00092 {
00093   this->Superclass::PrintSelf(os,indent);
00094 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1