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 // printf("DrawAxisTree3D::DrawOneAxis point %d -> %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] );
48 allTopology->InsertCellPoint( i-iGeneral );
50 polydata->SetPoints( allPoints );
51 polydata->SetLines( allTopology );
53 allTopology->Delete();
59 if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) )
61 r = bbGetInputColour()[0+iAxis*3];
62 g = bbGetInputColour()[1+iAxis*3];
63 b = bbGetInputColour()[2+iAxis*3];
65 r = (rand() % 100) / 100.0;
66 g = (rand() % 100) / 100.0;
67 b = (rand() % 100) / 100.0;
70 vtkactor->GetProperty()->SetColor( r,g,b );
71 vtkactor->GetProperty()->SetLineWidth( 0.5 );
73 if ( bbGetInputTransform()!=NULL )
75 vtkactor->SetUserTransform( bbGetInputTransform() );
79 if (bbGetInputRenderer()!=NULL )
81 bbGetInputRenderer()->AddActor( vtkactor );
86 void DrawAxisTree3D::Process()
88 printf("EED DrawAxisTree3D::Process start \n");
90 int iActor,sizeActors = vecVtkActors.size();
91 for (iActor=0 ; iActor<sizeActors; iActor++)
93 if (bbGetInputRenderer()!=NULL )
95 bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
96 vecVtkPolyData[iActor]->Delete();
97 vecVtkPolyDataMaper[iActor]->Delete();
98 vecVtkActors[iActor]->Delete();
101 vecVtkPolyData.clear();
102 vecVtkPolyDataMaper.clear();
103 vecVtkActors.clear();
107 int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
109 for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
111 numPoints = bbGetInputlstIndexs()[iAxis];
112 DrawOneAxis(iGeneral,numPoints,iAxis);
113 iGeneral = iGeneral+numPoints;
115 // if ((iAxis % 1)==0)
117 // printf("EED DrawAxisTree3D::Process %d/%d\n", iAxis,sizeLstAxis );
123 bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
124 printf("EED DrawAxisTree3D::Process end \n");
128 void DrawAxisTree3D::bbUserSetDefaultValues()
131 std::vector<double> colour;
133 colour.push_back(1.0);
134 colour.push_back(0.0);
135 colour.push_back(0.0);
137 colour.push_back(0.0);
138 colour.push_back(0.0);
139 colour.push_back(1.0);
141 colour.push_back(1.0);
142 colour.push_back(1.0);
143 colour.push_back(0.0);
145 colour.push_back(0.0);
146 colour.push_back(1.0);
147 colour.push_back(0.0);
149 colour.push_back(0.0);
150 colour.push_back(1.0);
151 colour.push_back(1.0);
154 colour.push_back(0.5);
155 colour.push_back(0.5);
156 colour.push_back(0.5);
158 bbSetInputColour(colour);
163 //-----------------------------------------------------------------
164 void DrawAxisTree3D::bbUserInitializeProcessing()
168 //-----------------------------------------------------------------
169 void DrawAxisTree3D::bbUserFinalizeProcessing()
173 //-----------------------------------------------------------------
176 // EO namespace bbcreaMaracasVisu