/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Sante) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ #include "vtkImageDataStrucPoints.h" #include "vtkStructuredPointsWriter.h" vtkImageDataStrucPoints::vtkImageDataStrucPoints() { _structuredPoints=NULL; } vtkImageDataStrucPoints::~vtkImageDataStrucPoints() { } void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX, vtkImageData* imageY, vtkImageData* imageZ, vtkImageData* Data1, vtkImageData* Data2, vtkImageData* Data3 , vtkImageData* Data4, vtkImageData* Data5, vtkImageData* Data6 ) { if ((imageX!=NULL) && (imageY!=NULL) && (imageZ!=NULL) ) { int ext[6]; imageY->Modified(); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 imageY->Update(); imageY->GetWholeExtent(ext); #else imageY->GetExtent(ext); #endif int dim[3]; double spc[3]; dim[0]=ext[1]-ext[0]+1; dim[1]=ext[3]-ext[2]+1; dim[2]=ext[5]-ext[4]+1; imageY->GetSpacing(spc); double *ptrX=NULL, *ptrY=NULL, *ptrZ=NULL; double *ptrD1=NULL, *ptrD2=NULL, *ptrD3=NULL, *ptrD4=NULL, *ptrD5=NULL, *ptrD6=NULL; if (imageX!=NULL) ptrX = (double *)imageX->GetScalarPointer(); if (imageY!=NULL) ptrY = (double *)imageY->GetScalarPointer(); if (imageZ!=NULL) ptrZ = (double *)imageZ->GetScalarPointer(); if (Data1 !=NULL) ptrD1 = (double *)Data1->GetScalarPointer(); if (Data2 !=NULL) ptrD2 = (double *)Data2->GetScalarPointer(); if (Data3 !=NULL) ptrD3 = (double *)Data3->GetScalarPointer(); if (Data4 !=NULL) ptrD4 = (double *)Data4->GetScalarPointer(); if (Data5 !=NULL) ptrD5 = (double *)Data5->GetScalarPointer(); if (Data6 !=NULL) ptrD6 = (double *)Data6->GetScalarPointer(); long int sizeimage = dim[0]*dim[1]*dim[2]; int components=3; // if ((Data1!=NULL) && (Data2==NULL) && (Data3==NULL) && (Data4==NULL) && (Data5==NULL) && (Data6==NULL) ) { components=4; } // if ((Data1!=NULL) && (Data2!=NULL) && (Data3!=NULL) && (Data4==NULL) && (Data5==NULL) && (Data6==NULL) ) { components=6; } // if ((Data1!=NULL) && (Data2!=NULL) && (Data3!=NULL) && (Data4!=NULL) && (Data5!=NULL) && (Data6!=NULL) ) { components=9; } vtkDoubleArray *array = vtkDoubleArray::New(); array->SetNumberOfTuples(sizeimage); array->SetNumberOfComponents(components); array->Allocate(sizeimage*components, 100 ); // ??? array->SetName("velocity"); vtkDoubleArray *array2 = vtkDoubleArray::New(); array2->SetNumberOfTuples(sizeimage); array2->SetNumberOfComponents(1); array2->Allocate(sizeimage*1, 100 ); // ??? array2->SetName("angle"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); printf("EED Warnning .... vtkImageDataStrucPoints::joinComponents Limpiar este codigo ........ \n"); double vx,vy,vz,d1=0,d2=0,d3=0,d4=0,d5=0,d6=0; int i; for( i = 0 ; i < sizeimage ; i++ ) { if (ptrX !=NULL) { vx = *ptrX; ptrX++; } else { vx=0; } if (ptrY !=NULL) { vy = *ptrY; ptrY++; } else { vy=0; } if (ptrZ !=NULL) { vz = *ptrZ; ptrZ++; } else { vz=0; } if (ptrD1!=NULL) { d1 = *ptrD1; ptrD1++;} if (ptrD2!=NULL) { d2 = *ptrD2; ptrD2++;} if (ptrD3!=NULL) { d3 = *ptrD3; ptrD3++;} if (ptrD4!=NULL) { d4 = *ptrD4; ptrD4++;} if (components==3) { array->SetTuple3(i,vx,vy,vz); } if (components==3) { array2->SetTuple1(i,d1); } // if (components==4) { array->SetTuple4(i,vx,vy,vz,d1); } // if (components==6) { array->SetTuple6(i,vx,vy,vz,d1,d2,d3); } // if (components==9) { array->SetTuple9(i,vx,vy,vz,d1,d2,d3,d4,d5,d6); } } // for i _structuredPoints = vtkStructuredPoints::New(); _structuredPoints->SetDimensions(dim[0], dim[1], dim[2]); _structuredPoints->SetSpacing(spc); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 _structuredPoints->SetScalarTypeToDouble(); _structuredPoints->SetNumberOfScalarComponents(3); #else vtkInformation* info=_structuredPoints->GetInformation(); vtkDataObject::SetPointDataActiveScalarInfo(info, VTK_DOUBLE, 3); #endif _structuredPoints->GetPointData()->SetVectors(array); _structuredPoints->GetPointData()->AddArray(array2); _structuredPoints->GetPointData()->SetNumberOfTuples(sizeimage); _structuredPoints->Modified(); //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 _structuredPoints->Update(); #else //... #endif /* _structuredPoints->Print(cout); vtkStructuredPointsWriter *writer2 = vtkStructuredPointsWriter::New(); writer2->SetFileName("/home/davila/tmp/VectorfromCal_EED_ups.vtk"); //writer->SetFileTypeToBinary(); writer2->SetFileTypeToASCII(); writer2->SetTensorsName("VectorfromCal"); writer2->SetFieldDataName("GlyphVector"); writer2->SetScalarsName("Scalar"); writer2->SetInput(_structuredPoints); writer2->Write(); */ } else { printf("EED Warnning! vtkImageDataStrucPoints::joinComponents imageX or image Y or image Z is EMPTY\n"); _structuredPoints=NULL; } // imageX imageY imageZ } vtkStructuredPoints* vtkImageDataStrucPoints::getStructuredPoints() { return _structuredPoints; }