2 // 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)
4 #include "bbcreaVtkMagnitudVector.h"
5 #include "bbcreaVtkPackage.h"
6 #include "creaVtk_MACROS.h"
10 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MagnitudVector)
11 BBTK_BLACK_BOX_IMPLEMENTATION(MagnitudVector,bbtk::AtomicBlackBox);
13 // 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)
15 void MagnitudVector::Process()
18 // THE MAIN PROCESSING METHOD BODY
19 // Here we simply set the input 'In' value to the output 'Out'
20 // And print out the output value
21 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
22 // void bbSet{Input|Output}NAME(const TYPE&)
23 // const TYPE& bbGet{Input|Output}NAME() const
25 // * NAME is the name of the input/output
26 // (the one provided in the attribute 'name' of the tag 'input')
27 // * TYPE is the C++ type of the input/output
28 // (the one provided in the attribute 'type' of the tag 'input')
30 // bbSetOutputOut( bbGetInputIn() );
31 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
33 if ( (bbGetInputvX()!=NULL) && (bbGetInputvY()!=NULL) && (bbGetInputvZ()!=NULL) )
35 if (imageoutput!=NULL)
37 imageoutput->Delete();
39 imageoutput = vtkImageData::New();
40 imageoutput->Initialize();
41 imageoutput->SetSpacing( bbGetInputvX()->GetSpacing() );
44 //EED 2017-01-01 Migration VTK7
45 #if (VTK_MAJOR_VERSION <= 5)
46 bbGetInputvX()->GetWholeExtent(ext );
48 #if (VTK_MAJOR_VERSION >= 6)
49 bbGetInputvX()->GetExtent(ext );
51 dim[0]=ext[1]-ext[0]+1;
52 dim[1]=ext[3]-ext[2]+1;
53 dim[2]=ext[5]-ext[4]+1;
54 imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
55 imageoutput->SetExtent( ext );
56 //EED 2017-01-01 Migration VTK7
57 #if (VTK_MAJOR_VERSION <= 5)
58 imageoutput->SetWholeExtent( ext );
59 imageoutput->SetScalarType( VTK_DOUBLE );
60 imageoutput->AllocateScalars();
62 #if (VTK_MAJOR_VERSION >= 6)
63 imageoutput->AllocateScalars( VTK_DOUBLE,1 );
66 DEF_POINTER_IMAGE_VTK_CREA(vvX,ssvX,pvX,stvX,bbGetInputvX() )
67 DEF_POINTER_IMAGE_VTK_CREA(vvY,ssvY,pvY,stvY,bbGetInputvY() )
68 DEF_POINTER_IMAGE_VTK_CREA(vvZ,ssvZ,pvZ,stvZ,bbGetInputvZ() )
69 DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput )
70 long int i, size=dim[0]*dim[1]*dim[2];
71 #pragma omp parallel for
72 for (i=0; i<size; i++)
74 GETVALUE2_VTK_CREA(vvX,pvX,stvX,i)
75 GETVALUE2_VTK_CREA(vvY,pvY,stvY,i)
76 GETVALUE2_VTK_CREA(vvZ,pvZ,stvZ,i)
77 if ( (vvX==0) && (vvY==0) &&(vvZ==0) )
79 SETVALUE2_VTK_CREA( 0 ,pOut,stOut,i)
81 SETVALUE2_VTK_CREA( sqrt(vvX*vvX + vvY*vvY + vvZ*vvZ),pOut,stOut,i)
82 } // if vvX vvY vvZ != 0
88 bbSetOutputOut( imageoutput );
91 // 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)
93 void MagnitudVector::bbUserSetDefaultValues()
96 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
97 // Here we initialize the input 'In' to 0
105 // 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)
107 void MagnitudVector::bbUserInitializeProcessing()
111 // THE INITIALIZATION METHOD BODY :
113 // but this is where you should allocate the internal/output pointers
119 // 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)
121 void MagnitudVector::bbUserFinalizeProcessing()
124 // THE FINALIZATION METHOD BODY :
126 // but this is where you should desallocate the internal/output pointers
131 // EO namespace bbcreaVtk