1 #include "bbmaracasvisuDrawAxisTree3D.h"
2 #include "bbcreaMaracasVisuPackage.h"
4 namespace bbcreaMaracasVisu
7 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxisTree3D)
8 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxisTree3D,bbtk::AtomicBlackBox);
12 void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
14 vtkPolyData *polydata = vtkPolyData::New( );
15 vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New();
16 vtkActor *vtkactor = vtkActor::New();
18 polydatamapper->SetInput(polydata);
19 vtkactor->SetMapper(polydatamapper);
21 vecVtkPolyData.push_back( polydata );
22 vecVtkPolyDataMaper.push_back( polydatamapper );
23 vecVtkActors.push_back( vtkactor );
25 // vtkImageData* img = bbGetInputImage();
28 // img->GetSpacing(spc);
33 if(!bbGetInputlstPointX().empty()){
34 vtkPoints* allPoints = vtkPoints::New( );
35 vtkCellArray* allTopology = vtkCellArray::New( );
36 allTopology->InsertNextCell( numPoints );
38 size=iGeneral+numPoints;
39 for (i=iGeneral;i<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( bbGetInputlstPointX()[i]*spc[0],
44 bbGetInputlstPointY()[i]*spc[1],
45 bbGetInputlstPointZ()[i]*spc[2] );
46 allTopology->InsertCellPoint( i-iGeneral );
48 polydata->SetPoints( allPoints );
49 polydata->SetLines( allTopology );
51 allTopology->Delete();
57 if ( (iAxis*3+1) < bbGetInputColour().size() ){
58 r = bbGetInputColour()[0+iAxis*3];
59 g = bbGetInputColour()[1+iAxis*3];
60 b = bbGetInputColour()[2+iAxis*3];
62 r = bbGetInputColour()[0];
63 g = bbGetInputColour()[1];
64 b = bbGetInputColour()[2];
67 vtkactor->GetProperty()->SetColor( 1,0,0 );
68 vtkactor->GetProperty()->SetLineWidth( 3 );
70 if ( bbGetInputTransform()!=NULL )
72 vtkactor->SetUserTransform( bbGetInputTransform() );
76 if (bbGetInputRenderer()!=NULL )
78 bbGetInputRenderer()->AddActor( vtkactor );
83 void DrawAxisTree3D::Process()
85 int iActor,sizeActors = vecVtkActors.size();
86 for (iActor=0 ; iActor<sizeActors; iActor++)
88 if (bbGetInputRenderer()!=NULL )
90 bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
91 vecVtkPolyData[iActor]->Delete();
92 vecVtkPolyDataMaper[iActor]->Delete();
93 vecVtkActors[iActor]->Delete();
96 vecVtkPolyData.clear();
97 vecVtkPolyDataMaper.clear();
102 int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
104 for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
106 numPoints = bbGetInputlstIndexs()[iAxis];
107 DrawOneAxis(iGeneral,numPoints,iAxis);
108 iGeneral = iGeneral+numPoints;
112 bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
116 void DrawAxisTree3D::bbUserConstructor()
119 std::vector<double> colour;
121 colour.push_back(1.0);
122 colour.push_back(0.0);
123 colour.push_back(0.0);
125 colour.push_back(0.0);
126 colour.push_back(0.0);
127 colour.push_back(1.0);
129 colour.push_back(1.0);
130 colour.push_back(1.0);
131 colour.push_back(0.0);
133 colour.push_back(0.0);
134 colour.push_back(1.0);
135 colour.push_back(0.0);
137 colour.push_back(0.0);
138 colour.push_back(1.0);
139 colour.push_back(1.0);
142 colour.push_back(0.5);
143 colour.push_back(0.5);
144 colour.push_back(0.5);
146 bbSetInputColour(colour);
150 void DrawAxisTree3D::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
154 void DrawAxisTree3D::bbUserDestructor()
159 // EO namespace bbcreaMaracasVisu