]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuDrawAxe3D.cxx
*** empty log message ***
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuDrawAxe3D.cxx
1 #include "bbmaracasvisuDrawAxe3D.h"
2 #include "bbcreaMaracasVisuPackage.h"
3
4
5 #include "vtkImageData.h"
6 #include "vtkActor.h"
7 #include "vtkPolyDataMapper.h"
8 #include "vtkPoints.h"
9 #include "vtkCellArray.h"
10 #include "vtkProperty.h"
11
12
13 namespace bbcreaMaracasVisu
14 {
15
16
17 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxe3D)
18 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox);
19 void DrawAxe3D::Process()
20 {
21
22         std::vector< double > vectx = bbGetInputlstPointX();
23         std::vector< double > vecty = bbGetInputlstPointY();
24         std::vector< double > vectz = bbGetInputlstPointZ();    
25
26 //      vtkImageData* img = bbGetInputImage();  
27         unsigned int i;
28         double spc[3];  
29 //      img->GetSpacing(spc);
30         spc[0]=1;
31         spc[1]=1;
32         spc[2]=1;
33
34         if(!vectx.empty()&&!vecty.empty()&&!vectz.empty()){
35                 vtkPoints* allPoints = vtkPoints::New( );
36                 vtkCellArray* allTopology = vtkCellArray::New( );
37                 allTopology->InsertNextCell( vectx.size() );
38
39                 for( i = 0; i < vectx.size( ); i++) {   
40                         //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
41                         //hay parĂ¡metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
42                         allPoints->InsertNextPoint( vectx[i]*spc[0],  vecty[i]*spc[1], vectz[i]*spc[2] );
43                         allTopology->InsertCellPoint( i );
44                 } // rof
45                 mallData->SetPoints( allPoints );
46                 mallData->SetLines( allTopology );
47                 allPoints->Delete();
48                 allTopology->Delete();  
49         }
50
51         mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
52                                                                                 bbGetInputColour()[1], 
53                                                                                 bbGetInputColour()[2] );
54
55
56      // Interface Update
57      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
58      {
59                 firsttime=false;
60             bbGetInputRenderer()->AddActor( mvtkactor );
61      }
62
63 }
64
65 void DrawAxe3D::bbUserConstructor()
66 {
67         firsttime                                                       = true;
68         mallData                                                        = vtkPolyData::New( );
69         vtkPolyDataMapper* polydatamapper       = vtkPolyDataMapper::New();
70         mvtkactor                                                       = vtkActor::New();
71         polydatamapper->SetInput(mallData);
72         mvtkactor->SetMapper(polydatamapper);
73         bbSetOutputOut(mvtkactor);
74
75     std::vector<double> colour;
76     colour.push_back(1.0);
77     colour.push_back(0.0);
78     colour.push_back(0.0);
79     bbSetInputColour(colour);
80 }
81
82 void DrawAxe3D::bbUserCopyConstructor()
83 {
84 }
85 void DrawAxe3D::bbUserDestructor()
86 {
87 }
88
89 }
90
91 // EO namespace bbcreaMaracasVisu
92
93