1 #include "bbmaracasvisuDrawAxisTree3D.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 namespace bbcreaMaracasVisu
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxisTree3D)
7 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxisTree3D,bbtk::AtomicBlackBox);
11 void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
13 vtkPolyData *polydata = vtkPolyData::New( );
14 vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New();
15 vtkActor *vtkactor = vtkActor::New();
17 polydatamapper->SetInput(polydata);
18 vtkactor->SetMapper(polydatamapper);
20 vecVtkPolyData.push_back( polydata );
21 vecVtkPolyDataMaper.push_back( polydatamapper );
22 vecVtkActors.push_back( vtkactor );
24 // vtkImageData* img = bbGetInputImage();
27 // img->GetSpacing(spc);
32 if(!bbGetInputlstPointX().empty()){
33 vtkPoints* allPoints = vtkPoints::New( );
34 vtkCellArray* allTopology = vtkCellArray::New( );
35 allTopology->InsertNextCell( numPoints );
37 size=iGeneral+numPoints;
38 for (i=iGeneral;i<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( bbGetInputlstPointX()[i]*spc[0],
43 bbGetInputlstPointY()[i]*spc[1],
44 bbGetInputlstPointZ()[i]*spc[2] );
45 allTopology->InsertCellPoint( i-iGeneral );
47 polydata->SetPoints( allPoints );
48 polydata->SetLines( allTopology );
50 allTopology->Delete();
56 if ( (iAxis*3+1) < bbGetInputColour().size() ){
57 r = bbGetInputColour()[0+iAxis*3];
58 g = bbGetInputColour()[1+iAxis*3];
59 b = bbGetInputColour()[2+iAxis*3];
61 r = bbGetInputColour()[0];
62 g = bbGetInputColour()[1];
63 b = bbGetInputColour()[2];
66 vtkactor->GetProperty()->SetColor( 1,0,0 );
67 vtkactor->GetProperty()->SetLineWidth( 3 );
70 if (bbGetInputRenderer()!=NULL )
72 bbGetInputRenderer()->AddActor( vtkactor );
77 void DrawAxisTree3D::Process()
79 int iActor,sizeActors = vecVtkActors.size();
80 for (iActor=0 ; iActor<sizeActors; iActor++)
82 if (bbGetInputRenderer()!=NULL )
84 bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
85 vecVtkPolyData[iActor]->Delete();
86 vecVtkPolyDataMaper[iActor]->Delete();
87 vecVtkActors[iActor]->Delete();
90 vecVtkPolyData.clear();
91 vecVtkPolyDataMaper.clear();
96 int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
98 for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
100 numPoints = bbGetInputlstIndexs()[iAxis];
101 DrawOneAxis(iGeneral,numPoints,iAxis);
102 iGeneral = iGeneral+numPoints;
106 bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
110 void DrawAxisTree3D::bbUserConstructor()
113 std::vector<double> colour;
115 colour.push_back(1.0);
116 colour.push_back(0.0);
117 colour.push_back(0.0);
119 colour.push_back(0.0);
120 colour.push_back(0.0);
121 colour.push_back(1.0);
123 colour.push_back(1.0);
124 colour.push_back(1.0);
125 colour.push_back(0.0);
127 colour.push_back(0.0);
128 colour.push_back(1.0);
129 colour.push_back(0.0);
131 colour.push_back(0.0);
132 colour.push_back(1.0);
133 colour.push_back(1.0);
136 colour.push_back(0.5);
137 colour.push_back(0.5);
138 colour.push_back(0.5);
140 bbSetInputColour(colour);
144 void DrawAxisTree3D::bbUserCopyConstructor()
148 void DrawAxisTree3D::bbUserDestructor()
153 // EO namespace bbcreaMaracasVisu