#include "gdcmFile.h"
#include "gdcmFileHelper.h"
#include "gdcmDebug.h"
#include "gdcmUtil.h"
#include "vtkGdcmWriter.h"
#include <vtkObjectFactory.h>
#include <vtkImageData.h>
#include <vtkPointData.h>
#include <vtkLookupTable.h>
Include dependency graph for vtkGdcmWriter.cxx:
Go to the source code of this file.
Defines | |
#define | vtkFloatingPointType float |
Functions | |
vtkCxxRevisionMacro (vtkGdcmWriter,"$Revision: 1.34 $") vtkStandardNewMacro(vtkGdcmWriter) vtkCxxSetObjectMacro(vtkGdcmWriter | |
size_t | ReverseData (vtkImageData *image, unsigned char **data) |
void | SetImageInformation (GDCM_NAME_SPACE::FileHelper *file, vtkImageData *image) |
Variables | |
LookupTable | |
vtkLookupTable |
|
Definition at line 33 of file vtkGdcmWriter.cxx. |
|
Copy the image and reverse the Y axis Definition at line 95 of file vtkGdcmWriter.cxx. 00096 { 00097 #if (VTK_MAJOR_VERSION >= 5) 00098 vtkIdType inc[3]; 00099 #else 00100 int inc[3]; 00101 #endif 00102 int *extent = image->GetUpdateExtent(); 00103 int dim[3] = {extent[1]-extent[0]+1, 00104 extent[3]-extent[2]+1, 00105 extent[5]-extent[4]+1}; 00106 00107 size_t lineSize = dim[0] * image->GetScalarSize() 00108 * image->GetNumberOfScalarComponents(); 00109 size_t planeSize = dim[1] * lineSize; 00110 size_t size = dim[2] * planeSize; 00111 00112 if( size>0 ) 00113 { 00114 *data = new unsigned char[size]; 00115 00116 image->GetIncrements(inc); 00117 unsigned char *src = (unsigned char *)image->GetScalarPointerForExtent(extent); 00118 unsigned char *dst = *data + planeSize - lineSize; 00119 for (int plane = extent[4]; plane <= extent[5]; plane++) 00120 { 00121 for (int line = extent[2]; line <= extent[3]; line++) 00122 { 00123 // Copy one line at proper destination: 00124 memcpy((void*)dst, (void*)src, lineSize); 00125 00126 src += inc[1] * image->GetScalarSize(); 00127 dst -= lineSize; 00128 } 00129 dst += 2 * planeSize; 00130 } 00131 } 00132 else 00133 { 00134 *data = NULL; 00135 } 00136 00137 return size; 00138 }
|
|
Set the data informations in the file
Definition at line 200 of file vtkGdcmWriter.cxx. References GDCM_NAME_SPACE::FileHelper::InsertEntryString(). Referenced by vtkGdcmWriter::WriteDcmFile(). 00201 { 00202 std::ostringstream str; 00203 00204 // Image size 00205 int *extent = image->GetUpdateExtent(); 00206 int dim[3] = {extent[1]-extent[0]+1, 00207 extent[3]-extent[2]+1, 00208 extent[5]-extent[4]+1}; 00209 00210 str.str(""); 00211 str << dim[0]; 00212 file->InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns 00213 00214 str.str(""); 00215 str << dim[1]; 00216 file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows 00217 00218 if(dim[2]>1) 00219 { 00220 str.str(""); 00221 str << dim[2]; 00222 //file->Insert(str.str(),0x0028,0x0012); // Planes 00223 file->InsertEntryString(str.str(),0x0028,0x0008,"US"); // Number of Frames 00224 } 00225 00226 // Pixel type 00227 str.str(""); 00228 str << image->GetScalarSize()*8; 00229 file->InsertEntryString(str.str(),0x0028,0x0100,"US"); // Bits Allocated 00230 file->InsertEntryString(str.str(),0x0028,0x0101,"US"); // Bits Stored 00231 00232 str.str(""); 00233 str << image->GetScalarSize()*8-1; 00234 file->InsertEntryString(str.str(),0x0028,0x0102,"US"); // High Bit 00235 00236 // Pixel Repr 00237 // FIXME : what do we do when the ScalarType is 00238 // VTK_UNSIGNED_INT or VTK_UNSIGNED_LONG 00239 str.str(""); 00240 if( image->GetScalarType() == VTK_UNSIGNED_CHAR || 00241 image->GetScalarType() == VTK_UNSIGNED_SHORT || 00242 image->GetScalarType() == VTK_UNSIGNED_INT || 00243 image->GetScalarType() == VTK_UNSIGNED_LONG ) 00244 { 00245 str << "0"; // Unsigned 00246 } 00247 else 00248 { 00249 str << "1"; // Signed 00250 } 00251 file->InsertEntryString(str.str(),0x0028,0x0103,"US"); // Pixel Representation 00252 00253 // Samples per pixel 00254 str.str(""); 00255 str << image->GetNumberOfScalarComponents(); 00256 file->InsertEntryString(str.str(),0x0028,0x0002,"US"); // Samples per Pixel 00257 00260 00261 // Spacing 00262 vtkFloatingPointType *sp = image->GetSpacing(); 00263 00264 str.str(""); 00265 // We are about to enter floating point value. 00266 // By default ostringstream are smart and don't do fixed point 00267 // thus forcing to fixed point value 00268 str.setf( std::ios::fixed ); 00269 str << sp[1] << "\\" << sp[0]; 00270 file->InsertEntryString(str.str(),0x0028,0x0030,"DS"); // Pixel Spacing 00271 str.str(""); 00272 str << sp[2]; 00273 file->InsertEntryString(str.str(),0x0018,0x0088,"DS"); // Spacing Between Slices 00274 00275 // Origin 00276 vtkFloatingPointType *org = image->GetOrigin(); 00277 00280 00281 str.str(""); 00282 str << org[0] << "\\" << org[1] << "\\" << org[2]; 00283 file->InsertEntryString(str.str(),0x0020,0x0032,"DS"); // Image Position Patient 00284 str.unsetf( std::ios::fixed ); //done with floating point values 00285 00286 // Window / Level 00287 vtkFloatingPointType *rng = image->GetScalarRange(); 00288 00289 str.str(""); 00290 str << rng[1]-rng[0]; 00291 file->InsertEntryString(str.str(),0x0028,0x1051,"DS"); // Window Width 00292 str.str(""); 00293 str << (rng[1]+rng[0])/2.0; 00294 file->InsertEntryString(str.str(),0x0028,0x1050,"DS"); // Window Center 00295 00296 // Pixels 00297 unsigned char *data; 00298 size_t size = ReverseData(image,&data); 00299 file->SetUserData(data,size); 00300 }
|
|
|
|
Definition at line 39 of file vtkGdcmWriter.cxx. Referenced by vtkCxxRevisionMacro(). |
|
Definition at line 39 of file vtkGdcmWriter.cxx. Referenced by main(). |