]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx
Support #1768 CREATIS Licence insertion
[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 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.3 $");
55 vtkStandardNewMacro(vtkClosePolyData);
56
57 //----------------------------------------------------------------------------
58 vtkClosePolyData::vtkClosePolyData()
59 {
60 }
61
62 //----------------------------------------------------------------------------
63 vtkClosePolyData::~vtkClosePolyData()
64 {
65 }
66
67 //----------------------------------------------------------------------------
68 // This method is much too long, and has to be broken up!
69 // Furthermore we are loosing the normals !!!
70 void vtkClosePolyData::Execute()
71 {
72   vtkPolyData *input = this->GetInput();
73   vtkPolyData *output = this->GetOutput();
74   
75    //#closing the polydata see : close.py for details
76   vtkFeatureEdges *boundary = vtkFeatureEdges::New();
77   boundary->SetInput( input );
78   boundary->BoundaryEdgesOn ();
79   boundary->FeatureEdgesOff ();
80   boundary->NonManifoldEdgesOff ();
81   boundary->ManifoldEdgesOff ();
82   //boundary->ColoringOff ();
83
84   vtkStripper *stripper = vtkStripper::New();
85   stripper->SetInput( boundary->GetOutput() );
86   stripper->Update(); //important
87   boundary->Delete();
88
89   vtkPolyData *pd = vtkPolyData::New();
90   pd->SetPoints ( stripper->GetOutput()->GetPoints() );
91   pd->SetPolys  ( stripper->GetOutput()->GetLines() );
92   stripper->Delete();
93     
94   //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
95   vtkTriangleFilter *triangle = vtkTriangleFilter::New();
96   triangle->SetInput( pd );
97   pd->Delete();
98     
99   vtkAppendPolyData *append = vtkAppendPolyData::New();
100   append->AddInput( input );
101   append->AddInput( triangle->GetOutput());
102   triangle->Delete();
103       
104   vtkCleanPolyData *clean = vtkCleanPolyData::New();
105   clean->SetInput( append->GetOutput());
106   append->Delete();
107     
108   // When all optimizations are complete, this squeeze will be unecessary.
109   // (But it does not seem to cost much.)
110   clean->Update();  //important before ShallowCopy
111   output->ShallowCopy( clean->GetOutput() );
112   clean->Delete();
113 }
114
115 //----------------------------------------------------------------------------
116 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
117 {
118   this->Superclass::PrintSelf(os,indent);
119 }