]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/vtkClosePolyData.cxx
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / vtkClosePolyData.cxx
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkClosePolyData.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/10/31 16:32:41 $
7   Version:   $Revision: 1.1 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 #include "vtkClosePolyData.h"
19
20 #include "vtkObjectFactory.h"
21 #include "vtkPolyData.h"
22 #include "vtkFeatureEdges.h"
23 #include "vtkStripper.h"
24 #include "vtkTriangleFilter.h"
25 //#include "vtkGLUTesselatorTriangleFilter.h"
26 #include "vtkAppendPolyData.h"
27 #include "vtkCleanPolyData.h"
28
29 vtkCxxRevisionMacro(vtkClosePolyData, "$Revision: 1.1 $");
30 vtkStandardNewMacro(vtkClosePolyData);
31
32 //----------------------------------------------------------------------------
33 vtkClosePolyData::vtkClosePolyData()
34 {
35 }
36
37 //----------------------------------------------------------------------------
38 vtkClosePolyData::~vtkClosePolyData()
39 {
40 }
41
42 //----------------------------------------------------------------------------
43 // This method is much too long, and has to be broken up!
44 // Furthermore we are loosing the normals !!!
45 void vtkClosePolyData::Execute()
46 {
47   vtkPolyData *input = this->GetInput();
48   vtkPolyData *output = this->GetOutput();
49   
50    //#closing the polydata see : close.py for details
51   vtkFeatureEdges *boundary = vtkFeatureEdges::New();
52   boundary->SetInput( input );
53   boundary->BoundaryEdgesOn ();
54   boundary->FeatureEdgesOff ();
55   boundary->NonManifoldEdgesOff ();
56   boundary->ManifoldEdgesOff ();
57   //boundary->ColoringOff ();
58
59   vtkStripper *stripper = vtkStripper::New();
60   stripper->SetInput( boundary->GetOutput() );
61   stripper->Update(); //important
62   boundary->Delete();
63
64   vtkPolyData *pd = vtkPolyData::New();
65   pd->SetPoints ( stripper->GetOutput()->GetPoints() );
66   pd->SetPolys  ( stripper->GetOutput()->GetLines() );
67   stripper->Delete();
68     
69   //vtkGLUTesselatorTriangleFilter *triangle = vtkGLUTesselatorTriangleFilter::New();
70   vtkTriangleFilter *triangle = vtkTriangleFilter::New();
71   triangle->SetInput( pd );
72   pd->Delete();
73     
74   vtkAppendPolyData *append = vtkAppendPolyData::New();
75   append->AddInput( input );
76   append->AddInput( triangle->GetOutput());
77   triangle->Delete();
78       
79   vtkCleanPolyData *clean = vtkCleanPolyData::New();
80   clean->SetInput( append->GetOutput());
81   append->Delete();
82     
83   // When all optimizations are complete, this squeeze will be unecessary.
84   // (But it does not seem to cost much.)
85   clean->Update();  //important before ShallowCopy
86   output->ShallowCopy( clean->GetOutput() );
87   clean->Delete();
88 }
89
90 //----------------------------------------------------------------------------
91 void vtkClosePolyData::PrintSelf(ostream& os, vtkIndent indent)
92 {
93   this->Superclass::PrintSelf(os,indent);
94 }