vtkImageData* ReadMHDPlane::CreateDefaultImage()
{
+ vtkImageData *newImage = NULL;
+/*
+ newImage = vtkImageData::New();
int i;
int sizeX, sizeY, sizeZ;
- sizeX = 200;
+ sizeX = 1;
sizeY = sizeX;
sizeZ = 1;
vtkImageData *newImage = vtkImageData::New();
newImage->AllocateScalars();
newImage->Update();
#else
- newImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+// newImage->AllocateScalars(VTK_UNSIGNED_CHAR,1);
+ newImage->AllocateScalars(VTK_SHORT,1);
#endif
- memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*1 );
- for (i=0; i<sizeX; i++)
- {
- newImage->SetScalarComponentFromDouble(i,i,0, 0, 255 );
- newImage->SetScalarComponentFromDouble(i,sizeY-1-i,0, 0, 255 );
- } // for i
+// memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*sizeZ*sizeof(unsigned char) );
+ memset ( (void*)newImage->GetScalarPointer(), 0, sizeX*sizeY*sizeof(short) );
+// for (i=0; i<sizeX; i++)
+// {
+// newImage->SetScalarComponentFromDouble(i,i ,0, 0, 255 );
+// newImage->SetScalarComponentFromDouble(i,sizeY-1-i ,0, 0, 255 );
+// } // for i
+ newImage->Modified();
+*/
return newImage;
}
vtkImageData* ReadMHDPlane::ChangeOrientation(vtkImageData* imgOrg)
{
- int width = bbGetInputWidth();
- int ext[6];
- int sizeXOrg, sizeYOrg,sizeZOrg;
- int sizeXDst, sizeYDst,sizeZDst;
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
- imgOrg->GetWholeExtent(ext);
-#else
- imgOrg->GetExtent(ext);
-#endif
- int sizeLine;
-
- sizeXOrg = ext[1]-ext[0]+1;
- sizeYOrg = ext[3]-ext[2]+1;
- sizeZOrg = ext[5]-ext[4]+1;
+ vtkImageData *imgDst = NULL;
- if (bbGetInputDirectionPlane()=="XY")
- {
- sizeXDst = ext[1]-ext[0]+1;
- sizeYDst = ext[3]-ext[2]+1;
- sizeZDst = width;
- } // XY
- if (bbGetInputDirectionPlane()=="YZ")
- {
- sizeXDst = width;
- sizeYDst = ext[1]-ext[0]+1;
- sizeZDst = ext[3]-ext[2]+1;
- sizeLine = sizeYDst;
- } // YZ
- if (bbGetInputDirectionPlane()=="ZX")
+ if (imgOrg!=NULL)
{
- sizeXDst = ext[1]-ext[0]+1;
- sizeYDst = width;
- sizeZDst = ext[3]-ext[2]+1;
- sizeLine = sizeXDst;
- } // ZX
- vtkImageData *imgDst = vtkImageData::New();
- imgDst->Initialize();
- imgDst->SetSpacing( imgOrg->GetSpacing() );
- imgDst->SetDimensions( sizeXDst,sizeYDst,sizeZDst );
- imgDst->SetExtent(0,sizeXDst-1,0,sizeYDst-1,0,sizeZDst-1 );
-
-//EED 2017-01-01 Migration VTK7
-#if VTK_MAJOR_VERSION <= 5
- imgDst->SetWholeExtent(0,sizeXDst-1,0,sizeYDst-1,0,sizeZDst-1 );
- imgDst->SetScalarType( imgOrg->GetScalarType() );
- imgDst->SetNumberOfScalarComponents(1);
- imgDst->AllocateScalars();
- imgDst->Update();
-#else
- imgDst->AllocateScalars(imgOrg->GetScalarType(),1);
-#endif
+ int width;
+ int ext[6];
+ int sizeXOrg, sizeYOrg,sizeZOrg;
+ int sizeXDst, sizeYDst,sizeZDst;
+ //EED 2017-01-01 Migration VTK7
+ #if VTK_MAJOR_VERSION <= 5
+ imgOrg->GetWholeExtent(ext);
+ #else
+ imgOrg->GetExtent(ext);
+ #endif
+ int sizeLine;
+
+ sizeXOrg = ext[1]-ext[0]+1;
+ sizeYOrg = ext[3]-ext[2]+1;
+ sizeZOrg = ext[5]-ext[4]+1;
+ width=sizeZOrg;
+
+ if (bbGetInputDirectionPlane()=="XY")
+ {
+ sizeXDst = ext[1]-ext[0]+1;
+ sizeYDst = ext[3]-ext[2]+1;
+ sizeZDst = width;
+ } // XY
+ if (bbGetInputDirectionPlane()=="YZ")
+ {
+ sizeXDst = width;
+ sizeYDst = ext[1]-ext[0]+1;
+ sizeZDst = ext[3]-ext[2]+1;
+ sizeLine = sizeYDst;
+ } // YZ
+ if (bbGetInputDirectionPlane()=="ZX")
+ {
+ sizeXDst = ext[1]-ext[0]+1;
+ sizeYDst = width;
+ sizeZDst = ext[3]-ext[2]+1;
+ sizeLine = sizeXDst;
+ } // ZX
+ imgDst = vtkImageData::New();
+ imgDst->Initialize();
+ imgDst->SetSpacing( imgOrg->GetSpacing() );
+ imgDst->SetDimensions( sizeXDst,sizeYDst,sizeZDst );
+ imgDst->SetExtent(0,sizeXDst-1,0,sizeYDst-1,0,sizeZDst-1 );
+
+ //EED 2017-01-01 Migration VTK7
+ #if VTK_MAJOR_VERSION <= 5
+ imgDst->SetWholeExtent(0,sizeXDst-1,0,sizeYDst-1,0,sizeZDst-1 );
+ imgDst->SetScalarType( imgOrg->GetScalarType() );
+ imgDst->SetNumberOfScalarComponents(1);
+ imgDst->AllocateScalars();
+ imgDst->Update();
+ #else
+ imgDst->AllocateScalars(imgOrg->GetScalarType(),1);
+ #endif
- char *ptrDst,*ptrOrg;
- int sizeBytes = imgOrg->GetScalarSize();
- int sizeLineBytes = sizeLine*imgOrg->GetScalarSize();
- int xx,yy,zz;
+ char *ptrDst,*ptrOrg;
+ int sizeBytes = imgOrg->GetScalarSize();
+ int sizeLineBytes = sizeLine*imgOrg->GetScalarSize();
+ int xx,yy,zz;
- long int sizeXDstBytes = sizeXDst*sizeBytes;
- long int sizeXYDstBytes = sizeXDst*sizeYDst*sizeBytes;
- long int sizeXYDstBytes2 = sizeXDst*sizeYDst*sizeBytes*2;
- long int sizeXYZDstBytes = sizeXDst*sizeYDst*sizeZDst*sizeBytes;
- long int sizeXYZDstBytes1 = sizeXDst*sizeYDst*(sizeZDst-1)*sizeBytes;
+ long int sizeXDstBytes = sizeXDst*sizeBytes;
+ long int sizeXYDstBytes = sizeXDst*sizeYDst*sizeBytes;
+ long int sizeXYDstBytes2 = sizeXDst*sizeYDst*sizeBytes*2;
+ long int sizeXYZDstBytes = sizeXDst*sizeYDst*sizeZDst*sizeBytes;
+ long int sizeXYZDstBytes1 = sizeXDst*sizeYDst*(sizeZDst-1)*sizeBytes;
- ptrOrg = (char*)( imgOrg->GetScalarPointer() );
+ ptrOrg = (char*)( imgOrg->GetScalarPointer() );
- if (bbGetInputDirectionPlane()=="XY")
- {
- memcpy ( imgDst->GetScalarPointer(), ptrOrg , sizeXDst*sizeYDst*sizeZDst*(imgOrg->GetScalarSize()) );
- } // if XY
+ if (bbGetInputDirectionPlane()=="XY")
+ {
+ memcpy ( imgDst->GetScalarPointer(), ptrOrg , sizeXDst*sizeYDst*sizeZDst*(imgOrg->GetScalarSize()) );
+ } // if XY
- if (bbGetInputDirectionPlane()=="ZX")
- {
- ptrDst = (char*)( imgDst->GetScalarPointer(0,0,sizeYOrg-00-1) );
- for( zz=0 ; zz<sizeZOrg ; zz++)
+ if (bbGetInputDirectionPlane()=="ZX")
{
-// ptrDst=(char*)( imgDst->GetScalarPointer(0,zz,sizeYOrg-00-1) );
- for( yy=0 ; yy<sizeYOrg ; yy++)
+ ptrDst = (char*)( imgDst->GetScalarPointer(0,0,sizeYOrg-00-1) );
+ for( zz=0 ; zz<sizeZOrg ; zz++)
{
-// ptrOrg=(char*)( imgOrg->GetScalarPointer(0,yy,zz) );
-// ptrDst=(char*)( imgDst->GetScalarPointer(0,zz,sizeYOrg-yy-1) );
- memcpy ( ptrDst, ptrOrg , sizeLineBytes );
- ptrOrg = ptrOrg + sizeLineBytes;
- ptrDst = ptrDst - sizeXYDstBytes;
- } // for yy
- ptrDst = ptrDst + sizeXDstBytes;
- ptrDst = ptrDst + sizeXYZDstBytes;
- } // for zz
- } // ZX
-
- if (bbGetInputDirectionPlane()=="YZ")
- {
- ptrDst = (char*)( imgDst->GetScalarPointer(0,0,sizeYOrg-0-1) );
- for( zz=0 ; zz<sizeZOrg ; zz++)
+ // ptrDst=(char*)( imgDst->GetScalarPointer(0,zz,sizeYOrg-00-1) );
+ for( yy=0 ; yy<sizeYOrg ; yy++)
+ {
+ // ptrOrg=(char*)( imgOrg->GetScalarPointer(0,yy,zz) );
+ // ptrDst=(char*)( imgDst->GetScalarPointer(0,zz,sizeYOrg-yy-1) );
+ memcpy ( ptrDst, ptrOrg , sizeLineBytes );
+ ptrOrg = ptrOrg + sizeLineBytes;
+ ptrDst = ptrDst - sizeXYDstBytes;
+ } // for yy
+ ptrDst = ptrDst + sizeXDstBytes;
+ ptrDst = ptrDst + sizeXYZDstBytes;
+ } // for zz
+ } // ZX
+
+ if (bbGetInputDirectionPlane()=="YZ")
{
- ptrDst=(char*)( imgDst->GetScalarPointer(zz,0,sizeYOrg-0-1) );
- for( yy=0 ; yy<sizeYOrg ; yy++)
+ ptrDst = (char*)( imgDst->GetScalarPointer(0,0,sizeYOrg-0-1) );
+ for( zz=0 ; zz<sizeZOrg ; zz++)
{
-// ptrDst=(char*)( imgDst->GetScalarPointer(zz,0,sizeYOrg-yy-1) );
- for( xx=0 ; xx<sizeXOrg ; xx++)
+ ptrDst=(char*)( imgDst->GetScalarPointer(zz,0,sizeYOrg-0-1) );
+ for( yy=0 ; yy<sizeYOrg ; yy++)
{
-// ptrOrg=(char*)( imgOrg->GetScalarPointer(xx,yy,zz) );
-// ptrDst=(char*)( imgDst->GetScalarPointer(zz,xx,sizeYOrg-yy-1) );
- memcpy ( ptrDst, ptrOrg , sizeBytes );
- ptrOrg+= sizeBytes;
- ptrDst+= sizeXDstBytes;
- } /// for xx
- ptrDst = ptrDst - sizeXYDstBytes2;
- } // for yy
- ptrDst = ptrDst + sizeXYZDstBytes;
-// ptrDst++;
- } // for zz
- } // ZX
-
+ // ptrDst=(char*)( imgDst->GetScalarPointer(zz,0,sizeYOrg-yy-1) );
+ for( xx=0 ; xx<sizeXOrg ; xx++)
+ {
+ // ptrOrg=(char*)( imgOrg->GetScalarPointer(xx,yy,zz) );
+ // ptrDst=(char*)( imgDst->GetScalarPointer(zz,xx,sizeYOrg-yy-1) );
+ memcpy ( ptrDst, ptrOrg , sizeBytes );
+ ptrOrg+= sizeBytes;
+ ptrDst+= sizeXDstBytes;
+ } /// for xx
+ ptrDst = ptrDst - sizeXYDstBytes2;
+ } // for yy
+ ptrDst = ptrDst + sizeXYZDstBytes;
+ // ptrDst++;
+ } // for zz
+ } // ZX
+ } // if imgOrg
return imgDst;
}
long int headersize=0;
vtkImageData *newImage=NULL;
char mystring[250];
- char strTmp[30];
- char strTmp2[30];
+ char strTmp[250];
+ char strTmp2[250];
FILE *ffIn = fopen( fileNameIn.c_str() , "r");
long long dataSize;
if (ffIn!=NULL)