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 int lstpointsXsize =bbGetInputlstPointX().size();
36 if( lstpointsXsize>0 ){
37 vtkPoints* allPoints = vtkPoints::New( );
38 vtkCellArray* allTopology = vtkCellArray::New( );
39 allTopology->InsertNextCell( numPoints );
41 size=iGeneral+numPoints;
42 for (i=iGeneral;i<size;i++)
44 //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
45 //hay parĀ·metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
46 allPoints->InsertNextPoint( bbGetInputlstPointX()[i]*spc[0],
47 bbGetInputlstPointY()[i]*spc[1],
48 bbGetInputlstPointZ()[i]*spc[2] );
49 // printf("DrawAxisTree3D::DrawOneAxis point %d -> %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] );
50 allTopology->InsertCellPoint( i-iGeneral );
52 polydata->SetPoints( allPoints );
53 polydata->SetLines( allTopology );
55 allTopology->Delete();
61 if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) )
63 r = bbGetInputColour()[0+iAxis*3];
64 g = bbGetInputColour()[1+iAxis*3];
65 b = bbGetInputColour()[2+iAxis*3];
67 r = (rand() % 100) / 100.0;
68 g = (rand() % 100) / 100.0;
69 b = (rand() % 100) / 100.0;
72 vtkactor->GetProperty()->SetColor( r,g,b );
73 vtkactor->GetProperty()->SetLineWidth( 0.5 );
74 vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
76 if ( bbGetInputTransform()!=NULL )
78 vtkactor->SetUserTransform( bbGetInputTransform() );
82 if (bbGetInputRenderer()!=NULL )
84 bbGetInputRenderer()->AddActor( vtkactor );
89 void DrawAxisTree3D::Process()
91 printf("EED DrawAxisTree3D::Process start \n");
94 int iAxis,sizeLstAxis=bbGetInputlstIndexs().size();
95 int iActor,sizeActors = vecVtkActors.size();
98 if (oldLstSize!=sizeLstAxis)
100 oldLstSize=sizeLstAxis;
101 for (iActor=0 ; iActor<sizeActors; iActor++)
103 if (bbGetInputRenderer()!=NULL )
105 bbGetInputRenderer()->RemoveActor( vecVtkActors[iActor] );
106 vecVtkPolyData[iActor]->Delete();
107 vecVtkPolyDataMaper[iActor]->Delete();
108 vecVtkActors[iActor]->Delete();
111 vecVtkPolyData.clear();
112 vecVtkPolyDataMaper.clear();
113 vecVtkActors.clear();
115 for ( iAxis=0 ; iAxis<sizeLstAxis ; iAxis++)
117 numPoints = bbGetInputlstIndexs()[iAxis];
118 DrawOneAxis(iGeneral,numPoints,iAxis);
119 iGeneral = iGeneral+numPoints;
121 // if ((iAxis % 1)==0)
123 // printf("EED DrawAxisTree3D::Process %d/%d\n", iAxis,sizeLstAxis );
128 if ( bbGetInputiAxis() < (int)(vecVtkActors.size()-1) )
130 bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
132 printf("TubeTreeFilter .ERROR. missing index vector...\n");
135 } else {// if oldLstSize
136 for (iActor=0 ; iActor<sizeActors; iActor++)
138 vecVtkActors[iActor]->GetProperty()->SetOpacity( bbGetInputOpacity() );
142 printf("EED DrawAxisTree3D::Process end \n");
146 void DrawAxisTree3D::bbUserSetDefaultValues()
150 std::vector<double> colour;
152 colour.push_back(1.0);
153 colour.push_back(0.0);
154 colour.push_back(0.0);
156 colour.push_back(0.0);
157 colour.push_back(0.0);
158 colour.push_back(1.0);
160 colour.push_back(1.0);
161 colour.push_back(1.0);
162 colour.push_back(0.0);
164 colour.push_back(0.0);
165 colour.push_back(1.0);
166 colour.push_back(0.0);
168 colour.push_back(0.0);
169 colour.push_back(1.0);
170 colour.push_back(1.0);
173 colour.push_back(0.5);
174 colour.push_back(0.5);
175 colour.push_back(0.5);
177 bbSetInputColour(colour);
178 bbSetInputOpacity(1);
179 bbSetInputColourLaw(1);
184 //-----------------------------------------------------------------
185 void DrawAxisTree3D::bbUserInitializeProcessing()
189 //-----------------------------------------------------------------
190 void DrawAxisTree3D::bbUserFinalizeProcessing()
194 //-----------------------------------------------------------------
197 // EO namespace bbcreaMaracasVisu