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