From: Eduardo DAVILA Date: Mon, 22 Aug 2016 14:20:27 +0000 (+0200) Subject: #3008 BBTK Feature New Normal - Active option in box vtk::IsoSurfaceExtractor X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d024c7fa8b822877956e4dee7fe98ea749415d47;p=bbtk.git #3008 BBTK Feature New Normal - Active option in box vtk::IsoSurfaceExtractor --- diff --git a/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbg b/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbg index a10d53f..ecb5e58 100644 --- a/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbg +++ b/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbg @@ -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 diff --git a/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbs b/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbs index 0a0add3..7389224 100644 --- a/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbs +++ b/packages/vtk/bbs/boxes/bbIsoSurfaceExtractor.bbs @@ -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 " " diff --git a/packages/vtk/src/bbvtkMarchingCubes.cxx b/packages/vtk/src/bbvtkMarchingCubes.cxx index 972c72f..83f9b4d 100644 --- a/packages/vtk/src/bbvtkMarchingCubes.cxx +++ b/packages/vtk/src/bbvtkMarchingCubes.cxx @@ -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); diff --git a/packages/vtk/src/bbvtkMarchingCubes.h b/packages/vtk/src/bbvtkMarchingCubes.h index 6198ee9..6d42456 100644 --- a/packages/vtk/src/bbvtkMarchingCubes.h +++ b/packages/vtk/src/bbvtkMarchingCubes.h @@ -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,""); diff --git a/packages/vtk/src/bbvtkMeasureLength.cxx b/packages/vtk/src/bbvtkMeasureLength.cxx index 11326b7..8cd7e4a 100644 --- a/packages/vtk/src/bbvtkMeasureLength.cxx +++ b/packages/vtk/src/bbvtkMeasureLength.cxx @@ -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) diff --git a/packages/vtk/src/bbvtkMetaImageReader.xml b/packages/vtk/src/bbvtkMetaImageReader.xml index 4575665..fd36427 100644 --- a/packages/vtk/src/bbvtkMetaImageReader.xml +++ b/packages/vtk/src/bbvtkMetaImageReader.xml @@ -15,6 +15,7 @@
    bbGetVtkObject()->SetFileName(bbGetInputIn().c_str());
+printf("EED MetaImageReader::Process  %s\n", bbGetInputIn().c_str() );
    bbGetVtkObject()->Update();
  
diff --git a/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx index f2a8495..154d8fe 100644 --- a/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx +++ b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx @@ -13,13 +13,9 @@ BBTK_BLACK_BOX_IMPLEMENTATION(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox); //===== void PointsXYZtoVTKPoints::Process() { - -//std::cout << "RaC PointsXYZtoVTKPoints::Process START"<< std::endl; std::vector lstPointsX = bbGetInputLstPointsX(); std::vector lstPointsY = bbGetInputLstPointsY(); std::vector 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) diff --git a/packages/vtk/src/bbvtkPolyDataToActor.cxx b/packages/vtk/src/bbvtkPolyDataToActor.cxx index d49a294..58852e8 100644 --- a/packages/vtk/src/bbvtkPolyDataToActor.cxx +++ b/packages/vtk/src/bbvtkPolyDataToActor.cxx @@ -54,13 +54,14 @@ namespace bbvtk void PolyDataToActor::bbUserSetDefaultValues() { - firsttime=true; + actorAdded=false; std::vector 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 + } diff --git a/packages/vtk/src/bbvtkPolyDataToActor.h b/packages/vtk/src/bbvtkPolyDataToActor.h index 8705f83..9dd2790 100644 --- a/packages/vtk/src/bbvtkPolyDataToActor.h +++ b/packages/vtk/src/bbvtkPolyDataToActor.h @@ -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); @@ -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*,""); diff --git a/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbg b/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbg index c353d2f..ca42713 100644 --- a/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbg +++ b/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbg @@ -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 diff --git a/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbs b/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbs index e2fd238..7959977 100644 --- a/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbs +++ b/packages/wxvtk/bbs/boxes/bbIsoSurfaceWidget.bbs @@ -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 " "