]> Creatis software - bbtk.git/commitdiff
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/bbtk
authorClaire Mouton <claire.mouton@creatis.insa-lyon.fr>
Wed, 16 Jan 2013 10:37:47 +0000 (11:37 +0100)
committerClaire Mouton <claire.mouton@creatis.insa-lyon.fr>
Wed, 16 Jan 2013 10:37:47 +0000 (11:37 +0100)
kernel/appli/bbPlugPackage/bbPlugPackage.cpp
packages/vtk/bbs/appli/exampleMeasureLength.bbg [new file with mode: 0644]
packages/vtk/bbs/appli/exampleMeasureLength.bbs [new file with mode: 0644]
packages/vtk/src/bbvtkBinaryOperations.h
packages/vtk/src/bbvtkMarchingCubes.cxx
packages/vtk/src/bbvtkMarchingCubes.h
packages/vtk/src/bbvtkMeasureLength.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkMeasureLength.h [new file with mode: 0644]
packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx [new file with mode: 0644]
packages/vtk/src/bbvtkPointsXYZtoVTKPoints.h [new file with mode: 0644]

index 6dbe260ceee2145ecebf4050db9175c7c8ba0509..bf6081451ad6b6d8844505f654b20e5884c5dc53 100644 (file)
@@ -42,7 +42,12 @@ int main(int argc, char **argv)
     }
 
   std::string path(argv[1]);
+  #ifdef WIN32
+  std::string fname = path + "\\bbtkPackage"; 
+  #else
   std::string fname = path + "/bbtkPackage"; 
