]> 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::RequestData(  vtkInformation *vtkNotUsed(request),  vtkInformationVector **inputVector,  vtkInformationVector *outputVector)
131 {
132
133         // get the info objects
134         vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
135         vtkInformation *outInfo = outputVector->GetInformationObject(0);
136
137         // get the input and output
138         vtkPolyData *input = vtkPolyData::SafeDownCast(    inInfo->Get(vtkDataObject::DATA_OBJECT()));
139         vtkPolyData *output = vtkPolyData::SafeDownCast(    outInfo->Get(vtkDataObject::DATA_OBJECT()));
140
141         //#closing the polydata see : close.py for details
142         vtkFeatureEdges *boundary = vtkFeatureEdges::New();
143         boundary->SetInputData( input );
144         boundary->BoundaryEdgesOn ();
145         boundary->FeatureEdgesOff ();
146         boundary->NonManifoldEdgesOff ();
147         boundary->ManifoldEdgesOff ();
148         //boundary->ColoringOff ();
149
150         vtkStripper *stripper = vtkStripper::New();
151         stripper->SetInputData( boundary->GetOutput() );
152         stripper->Update(); //important
153         boundary->Delete();
154
155         vtkPolyData *pd = vtkPolyData::New();
156         pd->SetPoints ( stripper->GetOutput()->GetPoints() );
157         pd->SetPolys  ( stripper->GetOutput()->GetLines() );
158         stripper->Delete();
159
160         //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
161         vtkTriangleFilter *triangle = vtkTriangleFilter::New();
162         triangle->SetInputData( pd );
163         pd->Delete();
164
165         vtkAppendPolyData *append = vtkAppendPolyData::New();
166         append->AddInputData( input );
167         append->AddInputData( triangle->GetOutput());
168         triangle->Delete();
169
170         vtkCleanPolyData *clean = vtkCleanPolyData::New();
171         clean->SetInputData( append->GetOutput());
172         append->Delete();
173   
174         // When all optimizations are complete, this squeeze will be unecessary.
175         // (But it does not seem to cost much.)
176         clean->Update();  //important before ShallowCopy
177         output->ShallowCopy( clean->GetOutput() );
178         clean->Delete();
179
180         return 1;
181 }
182
183 #endif
184
185 //----------------------------------------------------------------------------
186 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
187 {
188   this->Superclass::PrintSelf(os,indent);
189 }