1 #include "bbvtkSphereList.h"
2 #include "bbvtkPackage.h"
4 #include <vtkPolyDataMapper.h>
5 #include <vtkProperty.h>
6 #include <vtkRenderWindow.h>
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SphereList)
12 BBTK_BLACK_BOX_IMPLEMENTATION(SphereList,bbtk::AtomicBlackBox);
14 void SphereList::Process()
24 int last_valid_color_index = 0;
26 if (bbGetInputRenderer()!=NULL)
28 if (bbGetInputSpacing().size()==3)
30 spc[0]=bbGetInputSpacing()[0];
31 spc[1]=bbGetInputSpacing()[1];
32 spc[2]=bbGetInputSpacing()[2];
34 spc[0]=spc[1]=spc[2]=1;
38 iMax=bbGetInputlstPointX().size();
39 printf("EED SphereList::Process iMax=%d \n", iMax);
40 // If the vector Y or respectively the vector Z has a different size from the vector X, the position value py or respectively pz is set to 0.
41 for ( int i=iMin ; i<iMax ; i=i+1 )
43 px = bbGetInputlstPointX()[i]*spc[0];
44 if (bbGetInputlstPointY().size() == bbGetInputlstPointX().size() )
46 py = bbGetInputlstPointY()[i]*spc[1];
48 if (bbGetInputlstPointZ().size() == bbGetInputlstPointX().size() )
50 pz = bbGetInputlstPointZ()[i]*spc[2];
53 // If the number of elements in the radio list is different from the number of X coordinates, the radio value is set to 1.
54 if (bbGetInputlstRadio().size() == bbGetInputlstPointX().size() )
56 radio = bbGetInputlstRadio()[i];
60 if (bbGetInputlstRadio().size()>=1){
61 radio = bbGetInputlstRadio()[ bbGetInputlstRadio().size() - 1 ];
68 vtkSphereSource * newSphere = vtkSphereSource::New();
69 vtkSphere.push_back(newSphere);
71 newSphere -> SetThetaResolution(20);
72 newSphere -> SetPhiResolution(20);
73 newSphere -> SetRadius(radio);
75 vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
76 sphereMapper.push_back(newMapper);
77 newMapper -> SetInput( newSphere -> GetOutput() );
79 vtkActor * newActor = vtkActor::New();
80 sphereActor.push_back(newActor);
81 newActor -> SetMapper(newMapper);
82 newActor -> SetOrigin(0, 0, 0);
84 unsigned int j = 3*i +2;
85 if (j < bbGetInputColour().size() )
87 newActor -> GetProperty() -> SetColor( bbGetInputColour()[3*i] , bbGetInputColour()[3*i + 1] , bbGetInputColour()[3*i + 2] );
88 last_valid_color_index = 3*i;
91 newActor -> GetProperty() -> SetColor( bbGetInputColour()[last_valid_color_index] , bbGetInputColour()[last_valid_color_index + 1] , bbGetInputColour()[last_valid_color_index + 2] );
93 newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
94 newActor -> SetPosition( px,py,pz );
96 if ( bbGetInputTransform()!=NULL )
98 newActor->SetUserTransform( bbGetInputTransform() );
102 if (bbGetInputRenderer()!=NULL)
104 bbGetInputRenderer() -> AddActor( newActor );
109 if (sphereActor.size() != 0)
112 bbSetOutputActorList(sphereActor);
115 } // if (bbGetInputRenderer()!=NULL)
120 void SphereList::bbUserSetDefaultValues()
123 bbSetInputRenderer(NULL);
124 bbSetInputTransform(NULL);
126 // Sets default radio to 1.
127 std::vector<double> radio;
128 radio.push_back(1.0);
129 bbSetInputlstRadio(radio);
131 // Sets default colour to red.
132 std::vector<double> colour;
133 colour.push_back(1.0);
134 colour.push_back(0.0);
135 colour.push_back(0.0);
136 bbSetInputColour(colour);
138 // Sets default spacing.
139 std::vector<double> spacing;
140 spacing.push_back(1.0);
141 spacing.push_back(1.0);
142 spacing.push_back(1.0);
143 bbSetInputSpacing(spacing);
145 bbSetInputOpacity(1.0);
149 void SphereList::bbUserInitializeProcessing()
154 void SphereList::bbUserFinalizeProcessing()
159 // EO namespace bbvtk