]> Creatis software - creaVtk.git/blobdiff - lib/creaVtk/vtkImageDataStrucPoints.cpp
#3266 creaMaracasVisu Feature New Normal - ManualContour_Box by segments
[creaVtk.git] / lib / creaVtk / vtkImageDataStrucPoints.cpp
index 426d760118b1c0dce4f931d764d51bd9ff3c2292..0649c5e85e1e2b64d24e223f712c67c4f8324b48 100644 (file)
@@ -43,114 +43,121 @@ void vtkImageDataStrucPoints::joinComponents(vtkImageData* imageX,  vtkImageData
 {
 printf("EED vtkImageDataStrucPoints::joinComponents Start \n");
 
-       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
+       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");
+       } // imageX imageY imageZ
 
-/*
-       _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();  
-*/
 
 
 printf("EED vtkImageDataStrucPoints::joinComponents End\n");