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 spc[0]=spc[1]=spc[2]=1;
31 iMax=bbGetInputlstPointX().size();
32 printf("EED SphereList::Process iMax=%d \n", iMax);
33 // 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.
34 for ( int i=iMin ; i<iMax ; i=i+1 )
36 px = bbGetInputlstPointX()[i]*spc[0];
37 if (bbGetInputlstPointY().size() == bbGetInputlstPointX().size() )
39 py = bbGetInputlstPointY()[i]*spc[1];
41 if (bbGetInputlstPointZ().size() == bbGetInputlstPointX().size() )
43 pz = bbGetInputlstPointZ()[i]*spc[2];
46 // If the number of elements in the radio list is different from the number of X coordinates, the radio value is set to 1.
47 if (bbGetInputlstRadio().size() == bbGetInputlstPointX().size() )
49 radio = bbGetInputlstRadio()[i];
53 if (bbGetInputlstRadio().size()>=1){
54 radio = bbGetInputlstRadio()[ bbGetInputlstRadio().size() - 1 ];
61 vtkSphereSource * newSphere = vtkSphereSource::New();
62 vtkSphere.push_back(newSphere);
64 newSphere -> SetThetaResolution(20);
65 newSphere -> SetPhiResolution(20);
66 newSphere -> SetRadius(radio);
68 vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
69 sphereMapper.push_back(newMapper);
70 newMapper -> SetInput( newSphere -> GetOutput() );
72 vtkActor * newActor = vtkActor::New();
73 sphereActor.push_back(newActor);
74 newActor -> SetMapper(newMapper);
75 newActor -> SetOrigin(0, 0, 0);
77 unsigned int j = 3*i +2;
78 if (j < bbGetInputColour().size() )
80 newActor -> GetProperty() -> SetColor( bbGetInputColour()[3*i] , bbGetInputColour()[3*i + 1] , bbGetInputColour()[3*i + 2] );
81 last_valid_color_index = 3*i;
84 newActor -> GetProperty() -> SetColor( bbGetInputColour()[last_valid_color_index] , bbGetInputColour()[last_valid_color_index + 1] , bbGetInputColour()[last_valid_color_index + 2] );
86 newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
87 newActor -> SetPosition( px,py,pz );
89 if ( bbGetInputTransform()!=NULL )
91 newActor->SetUserTransform( bbGetInputTransform() );
95 if (bbGetInputRenderer()!=NULL)
97 bbGetInputRenderer() -> AddActor( newActor );
102 if (sphereActor.size() != 0)
105 bbSetOutputActorList(sphereActor);
108 } // if (bbGetInputRenderer()!=NULL)
113 void SphereList::bbUserSetDefaultValues()
116 bbSetInputRenderer(NULL);
117 bbSetInputTransform(NULL);
119 // Sets default radio to 1.
120 std::vector<double> radio;
121 radio.push_back(1.0);
122 bbSetInputlstRadio(radio);
124 // Sets default colour to red.
125 std::vector<double> colour;
126 colour.push_back(1.0);
127 colour.push_back(0.0);
128 colour.push_back(0.0);
129 bbSetInputColour(colour);
131 bbSetInputOpacity(1.0);
135 void SphereList::bbUserInitializeProcessing()
140 void SphereList::bbUserFinalizeProcessing()
145 // EO namespace bbvtk