1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 /*=========================================================================
28 Program: Visualization Toolkit
29 Module: $RCSfile: vtkClosePolyData.cxx,v $
31 Date: $Date: 2012/11/15 14:14:35 $
32 Version: $Revision: 1.3 $
34 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
36 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
38 This software is distributed WITHOUT ANY WARRANTY; without even
39 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
40 PURPOSE. See the above copyright notice for more information.
42 =========================================================================*/
43 #include "vtkClosePolyData.h"
45 #include "vtkObjectFactory.h"
46 #include "vtkPolyData.h"
47 #include "vtkFeatureEdges.h"
48 #include "vtkStripper.h"
49 #include "vtkTriangleFilter.h"
50 //#include "vtkGLUTesselatorTriangleFilter.h"
51 #include "vtkAppendPolyData.h"
52 #include "vtkCleanPolyData.h"
54 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $");
55 vtkStandardNewMacro(vtkClosePolyData);
57 //----------------------------------------------------------------------------
58 vtkClosePolyData::vtkClosePolyData()
62 //----------------------------------------------------------------------------
63 vtkClosePolyData::~vtkClosePolyData()
67 //----------------------------------------------------------------------------
68 // This method is much too long, and has to be broken up!
69 // Furthermore we are loosing the normals !!!
70 void vtkClosePolyData::Execute()
72 vtkPolyData *input = this->GetInput();
73 vtkPolyData *output = this->GetOutput();
75 //#closing the polydata see : close.py for details
76 vtkFeatureEdges *boundary = vtkFeatureEdges::New();
77 boundary->SetInput( input );
78 boundary->BoundaryEdgesOn ();
79 boundary->FeatureEdgesOff ();
80 boundary->NonManifoldEdgesOff ();
81 boundary->ManifoldEdgesOff ();
82 //boundary->ColoringOff ();
84 vtkStripper *stripper = vtkStripper::New();
85 stripper->SetInput( boundary->GetOutput() );
86 stripper->Update(); //important
89 vtkPolyData *pd = vtkPolyData::New();
90 pd->SetPoints ( stripper->GetOutput()->GetPoints() );
91 pd->SetPolys ( stripper->GetOutput()->GetLines() );
94 //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
95 vtkTriangleFilter *triangle = vtkTriangleFilter::New();
96 triangle->SetInput( pd );
99 vtkAppendPolyData *append = vtkAppendPolyData::New();
100 append->AddInput( input );
101 append->AddInput( triangle->GetOutput());
104 vtkCleanPolyData *clean = vtkCleanPolyData::New();
105 clean->SetInput( append->GetOutput());
108 // When all optimizations are complete, this squeeze will be unecessary.
109 // (But it does not seem to cost much.)
110 clean->Update(); //important before ShallowCopy
111 output->ShallowCopy( clean->GetOutput() );
115 //----------------------------------------------------------------------------
116 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
118 this->Superclass::PrintSelf(os,indent);