From 8b01430072604956a52213748415d28c87e018a6 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Sun, 1 May 2011 09:49:05 +0000 Subject: [PATCH] no message --- bbtk/src/bbcreaMaracasVisuTubeFilter.cxx | 95 ++++-- bbtk/src/bbcreaMaracasVisuTubeFilter.h | 50 +-- bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx | 312 +++++++++++++++++++ bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h | 88 ++++++ bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx | 111 ++++--- bbtk/src/bbmaracasvisuDrawAxisTree3D.h | 23 +- 6 files changed, 576 insertions(+), 103 deletions(-) create mode 100644 bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx create mode 100644 bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h diff --git a/bbtk/src/bbcreaMaracasVisuTubeFilter.cxx b/bbtk/src/bbcreaMaracasVisuTubeFilter.cxx index 2c191be..1644192 100644 --- a/bbtk/src/bbcreaMaracasVisuTubeFilter.cxx +++ b/bbtk/src/bbcreaMaracasVisuTubeFilter.cxx @@ -17,12 +17,10 @@ #include #include #include -#include #include #include #include -#include namespace bbcreaMaracasVisu @@ -31,37 +29,56 @@ namespace bbcreaMaracasVisu MaracasTubeFilter::MaracasTubeFilter() { } + + MaracasTubeFilter::~MaracasTubeFilter() + { + // Interface Update + if (renderer!=NULL ) + { + renderer->RemoveActor(actor); + } + + } + void MaracasTubeFilter::SetvtkRenderer(vtkRenderer *render) { this->renderer = render; } + + void MaracasTubeFilter::SetlstPoints( std::vector lstPointX , std::vector lstPointY , std::vector lstPointZ ) { - this->lstPointX=lstPointX; - this->lstPointY=lstPointY; - this->lstPointZ=lstPointZ; + this->lstPointX = lstPointX; + this->lstPointY = lstPointY; + this->lstPointZ = lstPointZ; } void MaracasTubeFilter::SetlstRadius( std::vector lstRadius ) { - this->lstRadius=lstRadius; + this->lstRadius = lstRadius; + } + + void MaracasTubeFilter::SetOpacity(double opacity) + { + this->opacity = opacity; + } + + void MaracasTubeFilter::SetTransform( vtkLinearTransform* transform ) + { + this->transform = transform; } + vtkActor *MaracasTubeFilter::GetActor() + { + return actor; + } void MaracasTubeFilter::Run() { - // Spiral tube -// double vX, vY, vZ; -// unsigned int nV = 256; // No. of vertices -// unsigned int nCyc = 5; // No. of spiral cycles -// double rT1 = 0.1, rT2 = 0.5;// Start/end tube radii -// double rS = 2; // Spiral radius -// double h = 10; // Height - unsigned int nTv = 8; // No. of surface elements for each tube vertex - unsigned int i; + unsigned int nTv = 8; // No. of surface elements for each tube vertex // Create points and cells vtkSmartPointer points = vtkSmartPointer::New(); @@ -122,11 +139,23 @@ namespace bbcreaMaracasVisu mapper->SetScalarModeToUsePointFieldData(); mapper->SelectColorArray("Colors"); - vtkSmartPointer actor = - vtkSmartPointer::New(); + // vtkSmartPointer actor =vtkSmartPointer::New(); + actor = vtkSmartPointer::New(); actor->SetMapper(mapper); + actor->GetProperty()->SetOpacity( opacity ); + - renderer->AddActor(actor); + if ( transform!=NULL ) + { + actor->SetUserTransform( transform ); + } + + // Interface Update + if (renderer!=NULL ) + { + renderer->AddActor(actor); + } + } @@ -154,51 +183,57 @@ void TubeFilter::Process() printf("EED TubeFilter::Process start \n"); + if (tubefilter!=NULL) + { + delete tubefilter; + } + + tubefilter = new MaracasTubeFilter(); tubefilter->SetvtkRenderer( bbGetInputRenderer() ); tubefilter->SetlstPoints( bbGetInputlstPointX(), bbGetInputlstPointY(), bbGetInputlstPointZ() ); tubefilter->SetlstRadius( bbGetInputlstRadio() ); + tubefilter->SetOpacity( bbGetInputOpacity() ); + tubefilter->SetTransform( bbGetInputTransform() ); tubefilter->Run(); - bbSetOutputOutAxis( NULL ); - + bbSetOutputOutAxis( tubefilter->GetActor() ); printf("EED TubeFilter::Process end \n"); } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TubeFilter::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 -// bbSetInputIn(0); - + bbSetInputOpacity(1); + bbSetInputTransform(NULL); + } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TubeFilter::bbUserInitializeProcessing() { - // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers -// if any - - tubefilter = new MaracasTubeFilter(); - +// if any + tubefilter = NULL; } + //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== void TubeFilter::bbUserFinalizeProcessing() { - // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any - } + } // EO namespace bbcreaMaracasVisu diff --git a/bbtk/src/bbcreaMaracasVisuTubeFilter.h b/bbtk/src/bbcreaMaracasVisuTubeFilter.h index fe6d8d8..c23d1fa 100644 --- a/bbtk/src/bbcreaMaracasVisuTubeFilter.h +++ b/bbtk/src/bbcreaMaracasVisuTubeFilter.h @@ -1,6 +1,6 @@ -//===== +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) -//===== +//===== #ifndef __bbcreaMaracasVisuTubeFilter_h_INCLUDED__ #define __bbcreaMaracasVisuTubeFilter_h_INCLUDED__ #include "bbcreaMaracasVisu_EXPORT.h" @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include namespace bbcreaMaracasVisu { @@ -19,51 +22,59 @@ namespace bbcreaMaracasVisu public: MaracasTubeFilter(); ~MaracasTubeFilter(); - + void SetvtkRenderer( vtkRenderer *render); void SetlstPoints( std::vector lstPointX , std::vector lstPointY , std::vector lstPointZ ); void SetlstRadius( std::vector lstRadius ); + void SetOpacity(double opacity); + void SetTransform( vtkLinearTransform* transform ); + vtkActor *GetActor(); void Run(); - + vtkRenderer *renderer; - + vtkSmartPointer actor; + + double opacity; + vtkLinearTransform *transform; std::vector lstPointX; std::vector lstPointY; std::vector lstPointZ; std::vector lstRadius; - + }; - + class bbcreaMaracasVisu_EXPORT TubeFilter - : + : public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(TubeFilter,bbtk::AtomicBlackBox); -//===== +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) -//===== +//===== BBTK_DECLARE_INPUT(Renderer ,vtkRenderer*); BBTK_DECLARE_INPUT(lstPointX,std::vector); BBTK_DECLARE_INPUT(lstPointY,std::vector); BBTK_DECLARE_INPUT(lstPointZ,std::vector); BBTK_DECLARE_INPUT(lstRadio ,std::vector); + BBTK_DECLARE_INPUT(Opacity,double); BBTK_DECLARE_INPUT(Colour ,std::vector); BBTK_DECLARE_INPUT(Transform, vtkLinearTransform *); + BBTK_DECLARE_OUTPUT(OutAxis,vtkProp3D *); BBTK_PROCESS(Process); void Process(); - + MaracasTubeFilter *tubefilter; -//===== +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) -//===== +//===== }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(TubeFilter,bbtk::AtomicBlackBox); - BBTK_NAME("TubeFilter"); - BBTK_AUTHOR("Info-Dev"); - BBTK_DESCRIPTION("vtk Tube Filter"); + BBTK_NAME("TubeFilter"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("vtk Tube Filter"); BBTK_CATEGORY("actor"); BBTK_INPUT(TubeFilter,Renderer,"Renderer",vtkRenderer*,""); BBTK_INPUT(TubeFilter,lstPointX,"lstPointX",std::vector,""); @@ -72,11 +83,12 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TubeFilter,bbtk::AtomicBlackBox); BBTK_INPUT(TubeFilter,lstRadio,"lstRadio",std::vector,""); BBTK_INPUT(TubeFilter,Colour,"Colour",std::vector,""); BBTK_INPUT(TubeFilter,Transform,"vtkTransform", vtkLinearTransform *,""); + BBTK_INPUT(TubeFilter,Opacity,"Opacity",double,""); BBTK_OUTPUT(TubeFilter,OutAxis,"Tube Actor",vtkProp3D *,""); - BBTK_END_DESCRIBE_BLACK_BOX(TubeFilter); -//===== +BBTK_END_DESCRIBE_BLACK_BOX(TubeFilter); +//===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) -//===== +//===== } // EO namespace bbcreaMaracasVisu diff --git a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx new file mode 100644 index 0000000..e6e860f --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.cxx @@ -0,0 +1,312 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbcreaMaracasVisuTubeTreeFilter.h" +#include "bbcreaMaracasVisuPackage.h" + +#include +#include +#include +#include +#include +#include + + +namespace bbcreaMaracasVisu +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,TubeTreeFilter) +BBTK_BLACK_BOX_IMPLEMENTATION(TubeTreeFilter,bbtk::AtomicBlackBox); + + + +void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube) +{ + int i; + unsigned int nTv = 8; // No. of surface elements for each tube vertex + + double spc[3]; + // img->GetSpacing(spc); + spc[0]=1; + spc[1]=1; + spc[2]=1; + + int size=iGeneral+numPoints; + + // Create points and cells + vtkSmartPointer points = vtkSmartPointer::New(); +//EED vtkPoints *points = vtkPoints::New(); + vtkSmartPointer lines = vtkSmartPointer::New(); +//EED vtkCellArray *lines = vtkCellArray::New(); + + lines->InsertNextCell( numPoints ); + + for (i=iGeneral;iInsertPoint(i-iGeneral, bbGetInputlstPointX()[i]*spc[0], + bbGetInputlstPointY()[i]*spc[1], + bbGetInputlstPointZ()[i]*spc[2] ); + lines->InsertCellPoint(i-iGeneral); + } + + vtkSmartPointer polyData = vtkSmartPointer::New(); +//EED vtkPolyData *polyData = vtkPolyData::New(); + polyData->SetPoints(points); + polyData->SetLines(lines); + + + // Varying tube radius using sine-function + vtkSmartPointer tubeRadius = vtkSmartPointer::New(); +//EED vtkDoubleArray *tubeRadius = vtkDoubleArray::New(); + tubeRadius->SetName("TubeRadius"); + tubeRadius->SetNumberOfTuples( numPoints ); + for (i=iGeneral;iSetTuple1(i-iGeneral, bbGetInputlstRadio()[i] ); + } + polyData->GetPointData()->AddArray(tubeRadius); + polyData->GetPointData()->SetActiveScalars("TubeRadius"); + + + +// Adding spheres at the start and end of the tube + + // Sphere start + i=iGeneral; + vtkSphereSource *vtksphereStart = vtkSphereSource::New(); + vtksphereStart->SetThetaResolution (10); + vtksphereStart->SetPhiResolution (10); + vtksphereStart->SetRadius( bbGetInputlstRadio()[i] ); + vtkPolyDataMapper *sphereMapperStart = vtkPolyDataMapper::New(); + sphereMapperStart->SetInput( vtksphereStart->GetOutput() ); + vtkActor *sphereActorStart = vtkActor::New(); + sphereActorStart->SetMapper(sphereMapperStart); + sphereActorStart->SetOrigin( 0,0,0 ); + sphereActorStart->SetPosition(bbGetInputlstPointX()[i]*spc[0], bbGetInputlstPointY()[i]*spc[1], bbGetInputlstPointZ()[i]*spc[2] ); + + // Sphere end + i=size-1; + vtkSphereSource *vtksphereEnd = vtkSphereSource::New(); + vtksphereEnd->SetThetaResolution (10); + vtksphereEnd->SetPhiResolution (10); + vtksphereEnd->SetRadius( bbGetInputlstRadio()[i] ); + vtkPolyDataMapper *sphereMapperEnd = vtkPolyDataMapper::New(); + sphereMapperEnd->SetInput( vtksphereEnd->GetOutput() ); + vtkActor *sphereActorEnd = vtkActor::New(); + sphereActorEnd->SetMapper(sphereMapperEnd); + sphereActorEnd->SetOrigin( 0,0,0 ); + sphereActorEnd->SetPosition(bbGetInputlstPointX()[i]*spc[0], bbGetInputlstPointY()[i]*spc[1], bbGetInputlstPointZ()[i]*spc[2] ); + + + // color + double r,g,b; + if ( (iTube*3+1) < (int)(bbGetInputColour().size()) ) + { + r = bbGetInputColour()[0+iTube*3]; + g = bbGetInputColour()[1+iTube*3]; + b = bbGetInputColour()[2+iTube*3]; + } else { + r = (rand() % 100) / 100.0; + g = (rand() % 100) / 100.0; + b = (rand() % 100) / 100.0; + } + r = bbGetInputColour()[0]; + g = bbGetInputColour()[1]; + b = bbGetInputColour()[2]; + + + + + vtkSmartPointer tube = vtkSmartPointer::New(); +//EED vtkTubeFilter *tube = vtkTubeFilter::New(); + tube->SetInput(polyData); + tube->SetNumberOfSides(nTv); + tube->SetVaryRadiusToVaryRadiusByAbsoluteScalar(); + + vtkSmartPointer mapper = vtkSmartPointer::New(); +//EED vtkPolyDataMapper *mapper = vtkPolyDataMapper::New(); + mapper->SetInputConnection(tube->GetOutputPort()); + mapper->ScalarVisibilityOn(); + mapper->SetScalarModeToUsePointFieldData(); + + // vtkSmartPointer actor =vtkSmartPointer::New(); + vtkSmartPointer actor = vtkSmartPointer::New(); +//EED vtkActor *actor = vtkActor::New(); + actor->SetMapper(mapper); + actor->GetProperty()->SetColor( r,g,b ); + actor->GetProperty()->SetOpacity( bbGetInputOpacity() ); + sphereActorStart->GetProperty()->SetColor( r,g,b );; + sphereActorEnd->GetProperty()->SetColor( r,g,b );; + sphereActorStart->GetProperty()->SetOpacity( bbGetInputOpacity() ); + sphereActorEnd->GetProperty()->SetOpacity( bbGetInputOpacity() ); + + vecVtkActors.push_back( actor ); + vecVtkActors.push_back( sphereActorStart ); + vecVtkActors.push_back( sphereActorEnd ); + + + if ( bbGetInputTransform()!=NULL ) + { + actor->SetUserTransform( bbGetInputTransform() ); + sphereActorStart->SetUserTransform( bbGetInputTransform() ); + sphereActorEnd->SetUserTransform( bbGetInputTransform() ); + } + + // Interface Update // Interface Update + if (bbGetInputRenderer()!=NULL ) + { + bbGetInputRenderer()->AddActor( actor ); + bbGetInputRenderer()->AddActor( sphereActorStart ); + bbGetInputRenderer()->AddActor( sphereActorEnd ); + } +} + + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubeTreeFilter::Process() +{ + + printf("EED TubeTreeFilter::Process start \n"); + + int iGeneral=0; + int iTube,sizeLstAxis=bbGetInputlstIndexs().size(); + int iActor,sizeActors = vecVtkActors.size(); + + int numPoints; + if (oldLstSize!=sizeLstAxis) + { + oldLstSize=sizeLstAxis; + for (iActor=0 ; iActorRemoveActor( vecVtkActors[iActor] ); + //EED vecVtkPolyData[iActor]->Delete(); + //EED vecVtkPolyDataMaper[iActor]->Delete(); + //EED vecVtkActors[iActor]->Delete(); + } + } + + //EED vecVtkPolyData.clear(); + //EED vecVtkPolyDataMaper.clear(); + vecVtkActors.clear(); + + for ( iTube=0 ; iTubeGetProperty()->SetOpacity( bbGetInputOpacity() ); + actor2->GetProperty()->SetOpacity( bbGetInputOpacity() ); + actor3->GetProperty()->SetOpacity( bbGetInputOpacity() ); + if (bbGetInputColourLaw()==1) + { + actor1->GetProperty()->SetColor( r,g,b ); + actor2->GetProperty()->SetColor( r,g,b ); + actor3->GetProperty()->SetColor( r,g,b ); + } + } // for + + + printf("EED TubeTreeFilter::Process end \n"); +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubeTreeFilter::bbUserSetDefaultValues() +{ + oldLstSize=-1; + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputiTube(0); + std::vector colour; + // 0- gray + colour.push_back(0.5); + colour.push_back(0.5); + colour.push_back(0.5); + // 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); + bbSetInputTransform(NULL); + bbSetInputRenderer(NULL); + bbSetInputColourLaw(1); + bbSetInputOpacity(1); + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubeTreeFilter::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void TubeTreeFilter::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbcreaMaracasVisu + + diff --git a/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h new file mode 100644 index 0000000..c6ee910 --- /dev/null +++ b/bbtk/src/bbcreaMaracasVisuTubeTreeFilter.h @@ -0,0 +1,88 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbcreaMaracasVisuTubeTreeFilter_h_INCLUDED__ +#define __bbcreaMaracasVisuTubeTreeFilter_h_INCLUDED__ +#include "bbcreaMaracasVisu_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + + +#include +#include +#include "vtkImageData.h" +#include "vtkActor.h" +#include "vtkPolyData.h" +#include "vtkPolyDataMapper.h" +#include "vtkPoints.h" +#include "vtkCellArray.h" +#include "vtkProperty.h" +#include "vtkLinearTransform.h" + + +namespace bbcreaMaracasVisu +{ + +class bbcreaMaracasVisu_EXPORT TubeTreeFilter + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(TubeTreeFilter,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(Renderer , vtkRenderer*); + BBTK_DECLARE_INPUT(lstIndexs , std::vector); + BBTK_DECLARE_INPUT(lstPointX , std::vector); + BBTK_DECLARE_INPUT(lstPointY , std::vector); + BBTK_DECLARE_INPUT(lstPointZ , std::vector); + BBTK_DECLARE_INPUT(lstRadio , std::vector); + BBTK_DECLARE_INPUT(Colour , std::vector); + BBTK_DECLARE_INPUT(ColourLaw , int); + BBTK_DECLARE_INPUT(Transform , vtkLinearTransform *); + BBTK_DECLARE_INPUT(Opacity , double ); + BBTK_DECLARE_INPUT(iTube , int ); + BBTK_DECLARE_OUTPUT(OutTube,vtkProp3D *); + BBTK_PROCESS(Process); + void Process(); + + private: + std::vector vecVtkActors; + void DrawOneTube(int iGeneral,int numPoints, int iTube); + int oldLstSize; + +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(TubeTreeFilter,bbtk::AtomicBlackBox); + BBTK_NAME("TubeTreeFilter"); + BBTK_AUTHOR("Info-Dev"); + BBTK_DESCRIPTION("vtk Tube Tree Filter"); + BBTK_CATEGORY("actor"); + + BBTK_INPUT(TubeTreeFilter,Renderer,"Renderer",vtkRenderer*,""); + BBTK_INPUT(TubeTreeFilter,lstIndexs,"Indexs",std::vector,""); + BBTK_INPUT(TubeTreeFilter,lstPointX,"lstPointX",std::vector,""); + BBTK_INPUT(TubeTreeFilter,lstPointY,"lstPointY",std::vector,""); + BBTK_INPUT(TubeTreeFilter,lstPointZ,"lstPointZ",std::vector,""); + BBTK_INPUT(TubeTreeFilter,lstRadio,"lstRadio",std::vector,""); + BBTK_INPUT(TubeTreeFilter,Colour,"Colour",std::vector,""); + BBTK_INPUT(TubeTreeFilter,ColourLaw,"ColorLaw 1(default) solid color, 2 color by segment, 3 color for each point",int,""); + BBTK_INPUT(TubeTreeFilter,Transform,"vtkTransform", vtkLinearTransform *,""); + BBTK_INPUT(TubeTreeFilter,iTube,"iTube",int,""); + BBTK_INPUT(TubeTreeFilter,Opacity,"Opacity",double,""); + BBTK_OUTPUT(TubeTreeFilter,OutTube,"Tube[iTube]",vtkProp3D *,""); + + + +BBTK_END_DESCRIBE_BLACK_BOX(TubeTreeFilter); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbcreaMaracasVisu + +#endif // __bbcreaMaracasVisuTubeTreeFilter_h_INCLUDED__ + diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx index faf8132..0e2d99d 100644 --- a/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.cxx @@ -23,15 +23,17 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) vecVtkPolyDataMaper.push_back( polydatamapper ); vecVtkActors.push_back( vtkactor ); -// vtkImageData* img = bbGetInputImage(); +// vtkImageData* img = bbGetInputImage(); unsigned int i,size; - double spc[3]; + double spc[3]; // img->GetSpacing(spc); spc[0]=1; spc[1]=1; spc[2]=1; - if(!bbGetInputlstPointX().empty()){ + int lstpointsXsize =bbGetInputlstPointX().size(); + + if( lstpointsXsize>0 ){ vtkPoints* allPoints = vtkPoints::New( ); vtkCellArray* allTopology = vtkCellArray::New( ); allTopology->InsertNextCell( numPoints ); @@ -41,8 +43,8 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) { //multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom //hay par·metro dycom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata - allPoints->InsertNextPoint( bbGetInputlstPointX()[i]*spc[0], - bbGetInputlstPointY()[i]*spc[1], + allPoints->InsertNextPoint( 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 ); @@ -50,7 +52,7 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) polydata->SetPoints( allPoints ); polydata->SetLines( allTopology ); allPoints->Delete(); - allTopology->Delete(); + allTopology->Delete(); } // color @@ -59,7 +61,7 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) ) { r = bbGetInputColour()[0+iAxis*3]; - g = bbGetInputColour()[1+iAxis*3]; + g = bbGetInputColour()[1+iAxis*3]; b = bbGetInputColour()[2+iAxis*3]; } else { r = (rand() % 100) / 100.0; @@ -69,6 +71,7 @@ void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis) vtkactor->GetProperty()->SetColor( r,g,b ); vtkactor->GetProperty()->SetLineWidth( 0.5 ); + vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() ); if ( bbGetInputTransform()!=NULL ) { @@ -87,46 +90,62 @@ void DrawAxisTree3D::Process() { printf("EED DrawAxisTree3D::Process start \n"); - 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 iActor,sizeActors = vecVtkActors.size(); int numPoints; - for ( iAxis=0 ; iAxisRemoveActor( vecVtkActors[iActor] ); + vecVtkPolyData[iActor]->Delete(); + vecVtkPolyDataMaper[iActor]->Delete(); + vecVtkActors[iActor]->Delete(); + } + } + vecVtkPolyData.clear(); + vecVtkPolyDataMaper.clear(); + vecVtkActors.clear(); + + for ( iAxis=0 ; iAxisGetProperty()->SetOpacity( bbGetInputOpacity() ); + } + } - bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] ); printf("EED DrawAxisTree3D::Process end \n"); } void DrawAxisTree3D::bbUserSetDefaultValues() -{ +{ + oldLstSize=-1; bbSetInputiAxis(0); std::vector colour; // 1- red @@ -145,32 +164,34 @@ void DrawAxisTree3D::bbUserSetDefaultValues() colour.push_back(0.0); colour.push_back(1.0); colour.push_back(0.0); - // 5- + // 5- colour.push_back(0.0); colour.push_back(1.0); colour.push_back(1.0); - // 6- + // 6- colour.push_back(0.5); colour.push_back(0.5); colour.push_back(0.5); bbSetInputColour(colour); + bbSetInputOpacity(1); + bbSetInputColourLaw(1); } - - //----------------------------------------------------------------- + + //----------------------------------------------------------------- void DrawAxisTree3D::bbUserInitializeProcessing() { } - - //----------------------------------------------------------------- + + //----------------------------------------------------------------- void DrawAxisTree3D::bbUserFinalizeProcessing() { } - - //----------------------------------------------------------------- + + //----------------------------------------------------------------- } // EO namespace bbcreaMaracasVisu diff --git a/bbtk/src/bbmaracasvisuDrawAxisTree3D.h b/bbtk/src/bbmaracasvisuDrawAxisTree3D.h index 8dca163..af21198 100644 --- a/bbtk/src/bbmaracasvisuDrawAxisTree3D.h +++ b/bbtk/src/bbmaracasvisuDrawAxisTree3D.h @@ -17,18 +17,20 @@ namespace bbcreaMaracasVisu { class /*BBTK_EXPORT*/ DrawAxisTree3D - : + : public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(DrawAxisTree3D,bbtk::AtomicBlackBox); - BBTK_DECLARE_INPUT(Renderer ,vtkRenderer*); - BBTK_DECLARE_INPUT(lstIndexs,std::vector); - BBTK_DECLARE_INPUT(lstPointX,std::vector); - BBTK_DECLARE_INPUT(lstPointY,std::vector); - BBTK_DECLARE_INPUT(lstPointZ,std::vector); - BBTK_DECLARE_INPUT(lstRadio ,std::vector); - BBTK_DECLARE_INPUT(Colour ,std::vector); - BBTK_DECLARE_INPUT(Transform, vtkLinearTransform *); + BBTK_DECLARE_INPUT(Renderer , vtkRenderer*); + BBTK_DECLARE_INPUT(lstIndexs , std::vector); + BBTK_DECLARE_INPUT(lstPointX , std::vector); + BBTK_DECLARE_INPUT(lstPointY , std::vector); + BBTK_DECLARE_INPUT(lstPointZ , std::vector); + BBTK_DECLARE_INPUT(lstRadio , std::vector); + BBTK_DECLARE_INPUT(ColourLaw , int ); + BBTK_DECLARE_INPUT(Colour , std::vector); + BBTK_DECLARE_INPUT(Transform , vtkLinearTransform *); + BBTK_DECLARE_INPUT(Opacity , double); BBTK_DECLARE_INPUT(iAxis, int ); BBTK_DECLARE_OUTPUT(OutAxis,vtkProp3D *); BBTK_PROCESS(Process); @@ -36,6 +38,7 @@ class /*BBTK_EXPORT*/ DrawAxisTree3D private: + int oldLstSize; std::vector vecVtkPolyData; std::vector vecVtkPolyDataMaper; std::vector vecVtkActors; @@ -55,6 +58,8 @@ BBTK_CATEGORY("actor"); BBTK_INPUT(DrawAxisTree3D,lstPointZ,"lstPointZ",std::vector,""); BBTK_INPUT(DrawAxisTree3D,lstRadio,"lstRadio",std::vector,""); BBTK_INPUT(DrawAxisTree3D,Colour,"Colour",std::vector,""); + BBTK_INPUT(DrawAxisTree3D,Opacity,"Opacity",double,""); + BBTK_INPUT(DrawAxisTree3D,ColourLaw,"ColorLaw 1(default) solid color, 2 color by segment, 3 color for each point",int,""); BBTK_INPUT(DrawAxisTree3D,Transform,"vtkTransform", vtkLinearTransform *,""); BBTK_INPUT(DrawAxisTree3D,iAxis,"iAxis",int,""); BBTK_OUTPUT(DrawAxisTree3D,OutAxis,"Axis[iAxis]",vtkProp3D *,""); -- 2.45.2