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()
25 if (bbGetInputRenderer()!=NULL)
27 spc[0]=spc[1]=spc[2]=1;
30 iMax=bbGetInputlstPointX().size();
31 printf("EED SphereList::Process iMax=%d \n", iMax);
32 // 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.
33 for ( int i=iMin ; i<iMax ; i=i+1 )
35 px = bbGetInputlstPointX()[i]*spc[0];
36 if (bbGetInputlstPointY().size() == bbGetInputlstPointX().size() )
38 py = bbGetInputlstPointY()[i]*spc[1];
40 if (bbGetInputlstPointZ().size() == bbGetInputlstPointX().size() )
42 pz = bbGetInputlstPointZ()[i]*spc[2];
45 // If the number of elements in the radio list is different from the number of X coordinates, the radio value is set to 1.
46 if (bbGetInputlstRadio().size() == bbGetInputlstPointX().size() )
48 radio = bbGetInputlstRadio()[i];
52 if (bbGetInputlstRadio().size()>=1){
53 radio = bbGetInputlstRadio()[ bbGetInputlstRadio().size() - 1 ];
60 vtkSphereSource * newSphere = vtkSphereSource::New();
61 vtkSphere.push_back(newSphere);
63 newSphere -> SetThetaResolution(20);
64 newSphere -> SetPhiResolution(20);
65 newSphere -> SetRadius(radio);
67 vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
68 sphereMapper.push_back(newMapper);
69 newMapper -> SetInput( newSphere -> GetOutput() );
71 vtkActor * newActor = vtkActor::New();
72 sphereActor.push_back(newActor);
73 newActor -> SetMapper(newMapper);
74 newActor -> SetOrigin(0, 0, 0);
75 newActor -> GetProperty() -> SetColor( bbGetInputColour()[0] , bbGetInputColour()[1] , bbGetInputColour()[2] );
76 newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
77 newActor -> SetPosition( px,py,pz );
79 if ( bbGetInputTransform()!=NULL )
81 newActor->SetUserTransform( bbGetInputTransform() );
85 if (bbGetInputRenderer()!=NULL)
87 bbGetInputRenderer() -> AddActor( newActor );
92 if (sphereActor.size() != 0)
95 bbSetOutputActorList(sphereActor);
98 } // if (bbGetInputRenderer()!=NULL)
103 void SphereList::bbUserSetDefaultValues()
106 bbSetInputRenderer(NULL);
107 bbSetInputTransform(NULL);
109 // Sets default radio to 1.
110 std::vector<double> radio;
111 radio.push_back(1.0);
112 bbSetInputlstRadio(radio);
114 // Sets default colour to red.
115 std::vector<double> colour;
116 colour.push_back(1.0);
117 colour.push_back(0.0);
118 colour.push_back(0.0);
119 bbSetInputColour(colour);
121 bbSetInputOpacity(1.0);
125 void SphereList::bbUserInitializeProcessing()
130 void SphereList::bbUserFinalizeProcessing()
135 // EO namespace bbvtk