]> Creatis software - bbtk.git/blobdiff - packages/vtk/src/bbvtkSphereList.cxx
no message
[bbtk.git] / packages / vtk / src / bbvtkSphereList.cxx
diff --git a/packages/vtk/src/bbvtkSphereList.cxx b/packages/vtk/src/bbvtkSphereList.cxx
new file mode 100644 (file)
index 0000000..8e552d7
--- /dev/null
@@ -0,0 +1,137 @@
+#include "bbvtkSphereList.h"
+#include "bbvtkPackage.h"
+
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkRenderWindow.h>
+
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SphereList)
+BBTK_BLACK_BOX_IMPLEMENTATION(SphereList,bbtk::AtomicBlackBox);
+
+void SphereList::Process()
+{
+
+        int iMin, iMax;
+       double px = 0.0;
+       double py = 0.0;
+       double pz = 0.0;
+       double radio;
+       double spc[3];
+
+       if (bbGetInputRenderer()!=NULL)
+       {
+               spc[0]=spc[1]=spc[2]=1;
+
+               iMin=0;
+               iMax=bbGetInputlstPointX().size();
+               printf("EED SphereList::Process   iMax=%d \n", iMax);
+               // 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.
+               for ( int i=iMin ; i<iMax ; i=i+1 )
+               {
+                       px = bbGetInputlstPointX()[i]*spc[0];
+                       if (bbGetInputlstPointY().size() == bbGetInputlstPointX().size() )
+                         {
+                           py = bbGetInputlstPointY()[i]*spc[1];
+                         }
+                       if (bbGetInputlstPointZ().size() == bbGetInputlstPointX().size() )
+                         {                     
+                           pz = bbGetInputlstPointZ()[i]*spc[2];
+                         }
+
+                       // If the number of elements in the radio list is different from the number of X coordinates, the radio value is set to 1.
+                       if (bbGetInputlstRadio().size() == bbGetInputlstPointX().size() )
+                         {
+                           radio = bbGetInputlstRadio()[i];
+                         }
+                       else
+                         {
+                           if  (bbGetInputlstRadio().size()>=1){
+                              radio = bbGetInputlstRadio()[ bbGetInputlstRadio().size() - 1 ];
+                               } else {
+                                       radio = 1.0;
+                               }
+                         }
+
+                       // Sphere
+                       vtkSphereSource * newSphere =  vtkSphereSource::New();
+                       vtkSphere.push_back(newSphere);
+
+                       newSphere -> SetThetaResolution(20);
+                       newSphere -> SetPhiResolution(20);
+                       newSphere -> SetRadius(radio); 
+
+                       vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
+                       sphereMapper.push_back(newMapper);
+                       newMapper -> SetInput( newSphere -> GetOutput() );
+       
+                       vtkActor * newActor = vtkActor::New();
+                       sphereActor.push_back(newActor);
+                       newActor -> SetMapper(newMapper);
+                       newActor -> SetOrigin(0, 0, 0);
+                       newActor -> GetProperty() -> SetColor( bbGetInputColour()[0] , bbGetInputColour()[1] , bbGetInputColour()[2] );
+                       newActor -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
+                       newActor -> SetPosition( px,py,pz );
+       
+                       if ( bbGetInputTransform()!=NULL )
+                       {
+                               newActor->SetUserTransform( bbGetInputTransform() );
+                       }
+       
+
+                       if (bbGetInputRenderer()!=NULL)
+                         {
+                           bbGetInputRenderer() -> AddActor( newActor );
+                         }
+
+               } // for
+
+               if (sphereActor.size() != 0)
+                 {
+                   // Sets the output.
+                   bbSetOutputActorList(sphereActor);
+                 }
+
+       } // if (bbGetInputRenderer()!=NULL)
+
+
+}
+
+void SphereList::bbUserSetDefaultValues()
+{
+  bbSetInputRenderer(NULL);
+  bbSetInputTransform(NULL);
+  // Sets default radio to 1.
+  std::vector<double> radio;
+  radio.push_back(1.0);
+  bbSetInputlstRadio(radio);
+
+  // Sets default colour to red.
+  std::vector<double> colour;
+  colour.push_back(1.0);
+  colour.push_back(0.0);
+  colour.push_back(0.0);
+  bbSetInputColour(colour);
+  
+  bbSetInputOpacity(1.0);
+
+}
+
+void SphereList::bbUserInitializeProcessing()
+{
+}
+
+void SphereList::bbUserFinalizeProcessing()
+{
+  
+}
+}
+// EO namespace bbvtk
+
+