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 "vtkPolyData.h"
46 #include "vtkFeatureEdges.h"
47 #include "vtkStripper.h"
48 #include "vtkTriangleFilter.h"
49 //#include "vtkGLUTesselatorTriangleFilter.h"
50 #include "vtkAppendPolyData.h"
51 #include "vtkCleanPolyData.h"
54 //EED 2017-01-01 Migration VTK7
55 #if VTK_MAJOR_VERSION <= 5
56 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $");
58 #include "vtkDataObject.h"
59 #include "vtkInformation.h"
60 #include "vtkDemandDrivenPipeline.h"
61 #include "vtkInformationVector.h"
64 vtkStandardNewMacro(vtkClosePolyData);
66 //----------------------------------------------------------------------------
67 vtkClosePolyData::vtkClosePolyData()
71 //----------------------------------------------------------------------------
72 vtkClosePolyData::~vtkClosePolyData()
77 //----------------------------------------------------------------------------
79 //EED 2017-01-01 Migration VTK7
80 #if VTK_MAJOR_VERSION <= 5
81 // This method is much too long, and has to be broken up!
82 // Furthermore we are loosing the normals !!!
83 void vtkClosePolyData::Execute()
85 vtkPolyData *input = this->GetInput();
86 vtkPolyData *output = this->GetOutput();
88 //#closing the polydata see : close.py for details
89 vtkFeatureEdges *boundary = vtkFeatureEdges::New();
90 boundary->SetInput( input );
91 boundary->BoundaryEdgesOn ();
92 boundary->FeatureEdgesOff ();
93 boundary->NonManifoldEdgesOff ();
94 boundary->ManifoldEdgesOff ();
95 //boundary->ColoringOff ();
97 vtkStripper *stripper = vtkStripper::New();
98 stripper->SetInput( boundary->GetOutput() );
99 stripper->Update(); //important
102 vtkPolyData *pd = vtkPolyData::New();
103 pd->SetPoints ( stripper->GetOutput()->GetPoints() );
104 pd->SetPolys ( stripper->GetOutput()->GetLines() );
107 //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
108 vtkTriangleFilter *triangle = vtkTriangleFilter::New();
109 triangle->SetInput( pd );
112 vtkAppendPolyData *append = vtkAppendPolyData::New();
113 append->AddInput( input );
114 append->AddInput( triangle->GetOutput());
117 vtkCleanPolyData *clean = vtkCleanPolyData::New();
118 clean->SetInput( append->GetOutput());
121 // When all optimizations are complete, this squeeze will be unecessary.
122 // (But it does not seem to cost much.)
123 clean->Update(); //important before ShallowCopy
124 output->ShallowCopy( clean->GetOutput() );
130 int vtkClosePolyData::RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector)
132 // get the info objects
133 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
134 vtkInformation *outInfo = outputVector->GetInformationObject(0);
135 // get the input and output
136 vtkPolyData *input = vtkPolyData::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT()));
137 vtkPolyData *output = vtkPolyData::SafeDownCast( outInfo->Get(vtkDataObject::DATA_OBJECT()));
138 //#closing the polydata see : close.py for details
139 vtkFeatureEdges *boundary = vtkFeatureEdges::New();
140 boundary->SetInputData( input );
141 boundary->BoundaryEdgesOn ();
142 boundary->FeatureEdgesOff ();
143 boundary->NonManifoldEdgesOff ();
144 boundary->ManifoldEdgesOff ();
145 //boundary->ColoringOff ();
146 vtkStripper *stripper = vtkStripper::New();
147 stripper->SetInputData( boundary->GetOutput() );
148 stripper->Update(); //important
150 vtkPolyData *pd = vtkPolyData::New();
151 pd->SetPoints ( stripper->GetOutput()->GetPoints() );
152 pd->SetPolys ( stripper->GetOutput()->GetLines() );
154 //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
155 vtkTriangleFilter *triangle = vtkTriangleFilter::New();
156 triangle->SetInputData( pd );
158 vtkAppendPolyData *append = vtkAppendPolyData::New();
159 append->AddInputData( input );
160 append->AddInputData( triangle->GetOutput() );
162 vtkCleanPolyData *clean = vtkCleanPolyData::New();
163 clean->SetInputData( append->GetOutput());
165 // When all optimizations are complete, this squeeze will be unecessary.
166 // (But it does not seem to cost much.)
167 clean->Update(); //important before ShallowCopy
168 output->ShallowCopy( clean->GetOutput() );
175 //----------------------------------------------------------------------------
176 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
178 this->Superclass::PrintSelf(os,indent);