+  #endif
+  
 
   if ( ! Utilities::FileExists( fname ) )
     {
@@ -54,6 +59,12 @@ int main(int argc, char **argv)
   f.open(fname.c_str());
   std::string pname;
   f >> pname;
+  while(pname[0] == '#')
+  {
+    getline(f, pname, '\n');
+    f >> pname;
+  }
+    
   f.close();
   
   
@@ -70,7 +81,7 @@ int main(int argc, char **argv)
   command += "\"";
 #endif
   command += " " + pname + " -q";
-
+  std::cout << "executing '" << command << "'" << std::endl;
 if ( system ( command.c_str() ) )
  {
     std::cout << "An error occured while running '" 
@@ -91,7 +102,7 @@ if ( system ( command.c_str() ) )
   command += "\"";
 #endif
   command += " -q";
+ std::cout << "executing '" << command << "'" << std::endl;
   if ( ! system ( command.c_str() ) )
     {
       std::cout << "Package '" 
diff --git a/packages/vtk/bbs/appli/exampleMeasureLength.bbg b/packages/vtk/bbs/appli/exampleMeasureLength.bbg
new file mode 100644 (file)
index 0000000..f1ac03b
--- /dev/null
@@ -0,0 +1,119 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:example
+DESCRIPTION:Evaluates the sum of the Euclidean distances among the points in the list following their order. Put some points in the image using the Points Widget and the click on Evaluate Length button. 
+AUTHOR:Ricardo A Corredor
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:8
+BOX
+creaMaracasVisu:ShowNPoints:Box00
+ISEXEC:TRUE
+-51.309471:11.810349:-900.000000
+-2.989471:1.810349:-900.000000
+PORT
+WinTitle:"Points Widget"
+PORT
+WinWidth:"200"
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box02
+ISEXEC:TRUE
+-26.721828:47.483487:-900.000000
+33.918172:37.483487:-900.000000
+PORT
+WinTitle:"Image Viewer"
+FIN_BOX
+BOX
+wx:CommandButton:Box03
+ISEXEC:TRUE
+-128.980270:47.281481:-900.000000
+-83.405270:37.281481:-900.000000
+PORT
+Label:"Evaluate length..."
+PORT
+WinHeight:"200"
+PORT
+WinTitle:"Measure Length"
+PORT
+WinWidth:"200"
+FIN_BOX
+BOX
+vtk:MeasureLength:Box04
+ISEXEC:FALSE
+-112.956474:-50.441103:-900.000000
+-67.381474:-60.441103:-900.000000
+FIN_BOX
+BOX
+vtk:PointsXYZtoVTKPoints:Box05
+ISEXEC:FALSE
+-54.277786:-36.674180:-900.000000
+16.897214:-46.674180:-900.000000
+FIN_BOX
+BOX
+wx:OutputText:Box06
+ISEXEC:FALSE
+-113.407849:-80.683196:-900.000000
+-67.832849:-90.683196:-900.000000
+FIN_BOX
+BOX
+vtk:MetaImageReader:Box07
+ISEXEC:FALSE
+-58.531222:83.907503:-900.000000
+-12.956222:73.907503:-900.000000
+FIN_BOX
+BOX
+wx:FileSelector:Box08
+ISEXEC:FALSE
+-57.766108:111.196570:-900.000000
+-12.191108:101.196570:-900.000000
+PORT
+Message:"Select an image ..."
+PORT
+Title:"Select an image ..."
+FIN_BOX
+CONNECTIONS:13
+CONNECTION
+Box02:Renderer1:Box00:Renderer
+NumberOfControlPoints:0
+CONNECTION
+Box02:Point:Box00:In
+NumberOfControlPoints:0
+CONNECTION
+Box02:BoxChange:Box00:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box00:lstPointsX:Box05:LstPointsX
+NumberOfControlPoints:0
+CONNECTION
+Box00:lstPointsY:Box05:LstPointsY
+NumberOfControlPoints:0
+CONNECTION
+Box00:lstPointsZ:Box05:LstPointsZ
+NumberOfControlPoints:0
+CONNECTION
+Box05:Points:Box04:Points
+NumberOfControlPoints:0
+CONNECTION
+Box03:BoxChange:Box06:BoxExecute
+NumberOfControlPoints:0
+CONNECTION
+Box04:Length:Box06:In
+NumberOfControlPoints:0
+CONNECTION
+Box07:Out:Box02:In
+NumberOfControlPoints:0
+CONNECTION
+Box07:Out:Box04:ImageData
+NumberOfControlPoints:0
+CONNECTION
+Box07:Out:Box00:Image
+NumberOfControlPoints:0
+CONNECTION
+Box08:Out:Box07:In
+NumberOfControlPoints:0
+APP_END
diff --git a/packages/vtk/bbs/appli/exampleMeasureLength.bbs b/packages/vtk/bbs/appli/exampleMeasureLength.bbs
new file mode 100644 (file)
index 0000000..4ffc5a7
--- /dev/null
@@ -0,0 +1,76 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script
+# - /home/corredor/Software/CreaTools/All_Dec2012/creatools_source/bbtk/packages/vtk/bbs/appli/exampleMeasureLength.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include creaMaracasVisu
+include wx
+include vtk
+
+author "Ricardo A Corredor"
+description "Evaluates the sum of the Euclidean distances among the points in the list following their order. Put some points in the image using the Points Widget and the click on Evaluate Length button. "
+category "example"
+
+new ShowNPoints Box00
+  set Box00.WinTitle "Points Widget"
+  set Box00.WinWidth "200"
+
+new ViewerNV Box02
+  set Box02.WinTitle "Image Viewer"
+
+new CommandButton Box03
+  set Box03.Label "Evaluate length..."
+  set Box03.WinHeight "200"
+  set Box03.WinTitle "Measure Length"
+  set Box03.WinWidth "200"
+
+new MeasureLength Box04
+
+new PointsXYZtoVTKPoints Box05
+
+new OutputText Box06
+
+new MetaImageReader Box07
+
+new FileSelector Box08
+  set Box08.Message "Select an image ..."
+  set Box08.Title "Select an image ..."
+
+
+connect Box02.Renderer1 Box00.Renderer
+
+connect Box02.Point Box00.In
+
+connect Box02.BoxChange Box00.BoxExecute
+
+connect Box00.lstPointsX Box05.LstPointsX
+
+connect Box00.lstPointsY Box05.LstPointsY
+
+connect Box00.lstPointsZ Box05.LstPointsZ
+
+connect Box05.Points Box04.Points
+
+connect Box03.BoxChange Box06.BoxExecute
+
+connect Box04.Length Box06.In
+
+connect Box07.Out Box02.In
+
+connect Box07.Out Box04.ImageData
+
+connect Box07.Out Box00.Image
+
+connect Box08.Out Box07.In
+
+
+
+# Complex input ports
+exec Box00
+exec Box02
+exec Box03
index b9d8683e8923bac0d692449ae5d4cf4fd1b235eb..9e6bd034774f0807f5a07860a6adcb814bfe350c 100644 (file)
@@ -68,7 +68,7 @@ class bbvtk_EXPORT BinaryOperations
 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryOperations,bbtk::AtomicBlackBox);
 BBTK_NAME("BinaryOperations");
 BBTK_AUTHOR("Info-Dev");
-BBTK_DESCRIPTION("Math operation between two images");
+BBTK_DESCRIPTION("Arithmetic operations between two images: add, substract, multiply, divide");
 BBTK_CATEGORY("filter");
 BBTK_INPUT(BinaryOperations,In1,"first image to be operated",vtkImageData*,"NULL default");
 BBTK_INPUT(BinaryOperations,In2,"second image to be operated",vtkImageData*,"NULL default");
index ebadda0e286a5e67c68cb5a38d9b8f83f21ea33f..972c72f5d696c03abccfd0a0af810c98c9fa12a7 100644 (file)
@@ -54,6 +54,15 @@ 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();             
        }
        
@@ -62,6 +71,8 @@ namespace bbvtk
        {
                 BBTK_VTK_SET_DEFAULT_VALUES();
                bbSetInputValue(400);
+               bbSetInputComputeNormalsOn(true);
+               bbSetInputComputeScalarsOn(true);
        }
        
        //-----------------------------------------------------------------     
index 083e34b4245228244107c1a1919e8714f9266771..6198ee99860b78b363f20af51fc3af8d1e9b1e2c 100644 (file)
@@ -75,6 +75,8 @@ namespace bbvtk
 
     BBTK_DECLARE_VTK_INPUT(In,vtkImageData *);
        BBTK_DECLARE_INPUT(Value,double);
+       BBTK_DECLARE_INPUT(ComputeNormalsOn,bool);
+       BBTK_DECLARE_INPUT(ComputeScalarsOn,bool);
     BBTK_DECLARE_VTK_OUTPUT(Out,vtkPolyData *);
 
     // For the 'Value' parameter, the standard bbtk macro does not work 
@@ -112,6 +114,8 @@ namespace bbvtk
 
   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,"");
