]> Creatis software - bbtk.git/commitdiff
#3008 BBTK Feature New Normal - Active option in box vtk::IsoSurfaceExtractor
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 22 Aug 2016 14:20:27 +0000 (16:20 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 22 Aug 2016 14:20:27 +0000 (16:20 +0200)
packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbg
packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbs
packages/vtk/src/bbvtkMarchingCubes.cxx
packages/vtk/src/bbvtkMarchingCubes.h
packages/vtk/src/bbvtkMeasureLength.cxx
packages/vtk/src/bbvtkMetaImageReader.xml
packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx
packages/vtk/src/bbvtkPolyDataToActor.cxx
packages/vtk/src/bbvtkPolyDataToActor.h
packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbg
packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbs

index a10d53f1d7c323f8f0988910f409af2acecb2331..ecb5e58f7d9e586327ce7e728e74c352b325169e 100644 (file)
@@ -15,7 +15,7 @@ COMPLEX_PORT
 Out
 -106.333698:-24.000230:-900.000000
 FIN_COMPLEX_PORT
-COMPLEXINPUTS:7
+COMPLEXINPUTS:8
 COMPLEX_PORT
 In
 12.336925:94.999712:-900.000000
@@ -44,7 +44,11 @@ COMPLEX_PORT
 BoxExecute
 -19.682203:95.133203:-900.000000
 FIN_COMPLEX_PORT
-BOXES:3
+COMPLEX_PORT
+active
+52.180776:96.404365:-900.000000
+FIN_COMPLEX_PORT
+BOXES:4
 BOX
 vtk:MarchingCubes:mc
 ISEXEC:FALSE
@@ -65,7 +69,13 @@ ISEXEC:FALSE
 PORT
 BoxProcessMode:"reactive"
 FIN_BOX
-CONNECTIONS:10
+BOX
+std:MagicBox:Box04
+ISEXEC:FALSE
+46.365909:66.717942:-900.000000
+91.940909:56.717942:-900.000000
+FIN_BOX
+CONNECTIONS:13
 CONNECTION
 mc:Out:polydatatoactor:In
 NumberOfControlPoints:0
@@ -96,4 +106,13 @@ NumberOfControlPoints:0
 CONNECTION
 Box03:BoxChange:polydatatoactor:BoxExecute
 NumberOfControlPoints:0
+CONNECTION
+active:active:Box04:In
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:mc:Active
+NumberOfControlPoints:0
+CONNECTION
+Box04:Out:polydatatoactor:Active
+NumberOfControlPoints:0
 APP_END
index 0a0add3670d6a01ae6c466bb78b65496d20ab464..7389224c2c3d70202da00d23e96bc55d9ba8c0d3 100644 (file)
@@ -22,9 +22,13 @@ new vtk:PolyDataToActor polydatatoactor
 new std:MultipleInputs Box03
   set Box03.BoxProcessMode "reactive"
 
+new std:MagicBox Box04
+
 
 connect mc.Out polydatatoactor.In
 connect Box03.BoxChange polydatatoactor.BoxExecute
+connect Box04.Out mc.Active
+connect Box04.Out polydatatoactor.Active
 
 # Complex input ports
 input In mc.In " "
@@ -34,6 +38,7 @@ input Colour polydatatoactor.Colour " "
 input Renderer polydatatoactor.Renderer " "
 input Transform polydatatoactor.Transform " "
 input BoxExecute Box03.In1 " "
+input active Box04.In " "
 
 # Complex output ports
 output Out polydatatoactor.Out " "
index 972c72f5d696c03abccfd0a0af810c98c9fa12a7..83f9b4d0eec2a8a3614255c86df2adde1c059270 100644 (file)
@@ -53,23 +53,33 @@ namespace bbvtk
 
        void MarchingCubes::Process()
        {
-               bbGetVtkObject()->SetValue(0, bbGetInputValue() );
-               if(bbGetInputComputeNormalsOn())
-                       bbGetVtkObject()->ComputeNormalsOn();
-               else
-                       bbGetVtkObject()->ComputeNormalsOff();
-
-               if(bbGetInputComputeScalarsOn())
-                       bbGetVtkObject()->ComputeScalarsOn();
-               else
-                       bbGetVtkObject()->ComputeScalarsOff();
-               bbGetVtkObject()->Update();             
+               if (bbGetInputActive()==true)
+               {
+                       bbGetVtkObject()->SetValue(0, bbGetInputValue() );
+
+                       if(bbGetInputComputeNormalsOn()) 
+                       {
+                               bbGetVtkObject()->ComputeNormalsOn();
+                       }else {
+                               bbGetVtkObject()->ComputeNormalsOff();
+                       }
+
+                       if(bbGetInputComputeScalarsOn())
+                       {
+                               bbGetVtkObject()->ComputeScalarsOn();
+                       }else{
+                               bbGetVtkObject()->ComputeScalarsOff();
+                       }
+
+                       bbGetVtkObject()->Update();             
+               }
        }
        
        //-----------------------------------------------------------------     
        void MarchingCubes::bbUserSetDefaultValues()
        {
                 BBTK_VTK_SET_DEFAULT_VALUES();
+               bbSetInputActive(true);
                bbSetInputValue(400);
                bbSetInputComputeNormalsOn(true);
                bbSetInputComputeScalarsOn(true);
index 6198ee99860b78b363f20af51fc3af8d1e9b1e2c..6d4245604785f670c79d4a92763bb4eb3b767e0a 100644 (file)
@@ -73,6 +73,7 @@ namespace bbvtk
                                 bbtk::AtomicBlackBox,
                                 vtkMarchingCubes);
 
+       BBTK_DECLARE_INPUT(Active,bool);
     BBTK_DECLARE_VTK_INPUT(In,vtkImageData *);
        BBTK_DECLARE_INPUT(Value,double);
        BBTK_DECLARE_INPUT(ComputeNormalsOn,bool);
@@ -112,6 +113,7 @@ namespace bbvtk
   BBTK_DESCRIPTION("Extracts an iso-surface of an image using the marching cubes algorithm (bbfication of vtkMarchingCubes)");
   BBTK_CATEGORY("image;mesh");
 
+  BBTK_INPUT(MarchingCubes,Active,"Active true/false (default true)",bool,"");
   BBTK_INPUT(MarchingCubes,In,"Image",vtkImageData*,"");
   BBTK_INPUT(MarchingCubes,Value,"Value of the iso-surface",double,"");
   BBTK_INPUT(MarchingCubes,ComputeNormalsOn,"Set the computation of normals",bool,"");
index 11326b71782d94761eedbf00dafaa786d40c418e..8cd7e4a037fa69d2f033cbd95514bfd8bd65f659 100644 (file)
@@ -13,11 +13,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(MeasureLength,bbtk::AtomicBlackBox);
 //===== 
 void MeasureLength::Process()
 {
-       std::cout << "RaC MeasureLength::Process START"<< std::endl;
-
        _points = bbGetInputPoints();
        _image  = bbGetInputImageData();
-
        double sumLength                = 0 ;
        double sumLengthVoxels  = 0 ;
        if(_image != NULL && _points->GetNumberOfPoints()>1)
@@ -86,11 +83,8 @@ void MeasureLength::Process()
                } // for
 
        } // if
