]> Creatis software - creaVtk.git/commitdiff
#3261 creaVtk Feature New Normal - box MagnitudVector
authorEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 29 May 2019 12:24:02 +0000 (14:24 +0200)
committerEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 29 May 2019 12:24:02 +0000 (14:24 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.cxx [new file with mode: 0644]
bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.h [new file with mode: 0644]

diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.cxx
new file mode 100644 (file)
index 0000000..c409205
--- /dev/null
@@ -0,0 +1,133 @@
+//===== 
+// 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 "bbcreaVtkMagnitudVector.h"
+#include "bbcreaVtkPackage.h"
+#include "creaVtk_MACROS.h"
+namespace bbcreaVtk
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MagnitudVector)
+BBTK_BLACK_BOX_IMPLEMENTATION(MagnitudVector,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 MagnitudVector::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+//   Here we simply set the input 'In' value to the output 'Out'
+//   And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+//    void bbSet{Input|Output}NAME(const TYPE&)
+//    const TYPE& bbGet{Input|Output}NAME() const 
+//    Where :
+//    * NAME is the name of the input/output
+//      (the one provided in the attribute 'name' of the tag 'input')
+//    * TYPE is the C++ type of the input/output
+//      (the one provided in the attribute 'type' of the tag 'input')
+
+//    bbSetOutputOut( bbGetInputIn() );
+//    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+       if ( (bbGetInputvX()!=NULL) && (bbGetInputvY()!=NULL) && (bbGetInputvZ()!=NULL) )
+       {
+               if (imageoutput!=NULL) 
+               {
+                       imageoutput->Delete();
+               }       
+               imageoutput = vtkImageData::New();
+               imageoutput->Initialize();
+               imageoutput->SetSpacing( bbGetInputvX()->GetSpacing() );
+               int dim[3];
+               int ext[6];
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
+               bbGetInputvX()->GetWholeExtent(ext );
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+               bbGetInputvX()->GetExtent(ext );
+#endif
+               dim[0]=ext[1]-ext[0]+1;
+               dim[1]=ext[3]-ext[2]+1;
+               dim[2]=ext[5]-ext[4]+1;
+               imageoutput->SetDimensions(  dim[0], dim[1], dim[2] );
+               imageoutput->SetExtent( ext );
+//EED 2017-01-01 Migration VTK7
+#if (VTK_MAJOR_VERSION <= 5) 
+               imageoutput->SetWholeExtent( ext );
+               imageoutput->SetScalarType( VTK_DOUBLE );       
+               imageoutput->AllocateScalars();
+#endif
+#if (VTK_MAJOR_VERSION >= 6) 
+               imageoutput->AllocateScalars( VTK_DOUBLE,1 );
+#endif
+
+               DEF_POINTER_IMAGE_VTK_CREA(vvX,ssvX,pvX,stvX,bbGetInputvX() )   
+               DEF_POINTER_IMAGE_VTK_CREA(vvY,ssvY,pvY,stvY,bbGetInputvY() )   
+               DEF_POINTER_IMAGE_VTK_CREA(vvZ,ssvZ,pvZ,stvZ,bbGetInputvZ() )   
+               DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput )  
+               long int i, size=dim[0]*dim[1]*dim[2];
+#pragma omp parallel for
+               for (i=0; i<size; i++)
+               {
+                       GETVALUE2_VTK_CREA(vvX,pvX,stvX,i) 
+                       GETVALUE2_VTK_CREA(vvY,pvY,stvY,i) 
+                       GETVALUE2_VTK_CREA(vvZ,pvZ,stvZ,i) 
+                       if ( (vvX==0) && (vvY==0) &&(vvZ==0) ) 
+                       {
+                               SETVALUE2_VTK_CREA( 0 ,pOut,stOut,i)
+                       } else {
+                               SETVALUE2_VTK_CREA( sqrt(vvX*vvX + vvY*vvY + vvZ*vvZ),pOut,stOut,i)
+                       } // if vvX  vvY  vvZ  != 0
+
+               } // for i
+
+       }//  vX vY vZ != NULL
+
+       bbSetOutputOut( imageoutput );
+}
+//===== 
+// 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 MagnitudVector::bbUserSetDefaultValues()
+{
+
+//  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
+//    Here we initialize the input 'In' to 0
+       imageoutput=NULL;
+   bbSetInputvX(NULL);
+   bbSetInputvY(NULL);
+   bbSetInputvZ(NULL);
+  
+}
+//===== 
+// 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 MagnitudVector::bbUserInitializeProcessing()
+{
+
+       imageoutput=NULL;
+//  THE INITIALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should allocate the internal/output pointers 
+//    if any 
+
+  
+}
+//===== 
+// 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 MagnitudVector::bbUserFinalizeProcessing()
+{
+
+//  THE FINALIZATION METHOD BODY :
+//    Here does nothing 
+//    but this is where you should desallocate the internal/output pointers 
+//    if any
+  
+}
+}
+// EO namespace bbcreaVtk
+
+
diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.h b/bbtk_creaVtk_PKG/src/bbcreaVtkMagnitudVector.h
new file mode 100644 (file)
index 0000000..3db2693
--- /dev/null
@@ -0,0 +1,55 @@
+//===== 
+// 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 __bbcreaVtkMagnitudVector_h_INCLUDED__
+#define __bbcreaVtkMagnitudVector_h_INCLUDED__
+
+#include "bbcreaVtk_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+#include "vtkImageData.h"
+
+namespace bbcreaVtk
+{
+
+class bbcreaVtk_EXPORT MagnitudVector
+ : 
+   public bbtk::AtomicBlackBox
+{
+  BBTK_BLACK_BOX_INTERFACE(MagnitudVector,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(vX,vtkImageData*);
+  BBTK_DECLARE_INPUT(vY,vtkImageData*);
+  BBTK_DECLARE_INPUT(vZ,vtkImageData*);
+  BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
+  BBTK_PROCESS(Process);
+  void Process();
+
+       vtkImageData* imageoutput;
+
+//===== 
+// 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(MagnitudVector,bbtk::AtomicBlackBox);
+  BBTK_NAME("MagnitudVector");
+  BBTK_AUTHOR("InfoDev");
+  BBTK_DESCRIPTION("No Description.");
+  BBTK_CATEGORY("empty");
+  BBTK_INPUT(MagnitudVector,vX,"component X of the vector",vtkImageData*,"");
+  BBTK_INPUT(MagnitudVector,vY,"component Y of the vector",vtkImageData*,"");
+  BBTK_INPUT(MagnitudVector,vZ,"component Z of the vector",vtkImageData*,"");
+  BBTK_OUTPUT(MagnitudVector,Out,"Image with the Magnitud",vtkImageData*,"");
+BBTK_END_DESCRIBE_BLACK_BOX(MagnitudVector);
+//===== 
+// 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 // __bbcreaVtkMagnitudVector_h_INCLUDED__
+