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::ProcessRequest( vtkInformation *request,
131 vtkInformationVector **inputVector,
132 vtkInformationVector *outputVector)
134 printf("EED Warning ERROR ! vtkClosePolyData::ProcessRequest not implemented VTK7 migration");
136 if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
138 // specify that the output (only one for this filter) will be double
139 vtkInformation* outInfo = outputVector->GetInformationObject(0);
140 outInfo->Set(vtkDataObject::SCALAR_TYPE(),VTK_DOUBLE);
143 return this->Superclass::ProcessRequest(request,inputVector,outputVector);
147 int vtkClosePolyData::RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector)
150 // get the info objects
151 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
152 vtkInformation *outInfo = outputVector->GetInformationObject(0);
154 // get the input and output
155 vtkPolyData *input = vtkPolyData::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT()));
156 vtkPolyData *output = vtkPolyData::SafeDownCast( outInfo->Get(vtkDataObject::DATA_OBJECT()));
158 //#closing the polydata see : close.py for details
159 vtkFeatureEdges *boundary = vtkFeatureEdges::New();
160 boundary->SetInputData( input );
161 boundary->BoundaryEdgesOn ();
162 boundary->FeatureEdgesOff ();
163 boundary->NonManifoldEdgesOff ();
164 boundary->ManifoldEdgesOff ();
165 //boundary->ColoringOff ();
167 vtkStripper *stripper = vtkStripper::New();
168 stripper->SetInputData( boundary->GetOutput() );
169 stripper->Update(); //important
172 vtkPolyData *pd = vtkPolyData::New();
173 pd->SetPoints ( stripper->GetOutput()->GetPoints() );
174 pd->SetPolys ( stripper->GetOutput()->GetLines() );
177 //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
178 vtkTriangleFilter *triangle = vtkTriangleFilter::New();
179 triangle->SetInputData( pd );
182 vtkAppendPolyData *append = vtkAppendPolyData::New();
183 append->AddInputData( input );
184 append->AddInputData( triangle->GetOutput());
187 vtkCleanPolyData *clean = vtkCleanPolyData::New();
188 clean->SetInputData( append->GetOutput());
191 // When all optimizations are complete, this squeeze will be unecessary.
192 // (But it does not seem to cost much.)
193 clean->Update(); //important before ShallowCopy
194 output->ShallowCopy( clean->GetOutput() );
202 //----------------------------------------------------------------------------
203 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
205 this->Superclass::PrintSelf(os,indent);