-
        bbSetOutputLength( sqrt(sumLength) );
        bbSetOutputLengthVoxels( sqrt(sumLengthVoxels) );
-
-       std::cout << "RaC MeasureLength::Process END"<< std::endl;
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
index 45756654707bd866621fcbe553a310eccc4bb5b2..fd36427c76664c67bda78fa7a7917b856223fa92 100644 (file)
@@ -15,6 +15,7 @@
  
  <process><PRE>
    bbGetVtkObject()->SetFileName(bbGetInputIn().c_str());
+printf("EED MetaImageReader::Process  %s\n", bbGetInputIn().c_str() );
    bbGetVtkObject()->Update();
  </PRE></process>
 
index f2a84952f828fbed74dcb9211926abc9793604ff..154d8fe511df470530c4afe0e552d6e4e944eae2 100644 (file)
@@ -13,13 +13,9 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox);
 //===== 
 void PointsXYZtoVTKPoints::Process()
 {
-
-//std::cout << "RaC PointsXYZtoVTKPoints::Process START"<< std::endl;
        std::vector<int> lstPointsX = bbGetInputLstPointsX();
        std::vector<int> lstPointsY = bbGetInputLstPointsY();
        std::vector<int> lstPointsZ = bbGetInputLstPointsZ();
-
-
        if(_points==NULL)
        {
                _points=vtkPoints::New();
@@ -30,7 +26,6 @@ void PointsXYZtoVTKPoints::Process()
        point[0]=0;
        point[1]=0;
        point[2]=0;
-
        for (int i =0; i < lstPointsX.size(); ++i)
        {
                point[0]=lstPointsX[i];
@@ -39,9 +34,6 @@ void PointsXYZtoVTKPoints::Process()
                _points->InsertPoint(i,point);
        }
        bbSetOutputPoints(_points);
-
-std::cout << "RaC PointsXYZtoVTKPoints::Process END"<< std::endl;
-  
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
index d49a2949b670e82ad829317b29e209f6b70ad5d4..58852e83ed9df71d7b01f60835d83c4e7aff505b 100644 (file)
@@ -54,13 +54,14 @@ namespace bbvtk
 
    void PolyDataToActor::bbUserSetDefaultValues() 
    { 
-          firsttime=true;
+          actorAdded=false;
           std::vector<double> colour;
           colour.push_back(1.0);
           colour.push_back(1.0);
           colour.push_back(0.5);
           bbSetInputColour(colour);
 
+          bbSetInputActive(true);
           bbSetInputIn(NULL);
           bbSetInputRenderer(NULL);
           bbSetInputTransform(NULL);
@@ -104,42 +105,50 @@ namespace bbvtk
        
 //---------------------------------------------------------------------
 
-   void PolyDataToActor::DoProcess()
-   {      
-     polydatamapper->SetInput( bbGetInputIn() );
-     
-        vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
-        vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
-          
-     vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
-                                       bbGetInputColour()[1], 
-                                       bbGetInputColour()[2] );
-          
-     vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
-     
-     if ( bbGetInputTransform()!=NULL )
-     {
-        vtkactor->SetUserTransform( bbGetInputTransform() );
-     }
-
-     bbSetOutputOut( vtkactor );
-
-     // Interface Update
-     if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
-     {
-       firsttime=false;
-       bbGetInputRenderer()->AddActor( vtkactor );
-     }  // firsttime
-
-     if (bbGetInputScalarVisibility()==true )
-     {
-            polydatamapper->ScalarVisibilityOn();
-     } else {
-            polydatamapper->ScalarVisibilityOff();
-     } // ScalarVisibility
+       void PolyDataToActor::DoProcess()
+       {
 
-
-   }
+               if (bbGetInputActive()==true)
+               {
+                        polydatamapper->SetInput( bbGetInputIn() );
+                        vtkactor->GetProperty()->SetRepresentation( bbGetInputRepresentation() );
+                        vtkactor->GetProperty()->SetLineWidth( bbGetInputLineWidth() );
+                          
+                        vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  
+                                                       bbGetInputColour()[1], 
+                                                       bbGetInputColour()[2] );
+                                 
+                        vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
+                        
+                        if ( bbGetInputTransform()!=NULL )
+                        {
+                               vtkactor->SetUserTransform( bbGetInputTransform() );
+                        }
+
+                        bbSetOutputOut( vtkactor );
+
+                        // Interface Update
+                        if ((actorAdded==false) && (bbGetInputRenderer()!=NULL ))
+                        {
+                          actorAdded=true;
+                          bbGetInputRenderer()->AddActor( vtkactor );
+                        }  // actorAdded
+
+                        if (bbGetInputScalarVisibility()==true )
+                        {
+                                polydatamapper->ScalarVisibilityOn();
+                        } else {
+                                polydatamapper->ScalarVisibilityOff();
+                        } // ScalarVisibility
+               } else {
+                        // Interface Update
+                        if ((actorAdded==true) && (bbGetInputRenderer()!=NULL ))
+                        {
+                          actorAdded=false;
+                          bbGetInputRenderer()->RemoveActor( vtkactor );
+                        }  // actorAdded
+               } // Active
+       }
 
 
 
index 8705f83906abff678c39337053bad68cc8172d17..9dd2790b872f7dc6482bc71b99900e635aac147c 100644 (file)
@@ -72,13 +72,14 @@ namespace bbvtk
     : 
     public bbtk::AtomicBlackBox
   {
-    bool              firsttime;
+    bool              actorAdded;
     vtkPolyDataMapper *polydatamapper;
     vtkActor          *vtkactor; 
     
     
     BBTK_BLACK_BOX_INTERFACE(PolyDataToActor,bbtk::AtomicBlackBox);
     
+    BBTK_DECLARE_INPUT(Active,bool);
     BBTK_DECLARE_INPUT(In,vtkPolyData *);
     BBTK_DECLARE_INPUT(Opacity,double);
     BBTK_DECLARE_INPUT(Colour,std::vector<double>);
@@ -103,6 +104,7 @@ namespace bbvtk
   BBTK_CATEGORY("3D object creator");
   BBTK_INPUT(PolyDataToActor,In,"Input image",vtkPolyData*,"");
 
+  BBTK_INPUT(PolyDataToActor,Active,"Active true/false (default true)",bool,"");
   BBTK_INPUT(PolyDataToActor,Opacity,"Opacity",double,"");
   BBTK_INPUT(PolyDataToActor,Colour,"r g b",vectorcolour,"colour");
   BBTK_INPUT(PolyDataToActor,Renderer,"3D scene in which to insert the surface",vtkRenderer*,"");
index c353d2f9c9317327b823c09251508447683c2b4e..ca427133d8fa410d49bb07acb3634e0d7adae0ba 100644 (file)
@@ -13,7 +13,7 @@ PACKAGENAME:wxvtk
 COMPLEXOUTPUTS:3
 COMPLEX_PORT
 Out
-63.993992:-275.375244:-900.000000
+58.302298:-288.767464:-900.000000
 FIN_COMPLEX_PORT
 COMPLEX_PORT
 Widget
@@ -60,7 +60,7 @@ COMPLEX_PORT
 vtkRenderer
 350.000000:100.000000:-900.000000
 FIN_COMPLEX_PORT
-BOXES:9
+BOXES:10
 BOX
 wx:LayoutLine:controls
 ISEXEC:FALSE
@@ -137,7 +137,19 @@ ISEXEC:FALSE
 170.465036:-148.550905:-900.000000
 216.040036:-158.550905:-900.000000
 FIN_BOX
-CONNECTIONS:28
+BOX
+wx:CheckBox:Box10
+ISEXEC:FALSE
+134.946534:-6.270599:-900.000000
+180.521534:-16.270599:-900.000000
+PORT
+In:"false"
+PORT
+ReactiveOnKeystroke:"true"
+PORT
+Title:"Active"
+FIN_BOX
+CONNECTIONS:31
 CONNECTION
 isovalue:Out:Asurface:Isovalue
 NumberOfControlPoints:0
@@ -157,15 +169,6 @@ CONNECTION
 opacity:BoxChange:refresh:In2
 NumberOfControlPoints:0
 CONNECTION
-colour:Widget:controls:Widget3
-NumberOfControlPoints:0
-CONNECTION
-isovalue:Widget:controls:Widget1
-NumberOfControlPoints:0
-CONNECTION
-opacity:Widget:controls:Widget2
-NumberOfControlPoints:0
-CONNECTION
 Box09:Out:Asurface:Renderer
 NumberOfControlPoints:0
 CONNECTION
@@ -222,4 +225,22 @@ NumberOfControlPoints:0
 CONNECTION
 colour:BoxChange:refresh:In3
 NumberOfControlPoints:0
+CONNECTION
+Box10:BoxChange:refresh:In5
+NumberOfControlPoints:0
+CONNECTION
+Box10:Out:Asurface:active
+NumberOfControlPoints:0
+CONNECTION
+colour:Widget:controls:Widget4
+NumberOfControlPoints:0
+CONNECTION
+opacity:Widget:controls:Widget3
+NumberOfControlPoints:0
+CONNECTION
+isovalue:Widget:controls:Widget2
+NumberOfControlPoints:0
+CONNECTION
+Box10:Widget:controls:Widget1
+NumberOfControlPoints:0
 APP_END
index e2fd23867e6c41fbfd6440b6a590e15c6e452ffc..79599779d0737130b85ebdf1b43510097fd280a6 100644 (file)
@@ -45,6 +45,11 @@ new vtk:UpdateRender Box08
 
 new std:MagicBox Box09
 
+new wx:CheckBox Box10
+  set Box10.In "false"
+  set Box10.ReactiveOnKeystroke "true"
+  set Box10.Title "Active"
+
 
 connect isovalue.Out Asurface.Isovalue
 connect opacity.Out Adiv.In1
@@ -52,9 +57,6 @@ connect Adiv.Out Asurface.Opacity
 connect colour.Out Asurface.Colour
 connect isovalue.BoxChange refresh.In1
 connect opacity.BoxChange refresh.In2
-connect colour.Widget controls.Widget3
-connect isovalue.Widget controls.Widget1
-connect opacity.Widget controls.Widget2
 connect Box09.Out Asurface.Renderer
 connect Box09.Out Box08.Renderer
 connect opacity.BoxChange refresh.BoxExecute
@@ -62,6 +64,12 @@ connect refresh.BoxChange Asurface.BoxExecute
 connect refresh.BoxChange Box08.BoxExecute
 connect refresh.BoxChange Adiv.BoxExecute
 connect colour.BoxChange refresh.In3
+connect Box10.BoxChange refresh.In5
+connect Box10.Out Asurface.active
+connect colour.Widget controls.Widget4
+connect opacity.Widget controls.Widget3
+connect isovalue.Widget controls.Widget2
+connect Box10.Widget controls.Widget1
 
 # Complex input ports
 input Title controls.WinTitle " "