polyData->SetPoints(points);
polyData->SetLines(lines);
-
+ double radio;
// Varying tube radius using sine-function
vtkSmartPointer<vtkDoubleArray> tubeRadius = vtkSmartPointer<vtkDoubleArray>::New();
tubeRadius->SetName("TubeRadius");
- tubeRadius->SetNumberOfTuples( lstRadius.size() );
- for (i=0 ;i<lstRadius.size() ; i++)
+ tubeRadius->SetNumberOfTuples( lstPointX.size() );
+ for (i=0 ;i<lstPointX.size() ; i++)
{
- tubeRadius->SetTuple1(i, lstRadius[i] );
+ if (lstRadius.size()==0)
+ {
+ radio=1;
+ } else if (i<lstRadius.size()) {
+ radio = lstRadius[i];
+ } else if (i>=lstRadius.size()) {
+ radio= lstRadius[ lstRadius.size()-1 ];
+ }
+
+ tubeRadius->SetTuple1(i, radio );
}
polyData->GetPointData()->AddArray(tubeRadius);
polyData->GetPointData()->SetActiveScalars("TubeRadius");
colour.push_back(0.0);
colour.push_back(0.0);
bbSetInputColour(colour);
+
+ std::vector<double> lstRadius;
+ lstRadius.push_back(1);
+ bbSetInputColour(lstRadius);
}
//=====
BBTK_BLACK_BOX_IMPLEMENTATION(TubeTreeFilter,bbtk::AtomicBlackBox);
+void TubeTreeFilter::SetRadioTube(int iGeneral,int numPoints, int iTube)
+{
+ int i;
+ double radiotmp=1;
+ int size=iGeneral+numPoints;
+ vtkDoubleArray *tubeRadius = vecTubeRadiosArray[iTube];
+
+ if (bbGetInputlstRadio().size()>=1)
+ {
+ if (bbGetInputlstRadioLaw()==0) // for All
+ {
+ radiotmp=bbGetInputlstRadio()[0];
+ } // Law 0 for All
+
+ if (bbGetInputlstRadioLaw()==1) // by segment
+ {
+ if (bbGetInputlstRadio().size()>=iTube)
+ {
+ radiotmp=bbGetInputlstRadio()[iTube];
+ } else {
+ radiotmp=bbGetInputlstRadio()[ bbGetInputlstRadio().size()-1 ];
+ }
+ } // Law 1 by segment
+
+ for (i=iGeneral;i<size;i++)
+ {
+ if (bbGetInputlstRadioLaw()==2) // by point
+ {
+ if (bbGetInputlstRadio().size()>=i)
+ {
+ radiotmp=bbGetInputlstRadio()[i];
+ } else {
+ radiotmp=bbGetInputlstRadio()[ bbGetInputlstRadio().size()-1 ];
+ }
+ } // Law 2 by points
+ tubeRadius->SetTuple1(i-iGeneral, radiotmp );
+ } // for
+ tubeRadius->Modified();
+ } // bbGetInputlstRadio().size()>=1
+
+
+}
+
void TubeTreeFilter::DrawOneTube(int iGeneral,int numPoints, int iTube)
{
//EED vtkDoubleArray *tubeRadius = vtkDoubleArray::New();
tubeRadius->SetName("TubeRadius");
tubeRadius->SetNumberOfTuples( numPoints );
- for (i=iGeneral;i<size;i++)
- {
- tubeRadius->SetTuple1(i-iGeneral, bbGetInputlstRadio()[i] );
- }
+ vecTubeRadiosArray.push_back( tubeRadius );
+
+
polyData->GetPointData()->AddArray(tubeRadius);
polyData->GetPointData()->SetActiveScalars("TubeRadius");
void TubeTreeFilter::SetGraphicProperties()
{
- int iTube,sizeLstAxis=bbGetInputlstIndexs().size();
+ int iTube,sizeLstAxis=bbGetInputlstIndexs().size();
+
+ int iGeneral=0;
+ int numPoints;
vtkActor *actorTube;
vtkActor *actorSpherEnd;
actorSpherEnd->GetProperty()->SetOpacity( bbGetInputOpacity() );
actorSpherStart->GetProperty()->SetOpacity( bbGetInputOpacity() );
- //Set Colour
+ // Set Transform
if ( bbGetInputTransform()!=NULL )
{
actorTube->SetUserTransform( bbGetInputTransform() );
actorSpherStart->SetUserTransform( bbGetInputTransform() );
}
+ //Set Colour
if (bbGetInputColourLaw()==1) // One solide colour
{
//
actorTube->GetProperty()->SetColor( r,g,b );
actorSpherEnd->GetProperty()->SetColor( r,g,b );
actorSpherStart->GetProperty()->SetColor( r,g,b );
+
+
+// Setting radio
+ numPoints = bbGetInputlstIndexs()[iTube];
+ SetRadioTube(iGeneral,numPoints,iTube);
+ iGeneral = iGeneral+numPoints;
+
} // for
}
//EED vecVtkPolyData.clear();
//EED vecVtkPolyDataMaper.clear();
vecVtkActors.clear();
+ vecTubeRadiosArray.clear();
for ( iTube=0 ; iTube<sizeLstAxis ; iTube++)
{
} else {
printf("TubeTreeFilter .ERROR. missing index vector...\n");
}// vector Actor size
- }
+ } // oldLstSize
SetGraphicProperties();
printf("EED TubeTreeFilter::Process end \n");
bbSetInputColourLaw(1);
bbSetInputOpacity(1);
+ std::vector<double> radio;
+ radio.push_back(1);
+ bbSetInputlstRadio( radio );
+ bbSetInputlstRadioLaw( 0 ); // for all
+
}
//=====
// 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(lstPointY , std::vector<double>);
BBTK_DECLARE_INPUT(lstPointZ , std::vector<double>);
BBTK_DECLARE_INPUT(lstRadio , std::vector<double>);
+ BBTK_DECLARE_INPUT(lstRadioLaw , int);
BBTK_DECLARE_INPUT(Colour , std::vector<double>);
BBTK_DECLARE_INPUT(ColourLaw , int);
BBTK_DECLARE_INPUT(Transform , vtkLinearTransform *);
private:
std::vector<vtkActor*> vecVtkActors;
+ std::vector< vtkDoubleArray* > vecTubeRadiosArray;
+
void DrawOneTube(int iGeneral,int numPoints, int iTube);
void SetGraphicProperties();
+ void SetRadioTube(int iGeneral,int numPoints, int iTube);
int oldLstSize;
//=====
BBTK_INPUT(TubeTreeFilter,lstPointX,"lstPointX",std::vector<double>,"");
BBTK_INPUT(TubeTreeFilter,lstPointY,"lstPointY",std::vector<double>,"");
BBTK_INPUT(TubeTreeFilter,lstPointZ,"lstPointZ",std::vector<double>,"");
- BBTK_INPUT(TubeTreeFilter,lstRadio,"lstRadio",std::vector<double>,"");
+ BBTK_INPUT(TubeTreeFilter,lstRadio,"lstRadio (default 1) ",std::vector<double>,"");
+ BBTK_INPUT(TubeTreeFilter,lstRadioLaw,"0(default) radio for all, 1 radio by segment, 2 radio by point",int,"");
BBTK_INPUT(TubeTreeFilter,Colour,"Colour",std::vector<double>,"");
- BBTK_INPUT(TubeTreeFilter,ColourLaw,"ColorLaw 1(default) solid color, 2 color by segment, 3 color for each point",int,"");
+ 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_OUTPUT(TubeTreeFilter,OutTube,"Tube[iTube]",vtkProp3D *,"");
BBTK_END_DESCRIBE_BLACK_BOX(TubeTreeFilter);
//=====
p++;
}
- for (iAxe=0 ; iAxe<sizeAxe-1; iAxe++)
+ for (iAxe=0 ; iAxe<sizeAxe; iAxe++)
{
if (sizeLstPointR<iAxe)
{
BBTK_BLACK_BOX_IMPLEMENTATION(DrawAxe3D,bbtk::AtomicBlackBox);
void DrawAxe3D::Process()
{
+printf("EED DrawAxe3D::Process Start\n");
std::vector< double > vectx = bbGetInputlstPointX();
std::vector< double > vecty = bbGetInputlstPointY();
std::vector< double > vectz = bbGetInputlstPointZ();
+printf("EED DrawAxe3D::Process size vector %d %d %d\n",vectx.size(),vecty.size(),vectz.size() );
+
// vtkImageData* img = bbGetInputImage();
unsigned int i;
double spc[3];
spc[1]=1;
spc[2]=1;
- if(!vectx.empty()&&!vecty.empty()&&!vectz.empty()){
+ if(!vectx.empty()&&!vecty.empty()&&!vectz.empty())
+ {
+printf("EED DrawAxe3D::Process 1\n");
vtkPoints* allPoints = vtkPoints::New( );
vtkCellArray* allTopology = vtkCellArray::New( );
allTopology->InsertNextCell( vectx.size() );
+printf("EED DrawAxe3D::Process 2\n");
for( i = 0; i < vectx.size( ); i++) {
//multiplicar ver parametros spacing, en maracas cuando se toca la imagen y se ve dycom
//hay parametro dicom, vtkImagedata valor spacing y esos datos hay que multiplicar al polydata
allPoints->InsertNextPoint( vectx[i]*spc[0], vecty[i]*spc[1], vectz[i]*spc[2] );
allTopology->InsertCellPoint( i );
+printf("EED DrawAxe3D::Process 3\n");
} // rof
mallData->SetPoints( allPoints );
mallData->SetLines( allTopology );
+printf("EED DrawAxe3D::Process 4\n");
allPoints->Delete();
allTopology->Delete();
+printf("EED DrawAxe3D::Process 5\n");
}
mvtkactor->GetProperty()->SetColor( bbGetInputColour()[0],
bbGetInputColour()[1],
bbGetInputColour()[2] );
+printf("EED DrawAxe3D::Process 6\n");
//EC Axe Opacity property added
///Default Values
double opacity=bbGetInputOpacity();
mvtkactor->GetProperty()->SetOpacity( opacity );
+printf("EED DrawAxe3D::Process 7\n");
if ( bbGetInputTransform()!=NULL )
{
+printf("EED DrawAxe3D::Process 8\n");
mvtkactor->SetUserTransform( bbGetInputTransform() );
}
// Interface Update
if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
{
+printf("EED DrawAxe3D::Process 9\n");
firsttime=false;
bbGetInputRenderer()->AddActor( mvtkactor );
}
+printf("EED DrawAxe3D::Process End\n");
}
+
+
+
void DrawAxe3D::bbUserSetDefaultValues()
{
firsttime = true;
colour.push_back(0.0);
bbSetInputColour(colour);
bbSetInputOpacity(1.0);
+ bbSetInputRenderer(NULL);
+ bbSetInputTransform(NULL);
}
#include "bbcreaMaracasVisuPackage.h"
#include "vtkLinearTransform.h"
+#include "vtkUnsignedCharArray.h"
+#include "vtkCellData.h"
+#include "vtkPolyLine.h"
+#include "vtkLine.h"
+
+
+
namespace bbcreaMaracasVisu
{
void DrawAxisTree3D::DrawOneAxis(int iGeneral,int numPoints, int iAxis)
{
+printf("EED DrawAxisTree3D::DrawOneAxis Start \n");
vtkPolyData *polydata = vtkPolyData::New( );
vtkPolyDataMapper *polydatamapper = vtkPolyDataMapper::New();
vtkActor *vtkactor = vtkActor::New();
+// polydatamapper->ScalarVisibilityOff();
polydatamapper->SetInput(polydata);
vtkactor->SetMapper(polydatamapper);
if( lstpointsXsize>0 ){
vtkPoints* allPoints = vtkPoints::New( );
+vtkPolyLine *polyline = vtkPolyLine::New();
vtkCellArray* allTopology = vtkCellArray::New( );
- allTopology->InsertNextCell( numPoints );
+// allTopology->InsertNextCell( numPoints );
size=iGeneral+numPoints;
for (i=iGeneral;i<size;i++)
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 );
+
+polyline->GetPointIds()->InsertNextId(i-iGeneral);
+
+// allTopology->InsertCellPoint( i-iGeneral );
} // rof
+ allTopology->InsertNextCell(polyline);
+
+ // create cell array for edges
+ vtkCellArray *edges = vtkCellArray::New();
+
+// connect edge's and vertexes point ids
+ for(vtkIdType i = iGeneral; i < size-1; i++)
+ {
+ vtkLine *edge = vtkLine::New();
+ edge->GetPointIds()->SetId(0, i-iGeneral);
+ edge->GetPointIds()->SetId(1, (i-iGeneral+1) );
+ edges->InsertNextCell(edge);
+ edge->Delete();
+// vtkSmartPointer<vtkVertex> vertex = vtkSmartPointer<vtkVertex>::New();
+// vertex->GetPointIds()->SetId(0, i);
+// vertexes->InsertNextCell(vertex);
+ }
+
polydata->SetPoints( allPoints );
- polydata->SetLines( allTopology );
+ polydata->SetLines(edges);
+// polydata->SetLines( allTopology );
+
+
+ // polydata->SetPolys( allTopology );
+
+ edges->Delete();
allPoints->Delete();
allTopology->Delete();
}
// color
double r,g,b;
- if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) )
+ if (bbGetInputColourLaw()==1) // the same color for all
{
+ r = bbGetInputColour()[0];
+ g = bbGetInputColour()[1];
+ b = bbGetInputColour()[2];
+ vtkactor->GetProperty()->SetColor( r,g,b );
+ } // Law 1 color for all
+
+ if (bbGetInputColourLaw()==2) // different colors for each segment
+ {
+ if ( (iAxis*3+1) < (int)(bbGetInputColour().size()) )
+ {
r = bbGetInputColour()[0+iAxis*3];
g = bbGetInputColour()[1+iAxis*3];
b = bbGetInputColour()[2+iAxis*3];
- } else {
+ } else {
r = (rand() % 100) / 100.0;
g = (rand() % 100) / 100.0;
b = (rand() % 100) / 100.0;
- }
+ }
+ vtkactor->GetProperty()->SetColor( r,g,b );
+ } // Law 2 color for each segment
+
+
+ if (bbGetInputColourLaw()==3) // color for each point
+ {
+ // Setup the colors array
+ vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New();
+ colors->SetNumberOfComponents(3);
+ colors->SetName("Colors");
+// colors->SetName("vertex color");
+ int iPoint,pointSize=iGeneral+numPoints;
+
+
+ for (iPoint=iGeneral; iPoint<pointSize; iPoint++)
+ {
+ r = bbGetInputColour()[0+iPoint*3]*255.0;
+ g = bbGetInputColour()[1+iPoint*3]*255.0;
+ b = bbGetInputColour()[2+iPoint*3]*255.0;
+ //colors->SetTuple3(iPoint,r,g,b);
+printf("EED DrawAxisTree3D::DrawOneAxis iPoint=%d size=%d rgb=%f% f% f \n", iPoint , bbGetInputColour().size() , r,g,b);
+ colors->InsertNextTuple3(r,g,b);
+ }
+ polydata->GetCellData()->SetScalars(colors);
+ polydata->Modified();
+
+ } // Law 3 color for each point
- vtkactor->GetProperty()->SetColor( r,g,b );
vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
{
bbGetInputRenderer()->AddActor( vtkactor );
}
+printf("EED DrawAxisTree3D::DrawOneAxis End \n");
}
{
bbSetOutputOutAxis( vecVtkActors[ bbGetInputiAxis() ] );
} else {
- printf("TubeTreeFilter .ERROR. missing index vector...\n");
+ printf("DrawAxisTree3D .ERROR. missing index vector...\n");
}
} else {// if oldLstSize
BBTK_INPUT(DrawAxisTree3D,lstPointZ,"lstPointZ",std::vector<double>,"");
BBTK_INPUT(DrawAxisTree3D,lstRadio,"lstRadio",std::vector<double>,"");
BBTK_INPUT(DrawAxisTree3D,Colour,"Colour R1 G1 B1 R2 G2 B2 ... range[0..1]",std::vector<double>,"");
- BBTK_INPUT(DrawAxisTree3D,ColourLaw,"ColorLaw 1(default) solid color, 2 color by segment, 3 color for each point",int,"");
+ BBTK_INPUT(DrawAxisTree3D,ColourLaw,"ColorLaw 1(default) solid color, 2 color by segment (random if is necessary) , 3 color for each point",int,"");
BBTK_INPUT(DrawAxisTree3D,Transform,"vtkTransform", vtkLinearTransform *,"");
BBTK_INPUT(DrawAxisTree3D,Opacity,"Opacity",double,"");
BBTK_INPUT(DrawAxisTree3D,LineWidth,"LineWidth (default 0.5)",double,"");