2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
28 #include "vtkImageDataStrucPoints.h"
29 #include "vtkStructuredPointsWriter.h"
32 vtkImageDataStrucPoints::vtkImageDataStrucPoints()
36 vtkImageDataStrucPoints::~vtkImageDataStrucPoints()
40 void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* imageY, vtkImageData* imageZ,
41 vtkImageData* Data1, vtkImageData* Data2, vtkImageData* Data3 ,
42 vtkImageData* Data4, vtkImageData* Data5, vtkImageData* Data6 )
44 printf("EED vtkImageDataStrucPoints::joinComponents Start \n");
48 //EED 2017-01-01 Migration VTK7
49 #if VTK_MAJOR_VERSION <= 5
51 imageY->GetWholeExtent(ext);
53 imageY->GetExtent(ext);
57 dim[0]=ext[1]-ext[0]+1;
58 dim[1]=ext[3]-ext[2]+1;
59 dim[2]=ext[5]-ext[4]+1;
60 imageY->GetSpacing(spc);
61 double *ptrX=NULL, *ptrY=NULL, *ptrZ=NULL;
62 double *ptrD1=NULL, *ptrD2=NULL, *ptrD3=NULL, *ptrD4=NULL, *ptrD5=NULL, *ptrD6=NULL;
64 if (imageX!=NULL) ptrX = (double *)imageX->GetScalarPointer();
65 if (imageY!=NULL) ptrY = (double *)imageY->GetScalarPointer();
66 if (imageZ!=NULL) ptrZ = (double *)imageZ->GetScalarPointer();
67 if (Data1 !=NULL) ptrD1 = (double *)Data1->GetScalarPointer();
68 if (Data2 !=NULL) ptrD2 = (double *)Data2->GetScalarPointer();
69 if (Data3 !=NULL) ptrD3 = (double *)Data3->GetScalarPointer();
70 if (Data4 !=NULL) ptrD4 = (double *)Data4->GetScalarPointer();
71 if (Data5 !=NULL) ptrD5 = (double *)Data5->GetScalarPointer();
72 if (Data6 !=NULL) ptrD6 = (double *)Data6->GetScalarPointer();
74 long int sizeimage = dim[0]*dim[1]*dim[2];
76 // if ((Data1!=NULL) && (Data2==NULL) && (Data3==NULL) && (Data4==NULL) && (Data5==NULL) && (Data6==NULL) ) { components=4; }
77 // if ((Data1!=NULL) && (Data2!=NULL) && (Data3!=NULL) && (Data4==NULL) && (Data5==NULL) && (Data6==NULL) ) { components=6; }
78 // if ((Data1!=NULL) && (Data2!=NULL) && (Data3!=NULL) && (Data4!=NULL) && (Data5!=NULL) && (Data6!=NULL) ) { components=9; }
79 vtkDoubleArray *array = vtkDoubleArray::New();
80 array->SetNumberOfTuples(sizeimage);
81 array->SetNumberOfComponents(components);
82 array->Allocate(sizeimage*components, 100 ); // ???
83 array->SetName("velocity");
85 vtkDoubleArray *array2 = vtkDoubleArray::New();
86 array2->SetNumberOfTuples(sizeimage);
87 array2->SetNumberOfComponents(1);
88 array2->Allocate(sizeimage*1, 100 ); // ???
89 array2->SetName("angle");
91 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
92 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
93 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
94 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
95 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
96 printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n");
98 double vx,vy,vz,d1=0,d2=0,d3=0,d4=0,d5=0,d6=0;
100 for( i = 0 ; i < sizeimage ; i++ )
102 if (ptrX !=NULL) { vx = *ptrX; ptrX++; } else { vx=0; }
103 if (ptrY !=NULL) { vy = *ptrY; ptrY++; } else { vy=0; }
104 if (ptrZ !=NULL) { vz = *ptrZ; ptrZ++; } else { vz=0; }
105 if (ptrD1!=NULL) { d1 = *ptrD1; ptrD1++;}
106 if (ptrD2!=NULL) { d2 = *ptrD2; ptrD2++;}
107 if (ptrD3!=NULL) { d3 = *ptrD3; ptrD3++;}
108 if (ptrD4!=NULL) { d4 = *ptrD4; ptrD4++;}
110 if (components==3) { array->SetTuple3(i,vx,vy,vz); }
111 if (components==3) { array2->SetTuple1(i,d1); }
112 // if (components==4) { array->SetTuple4(i,vx,vy,vz,d1); }
113 // if (components==6) { array->SetTuple6(i,vx,vy,vz,d1,d2,d3); }
114 // if (components==9) { array->SetTuple9(i,vx,vy,vz,d1,d2,d3,d4,d5,d6); }
117 _structuredPoints = vtkStructuredPoints::New();
118 _structuredPoints->SetDimensions(dim[0], dim[1], dim[2]);
119 _structuredPoints->SetSpacing(spc);
121 //EED 2017-01-01 Migration VTK7
122 #if VTK_MAJOR_VERSION <= 5
123 _structuredPoints->SetScalarTypeToDouble();
124 _structuredPoints->SetNumberOfScalarComponents(3);
126 vtkInformation* info=_structuredPoints->GetInformation();
127 vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_DOUBLE, 3);
131 _structuredPoints->GetPointData()->SetVectors(array);
132 _structuredPoints->GetPointData()->AddArray(array2);
133 _structuredPoints->GetPointData()->SetNumberOfTuples(sizeimage);
134 _structuredPoints->Modified();
135 //EED 2017-01-01 Migration VTK7
136 #if VTK_MAJOR_VERSION <= 5
137 _structuredPoints->Update();
143 _structuredPoints->Print(cout);
144 vtkStructuredPointsWriter *writer2 = vtkStructuredPointsWriter::New();
145 writer2->SetFileName("/home/davila/tmp/VectorfromCal_EED_ups.vtk");
146 //writer->SetFileTypeToBinary();
147 writer2->SetFileTypeToASCII();
148 writer2->SetTensorsName("VectorfromCal");
149 writer2->SetFieldDataName("GlyphVector");
150 writer2->SetScalarsName("Scalar");
151 writer2->SetInput(_structuredPoints);
156 printf("EED vtkImageDataStrucPoints::joinComponents End\n");
160 vtkStructuredPoints* vtkImageDataStrucPoints::getStructuredPoints()
162 return _structuredPoints;