]> Creatis software - bbtk.git/commitdiff
#3463 Bug SphereLst box Refresh
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 7 Jun 2021 17:25:08 +0000 (19:25 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 7 Jun 2021 17:25:08 +0000 (19:25 +0200)
packages/vtk/src/bbvtkSphereList.cxx
packages/vtk/src/bbvtkSphereList.h

index cde4561ad0c8eb6e629f2c7bc3a26c3afa8d2fcd..b8519fbfa32f9122536846c7ec9884d0cffc2fd9 100644 (file)
@@ -98,20 +98,19 @@ void SphereList::GetColor(int i, double &cr,double &cg,double &cb)
 
 void SphereList::Process()
 {
-printf("EED SphereList::Process Start\n");
-
+/*
        if (bbGetInputRenderer()!=NULL)
        {
-               int sizeLstX=bbGetInputlstPointX().size();      
-               int sizeLstY=bbGetInputlstPointY().size();
-               int sizeLstZ=bbGetInputlstPointZ().size();
-               int sizeLstActors=sphereActor.size();
+               int sizeLstX            = bbGetInputlstPointX().size(); 
+               int sizeLstY            = bbGetInputlstPointY().size();
+               int sizeLstZ            = bbGetInputlstPointZ().size();
+               int sizeLstActors       = sphereActor.size();
                if ((sizeLstX==sizeLstY) &&(sizeLstX==sizeLstZ))
                {
+                       int i,diff;
                        if (sizeLstActors>sizeLstX)
                        {
-                               int i;
-                               int diff=sizeLstActors-sizeLstX;
+                               diff=sizeLstActors-sizeLstX;
                                for (i=0;i<diff;i++)
                                {
                                        bbGetInputRenderer()->RemoveActor( sphereActor[0] );
@@ -124,8 +123,7 @@ printf("EED SphereList::Process Start\n");
 
                        if (sizeLstActors<sizeLstX)
                        {
-                               int i;
-                               int diff=sizeLstX-sizeLstActors;
+                               diff=sizeLstX-sizeLstActors;
                                for (i=0;i<diff;i++)
                                {
                                        // Sphere
@@ -157,7 +155,7 @@ printf("EED SphereList::Process Start\n");
                        } // if size
 
                        // Refresh data
-               for (int i = 0; i < sphereActor.size() ; i++)
+               for (i = 0; i < sphereActor.size() ; i++)
                {
                                double px = 0.0;
                                double py = 0.0;
@@ -188,7 +186,81 @@ printf("EED SphereList::Process Start\n");
        }// if Renderer
 
 //====================================================================
+*/
+
+       if (bbGetInputRenderer()!=NULL)
+       {
+               int sizeLstX            = bbGetInputlstPointX().size(); 
+               int sizeLstY            = bbGetInputlstPointY().size();
+               int sizeLstZ            = bbGetInputlstPointZ().size();
+               int sizeLstActors       = sphereActor.size();
+               if ((sizeLstX==sizeLstY) &&(sizeLstX==sizeLstZ))
+               {
+                       int i;
+                       double px,py,pz;
+                       double cr,cg,cb;
+                       for ( i=0 ; i<sizeLstActors ; i++ )
+                       {
+                               bbGetInputRenderer()->RemoveActor( sphereActor[i] );
+                               vtkspheresourceLst[i]->Delete();
+                               vtkpolydatamaperLst[i]->Delete();
+                               sphereActor[i]->Delete();
+                       } // for 
+                       vtkspheresourceLst.clear();
+                       vtkpolydatamaperLst.clear();
+                       sphereActor.clear();
+                       
+                       
+                       for (i=0;i<sizeLstX;i++)
+                       {
+                               // Sphere
+                               vtkSphereSource * newSphere = vtkSphereSource::New();
+                               vtkspheresourceLst.push_back(newSphere);
+                               newSphere -> SetThetaResolution(20);
+                               newSphere -> SetPhiResolution(20);
+                               newSphere -> SetRadius( 1 ); 
+                               vtkPolyDataMapper * newMapper = vtkPolyDataMapper::New();
+                               vtkpolydatamaperLst.push_back(newMapper);
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+                               newMapper -> SetInput( newSphere -> GetOutput() );      
+#else
+                               newSphere -> Update();
+                               newMapper -> SetInputData( newSphere -> GetOutput() );  
+#endif
+
+                               vtkActor * newActor = vtkActor::New();
+                               sphereActor.push_back(newActor);
+                               newActor -> SetMapper(newMapper);
+                               newActor -> SetOrigin(0, 0, 0);                         
+                               if ( bbGetInputTransform()!=NULL )
+                               {
+                                       newActor->SetUserTransform( bbGetInputTransform() );
+                               }
+                               bbGetInputRenderer()->AddActor( newActor );
+                       } // for
+
+
+                       // Refresh data
+               for (i = 0; i < sphereActor.size() ; i++)
+               {
+                               GetPoint(i, px,py,pz);
+                               GetColor(i, cr,cg,cb);
+                               sphereActor[i] ->SetPosition( px,py,pz );
+                sphereActor[i] -> GetProperty() -> SetOpacity( bbGetInputOpacity() );
+                sphereActor[i] -> GetProperty() -> SetColor( cr,cg,cb );
+                vtkspheresourceLst[i] -> SetRadius( GetRadio(i) ); 
+                       vtkspheresourceLst[i] -> Update();
+               } // for i
+                       
+               if (sphereActor.size() != 0)
+            {
+               // Sets the output.
+               bbSetOutputActorList(sphereActor);
+               }
 
+               } // sizeLstX sizeLstY sizeLstZ 
+       } // if Renderer
 }
 
 
index 070da9519e575347b8a23ae63fa3b85d157b2e02..89b471f692088c1a550c0c1db4a77c7c73e25797 100644 (file)
@@ -62,6 +62,7 @@ class bbvtk_EXPORT SphereList
   void Process();
 
   std::vector<vtkActor *> sphereActor;
+  std::vector<vtkPolyDataMapper *>vtkpolydatamaperLst;
   std::vector<vtkSphereSource *> vtkspheresourceLst;
 
 private: