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"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MagnitudVector)
13 BBTK_BLACK_BOX_IMPLEMENTATION(MagnitudVector,bbtk::AtomicBlackBox);
15 // 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)
17 void MagnitudVector::Process()
20 // THE MAIN PROCESSING METHOD BODY
21 // Here we simply set the input 'In' value to the output 'Out'
22 // And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 // void bbSet{Input|Output}NAME(const TYPE&)
25 // const TYPE& bbGet{Input|Output}NAME() const
27 // * NAME is the name of the input/output
28 // (the one provided in the attribute 'name' of the tag 'input')
29 // * TYPE is the C++ type of the input/output
30 // (the one provided in the attribute 'type' of the tag 'input')
32 // bbSetOutputOut( bbGetInputIn() );
33 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35 if ( (bbGetInputvX()!=NULL) && (bbGetInputvY()!=NULL) && (bbGetInputvZ()!=NULL) )
37 if (imageoutput!=NULL)
39 imageoutput->Delete();
41 imageoutput = vtkImageData::New();
42 imageoutput->Initialize();
43 imageoutput->SetSpacing( bbGetInputvX()->GetSpacing() );
46 //EED 2017-01-01 Migration VTK7
47 #if (VTK_MAJOR_VERSION <= 5)
48 bbGetInputvX()->GetWholeExtent(ext );
50 #if (VTK_MAJOR_VERSION >= 6)
51 bbGetInputvX()->GetExtent(ext );
53 dim[0]=ext[1]-ext[0]+1;
54 dim[1]=ext[3]-ext[2]+1;
55 dim[2]=ext[5]-ext[4]+1;
56 imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
57 imageoutput->SetExtent( ext );
58 //EED 2017-01-01 Migration VTK7
59 #if (VTK_MAJOR_VERSION <= 5)
60 imageoutput->SetWholeExtent( ext );
61 imageoutput->SetScalarType( VTK_DOUBLE );
62 imageoutput->AllocateScalars();
64 #if (VTK_MAJOR_VERSION >= 6)
65 imageoutput->AllocateScalars( VTK_DOUBLE,1 );
68 DEF_POINTER_IMAGE_VTK_CREA(vvX,ssvX,pvX,stvX,bbGetInputvX() )
69 DEF_POINTER_IMAGE_VTK_CREA(vvY,ssvY,pvY,stvY,bbGetInputvY() )
70 DEF_POINTER_IMAGE_VTK_CREA(vvZ,ssvZ,pvZ,stvZ,bbGetInputvZ() )
71 DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,imageoutput )
72 long int i, size=dim[0]*dim[1]*dim[2];
74 long int k1omp=(double)(size-1)*0.0;
75 long int k2omp=(double)(size-1)*0.2;
76 long int k3omp=(double)(size-1)*0.4;
77 long int k4omp=(double)(size-1)*0.6;
78 long int k5omp=(double)(size-1)*0.8;
79 long int k6omp=(double)(size-1)*1.0;
80 printf("EED MagnitudVector::Process (with openmp)\n");
81 #pragma omp parallel for
82 for (i=0; i<size; i++)
84 if ( (k1omp==i) || (k2omp==i) || (k3omp==i) ||
85 (k4omp==i) || (k5omp==i) || (k6omp==i) ) { printf(" %d%\n", (int)(((double)i/(double)(size-1))*100 )); }
89 GETVALUE2_VTK_CREA(vvXtmpOMP,pvX,stvX,i)
90 GETVALUE2_VTK_CREA(vvYtmpOMP,pvY,stvY,i)
91 GETVALUE2_VTK_CREA(vvZtmpOMP,pvZ,stvZ,i)
92 if ( (vvXtmpOMP==0) && (vvYtmpOMP==0) &&(vvZtmpOMP==0) )
94 SETVALUE2_VTK_CREA( 0 ,pOut,stOut,i)
96 SETVALUE2_VTK_CREA( sqrt(vvXtmpOMP*vvXtmpOMP + vvYtmpOMP*vvYtmpOMP + vvZtmpOMP*vvZtmpOMP) ,pOut,stOut,i)
97 } // if vvX vvY vvZ != 0
103 bbSetOutputOut( imageoutput );
106 // 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)
108 void MagnitudVector::bbUserSetDefaultValues()
111 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
112 // Here we initialize the input 'In' to 0
120 // 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)
122 void MagnitudVector::bbUserInitializeProcessing()
126 // THE INITIALIZATION METHOD BODY :
128 // but this is where you should allocate the internal/output pointers
134 // 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)
136 void MagnitudVector::bbUserFinalizeProcessing()
139 // THE FINALIZATION METHOD BODY :
141 // but this is where you should desallocate the internal/output pointers
146 // EO namespace bbcreaVtk