1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkClosePolyData.cxx,v $
6 Date: $Date: 2009/05/14 13:54:34 $
7 Version: $Revision: 1.2 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 #include "vtkClosePolyData.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkPolyData.h"
22 #include "vtkFeatureEdges.h"
23 #include "vtkStripper.h"
24 #include "vtkTriangleFilter.h"
25 //#include "vtkGLUTesselatorTriangleFilter.h"
26 #include "vtkAppendPolyData.h"
27 #include "vtkCleanPolyData.h"
29 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.2 $");
30 vtkStandardNewMacro(vtkClosePolyData);
32 //----------------------------------------------------------------------------
33 vtkClosePolyData::vtkClosePolyData()
37 //----------------------------------------------------------------------------
38 vtkClosePolyData::~vtkClosePolyData()
42 //----------------------------------------------------------------------------
43 // This method is much too long, and has to be broken up!
44 // Furthermore we are loosing the normals !!!
45 void vtkClosePolyData::Execute()
47 vtkPolyData *input = this->GetInput();
48 vtkPolyData *output = this->GetOutput();
50 //#closing the polydata see : close.py for details
51 vtkFeatureEdges *boundary = vtkFeatureEdges::New();
52 boundary->SetInput( input );
53 boundary->BoundaryEdgesOn ();
54 boundary->FeatureEdgesOff ();
55 boundary->NonManifoldEdgesOff ();
56 boundary->ManifoldEdgesOff ();
57 //boundary->ColoringOff ();
59 vtkStripper *stripper = vtkStripper::New();
60 stripper->SetInput( boundary->GetOutput() );
61 stripper->Update(); //important
64 vtkPolyData *pd = vtkPolyData::New();
65 pd->SetPoints ( stripper->GetOutput()->GetPoints() );
66 pd->SetPolys ( stripper->GetOutput()->GetLines() );
69 //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
70 vtkTriangleFilter *triangle = vtkTriangleFilter::New();
71 triangle->SetInput( pd );
74 vtkAppendPolyData *append = vtkAppendPolyData::New();
75 append->AddInput( input );
76 append->AddInput( triangle->GetOutput());
79 vtkCleanPolyData *clean = vtkCleanPolyData::New();
80 clean->SetInput( append->GetOutput());
83 // When all optimizations are complete, this squeeze will be unecessary.
84 // (But it does not seem to cost much.)
85 clean->Update(); //important before ShallowCopy
86 output->ShallowCopy( clean->GetOutput() );
90 //----------------------------------------------------------------------------
91 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
93 this->Superclass::PrintSelf(os,indent);