2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #include "bbvtkSphereList.h"
29 #include "bbvtkPackage.h"
31 #include <vtkPolyDataMapper.h>
32 #include <vtkProperty.h>
33 #include <vtkRenderWindow.h>
38 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SphereList)
39 BBTK_BLACK_BOX_IMPLEMENTATION(SphereList,bbtk::AtomicBlackBox);
41 void SphereList::Process()
51 int last_valid_color_index = 0;
53 if (bbGetInputRenderer()!=NULL)
55 if (bbGetInputSpacing().size()==3)
57 spc[0]=bbGetInputSpacing()[0];
58 spc[1]=bbGetInputSpacing()[1];
59 spc[2]=bbGetInputSpacing()[2];
61 spc[0]=spc[1]=spc[2]=1;
65 iMax=bbGetInputlstPointX().size();
66 printf("EED SphereList::Process iMax=%d \n", iMax);
67 // 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.
68 for ( int i=iMin ; i<iMax ; i=i+1 )
70 px = bbGetInputlstPointX()[i]*spc[0];
71 if (bbGetInputlstPointY().size() == bbGetInputlstPointX().size() )
73 py = bbGetInputlstPointY()[i]*spc[1];
75 if (bbGetInputlstPointZ().size() == bbGetInputlstPointX().size() )
77 pz = bbGetInputlstPointZ()[i]*spc[2];
80 // If the number of elements in the radio list is different from the number of X coordinates, the radio value is set to 1.
81 if (bbGetInputlstRadio().size() == bbGetInputlstPointX().size() )
83 radio = bbGetInputlstRadio()[i];
87 if (bbGetInputlstRadio().size()>=1){
88 radio = bbGetInputlstRadio()[ bbGetInputlstRadio().size() - 1 ];
95 vtkSphereSource * newSphere = vtkSphereSource::New();
96 vtkSphere.push_back(newSphere);
98 newSphere -> SetThetaResolution(20);
99 newSphere -> SetPhiResolution(20);
100 newSphere -> SetRadius(radio);
102 vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
103 sphereMapper.push_back(newMapper);
104 newMapper -> SetInput( newSphere -> GetOutput() );
106 vtkActor * newActor = vtkActor::New();
107 sphereActor.push_back(newActor);
108 newActor -> SetMapper(newMapper);
109 newActor -> SetOrigin(0, 0, 0);
111 unsigned int j = 3*i +2;
112 if (j < bbGetInputColour().size() )
114 newActor -> GetProperty() -> SetColor( bbGetInputColour()[3*i] , bbGetInputColour()[3*i + 1] , bbGetInputColour()[3*i + 2] );
115 last_valid_color_index = 3*i;
118 newActor -> GetProperty() -> SetColor( bbGetInputColour()[last_valid_color_index] , bbGetInputColour()[last_valid_color_index + 1] , bbGetInputColour()[last_valid_color_index + 2] );
120 newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
121 newActor -> SetPosition( px,py,pz );
123 if ( bbGetInputTransform()!=NULL )
125 newActor->SetUserTransform( bbGetInputTransform() );
129 if (bbGetInputRenderer()!=NULL)
131 bbGetInputRenderer() -> AddActor( newActor );
136 if (sphereActor.size() != 0)
139 bbSetOutputActorList(sphereActor);
142 } // if (bbGetInputRenderer()!=NULL)
147 void SphereList::bbUserSetDefaultValues()
150 bbSetInputRenderer(NULL);
151 bbSetInputTransform(NULL);
153 // Sets default radio to 1.
154 std::vector<double> radio;
155 radio.push_back(1.0);
156 bbSetInputlstRadio(radio);
158 // Sets default colour to red.
159 std::vector<double> colour;
160 colour.push_back(1.0);
161 colour.push_back(0.0);
162 colour.push_back(0.0);
163 bbSetInputColour(colour);
165 // Sets default spacing.
166 std::vector<double> spacing;
167 spacing.push_back(1.0);
168 spacing.push_back(1.0);
169 spacing.push_back(1.0);
170 bbSetInputSpacing(spacing);
172 bbSetInputOpacity(1.0);
176 void SphereList::bbUserInitializeProcessing()
181 void SphereList::bbUserFinalizeProcessing()
186 // EO namespace bbvtk