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];
72 long int k1omp=(double)(size-1)*0.0;
73 long int k2omp=(double)(size-1)*0.2;
74 long int k3omp=(double)(size-1)*0.4;
75 long int k4omp=(double)(size-1)*0.6;
76 long int k5omp=(double)(size-1)*0.8;
77 long int k6omp=(double)(size-1)*1.0;
78 printf("EED MagnitudVector::Process (with openmp)\n");
79 #pragma omp parallel for
80 for (i=0; i<size; i++)
82 if ( (k1omp==i) || (k2omp==i) || (k3omp==i) ||
83 (k4omp==i) || (k5omp==i) || (k6omp==i) ) { printf(" %d%\n", (int)(((double)i/(double)(size-1))*100 )); }
87 GETVALUE2_VTK_CREA(vvXtmpOMP,pvX,stvX,i)
88 GETVALUE2_VTK_CREA(vvYtmpOMP,pvY,stvY,i)
89 GETVALUE2_VTK_CREA(vvZtmpOMP,pvZ,stvZ,i)
90 if ( (vvXtmpOMP==0) && (vvYtmpOMP==0) &&(vvZtmpOMP==0) )
92 SETVALUE2_VTK_CREA( 0 ,pOut,stOut,i)
94 SETVALUE2_VTK_CREA( sqrt(vvXtmpOMP*vvXtmpOMP + vvYtmpOMP*vvYtmpOMP + vvZtmpOMP*vvZtmpOMP) ,pOut,stOut,i)
95 } // if vvX vvY vvZ != 0
101 bbSetOutputOut( imageoutput );
104 // 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)
106 void MagnitudVector::bbUserSetDefaultValues()
109 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
110 // Here we initialize the input 'In' to 0
118 // 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)
120 void MagnitudVector::bbUserInitializeProcessing()
124 // THE INITIALIZATION METHOD BODY :
126 // but this is where you should allocate the internal/output pointers
132 // 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)
134 void MagnitudVector::bbUserFinalizeProcessing()
137 // THE FINALIZATION METHOD BODY :
139 // but this is where you should desallocate the internal/output pointers
144 // EO namespace bbcreaVtk