]> Creatis software - creaVtk.git/commitdiff
2387 creaVtk Feature New Normal New box, lib, script ImageDataStructuredPoints 2014...
authorctorres <carlos.torres@creatis.insa-lyon.fr>
Fri, 6 Jun 2014 15:04:27 +0000 (17:04 +0200)
committerctorres <carlos.torres@creatis.insa-lyon.fr>
Fri, 6 Jun 2014 15:04:27 +0000 (17:04 +0200)
bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbg [new file with mode: 0644]
bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbs [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.h [new file with mode: 0644]
lib/creaVtk/vtkImageDataStrucPoints.cpp [new file with mode: 0644]
lib/creaVtk/vtkImageDataStrucPoints.h [new file with mode: 0644]

diff --git a/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbg b/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbg
new file mode 100644 (file)
index 0000000..1d262bc
--- /dev/null
@@ -0,0 +1,56 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/ctorres/Documents/creatis/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:FALSE
+COMPLEXINPUTS:0
+BOXES:5
+BOX
+creaVtk:ImageDataStructuredPoints:Box00
+ISEXEC:TRUE
+-23.896150:21.040635:-900.000000
+47.278850:11.040635:-900.000000
+FIN_BOX
+BOX
+creaImageIO:ImagesChooserDialogBox:Box01
+ISEXEC:FALSE
+-117.977848:82.058478:-900.000000
+-46.802848:72.058478:-900.000000
+FIN_BOX
+BOX
+creaImageIO:ImagesChooserDialogBox:Box02
+ISEXEC:FALSE
+-37.722853:81.156736:-900.000000
+33.452147:71.156736:-900.000000
+FIN_BOX
+BOX
+creaImageIO:ImagesChooserDialogBox:Box03
+ISEXEC:FALSE
+40.127497:79.954414:-900.000000
+111.302497:69.954414:-900.000000
+FIN_BOX
+BOX
+creaMaracasVisu:ViewerNV:Box04
+ISEXEC:TRUE
+-54.555361:-9.017415:-900.000000
+6.084639:-19.017415:-900.000000
+FIN_BOX
+CONNECTIONS:4
+CONNECTION
+Box01:Out:Box00:X
+NumberOfControlPoints:0
+CONNECTION
+Box02:Out:Box00:Y
+NumberOfControlPoints:0
+CONNECTION
+Box03:Out:Box00:Z
+NumberOfControlPoints:0
+CONNECTION
+Box01:Out:Box04:In
+NumberOfControlPoints:0
+APP_END
diff --git a/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbs b/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbs
new file mode 100644 (file)
index 0000000..e06fdce
--- /dev/null
@@ -0,0 +1,42 @@
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script
+# - /home/ctorres/Documents/creatis/creaVtk/bbtk_creaVtk_PKG/bbs/appli/exampleImageDataStructuresPoints.bbs
+# ----------------------------------
+
+# BBTK GEditor Script
+# ----------------------
+
+include std
+include itkvtk
+include creaVtk
+include creaImageIO
+include creaMaracasVisu
+
+author "Author ??"
+description "Description ??"
+category "<VOID>"
+
+new ImageDataStructuredPoints Box00
+
+new ImagesChooserDialogBox Box01
+
+new ImagesChooserDialogBox Box02
+
+new ImagesChooserDialogBox Box03
+
+new ViewerNV Box04
+
+
+connect Box01.Out Box00.X
+
+connect Box02.Out Box00.Y
+
+connect Box03.Out Box00.Z
+
+connect Box01.Out Box04.In
+
+
+
+# Complex input ports
+exec Box00
+exec Box04
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.cxx
new file mode 100644 (file)
index 0000000..20c25c7
--- /dev/null
@@ -0,0 +1,50 @@
+//===== 
+// 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 "bbcreaVtkImageDataStructuredPoints.h"
+#include "bbcreaVtkPackage.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageDataStructuredPoints)
+BBTK_BLACK_BOX_IMPLEMENTATION(ImageDataStructuredPoints,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 ImageDataStructuredPoints::Process()
+{
+               vtkImageData* imageX = bbGetInputX();
+               vtkImageData* imageY = bbGetInputY();
+               vtkImageData* imageZ = bbGetInputZ(); 
+               
+               vtkImageDataStrucPoints idsp;
+
+               idsp.joinComponents(imageX, imageY, imageZ);    
+               bbSetOutputImageEnsemble( idsp.getStructuredPoints() );
+      
+}
+//===== 
+// 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 ImageDataStructuredPoints::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 ImageDataStructuredPoints::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 ImageDataStructuredPoints::bbUserFinalizeProcessing()
+{
+
+}
+}
+// EO namespace bbcreaVtk
+
+
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.h b/bbtk_creaVtk_PKG/src/bbcreaVtkImageDataStructuredPoints.h
new file mode 100644 (file)
index 0000000..93d6d40
--- /dev/null
@@ -0,0 +1,52 @@
+//===== 
+// 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 __bbcreaVtkImageDataStructuredPoints_h_INCLUDED__
+#define __bbcreaVtkImageDataStructuredPoints_h_INCLUDED__
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+#include "vtkImageData.h"
+#include "vtkStructuredPoints.h"
+#include "vtkImageDataStrucPoints.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT ImageDataStructuredPoints
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(ImageDataStructuredPoints,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(X, vtkImageData*);
+  BBTK_DECLARE_INPUT(Y, vtkImageData*);
+  BBTK_DECLARE_INPUT(Z, vtkImageData*);
+  BBTK_DECLARE_OUTPUT(ImageEnsemble,  vtkStructuredPoints*);
+  BBTK_PROCESS(Process);
+  void Process();
+//===== 
+// 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(ImageDataStructuredPoints,bbtk::AtomicBlackBox);
+BBTK_NAME("ImageDataStructuredPoints");
+BBTK_AUTHOR("Carlos Torres");
+BBTK_DESCRIPTION("No Description.");
+BBTK_CATEGORY("empty");
+BBTK_INPUT(ImageDataStructuredPoints,X,"Image X",vtkImageData*,"");
+BBTK_INPUT(ImageDataStructuredPoints,Y,"Image Y",vtkImageData*,"");
+BBTK_INPUT(ImageDataStructuredPoints,Z,"Image Z",vtkImageData*,"");
+BBTK_OUTPUT(ImageDataStructuredPoints,ImageEnsemble,"Image Ensemble",vtkStructuredPoints*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(ImageDataStructuredPoints);
+//===== 
+// 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 bbcreaVtk
+
+#endif // __bbcreaVtkImageDataStructuredPoints_h_INCLUDED__
+
diff --git a/lib/creaVtk/vtkImageDataStrucPoints.cpp b/lib/creaVtk/vtkImageDataStrucPoints.cpp
new file mode 100644 (file)
index 0000000..69ac58a
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sante)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+*/
+
+#include "vtkImageDataStrucPoints.h"
+
+vtkImageDataStrucPoints::vtkImageDataStrucPoints()
+{
+}
+
+vtkImageDataStrucPoints::~vtkImageDataStrucPoints()
+{
+}
+void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* imageY, vtkImageData* imageZ)
+{
+       imageY->Modified();
+       imageY->Update();
+       int ext[6];
+       imageY->GetWholeExtent(ext);
+       int dim[3];
+  double spc[3];;
+  dim[0]=ext[1]-ext[0]+1;
+  dim[1]=ext[3]-ext[2]+1;
+  dim[2]=ext[5]-ext[4]+1;      
+       std::cout<<"dim "<< dim[0] <<" "<< dim[1] <<" "<< dim[2] <<std::endl;
+
+       imageY->GetSpacing(spc);
+
+       vtkDoubleArray *arrayX;
+       vtkDoubleArray *arrayY;
+       vtkDoubleArray *arrayZ;
+
+   unsigned char *ptrUCharX = (unsigned char *)imageX->GetScalarPointer();
+   unsigned char *ptrUCharY = (unsigned char *)imageY->GetScalarPointer();
+   unsigned char *ptrUCharZ = (unsigned char *)imageZ->GetScalarPointer();
+
+        long int sizeimage = dim[0]*dim[1]*dim[2];
+
+        vtkDoubleArray *array =  vtkDoubleArray::New();
+        array->SetNumberOfTuples(sizeimage);
+        array->SetNumberOfComponents(3);
+        array->Allocate(sizeimage*3, 100 ); // ???
+        array->SetName("velocity");
+
+        double vx;
+        double vy;
+        double vz;
+
+  int i;
+       for( i = 0 ; i < sizeimage ; i++ )
+       {
+                       vx = *ptrUCharX;
+                       vy = *ptrUCharY;
+                       vz = *ptrUCharZ;
+                       ptrUCharX++;
+                       ptrUCharY++;
+                       ptrUCharZ++;
+       array->SetTuple3(i,vx, vy , vz );
+       } // for i
+
+
+
+       _structuredPoints = vtkStructuredPoints::New();
+       _structuredPoints->SetDimensions(dim[0], dim[1], dim[2]);
+       _structuredPoints->SetSpacing(spc);
+       _structuredPoints->SetScalarTypeToFloat();
+       _structuredPoints->SetNumberOfScalarComponents(1);
+       _structuredPoints->GetPointData()->SetVectors(array);
+       _structuredPoints->GetPointData()->SetNumberOfTuples(sizeimage);
+
+}
+
+vtkStructuredPoints* vtkImageDataStrucPoints::getStructuredPoints()
+{
+               return _structuredPoints;
+}
+
diff --git a/lib/creaVtk/vtkImageDataStrucPoints.h b/lib/creaVtk/vtkImageDataStrucPoints.h
new file mode 100644 (file)
index 0000000..d5dd52c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sante)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+*/
+
+#ifndef _VTKIMAGEDATASTRUCPOINTS_H_
+#define _VTKIMAGEDATASTRUCPOINTS_H_
+#include "vtkImageData.h"
+#include "vtkStructuredPoints.h"
+#include "vtkDoubleArray.h"
+#include "vtkPointData.h"
+
+
+class vtkImageDataStrucPoints
+{
+
+public :
+  vtkImageDataStrucPoints();
+  ~vtkImageDataStrucPoints();
+       void joinComponents(vtkImageData* imageX, vtkImageData* imageY, vtkImageData* imageZ);
+       vtkStructuredPoints* getStructuredPoints();
+
+       vtkStructuredPoints* _structuredPoints;
+
+protected:
+
+private:
+
+};
+
+//-end of _VTKIMAGEDATASTRUCPOINTS_H_------------------------------------------------------
+#endif