]> Creatis software - bbtk.git/commitdiff
*** empty log message ***
authorguigues <guigues>
Mon, 3 Mar 2008 13:33:50 +0000 (13:33 +0000)
committerguigues <guigues>
Mon, 3 Mar 2008 13:33:50 +0000 (13:33 +0000)
packages/std/src/bbstdDiv.xml [new file with mode: 0644]
packages/vtk/src/bbvtkSurface.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkSurface.h [new file with mode: 0644]
packages/wxvtk/bbs/appli/ExampleIsoSurfaceWithControls.bbs [new file with mode: 0644]
packages/wxvtk/bbs/boxes/bbIsoSurfaceWithControls.bbs [new file with mode: 0644]

diff --git a/packages/std/src/bbstdDiv.xml b/packages/std/src/bbstdDiv.xml
new file mode 100644 (file)
index 0000000..7a6ccfa
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<blackbox name="Div">
+
+  <author>laurent.guigues@creatis.insa-lyon.fr</author>
+  <description>Divides its inputs</description>
+  <category>math</category>
+
+  <input name="In1" type="double" description="Numerator"/>
+  <input name="In2" type="double" description="Denominator"/>
+  <output name="Out" type="double" description="Result"/>
+
+  <process><PRE>
+    bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() );
+  </PRE></process>
+  
+  <constructor><PRE>
+    bbSetInputIn1(0);
+    bbSetInputIn2(1);
+    bbSetOutputOut(0);
+  </PRE></constructor>    
+
+</blackbox>
+
diff --git a/packages/vtk/src/bbvtkSurface.cxx b/packages/vtk/src/bbvtkSurface.cxx
new file mode 100644 (file)
index 0000000..786aa79
--- /dev/null
@@ -0,0 +1,106 @@
+
+/*=========================================================================
+                                                                                
+  Program:   bbtk
+  Module:    $RCSfile: bbvtkSurface.cxx,v $
+  Language:  C++
+  Date:      $Date: 2008/03/03 13:33:50 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+/**
+ *  \file 
+ *  \brief 
+ */
+
+
+#ifdef _USE_VTK_
+
+#include "vtkProperty.h"
+
+#include "bbvtkSurface.h"
+#include "bbvtkPackage.h"
+
+namespace bbvtk
+{
+   BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Surface)
+   BBTK_USER_BLACK_BOX_IMPLEMENTATION(Surface,bbtk::AtomicBlackBox);
+
+   void Surface::bbUserConstructor() 
+   { 
+     Init();
+     std::vector<double> colour;
+     colour.push_back(1.0);
+     colour.push_back(1.0);
+     colour.push_back(0.5);
+     bbSetInputColour(colour);
+
+   }
+   void Surface::bbUserCopyConstructor() 
+   { 
+     Init();
+   }
+
+   void Surface::Init() 
+   { 
+     firsttime=true;
+
+         bbSetInputIn(NULL);
+     bbSetInputInVtkObject(NULL);
+     bbSetInputRenderer(NULL);
+     bbSetInputIsovalue(400);
+     bbSetInputOpacity(1);
+        
+        marchingcubes  = vtkMarchingCubes::New();
+     polydatamapper    = vtkPolyDataMapper::New();
+     vtkactor        = vtkActor::New();
+
+     polydatamapper->SetInput(marchingcubes->GetOutput());
+     vtkactor->SetMapper(polydatamapper);
+
+     polydatamapper->ScalarVisibilityOff();
+     polydatamapper->ImmediateModeRenderingOn();
+
+
+}
+
+//---------------------------------------------------------------------
+
+   void Surface::DoProcess()
+   {
+     //   bbGetInputIn()->Print(std::cout);
+      // Visualisation - result volume
+      marchingcubes->SetInput( bbGetInputIn() );
+      marchingcubes->SetValue(0,  bbGetInputIsovalue() );
+      marchingcubes->Update();
+
+   // if (_2_isoActorMC6!=NULL)
+   //  {
+   //   bbGetInputRenderer()->RemoveActor(vtkactor);
+   //  }
+  
+      vtkactor->GetProperty()->SetColor( bbGetInputColour()[0],  bbGetInputColour()[1], bbGetInputColour()[2] );
+
+      
+      vtkactor->GetProperty()->SetOpacity( bbGetInputOpacity() );
+          bbSetOutputOut( vtkactor );
+      
+      // Interface Update
+
+      if ((firsttime==true) && (bbGetInputRenderer()!=NULL ))
+      {
+        firsttime=false;
+            bbGetInputRenderer()->AddActor( vtkactor );
+      }
+   }
+} // EO namespace bbtk
+
+#endif //_USE_VTK_
diff --git a/packages/vtk/src/bbvtkSurface.h b/packages/vtk/src/bbvtkSurface.h
new file mode 100644 (file)
index 0000000..7691b37
--- /dev/null
@@ -0,0 +1,102 @@
+/*=========================================================================
+                                                                                
+  Program:   bbtk
+  Module:    $RCSfile: bbvtkSurface.h,v $
+  Language:  C++
+  Date:      $Date: 2008/03/03 13:33:50 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*//**
+ * \brief Short description in one line
+ * 
+ * Long description which 
+ * can span multiple lines
+ */
+/**
+ * \file 
+ * \brief Pattern for the definition of a new type of Node (header)
+ */
+/**
+ * \class bbtk::NodePatern 
+ * \brief Pattern for the definition of a new type of Node 
+ */
+
+
+#ifdef _USE_VTK_
+
+
+#ifndef __vtkSurface_h__
+#define __vtkSurface_h__
+
+#include "vtkImageData.h"
+#include "vtkRenderer.h"
+#include "vtkMarchingCubes.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkProp3D.h"
+#include "vtkActor.h"
+#include <vector>
+
+#include "bbtkAtomicBlackBox.h"
+
+namespace bbvtk
+{
+
+   class /*BBTK_EXPORT*/ Surface
+   : 
+   public bbtk::AtomicBlackBox
+   {
+      bool              firsttime;
+      vtkMarchingCubes  *marchingcubes;
+      vtkPolyDataMapper *polydatamapper;
+      vtkActor          *vtkactor; 
+
+
+      BBTK_USER_BLACK_BOX_INTERFACE(Surface,bbtk::AtomicBlackBox);
+
+      BBTK_DECLARE_INPUT(In,vtkImageData *);
+      BBTK_DECLARE_INPUT(InVtkObject,vtkObject *);
+      BBTK_DECLARE_INPUT(Isovalue,double);
+      BBTK_DECLARE_INPUT(Opacity,double);
+      BBTK_DECLARE_INPUT(Colour,std::vector<double>);
+      BBTK_DECLARE_INPUT(Renderer,vtkRenderer *);
+      BBTK_DECLARE_OUTPUT(Out,vtkProp3D *);
+
+      BBTK_PROCESS(DoProcess);
+      void DoProcess();
+
+      protected:
+      virtual void bbUserConstructor();
+      virtual void bbUserCopyConstructor();
+     void Init();
+};
+
+   BBTK_BEGIN_DESCRIBE_BLACK_BOX(Surface,bbtk::AtomicBlackBox);
+   BBTK_NAME("Surface");
+   BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
+   BBTK_DESCRIPTION("Construction of a vtkActor and add it to the 3D window");
+     typedef std::vector<double> vectorcolour;
+     BBTK_INPUT(Surface,In,"Image",vtkImageData*);
+     BBTK_INPUT(Surface,InVtkObject,"Image vtkObject",vtkObject*);
+     BBTK_INPUT(Surface,Isovalue,"Isovalue",double);
+     BBTK_INPUT(Surface,Opacity,"Opacity",double);
+     BBTK_INPUT(Surface,Colour,"r g b",vectorcolour);
+     BBTK_INPUT(Surface,Renderer,"3D window to add the actor (VTK)",vtkRenderer*);
+     BBTK_OUTPUT(Surface,Out,"Image",vtkProp3D *);
+
+   BBTK_END_DESCRIBE_BLACK_BOX(Surface);
+
+}// EO namespace bbtk
+
+
+#endif  //__Surface_h__
+
+#endif //_USE_VTK_
+
diff --git a/packages/wxvtk/bbs/appli/ExampleIsoSurfaceWithControls.bbs b/packages/wxvtk/bbs/appli/ExampleIsoSurfaceWithControls.bbs
new file mode 100644 (file)
index 0000000..95dcfbd
--- /dev/null
@@ -0,0 +1,39 @@
+include wxvtk/boxes/bbIsoSurfaceWithControls
+include vtk/boxes/bbLoadHola
+new IsoSurfaceWithControls surface1
+new IsoSurfaceWithControls surface2
+
+load wxvtk
+new Viewer3D viewer
+new LoadHola image
+
+connect image.Out surface1.In
+connect image.Out surface2.In
+connect surface1.Out viewer.In1
+connect surface2.Out viewer.In2
+new MultipleInputs refresh
+connect surface1.BoxChange refresh.In1
+connect surface2.BoxChange refresh.In2
+connect refresh.Out viewer.BoxExecute
+
+new LayoutLine main
+new LayoutLine controls
+connect viewer.Widget main.Widget1
+connect controls.Widget main.Widget2 
+connect surface1.Widget controls.Widget1 
+connect surface2.Widget controls.Widget2
+
+
+set surface1.Isovalue 100
+set surface1.Opacity 100
+set surface1.Colour "0.5 0 0"
+set surface1.Title "Iso-surface 1"
+
+set surface2.Isovalue 200
+set surface2.Opacity 20
+set surface2.Title "Iso-surface 2"
+
+
+#message All 9
+exec main
diff --git a/packages/wxvtk/bbs/boxes/bbIsoSurfaceWithControls.bbs b/packages/wxvtk/bbs/boxes/bbIsoSurfaceWithControls.bbs
new file mode 100644 (file)
index 0000000..ce95148
--- /dev/null
@@ -0,0 +1,67 @@
+load wx
+load vtk
+load std
+
+define IsoSurfaceWithControls
+  author "laurent.guigues@creatis.insa-lyon.fr"
+  description "Image iso-surface extractor with associated control panel (isovalue, opacity and colour)"
+  category "image;mesh;widget;viewer"
+
+  new LayoutLine controls
+  new LayoutLine sliders
+  new Surface surface
+  new Slider isovalue
+  new Slider opacity
+#  new CommandButton colourButton
+  new LayoutLine colourFrame
+  new ColourSelectorButton colour
+  new MultipleInputs refresh  
+  new Div div
+
+  connect sliders.Widget controls.Widget1
+  connect colourFrame.Widget controls.Widget2
+
+  connect colour.Widget colourFrame.Widget1
+#Button.Widget 
+  connect isovalue.Widget sliders.Widget1
+  connect opacity.Widget sliders.Widget2
+  
+  connect isovalue.Out surface.Isovalue
+  connect opacity.Out div.In1
+  set div.In2 100
+  connect div.Out surface.Opacity 
+  connect colour.Out surface.Colour
+
+  connect isovalue.BoxChange refresh.In1
+  connect opacity.BoxChange refresh.In2
+  connect colour.BoxChange refresh.In3
+
+#  connect colourButton.BoxChange colour.BoxExecute
+
+  set colourFrame.WinTitle "Colour"
+  set controls.Orientation 0
+  set isovalue.Title "Isovalue"
+  set opacity.Title "Opacity"
+  set opacity.Min 0
+  set opacity.Max 100
+  set opacity.In 100
+#  set colourButton.Label "Colour"
+
+
+  input Title controls.WinTitle "Title of the control panel" 
+  input In surface.In "Input image"
+
+  input Opacity opacity.In "Initial opacity"
+  input Isovalue isovalue.In "Initial isovalue"
+  input Colour colour.In "Initial colour"
+
+  input BoxExecute surface.BoxExecute "Box execution"
+
+  input Vertical controls.Orientation "Set to 1 to have controls arranged vertically"
+
+  output Out surface.Out "Output surface"
+  output BoxChange refresh.Out "BoxChange" 
+  output Widget controls.Widget "Widget"
+
+endefine