1 #include "bbmaracasvisuDrawAxisTree3D.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 #include "vtkLinearTransform.h"
5 namespace bbcreaMaracasVisu
8 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxisTree3D)
9 BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxisTree3D,bbtk::AtomicBlackBox);
13 void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
15 vtkPolyData *polydata = vtkPolyData::New( );
16 vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New();
17 vtkActor *vtkactor = vtkActor::New();
19 polydatamapper->SetInput(polydata);
20 vtkactor->SetMapper(polydatamapper);
22 vecVtkPolyData.push_back( polydata );
23 vecVtkPolyDataMaper.push_back( polydatamapper );
24 vecVtkActors.push_back( vtkactor );
26 // vtkImageData* img = bbGetInputImage();
29 // img->GetSpacing(spc);
34 if(!bbGetInputlstPointX().empty()){
35 vtkPoints* allPoints = vtkPoints::New( );
36 vtkCellArray* allTopology = vtkCellArray::New( );
37 allTopology->InsertNextCell( numPoints );
39 size=iGeneral+numPoints;
40 for (i=iGeneral;i<size;i++)
42 //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
43 //hay parĂ¡metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
44 allPoints->InsertNextPoint( bbGetInputlstPointX()[i]*spc[0],
45 bbGetInputlstPointY()[i]*spc[1],
46 bbGetInputlstPointZ()[i]*spc[2] );
47 allTopology->InsertCellPoint( i-iGeneral );
49 polydata->SetPoints( allPoints );
50 polydata->SetLines( allTopology );
52 allTopology->Delete();
58 if ( (iAxis*3+1) < bbGetInputColour().size() ){
59 r = bbGetInputColour()[0+iAxis*3];
60 g = bbGetInputColour()[1+iAxis*3];
61 b = bbGetInputColour()[2+iAxis*3];
63 r = bbGetInputColour()[0];
64 g = bbGetInputColour()[1];
65 b = bbGetInputColour()[2];
68 vtkactor->GetProperty()->SetColor( 1,0,0 );
69 vtkactor->GetProperty()->SetLineWidth( 3 );
71 if ( bbGetInputTransform()!=NULL )
73 vtkactor->SetUserTransform( bbGetInputTransform() );
77 if (bbGetInputRenderer()!=NULL )
79 bbGetInputRenderer()->AddActor( vtkactor );
84 void DrawAxisTree3D::Process()
86 int iActor,sizeActors = vecVtkActors.size();
87 for (iActor=0 ; iActor<sizeActors; iActor++)
89 if (bbGetInputRenderer()!=NULL )
91 bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
92 vecVtkPolyData[iActor]->Delete();
93 vecVtkPolyDataMaper[iActor]->Delete();
94 vecVtkActors[iActor]->Delete();
97 vecVtkPolyData.clear();
98 vecVtkPolyDataMaper.clear();
103 int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
105 for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
107 numPoints = bbGetInputlstIndexs()[iAxis];
108 DrawOneAxis(iGeneral,numPoints,iAxis);
109 iGeneral = iGeneral+numPoints;
113 bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
117 void DrawAxisTree3D::bbUserConstructor()
120 std::vector<double> colour;
122 colour.push_back(1.0);
123 colour.push_back(0.0);
124 colour.push_back(0.0);
126 colour.push_back(0.0);
127 colour.push_back(0.0);
128 colour.push_back(1.0);
130 colour.push_back(1.0);
131 colour.push_back(1.0);
132 colour.push_back(0.0);
134 colour.push_back(0.0);
135 colour.push_back(1.0);
136 colour.push_back(0.0);
138 colour.push_back(0.0);
139 colour.push_back(1.0);
140 colour.push_back(1.0);
143 colour.push_back(0.5);
144 colour.push_back(0.5);
145 colour.push_back(0.5);
147 bbSetInputColour(colour);
151 void DrawAxisTree3D::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
155 void DrawAxisTree3D::bbUserDestructor()
160 // EO namespace bbcreaMaracasVisu