#include "bbmaracasvisuDrawAxisTree3D.h" #include "bbcreaMaracasVisuPackage.h" #include "vtkLinearTransform.h" namespace bbcreaMaracasVisu { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,DrawAxisTree3D) BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxisTree3D,bbtk::AtomicBlackBox); void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) { vtkPolyData *polydata = vtkPolyData::New( ); vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New(); vtkActor *vtkactor = vtkActor::New(); polydatamapper->SetInput(polydata); vtkactor->SetMapper(polydatamapper); vecVtkPolyData.push_back( polydata ); vecVtkPolyDataMaper.push_back( polydatamapper ); vecVtkActors.push_back( vtkactor ); // vtkImageData* img = bbGetInputImage(); unsigned int i,size; double spc[3]; // img->GetSpacing(spc); spc[0]=1; spc[1]=1; spc[2]=1; if(!bbGetInputlstPointX().empty()){ vtkPoints* allPoints = vtkPoints::New( ); vtkCellArray* allTopology = vtkCellArray::New( ); allTopology->InsertNextCell( numPoints ); size=iGeneral+numPoints; for (i=iGeneral;iInsertNextPoint( bbGetInputlstPointX()[i]*spc[0], bbGetInputlstPointY()[i]*spc[1], bbGetInputlstPointZ()[i]*spc[2] ); printf("DrawAxisTree3D::DrawOneAxis point %d -> %f, %f, %f \n", i, bbGetInputlstPointX()[i], bbGetInputlstPointY()[i], bbGetInputlstPointZ()[i] ); allTopology->InsertCellPoint( i-iGeneral ); } // rof polydata->SetPoints( allPoints ); polydata->SetLines( allTopology ); allPoints->Delete(); allTopology->Delete(); } // color double r,g,b; if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) ) { r = bbGetInputColour()[0+iAxis*3]; g = bbGetInputColour()[1+iAxis*3]; b = bbGetInputColour()[2+iAxis*3]; } else { // r = bbGetInputColour()[0]; // g = bbGetInputColour()[1]; // b = bbGetInputColour()[2]; r = (rand() % 100) / 100.0; g = (rand() % 100) / 100.0; b = (rand() % 100) / 100.0; } vtkactor->GetProperty()->SetColor( r,g,b ); vtkactor->GetProperty()->SetLineWidth( 0.5 ); if ( bbGetInputTransform()!=NULL ) { vtkactor->SetUserTransform( bbGetInputTransform() ); } // Interface Update if (bbGetInputRenderer()!=NULL ) { bbGetInputRenderer()->AddActor( vtkactor ); } } void DrawAxisTree3D::Process() { int iActor,sizeActors = vecVtkActors.size(); for (iActor=0 ; iActorRemoveActor( vecVtkActors[iActor] ); vecVtkPolyData[iActor]->Delete(); vecVtkPolyDataMaper[iActor]->Delete(); vecVtkActors[iActor]->Delete(); } } vecVtkPolyData.clear(); vecVtkPolyDataMaper.clear(); vecVtkActors.clear(); int iGeneral=0; int iAxis,sizeLstAxis=bbGetInputlstIndexs().size(); int numPoints; for ( iAxis=0 ; iAxis colour; // 1- red colour.push_back(1.0); colour.push_back(0.0); colour.push_back(0.0); // 2- blue colour.push_back(0.0); colour.push_back(0.0); colour.push_back(1.0); // 3- yellow colour.push_back(1.0); colour.push_back(1.0); colour.push_back(0.0); // 4- green colour.push_back(0.0); colour.push_back(1.0); colour.push_back(0.0); // 5- colour.push_back(0.0); colour.push_back(1.0); colour.push_back(1.0); // 6- colour.push_back(0.5); colour.push_back(0.5); colour.push_back(0.5); bbSetInputColour(colour); } //----------------------------------------------------------------- void DrawAxisTree3D::bbUserInitializeProcessing() { } //----------------------------------------------------------------- void DrawAxisTree3D::bbUserFinalizeProcessing() { } //----------------------------------------------------------------- } // EO namespace bbcreaMaracasVisu