]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkDelaunay3D.cxx
#3274 creaVtk Feature New Normal - BooleanOperationPolyDataFilter BoxWidget ClipPol...
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkDelaunay3D.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaVtkDelaunay3D.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include "vtkPoints.h"
8 #include "vtkDelaunay2D.h"
9 #include "vtkDelaunay3D.h"
10 #include "vtkShrinkFilter.h"
11 #include "vtkGeometryFilter.h"
12 #include <vtkUnstructuredGrid.h>
13 #include <vtkCleanPolyData.h>
14
15 #include <vtkPCANormalEstimation.h>
16 #include <vtkSignedDistance.h>
17 #include <vtkExtractSurface.h>
18 #include <vtkPointData.h>
19
20 #include <vtkSurfaceReconstructionFilter.h>
21 #include <vtkContourFilter.h>
22 #include <vtkReverseSense.h>
23
24
25
26 namespace bbcreaVtk
27 {
28
29 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Delaunay3D)
30 BBTK_BLACK_BOX_IMPLEMENTATION(Delaunay3D,bbtk::AtomicBlackBox);
31 //===== 
32 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
33 //===== 
34 void Delaunay3D::Process()
35 {
36
37 // THE MAIN PROCESSING METHOD BODY
38 //   Here we simply set the input 'In' value to the output 'Out'
39 //   And print out the output value
40 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
41 //    void bbSet{Input|Output}NAME(const TYPE&)
42 //    const TYPE& bbGet{Input|Output}NAME() const 
43 //    Where :
44 //    * NAME is the name of the input/output
45 //      (the one provided in the attribute 'name' of the tag 'input')
46 //    * TYPE is the C++ type of the input/output
47 //      (the one provided in the attribute 'type' of the tag 'input')
48 //    bbSetOutputOut( bbGetInputIn() );
49 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
50   
51         std::vector<double> lstX=bbGetInputLstPointsX();
52         std::vector<double> lstY=bbGetInputLstPointsY();
53         std::vector<double> lstZ=bbGetInputLstPointsZ();
54         if (lstX.size()!=0)
55         {
56                 vtkPoints *points = vtkPoints::New();
57                 int i,size=lstX.size();
58                 for (i=0;i<size;i++)
59                 {
60                         points->InsertNextPoint( lstX[i], lstY[i], lstZ[i] );
61                 } // for i
62
63                 vtkPolyData *inputpolydata = vtkPolyData::New();
64                 inputpolydata->SetPoints( points );
65
66 /* Delaunay */
67                 vtkDelaunay3D* delaunay = vtkDelaunay3D::New();
68                 delaunay->SetInputData( inputpolydata );
69                 delaunay->SetTolerance( bbGetInputTolerance() ); //0.01
70                 delaunay->SetAlpha( bbGetInputAlpha() ); //0.2
71                 delaunay->BoundingTriangulationOff();
72                 delaunay->Update();
73                 vtkGeometryFilter *geometry = vtkGeometryFilter::New();
74                 geometry->SetInputData( delaunay->GetOutput() );
75                 geometry->Update();
76                 bbSetOutputOut( geometry->GetOutput() );
77         } else {
78                 printf("Warnning! Delaunay3D::Process:  list of points empty. \n");
79         } // if lstX.size
80 }
81
82 //===== 
83 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
84 //===== 
85 void Delaunay3D::bbUserSetDefaultValues()
86 {
87
88 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
89 //    Here we initialize the input 'In' to 0
90    bbSetInputTolerance( 0 );
91    bbSetInputAlpha( 0 );
92 }
93 //===== 
94 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
95 //===== 
96 void Delaunay3D::bbUserInitializeProcessing()
97 {
98
99 //  THE INITIALIZATION METHOD BODY :
100 //    Here does nothing 
101 //    but this is where you should allocate the internal/output pointers 
102 //    if any 
103
104   
105 }
106 //===== 
107 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
108 //===== 
109 void Delaunay3D::bbUserFinalizeProcessing()
110 {
111
112 //  THE FINALIZATION METHOD BODY :
113 //    Here does nothing 
114 //    but this is where you should desallocate the internal/output pointers 
115 //    if any
116   
117 }
118 }
119 // EO namespace bbcreaVtk
120
121