80 : DATABUFFSIZE(8192), LINEBUFFSIZE(5020), FILENAMESIZE(512),
81 fCompression(0), fNFiles(0), fRows(0), fColumns(0),
82 fBitAllocated(0), fMaxPixelValue(0), fMinPixelValue(0),
83 fPixelSpacingX(0.), fPixelSpacingY(0.),
84 fSliceThickness(0.), fSliceLocation(0.),
85 fRescaleIntercept(0), fRescaleSlope(0),
86 fLittleEndian(true), fImplicitEndian(false),
87 fPixelRepresentation(0), fNbrequali(0),
88 fValueDensity(NULL),fValueCT(NULL),fReadCalibration(false),
89 fMergedSlices(NULL),fDriverFile(
"Data.dat"),fCt2DensityFile(
"CT2Density.dat")
106 G4int returnvalue = 0;
size_t rflag = 0;
107 char *
buffer =
new char[LINEBUFFSIZE];
109 fImplicitEndian =
false;
110 fLittleEndian =
true;
112 rflag = std::fread( buffer, 1, 128, dicom );
115 rflag = std::fread( buffer, 1, 4, dicom );
117 if(std::strncmp(
"DICM", buffer, 4) != 0) {
118 std::fseek(dicom, 0, SEEK_SET);
119 fImplicitEndian =
true;
124 short elementLength2;
127 unsigned long elementLength4;
129 char *
data =
new char[DATABUFFSIZE];
138 rflag = std::fread(buffer, 2, 1, dicom);
139 GetValue(buffer, readGroupId);
141 rflag = std::fread(buffer, 2, 1, dicom);
142 GetValue(buffer, readElementId);
145 G4int tagDictionary = readGroupId*0x10000 + readElementId;
148 if(tagDictionary == 0x7FE00010) {
151 rflag = std::fread(buffer,2,1,dicom);
153 rflag = std::fread(buffer,4,1,dicom);
159 rflag = std::fread(buffer,2,1,dicom);
160 GetValue(buffer, elementLength2);
164 if((elementLength2 == 0x424f ||
165 elementLength2 == 0x574f ||
166 elementLength2 == 0x464f ||
167 elementLength2 == 0x5455 ||
168 elementLength2 == 0x5153 ||
169 elementLength2 == 0x4e55) &&
172 rflag = std::fread(buffer, 2, 1, dicom);
175 rflag = std::fread(buffer, 4, 1, dicom);
176 GetValue(buffer, elementLength4);
178 if(elementLength2 == 0x5153)
180 if(elementLength4 == 0xFFFFFFFF)
182 read_undefined_nested( dicom );
185 if(read_defined_nested( dicom, elementLength4 )==0){
189 "Function read_defined_nested() failed!");
194 rflag = std::fread(data, elementLength4,1,dicom);
200 if(!fImplicitEndian || readGroupId == 2) {
204 rflag = std::fread(buffer, 2, 1, dicom);
205 GetValue(buffer, elementLength2);
206 elementLength4 = elementLength2;
208 rflag = std::fread(data, elementLength4, 1, dicom);
215 if(std::fseek(dicom, -2, SEEK_CUR) != 0) {
222 rflag = std::fread(buffer, 4, 1, dicom);
223 GetValue(buffer, elementLength4);
227 if(elementLength4 == 0xFFFFFFFF)
229 read_undefined_nested(dicom);
232 rflag = std::fread(data, elementLength4, 1, dicom);
239 data[elementLength4] =
'\0';
242 GetInformation(tagDictionary, data);
250 std::map<G4float,G4String>::const_iterator ite;
251 for( ite = fMaterialIndices.begin(); ite != fMaterialIndices.end(); ++ite){
259 zslice->
SetMinX(-fPixelSpacingX*fColumns/2.);
260 zslice->
SetMaxX(fPixelSpacingX*fColumns/2.);
262 zslice->
SetMinY(-fPixelSpacingY*fRows/2.);
263 zslice->
SetMaxY(fPixelSpacingY*fRows/2.);
265 zslice->
SetMinZ(fSliceLocation-fSliceThickness/2.);
266 zslice->
SetMaxZ(fSliceLocation+fSliceThickness/2.);
287 if (rflag)
return returnvalue;
293 void DicomHandler::GetInformation(
G4int & tagDictionary,
char *
data)
295 if(tagDictionary == 0x00280010 ) {
296 GetValue(data, fRows);
297 std::printf(
"[0x00280010] Rows -> %i\n",fRows);
299 }
else if(tagDictionary == 0x00280011 ) {
300 GetValue(data, fColumns);
301 std::printf(
"[0x00280011] Columns -> %i\n",fColumns);
303 }
else if(tagDictionary == 0x00280102 ) {
305 GetValue(data, highBits);
306 std::printf(
"[0x00280102] High bits -> %i\n",highBits);
308 }
else if(tagDictionary == 0x00280100 ) {
309 GetValue(data, fBitAllocated);
310 std::printf(
"[0x00280100] Bits allocated -> %i\n", fBitAllocated);
312 }
else if(tagDictionary == 0x00280101 ) {
314 GetValue(data, bitStored);
315 std::printf(
"[0x00280101] Bits stored -> %i\n",bitStored);
317 }
else if(tagDictionary == 0x00280106 ) {
318 GetValue(data, fMinPixelValue);
319 std::printf(
"[0x00280106] Min. pixel value -> %i\n", fMinPixelValue);
321 }
else if(tagDictionary == 0x00280107 ) {
322 GetValue(data, fMaxPixelValue);
323 std::printf(
"[0x00280107] Max. pixel value -> %i\n", fMaxPixelValue);
325 }
else if(tagDictionary == 0x00281053) {
326 fRescaleSlope = atoi(data);
327 std::printf(
"[0x00281053] Rescale Slope -> %d\n", fRescaleSlope);
329 }
else if(tagDictionary == 0x00281052 ) {
330 fRescaleIntercept = atoi(data);
331 std::printf(
"[0x00281052] Rescale Intercept -> %d\n",
334 }
else if(tagDictionary == 0x00280103 ) {
336 fPixelRepresentation = atoi(data);
337 std::printf(
"[0x00280103] Pixel Representation -> %i\n",
338 fPixelRepresentation);
339 if(fPixelRepresentation == 1 ) {
340 std::printf(
"### PIXEL REPRESENTATION = 1, BITS ARE SIGNED, ");
341 std::printf(
"DICOM READING SCAN FOR UNSIGNED VALUE, POSSIBLE ");
342 std::printf(
"ERROR !!!!!! -> \n");
345 }
else if(tagDictionary == 0x00080006 ) {
346 std::printf(
"[0x00080006] Modality -> %s\n", data);
348 }
else if(tagDictionary == 0x00080070 ) {
349 std::printf(
"[0x00080070] Manufacturer -> %s\n", data);
351 }
else if(tagDictionary == 0x00080080 ) {
352 std::printf(
"[0x00080080] Institution Name -> %s\n", data);
354 }
else if(tagDictionary == 0x00080081 ) {
355 std::printf(
"[0x00080081] Institution Address -> %s\n", data);
357 }
else if(tagDictionary == 0x00081040 ) {
358 std::printf(
"[0x00081040] Institution Department Name -> %s\n", data);
360 }
else if(tagDictionary == 0x00081090 ) {
361 std::printf(
"[0x00081090] Manufacturer's Model Name -> %s\n", data);
363 }
else if(tagDictionary == 0x00181000 ) {
364 std::printf(
"[0x00181000] Device Serial Number -> %s\n", data);
366 }
else if(tagDictionary == 0x00080008 ) {
367 std::printf(
"[0x00080008] Image Types -> %s\n", data);
369 }
else if(tagDictionary == 0x00283000 ) {
370 std::printf(
"[0x00283000] Modality LUT Sequence SQ 1 -> %s\n", data);
372 }
else if(tagDictionary == 0x00283002 ) {
373 std::printf(
"[0x00283002] LUT Descriptor US or SS 3 -> %s\n", data);
375 }
else if(tagDictionary == 0x00283003 ) {
376 std::printf(
"[0x00283003] LUT Explanation LO 1 -> %s\n", data);
378 }
else if(tagDictionary == 0x00283004 ) {
379 std::printf(
"[0x00283004] Modality LUT Type LO 1 -> %s\n", data);
381 }
else if(tagDictionary == 0x00283006 ) {
382 std::printf(
"[0x00283006] LUT Data US or SS -> %s\n", data);
384 }
else if(tagDictionary == 0x00283010 ) {
385 std::printf(
"[0x00283010] VOI LUT Sequence SQ 1 -> %s\n", data);
387 }
else if(tagDictionary == 0x00280120 ) {
388 std::printf(
"[0x00280120] Pixel Padding Value US or SS 1 -> %s\n", data);
390 }
else if(tagDictionary == 0x00280030 ) {
392 int iss = datas.find(
'\\');
393 fPixelSpacingX = atof( datas.substr(0,iss).c_str() );
394 fPixelSpacingY = atof( datas.substr(iss+2,datas.length()).c_str() );
396 }
else if(tagDictionary == 0x00200037 ) {
397 std::printf(
"[0x00200037] Image Orientation (Phantom) -> %s\n", data);
399 }
else if(tagDictionary == 0x00200032 ) {
400 std::printf(
"[0x00200032] Image Position (Phantom,mm) -> %s\n", data);
402 }
else if(tagDictionary == 0x00180050 ) {
403 fSliceThickness = atof(data);
404 std::printf(
"[0x00180050] Slice Thickness (mm) -> %f\n", fSliceThickness);
406 }
else if(tagDictionary == 0x00201041 ) {
407 fSliceLocation = atof(data);
408 std::printf(
"[0x00201041] Slice Location -> %f\n", fSliceLocation);
410 }
else if(tagDictionary == 0x00280004 ) {
412 std::printf(
"[0x00280004] Photometric Interpretation -> %s\n", data);
414 }
else if(tagDictionary == 0x00020010) {
415 if(strcmp(data,
"1.2.840.10008.1.2") == 0)
416 fImplicitEndian =
true;
417 else if(strncmp(data,
"1.2.840.10008.1.2.2", 19) == 0)
418 fLittleEndian =
false;
421 std::printf(
"[0x00020010] Endian -> %s\n", data);
440 if(!dcmPZSH) {
return; }
445 if(fCompression == 1) {
446 for(
G4int ww = 0; ww < fRows; ww++) {
448 for(
G4int xx = 0; xx < fColumns; xx++) {
450 density = Pixel2density(mean);
452 dcmPZSH->
AddMateID(GetMaterialIndex(density));
459 for(
G4int ww = 0; ww < fRows ;ww += fCompression ) {
461 for(
G4int xx = 0; xx < fColumns ;xx +=fCompression ) {
464 for(
int sumx = 0; sumx < fCompression; sumx++) {
465 for(
int sumy = 0; sumy < fCompression; sumy++) {
466 if(ww+sumy >= fRows || xx+sumx >= fColumns) overflow =
true;
467 mean += fTab[ww+sumy][xx+sumx];
471 mean /= fCompression*fCompression;
474 density = Pixel2density(mean);
476 dcmPZSH->
AddMateID(GetMaterialIndex(density));
488 void DicomHandler::StoreData(std::ofstream& foutG4DCM)
495 if(fCompression == 1) {
496 for(
G4int ww = 0; ww < fRows; ww++) {
497 for(
G4int xx = 0; xx < fColumns; xx++) {
499 density = Pixel2density(mean);
500 foutG4DCM << GetMaterialIndex( density ) <<
" ";
508 for(
G4int ww = 0; ww < fRows ;ww += fCompression ) {
509 for(
G4int xx = 0; xx < fColumns ;xx +=fCompression ) {
512 for(
int sumx = 0; sumx < fCompression; sumx++) {
513 for(
int sumy = 0; sumy < fCompression; sumy++) {
514 if(ww+sumy >= fRows || xx+sumx >= fColumns) overflow =
true;
515 mean += fTab[ww+sumy][xx+sumx];
519 mean /= fCompression*fCompression;
522 density = Pixel2density(mean);
523 foutG4DCM << GetMaterialIndex( density ) <<
" ";
532 if(fCompression == 1) {
533 for(
G4int ww = 0; ww < fRows; ww++) {
534 for(
G4int xx = 0; xx < fColumns; xx++) {
536 density = Pixel2density(mean);
537 foutG4DCM << density <<
" ";
538 if( xx%8 == 3 ) foutG4DCM <<
G4endl;
545 for(
G4int ww = 0; ww < fRows ;ww += fCompression ) {
546 for(
G4int xx = 0; xx < fColumns ;xx +=fCompression ) {
549 for(
int sumx = 0; sumx < fCompression; sumx++) {
550 for(
int sumy = 0; sumy < fCompression; sumy++) {
551 if(ww+sumy >= fRows || xx+sumx >= fColumns) overflow =
true;
552 mean += fTab[ww+sumy][xx+sumx];
556 mean /= fCompression*fCompression;
559 density = Pixel2density(mean);
560 foutG4DCM << density <<
" ";
561 if( xx/fCompression%8 == 3 ) foutG4DCM <<
G4endl;
572 void DicomHandler::ReadMaterialIndices( std::ifstream& finData)
578 if( finData.eof() )
return;
581 for(
unsigned int ii = 0; ii < nMate; ii++ ){
582 finData >> mateName >> densityMax;
583 fMaterialIndices[densityMax] = mateName;
592 unsigned int DicomHandler::GetMaterialIndex(
G4float density )
594 std::map<G4float,G4String>::reverse_iterator ite;
595 G4int ii = fMaterialIndices.size();
596 for( ite = fMaterialIndices.rbegin(); ite != fMaterialIndices.rend();
598 if( density >= (*ite).first ) {
604 if(static_cast<unsigned int>(ii) == fMaterialIndices.size())
605 { ii = fMaterialIndices.size()-1; }
615 G4int returnvalue = 0;
size_t rflag = 0;
620 fTab =
new G4int*[fRows];
621 for (
G4int i = 0; i < fRows; i ++ ) {
622 fTab[i] =
new G4int[fColumns];
625 if(fBitAllocated == 8) {
627 std::printf(
"@@@ Error! Picture != 16 bits...\n");
628 std::printf(
"@@@ Error! Picture != 16 bits...\n");
629 std::printf(
"@@@ Error! Picture != 16 bits...\n");
631 unsigned char ch = 0;
633 for(
G4int j = 0; j < fRows; j++) {
634 for(
G4int i = 0; i < fColumns; i++) {
636 rflag = std::fread( &ch, 1, 1, dicom);
637 fTab[j][i] = ch*fRescaleSlope + fRescaleIntercept;
645 for(
G4int j = 0; j < fRows; j++) {
646 for(
G4int i = 0; i < fColumns; i++) {
648 rflag = std::fread(sbuff, 2, 1, dicom);
649 GetValue(sbuff, pixel);
650 fTab[j][i] = pixel*fRescaleSlope + fRescaleIntercept;
656 char * nameProcessed =
new char[FILENAMESIZE];
659 std::sprintf(nameProcessed,
"%s.g4dcmb",filename2);
660 fileOut = std::fopen(nameProcessed,
"w+b");
661 std::printf(
"### Writing of %s ###\n",nameProcessed);
663 unsigned int nMate = fMaterialIndices.size();
664 rflag = std::fwrite(&nMate,
sizeof(
unsigned int), 1, fileOut);
666 std::map<G4float,G4String>::const_iterator ite;
667 for( ite = fMaterialIndices.begin(); ite != fMaterialIndices.end(); ite++ ){
669 for(
G4int ii = (*ite).second.length(); ii < 40; ii++ ) {
673 const char* mateNameC = mateName.c_str();
674 rflag = std::fwrite(mateNameC,
sizeof(
char),40, fileOut);
677 unsigned int fRowsC = fRows/fCompression;
678 unsigned int fColumnsC = fColumns/fCompression;
679 unsigned int planesC = 1;
680 G4float pixelLocationXM = -fPixelSpacingX*fColumns/2.;
681 G4float pixelLocationXP = fPixelSpacingX*fColumns/2.;
682 G4float pixelLocationYM = -fPixelSpacingY*fRows/2.;
683 G4float pixelLocationYP = fPixelSpacingY*fRows/2.;
684 G4float fSliceLocationZM = fSliceLocation-fSliceThickness/2.;
685 G4float fSliceLocationZP = fSliceLocation+fSliceThickness/2.;
687 rflag = std::fwrite(&fRowsC,
sizeof(
unsigned int), 1, fileOut);
688 rflag = std::fwrite(&fColumnsC,
sizeof(
unsigned int), 1, fileOut);
689 rflag = std::fwrite(&planesC,
sizeof(
unsigned int), 1, fileOut);
691 rflag = std::fwrite(&pixelLocationXM,
sizeof(
G4float), 1, fileOut);
692 rflag = std::fwrite(&pixelLocationXP,
sizeof(
G4float), 1, fileOut);
693 rflag = std::fwrite(&pixelLocationYM,
sizeof(
G4float), 1, fileOut);
694 rflag = std::fwrite(&pixelLocationYP,
sizeof(
G4float), 1, fileOut);
695 rflag = std::fwrite(&fSliceLocationZM,
sizeof(
G4float), 1, fileOut);
696 rflag = std::fwrite(&fSliceLocationZP,
sizeof(
G4float), 1, fileOut);
699 std::printf(
"%8i %8i\n",fRows,fColumns);
700 std::printf(
"%8f %8f\n",fPixelSpacingX,fPixelSpacingY);
701 std::printf(
"%8f\n", fSliceThickness);
702 std::printf(
"%8f\n", fSliceLocation);
703 std::printf(
"%8i\n", fCompression);
705 G4int compSize = fCompression;
712 for(
G4int ww = 0; ww < fRows; ww++) {
713 for(
G4int xx = 0; xx < fColumns; xx++) {
715 density = Pixel2density(mean);
716 unsigned int mateID = GetMaterialIndex( density );
717 rflag = std::fwrite(&mateID,
sizeof(
unsigned int), 1, fileOut);
724 for(
G4int ww = 0; ww < fRows ;ww += compSize ) {
725 for(
G4int xx = 0; xx < fColumns ;xx +=compSize ) {
728 for(
int sumx = 0; sumx < compSize; sumx++) {
729 for(
int sumy = 0; sumy < compSize; sumy++) {
730 if(ww+sumy >= fRows || xx+sumx >= fColumns) overflow =
true;
731 mean += fTab[ww+sumy][xx+sumx];
735 mean /= compSize*compSize;
738 density = Pixel2density(mean);
739 unsigned int mateID = GetMaterialIndex( density );
740 rflag = std::fwrite(&mateID,
sizeof(
unsigned int), 1, fileOut);
749 for(
G4int ww = 0; ww < fRows; ww++) {
750 for(
G4int xx = 0; xx < fColumns; xx++) {
752 density = Pixel2density(mean);
753 rflag = std::fwrite(&density,
sizeof(
G4float), 1, fileOut);
760 for(
G4int ww = 0; ww < fRows ;ww += compSize ) {
761 for(
G4int xx = 0; xx < fColumns ;xx +=compSize ) {
764 for(
int sumx = 0; sumx < compSize; sumx++) {
765 for(
int sumy = 0; sumy < compSize; sumy++) {
766 if(ww+sumy >= fRows || xx+sumx >= fColumns) overflow =
true;
767 mean += fTab[ww+sumy][xx+sumx];
771 mean /= compSize*compSize;
774 density = Pixel2density(mean);
775 rflag = std::fwrite(&density,
sizeof(
G4float), 1, fileOut);
782 rflag = std::fclose(fileOut);
784 delete [] nameProcessed;
792 if (rflag)
return returnvalue;
800 void DicomHandler::ReadCalibration()
806 std::ifstream calibration(fCt2DensityFile.c_str());
807 calibration >> fNbrequali;
809 fValueDensity =
new G4double[fNbrequali];
810 fValueCT =
new G4double[fNbrequali];
816 "@@@ No value to transform pixels in density!");
819 for(
G4int i = 0; i < fNbrequali; i++) {
821 calibration >> fValueCT[i] >> fValueDensity[i];
826 fReadCalibration =
true;
833 if(!fReadCalibration) { ReadCalibration(); }
840 for(
G4int j = 1; j < fNbrequali; j++) {
841 if( pixel >= fValueCT[j-1] && pixel < fValueCT[j]) {
843 deltaCT = fValueCT[j] - fValueCT[j-1];
844 deltaDensity = fValueDensity[j] - fValueDensity[j-1];
847 density = fValueDensity[j] - ((fValueCT[j] - pixel)*deltaDensity/deltaCT );
853 std::printf(
"@@@ Error density = %f && Pixel = %i \
854 (0x%x) && deltaDensity/deltaCT = %f\n",density,pixel,pixel,
855 deltaDensity/deltaCT);
865 std::ifstream checkData(fDriverFile.c_str());
866 char * oneLine =
new char[128];
868 if(!(checkData.is_open())) {
871 "\nDicomG4 needs Data.dat (or another driver file specified";
872 message +=
" in command line):\n";
873 message +=
"\tFirst line: number of image pixel for a voxel (G4Box)\n";
874 message +=
"\tSecond line: number of images (CT slices) to read\n";
875 message +=
"\tEach following line contains the name of a Dicom image";
876 message +=
" except for the .dcm extension";
883 checkData >> fCompression;
884 checkData >> fNFiles;
886 checkData.getline(oneLine,100);
887 std::ifstream testExistence;
888 G4bool existAlready =
true;
889 for(
G4int rep = 0; rep < fNFiles; rep++) {
890 checkData.getline(oneLine,100);
893 G4cout << fNFiles <<
" test file " << oneName <<
G4endl;
894 testExistence.open(oneName.
data());
895 if(!(testExistence.is_open())) {
896 existAlready =
false;
897 testExistence.clear();
898 testExistence.close();
900 testExistence.clear();
901 testExistence.close();
904 ReadMaterialIndices( checkData );
909 if( existAlready ==
false ) {
911 G4cout <<
"\nAll the necessary images were not found in processed form "
912 <<
", starting with .dcm images\n";
916 char * fCompressionc =
new char[LINEBUFFSIZE];
917 char * maxc =
new char[LINEBUFFSIZE];
919 char *
name =
new char[FILENAMESIZE];
920 char * inputFile =
new char[FILENAMESIZE];
923 lecturePref = std::fopen(fDriverFile.c_str(),
"r");
924 rflag = std::fscanf(lecturePref,
"%s",fCompressionc);
925 fCompression = atoi(fCompressionc);
926 rflag = std::fscanf(lecturePref,
"%s",maxc);
927 fNFiles = atoi(maxc);
930 for(
G4int i = 1; i <= fNFiles; i++ ) {
932 rflag = std::fscanf(lecturePref,
"%s",inputFile);
933 std::sprintf(name,
"%s.dcm",inputFile);
936 std::printf(
"### Opening %s and reading :\n",name);
937 dicom = std::fopen(name,
"rb");
946 rflag = std::fclose(dicom);
948 rflag = std::fclose(lecturePref);
953 delete [] fCompressionc;
961 if(fValueDensity) {
delete [] fValueDensity; }
962 if(fValueCT) {
delete [] fValueCT; }
963 if(fMergedSlices) {
delete fMergedSlices; }
969 G4int DicomHandler::read_defined_nested(FILE * nested,
G4int SQ_Length)
972 unsigned short item_GroupNumber;
973 unsigned short item_ElementNumber;
975 G4int items_array_length=0;
976 char *
buffer=
new char[LINEBUFFSIZE];
979 while(items_array_length < SQ_Length)
981 rflag = std::fread(buffer, 2, 1, nested);
982 GetValue(buffer, item_GroupNumber);
984 rflag = std::fread(buffer, 2, 1, nested);
985 GetValue(buffer, item_ElementNumber);
987 rflag = std::fread(buffer, 4, 1, nested);
988 GetValue(buffer, item_Length);
990 rflag = std::fread(buffer, item_Length, 1, nested);
992 items_array_length= items_array_length+8+item_Length;
997 if( SQ_Length>items_array_length )
1001 if (rflag)
return 1;
1006 void DicomHandler::read_undefined_nested(FILE * nested)
1009 unsigned short item_GroupNumber;
1010 unsigned short item_ElementNumber;
1011 unsigned int item_Length;
1012 char * buffer=
new char[LINEBUFFSIZE];
1017 rflag = std::fread(buffer, 2, 1, nested);
1018 GetValue(buffer, item_GroupNumber);
1020 rflag = std::fread(buffer, 2, 1, nested);
1021 GetValue(buffer, item_ElementNumber);
1023 rflag = std::fread(buffer, 4, 1, nested);
1024 GetValue(buffer, item_Length);
1026 if(item_Length!=0xffffffff)
1027 rflag = std::fread(buffer, item_Length, 1, nested);
1029 read_undefined_item(nested);
1032 }
while(item_GroupNumber!=0xFFFE || item_ElementNumber!=0xE0DD
1041 void DicomHandler::read_undefined_item(FILE * nested)
1044 unsigned short item_GroupNumber;
1045 unsigned short item_ElementNumber;
1046 G4int item_Length;
size_t rflag = 0;
1047 char *buffer=
new char[LINEBUFFSIZE];
1051 rflag = std::fread(buffer, 2, 1, nested);
1052 GetValue(buffer, item_GroupNumber);
1054 rflag = std::fread(buffer, 2, 1, nested);
1055 GetValue(buffer, item_ElementNumber);
1057 rflag = std::fread(buffer, 4, 1, nested);
1058 GetValue(buffer, item_Length);
1062 rflag = std::fread(buffer,item_Length,1,nested);
1065 while(item_GroupNumber!=0xFFFE || item_ElementNumber!=0xE00D
1074 template <
class Type>
1075 void DicomHandler::GetValue(
char * _val, Type & _rval) {
1077 #if BYTE_ORDER == BIG_ENDIAN
1079 #else // BYTE_ORDER == LITTLE_ENDIAN
1080 if(!fLittleEndian) {
1082 const int SIZE =
sizeof(_rval);
1084 for(
int i = 0; i < SIZE/2; i++) {
1086 _val[i] = _val[SIZE - 1 - i];
1087 _val[SIZE - 1 - i] = ctemp;
1090 _rval = *(Type *)_val;
Definition of the DicomPhantomZSliceMerged class.
const XML_Char const XML_Char * data
static DicomHandler * Instance()
G4GLOB_DLL std::ostream G4cout
G4int ReadFile(FILE *, char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const char * data() const
G4int ReadData(FILE *, char *)
Definition of the DicomHandler class.
void AddZSlice(DicomPhantomZSliceHeader *val)