]> 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 "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"
53
54
55 //EED 2017-01-01 Migration VTK7
56 #if VTK_MAJOR_VERSION <= 5
57 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $");
58 #else
59   //...
60 #endif
61
62 vtkStandardNewMacro(vtkClosePolyData);
63
64 //----------------------------------------------------------------------------
65 vtkClosePolyData::vtkClosePolyData()
66 {
67 }
68
69 //----------------------------------------------------------------------------
70 vtkClosePolyData::~vtkClosePolyData()
71 {
72 }
73
74
75 //----------------------------------------------------------------------------
76
77 //EED 2017-01-01 Migration VTK7
78 #if VTK_MAJOR_VERSION <= 5
79         // This method is much too long, and has to be broken up!
80         // Furthermore we are loosing the normals !!!
81         void vtkClosePolyData::Execute()
82         {
83           vtkPolyData *input = this->GetInput();
84           vtkPolyData *output = this->GetOutput();
85           
86            //#closing the polydata see : close.py for details
87           vtkFeatureEdges *boundary = vtkFeatureEdges::New();
88           boundary->SetInput( input );
89           boundary->BoundaryEdgesOn ();
90           boundary->FeatureEdgesOff ();
91           boundary->NonManifoldEdgesOff ();
92           boundary->ManifoldEdgesOff ();
93           //boundary->ColoringOff ();
94
95           vtkStripper *stripper = vtkStripper::New();
96           stripper->SetInput( boundary->GetOutput() );
97           stripper->Update(); //important
98           boundary->Delete();
99
100           vtkPolyData *pd = vtkPolyData::New();
101           pd->SetPoints ( stripper->GetOutput()->GetPoints() );
102           pd->SetPolys  ( stripper->GetOutput()->GetLines() );
103           stripper->Delete();
104             
105           //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
106           vtkTriangleFilter *triangle = vtkTriangleFilter::New();
107           triangle->SetInput( pd );
108           pd->Delete();
109             
110           vtkAppendPolyData *append = vtkAppendPolyData::New();
111           append->AddInput( input );
112           append->AddInput( triangle->GetOutput());
113           triangle->Delete();
114               
115           vtkCleanPolyData *clean = vtkCleanPolyData::New();
116           clean->SetInput( append->GetOutput());
117           append->Delete();
118             
119           // When all optimizations are complete, this squeeze will be unecessary.
120           // (But it does not seem to cost much.)
121           clean->Update();  //important before ShallowCopy
122           output->ShallowCopy( clean->GetOutput() );
123           clean->Delete();
124         }
125
126 #else
127         int vtkClosePolyData::ProcessRequest(   vtkInformation *request, 
128                                                                                         vtkInformationVector **inputVector, 
129                                                                                         vtkInformationVector *outputVector)
130         {
131 printf("EED Warning ERROR ! vtkClosePolyData::ProcessRequest  not implemented  VTK7 migration")
132         }
133
134 #endif
135
136 //----------------------------------------------------------------------------
137 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
138 {
139   this->Superclass::PrintSelf(os,indent);
140 }