+  BBTK_INPUT(MarchingCubes,ComputeScalarsOn,"Set the computation of scalars",bool,"");
   BBTK_OUTPUT(MarchingCubes,Out,"Output iso-surface",vtkPolyData*,"");
   
   BBTK_END_DESCRIBE_BLACK_BOX(MarchingCubes);
diff --git a/packages/vtk/src/bbvtkMeasureLength.cxx b/packages/vtk/src/bbvtkMeasureLength.cxx
new file mode 100644 (file)
index 0000000..1b2a645
--- /dev/null
@@ -0,0 +1,95 @@
+//===== 
+// 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)
+//===== 
+#include "bbvtkMeasureLength.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MeasureLength)
+BBTK_BLACK_BOX_IMPLEMENTATION(MeasureLength,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+void MeasureLength::Process()
+{
+       //std::cout << "RaC MeasureLength::Process START"<< std::endl;
+
+       _points = bbGetInputPoints();
+       _image = bbGetInputImageData();
+
+       double sumLength =0;
+       if(_image != NULL && _points->GetNumberOfPoints()>1)
+       {
+
+               double spc[3];
+               double origin[3];
+
+               _image->GetSpacing(spc);
+               _image->GetOrigin(origin);
+
+               double* first;
+               first = _points->GetPoint(0);
+
+               double firstWorld[3];
+               firstWorld[0] = first[0]*spc[0] + origin[0];
+               firstWorld[1] = first[1]*spc[1] + origin[1];
+               firstWorld[2] = first[2]*spc[2] + origin[2];
+
+
+
+               for(int i = 1; i<_points->GetNumberOfPoints();i++)
+               {
+                       double* second;
+                       second = _points->GetPoint(i);
+                       double secondWorld[3];
+                       secondWorld[0] = second[0]*spc[0] + origin[0];
+                       secondWorld[1] = second[1]*spc[1] + origin[1];
+                       secondWorld[2] = second[2]*spc[2] + origin[2];
+
+                       double XFactor = secondWorld[0]-firstWorld[0];
+                       double YFactor = secondWorld[1]-firstWorld[1];
+                       double ZFactor = secondWorld[2]-firstWorld[2];
+                       sumLength += XFactor*XFactor + YFactor*YFactor + ZFactor*ZFactor;
+
+                       firstWorld[0] = secondWorld[0];
+                       firstWorld[1] = secondWorld[1];
+                       firstWorld[2] = secondWorld[2];
+
+               }
+       }
+
+       bbSetOutputLength(sumLength);
+
+       //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)
+//===== 
+void MeasureLength::bbUserSetDefaultValues()
+{
+       bbSetOutputLength(0);
+}
+//===== 
+// 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)
+//===== 
+void MeasureLength::bbUserInitializeProcessing()
+{
+
+
+
+  
+}
+//===== 
+// 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)
+//===== 
+void MeasureLength::bbUserFinalizeProcessing()
+{
+
+
+  
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkMeasureLength.h b/packages/vtk/src/bbvtkMeasureLength.h
new file mode 100644 (file)
index 0000000..d7110e9
--- /dev/null
@@ -0,0 +1,57 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbvtkMeasureLength_h_INCLUDED__
+#define __bbvtkMeasureLength_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+
+#include "iostream"
+#include "vector"
+#include "math.h"
+
+//VTK
+#include "vtkPoints.h"
+#include "vtkImageData.h"
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT MeasureLength
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(MeasureLength,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+  BBTK_DECLARE_INPUT(Points,vtkPoints*);
+  BBTK_DECLARE_INPUT(ImageData,vtkImageData*);
+  BBTK_DECLARE_OUTPUT(Length,double);
+  BBTK_PROCESS(Process);
+  void Process();
+private:
+  vtkImageData* _image;
+  vtkPoints* _points;
+//===== 
+// 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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(MeasureLength,bbtk::AtomicBlackBox);
+BBTK_NAME("MeasureLength");
+BBTK_AUTHOR("Ricardo A Corredor");
+BBTK_DESCRIPTION("Evaluates the sum of the Euclidean distances among the points in the list following their order.");
+BBTK_CATEGORY("");
+BBTK_INPUT(MeasureLength,Points,"List of points",vtkPoints*,"");
+BBTK_INPUT(MeasureLength,ImageData,"Set an image if you want real lentgh (usually in mm)",vtkImageData*,"");
+BBTK_OUTPUT(MeasureLength,Length,"Sum of the Euclidean distances among the points",double,"");
+BBTK_END_DESCRIBE_BLACK_BOX(MeasureLength);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkMeasureLength_h_INCLUDED__
+
diff --git a/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.cxx
new file mode 100644 (file)
index 0000000..0a825a2
--- /dev/null
@@ -0,0 +1,70 @@
+//===== 
+// 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)
+//===== 
+#include "bbvtkPointsXYZtoVTKPoints.h"
+#include "bbvtkPackage.h"
+namespace bbvtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,PointsXYZtoVTKPoints)
+BBTK_BLACK_BOX_IMPLEMENTATION(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+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();
+       else
+               _points->Reset();//CLEAR
+
+       for (int i =0; i < lstPointsX.size(); ++i)
+       {
+               double point[3];
+               point[0]=lstPointsX[i];
+               point[1]=lstPointsY[i];
+               point[2]=lstPointsZ[i];
+               _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)
+//===== 
+void PointsXYZtoVTKPoints::bbUserSetDefaultValues()
+{
+
+
+  
+}
+//===== 
+// 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)
+//===== 
+void PointsXYZtoVTKPoints::bbUserInitializeProcessing()
+{
+
+
+  
+}
+//===== 
+// 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)
+//===== 
+void PointsXYZtoVTKPoints::bbUserFinalizeProcessing()
+{
+
+       _points->Delete();
+  
+}
+}
+// EO namespace bbvtk
+
+
diff --git a/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.h b/packages/vtk/src/bbvtkPointsXYZtoVTKPoints.h
new file mode 100644 (file)
index 0000000..2a513ff
--- /dev/null
@@ -0,0 +1,57 @@
+//===== 
+// 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)
+//===== 
+#ifndef __bbvtkPointsXYZtoVTKPoints_h_INCLUDED__
+#define __bbvtkPointsXYZtoVTKPoints_h_INCLUDED__
+#include "bbvtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+
+#include "iostream"
+#include "vector"
+
+//VTK
+#include "vtkPoints.h"
+
+namespace bbvtk
+{
+
+class bbvtk_EXPORT PointsXYZtoVTKPoints
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox);
+//===== 
+// 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)
+//===== 
+  BBTK_DECLARE_INPUT( LstPointsX, std::vector<int> );
+  BBTK_DECLARE_INPUT( LstPointsY, std::vector<int> );
+  BBTK_DECLARE_INPUT( LstPointsZ, std::vector<int> );
+  BBTK_DECLARE_OUTPUT(Points,vtkPoints*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+private:
+  vtkPoints* _points;
+//===== 
+// 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)
+//===== 
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PointsXYZtoVTKPoints,bbtk::AtomicBlackBox);
+BBTK_NAME("PointsXYZtoVTKPoints");
+BBTK_AUTHOR("Ricardo A Corredor");
+BBTK_DESCRIPTION("Transforms independent vectors of X, Y and Z coordinates into a vtkPoints object");
+BBTK_CATEGORY("");
+BBTK_INPUT(PointsXYZtoVTKPoints,LstPointsX,"List of points X-coordinate", std::vector<int> ,"");
+BBTK_INPUT(PointsXYZtoVTKPoints,LstPointsY,"List of points Y-coordinate", std::vector<int> ,"");
+BBTK_INPUT(PointsXYZtoVTKPoints,LstPointsZ,"List of points Z-coordinate", std::vector<int> ,"");
+BBTK_OUTPUT(PointsXYZtoVTKPoints,Points,"Points in vtkPoints",vtkPoints*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(PointsXYZtoVTKPoints);
+//===== 
+// 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)
+//===== 
+}
+// EO namespace bbvtk
+
+#endif // __bbvtkPointsXYZtoVTKPoints_h_INCLUDED__
+