]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx
#3109 creaMaracasVisu Bug New Normal - branch vtk7itk4 compilation with vtk7
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkClosePolyData.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28   Program:   Visualization Toolkit
29   Module:    $RCSfile: vtkClosePolyData.cxx,v $
30   Language:  C++
31   Date:      $Date: 2012/11/15 14:14:35 $
32   Version:   $Revision: 1.3 $
33
34   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
35   All rights reserved.
36   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
37
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.
41
42 =========================================================================*/
43 #include "vtkClosePolyData.h"
44
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"
52
53
54 //EED 2017-01-01 Migration VTK7
55 #if VTK_MAJOR_VERSION <= 5
56   vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $");
57 #else
58   #include "vtkDataObject.h"
59   #include "vtkInformation.h"
60   #include "vtkDemandDrivenPipeline.h"
61   #include "vtkInformationVector.h"
62 #endif
63
64 vtkStandardNewMacro(vtkClosePolyData);
65
66 //----------------------------------------------------------------------------
67 vtkClosePolyData::vtkClosePolyData()
68 {
69 }
70
71 //----------------------------------------------------------------------------
72 vtkClosePolyData::~vtkClosePolyData()
73 {
74 }
75
76
77 //----------------------------------------------------------------------------
78
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()
84         {
85           vtkPolyData *input = this->GetInput();
86           vtkPolyData *output = this->GetOutput();
87           
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 ();
96
97           vtkStripper *stripper = vtkStripper::New();
98           stripper->SetInput( boundary->GetOutput() );
99           stripper->Update(); //important
100           boundary->Delete();
101
102           vtkPolyData *pd = vtkPolyData::New();
103           pd->SetPoints ( stripper->GetOutput()->GetPoints() );
104           pd->SetPolys  ( stripper->GetOutput()->GetLines() );
105           stripper->Delete();
106             
107           //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
108           vtkTriangleFilter *triangle = vtkTriangleFilter::New();
109           triangle->SetInput( pd );
110           pd->Delete();
111             
112           vtkAppendPolyData *append = vtkAppendPolyData::New();
113           append->AddInput( input );
114           append->AddInput( triangle->GetOutput());
115           triangle->Delete();
116               vtkInformation
117           vtkCleanPolyData *clean = vtkCleanPolyData::New();
118           clean->SetInput( append->GetOutput());
119           append->Delete();
120             
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() );
125           clean->Delete();
126         }
127
128 #else
129 /*
130         int vtkClosePolyData::ProcessRequest(   vtkInformation *request, 
131                                                                                         vtkInformationVector **inputVector, 
132                                                                                         vtkInformationVector *outputVector)
133         {
134 printf("EED Warning ERROR ! vtkClosePolyData::ProcessRequest  not implemented  VTK7 migration");
135                 // generate the data
136                 if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
137                 {
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);
141                         return 1;
142                 }
143                 return this->Superclass::ProcessRequest(request,inputVector,outputVector);
144         }
145 */
146
147 int vtkClosePolyData::RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector)
148 {
149
150         // get the info objects
151         vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
152         vtkInformation *outInfo = outputVector->GetInformationObject(0);
153
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()));
157
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 ();
166
167         vtkStripper *stripper = vtkStripper::New();
168         stripper->SetInputData( boundary->GetOutput() );
169         stripper->Update(); //important
170         boundary->Delete();
171
172         vtkPolyData *pd = vtkPolyData::New();
173         pd->SetPoints ( stripper->GetOutput()->GetPoints() );
174         pd->SetPolys  ( stripper->GetOutput()->GetLines() );
175         stripper->Delete();
176
177         //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
178         vtkTriangleFilter *triangle = vtkTriangleFilter::New();
179         triangle->SetInputData( pd );
180         pd->Delete();
181
182         vtkAppendPolyData *append = vtkAppendPolyData::New();
183         append->AddInputData( input );
184         append->AddInputData( triangle->GetOutput());
185         triangle->Delete();
186
187         vtkCleanPolyData *clean = vtkCleanPolyData::New();
188         clean->SetInputData( append->GetOutput());
189         append->Delete();
190   
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() );
195         clean->Delete();
196
197         return 1;
198 }
199
200
201
202
203 #endif
204
205 //----------------------------------------------------------------------------
206 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
207 {
208   this->Superclass::PrintSelf(os,indent);
209 }