52 #define LITTLE_ENDIAN 1234
53 #define BYTE_ORDER LITTLE_ENDIAN
75 if (
this == &_right)
return *
this;
76 for(
int i = 0; i < 3; i++) {
77 kSize[i] = _right.
kSize[i];
81 for(
int i = 0; i < 2; i++) kMinmax[i] = _right.
kMinmax[i];
82 int num = kSize[0]*kSize[1];
84 for(
int z = 0; z < kSize[2]; z++) {
86 for(
int i = 0; i < num; i++) img[i] =_right.
kImage[z][i];
87 kImage.push_back(img);
97 for(
int i = 0; i < 3; i++) {
98 if(kSize[i] != _right.
kSize[i]) stat =
false;
99 if(kCenter[i] != _right.
kCenter[i]) stat =
false;
103 G4cout <<
"Warning: operator + "
104 <<
" Cannot do the operator +"
112 T mms[2] = {9e100,-9e100};
116 int num = kSize[0]*kSize[1];
117 for(
int z = 0; z < kSize[2]; z++) {
118 T * img =
new T[num];
119 for(
int xy = 0; xy < num; xy++) {
120 img[xy] = kImage[z][xy] + _right.
kImage[z][xy];
121 if(mms[0] > img[xy]) mms[0] = img[xy];
122 if(mms[1] < img[xy]) mms[1] = img[xy];
138 for(
int i = 0; i < 3; i++) {
139 if(kSize[i] != _right.
kSize[i]) stat =
false;
140 if(kCenter[i] != _right.
kCenter[i]) stat =
false;
145 <<
" Cannot do the operator +="
150 if(kMinmax[0] > _right.
kMinmax[0]) kMinmax[0] = _right.
kMinmax[0];
151 if(kMinmax[1] < _right.
kMinmax[1]) kMinmax[1] = _right.
kMinmax[1];
153 int num = kSize[0]*kSize[1];
154 for(
int z = 0; z < kSize[2]; z++) {
155 for(
int xy = 0; xy < num; xy++) {
156 kImage[z][xy] += _right.
kImage[z][xy];
157 if(kMinmax[0] > kImage[z][xy]) kMinmax[0] = kImage[z][xy];
158 if(kMinmax[1] < kImage[z][xy]) kMinmax[1] = kImage[z][xy];
167 template <
typename T>
169 for(
int i = 0; i < 3; i++) {
174 kMinmax[0] = (T)32109;
175 kMinmax[1] = (T)-32109;
179 template <
typename T>
181 typename std::vector<T *>::iterator itr;
182 for(itr = kImage.begin(); itr != kImage.end(); itr++) {
187 template <
typename T>
189 for(
int i = 0; i < 3; i++) kSize[i] = _size[i];
191 template <
typename T>
193 for(
int i = 0; i < 3; i++) _size[i] = kSize[i];
195 template <
typename T>
199 template <
typename T>
203 template <
typename T>
205 for(
int i = 0; i < 2; i++) kMinmax[i] = _minmax[i];
207 template <
typename T>
209 for(
int i = 0; i < 2; i++) _minmax[i] = kMinmax[i];
212 template <
typename T>
216 template <
typename T>
218 kImage.push_back(_image);
220 template <
typename T>
224 template <
typename T>
226 if(_z >= (
int)kImage.size())
return 0;
229 template <
typename T>
231 for(
int i = 0; i < 3; i++) kCenter[i] = _center[i];
233 template <
typename T>
235 for(
int i = 0; i < 3; i++) _center[i] = kCenter[i];
237 template <
typename T>
241 template <
typename T>
252 for(
int i = 0; i < 3; i++)
kColor[i] = 0;
256 float _endx,
float _endy,
float _endz) {
267 float & _endx,
float & _endy,
float & _endz,
269 if(_num >= (
int)
kTrack.size()) {
271 G4cout <<
"GMocrenTrack::getStep(...) Error: "
272 <<
"invalid step # : " << _num <<
G4endl;
276 _startx =
kTrack[_num].startPoint[0];
277 _starty =
kTrack[_num].startPoint[1];
278 _startz =
kTrack[_num].startPoint[2];
279 _endx =
kTrack[_num].endPoint[0];
280 _endy =
kTrack[_num].endPoint[1];
281 _endz =
kTrack[_num].endPoint[2];
284 std::vector<struct Step>::iterator itr =
kTrack.begin();
285 for(; itr !=
kTrack.end(); itr++) {
286 for(
int i = 0; i < 3; i++ ) {
287 itr->startPoint[i] += _translate[i];
288 itr->endPoint[i] += _translate[i];
303 for(
int i = 0; i < 3; i++)
kColor[i] = 0;
307 float _endx,
float _endy,
float _endz) {
318 float & _endx,
float & _endy,
float & _endz,
322 G4cout <<
"GMocrenDetector::getEdge(...) Error: "
323 <<
"invalid edge # : " << _num <<
G4endl;
335 std::vector<struct Edge>::iterator itr =
kDetector.begin();
337 for(
int i = 0; i < 3; i++) {
338 itr->startPoint[i] += _translate[i];
339 itr->endPoint[i] += _translate[i];
358 #if BYTE_ORDER == LITTLE_ENDIAN
403 : kTracksWillBeStored(true) {
419 #if BYTE_ORDER == LITTLE_ENDIAN
441 std::vector<float *>::iterator itr;
442 for(itr =
kSteps.begin(); itr !=
kSteps.end(); itr++)
delete [] *itr;
444 std::vector<unsigned char *>::iterator citr;
467 G4cout <<
">>>>>>> store data (ver.4) <<<<<<<" <<
G4endl;
473 std::ios_base::out|std::ios_base::binary);
478 ofile.write(
"gMocren ", 8);
481 unsigned char ver = 0x04;
482 ofile.write((
char *)&ver, 1);
486 char littleEndian = 0x01;
487 ofile.write((
char *)&littleEndian,
sizeof(
char));
490 G4cout <<
"Endian: " << (
int)littleEndian << G4endl;
499 int commentLength = 1024;
501 ofile.write((
char *)&commentLength, 4);
504 ofile.write((
char *)itmp, 4);
509 for(
int i = 0; i < 1025; i++) cmt[i] =
'\0';
511 const char * cmnt =
kComment.c_str();
512 size_t lcm = std::strlen(cmnt);
513 if(lcm > 1024) lcm = 1024;
514 std::strncpy(cmt, cmnt, lcm);
515 ofile.write((
char *)cmt, 1024);
517 G4cout <<
"Data comment : "
525 for(
int j = 0; j < 3; j++)
527 ofile.write((
char *)ftmp, 12);
530 G4cout <<
"Voxel spacing : ("
545 ofile.write((
char *)itmp, 4);
552 ofile.write((
char *)&nDoseDist, 4);
555 ofile.write((
char *)itmp, 4);
560 for(
int i = 0; i < nDoseDist; i++) {
564 for(
int i = 0; i < nDoseDist; i++) {
566 ofile.write((
char *)itmp, 4);
575 ofile.write((
char *)itmp, 4);
583 ofile.write((
char *)itmp, 4);
591 ofile.write((
char *)itmp, 4);
595 G4cout <<
"Each pointer to data : "
597 for(
int i = 0; i < nDoseDist; i++) {
617 ofile.write((
char *)size, 3*
sizeof(
int));
619 for(
int j = 0; j < 3; j++)
621 ofile.write((
char *)itmp, 12);
625 G4cout <<
"Modality image size : ("
635 ofile.write((
char *)minmax, 4);
637 for(
int j = 0; j < 2; j++)
639 ofile.write((
char *)stmp, 4);
643 char munit[13] =
"g/cm3\0";
644 ofile.write((
char *)munit, 12);
649 ofile.write((
char *)&scale, 4);
652 ofile.write((
char *)ftmp, 4);
655 G4cout <<
"Modality image min., max., scale : "
662 int psize = size[0]*size[1];
664 for(
int i = 0; i < size[2]; i++) {
667 ofile.write((
char *)image, psize*
sizeof(
short));
669 for(
int j = 0; j < psize; j++) {
671 ofile.write((
char *)stmp, 2);
675 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
680 size_t msize = minmax[1] - minmax[0]+1;
682 G4cout <<
"modality image : " << minmax[0] <<
", " << minmax[1] <<
G4endl;
683 float * pdmap =
new float[msize];
687 ofile.write((
char *)pdmap, msize*
sizeof(
float));
689 for(
int j = 0; j < (
int)msize; j++) {
691 ofile.write((
char *)ftmp, 4);
696 G4cout <<
"density map : " << std::ends;
697 for(
int i = 0; i < (
int)msize; i+=50)
710 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
712 kDose[ndose].getSize(size);
714 ofile.write((
char *)size, 3*
sizeof(
int));
716 for(
int j = 0; j < 3; j++)
718 ofile.write((
char *)itmp, 12);
721 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
731 ofile.write((
char *)minmax, 2*2);
733 for(
int j = 0; j < 2; j++)
735 ofile.write((
char *)stmp, 4);
740 for(
int i = 0; i < 13; i++) cdunit[i] =
'\0';
742 size_t lcu = std::strlen(cu);
743 if(lcu > 12) lcu = 12;
744 std::strncpy(cdunit, cu, lcu);
745 ofile.write((
char *)cdunit, 12);
753 scale = float(dscale);
755 ofile.write((
char *)&scale, 4);
758 ofile.write((
char *)ftmp, 4);
761 G4cout <<
"Dose dist. [" << ndose
762 <<
"] image min., max., scale : "
769 int dsize = size[0]*size[1];
770 short * dimage =
new short[dsize];
771 for(
int z = 0; z < size[2]; z++) {
774 ofile.write((
char *)dimage, dsize*2);
776 for(
int j = 0; j < dsize; j++) {
778 ofile.write((
char *)stmp, 2);
783 for(
int j = 0; j < dsize; j++) {
785 G4cout <<
"[" << j <<
"," << z <<
"]"
786 << dimage[j] <<
", ";
796 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
798 ofile.write((
char *)iCenter, 3*4);
800 for(
int j = 0; j < 3; j++)
802 ofile.write((
char *)itmp, 12);
805 G4cout <<
"Dose dist. [" << ndose
806 <<
"]image relative location : ("
807 << iCenter[0] <<
", "
808 << iCenter[1] <<
", "
809 << iCenter[2] <<
")" <<
G4endl;
814 if(name.size() == 0) name =
"dose";
816 ofile.write((
char *)name.c_str(), 80);
827 kRoi[0].getSize(size);
829 ofile.write((
char *)size, 3*
sizeof(
int));
831 for(
int j = 0; j < 3; j++)
833 ofile.write((
char *)itmp, 12);
836 G4cout <<
"ROI image size : ("
844 kRoi[0].getMinMax(minmax);
846 ofile.write((
char *)minmax,
sizeof(
short)*2);
848 for(
int j = 0; j < 2; j++)
850 ofile.write((
char *)stmp, 4);
854 scale = (float)
kRoi[0].getScale();
856 ofile.write((
char *)&scale,
sizeof(
float));
859 ofile.write((
char *)ftmp, 4);
862 G4cout <<
"ROI image min., max., scale : "
869 int rsize = size[0]*size[1];
870 for(
int i = 0; i < size[2]; i++) {
871 short * rimage =
kRoi[0].getImage(i);
873 ofile.write((
char *)rimage, rsize*
sizeof(
short));
875 for(
int j = 0; j < rsize; j++) {
877 ofile.write((
char *)stmp, 2);
884 kRoi[0].getCenterPosition(fCenter);
885 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
887 ofile.write((
char *)iCenter, 3*
sizeof(
int));
889 for(
int j = 0; j < 3; j++)
891 ofile.write((
char *)itmp, 12);
894 G4cout <<
"ROI image relative location : ("
895 << iCenter[0] <<
", "
896 << iCenter[1] <<
", "
897 << iCenter[2] <<
")" <<
G4endl;
907 ofile.write((
char *)&ntrk,
sizeof(
int));
910 ofile.write((
char *)itmp, 4);
913 G4cout <<
"# of tracks : "
917 for(
int nt = 0; nt < ntrk; nt++) {
920 int nsteps =
kTracks[nt].getNumberOfSteps();
922 ofile.write((
char *)&nsteps,
sizeof(
int));
925 ofile.write((
char *)itmp, 4);
932 unsigned char tcolor[3];
934 ofile.write((
char *)tcolor, 3);
938 for(
int isteps = 0; isteps < nsteps; isteps++) {
939 kTracks[nt].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
940 stepPoints[3], stepPoints[4], stepPoints[5],
944 ofile.write((
char *)stepPoints,
sizeof(
float)*6);
946 for(
int j = 0; j < 6; j++)
948 ofile.write((
char *)ftmp, 24);
959 ofile.write((
char *)&ndet,
sizeof(
int));
962 ofile.write((
char *)itmp, 4);
965 G4cout <<
"# of detectors : "
969 for(
int nd = 0; nd < ndet; nd++) {
972 int nedges =
kDetectors[nd].getNumberOfEdges();
974 ofile.write((
char *)&nedges,
sizeof(
int));
977 ofile.write((
char *)itmp, 4);
980 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
985 for(
int ne = 0; ne < nedges; ne++) {
986 kDetectors[nd].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
987 edgePoints[3], edgePoints[4], edgePoints[5],
991 ofile.write((
char *)edgePoints,
sizeof(
float)*6);
993 for(
int j = 0; j < 6; j++)
995 ofile.write((
char *)ftmp, 24);
1000 G4cout <<
" edge : (" << edgePoints[0] <<
", "
1001 << edgePoints[1] <<
", "
1002 << edgePoints[2] <<
") - ("
1003 << edgePoints[3] <<
", "
1004 << edgePoints[4] <<
", "
1005 << edgePoints[5] <<
")" <<
G4endl;
1011 unsigned char dcolor[3];
1013 ofile.write((
char *)dcolor, 3);
1015 G4cout <<
" rgb : (" << (
int)dcolor[0] <<
", "
1016 << (
int)dcolor[1] <<
", "
1017 << (
int)dcolor[2] <<
")" << G4endl;
1021 std::string dname =
kDetectors[nd].getName();
1023 ofile.write((
char *)dname.c_str(), 80);
1032 ofile.write(
"END", 3);
1049 std::ios_base::out|std::ios_base::binary);
1052 ofile.write(
"gMocren ", 8);
1055 unsigned char ver = 0x03;
1056 ofile.write((
char *)&ver, 1);
1062 int commentLength = 1024;
1063 ofile.write((
char *)&commentLength, 4);
1067 std::strncpy(cmt,
kComment.c_str(), 1024);
1068 ofile.write((
char *)cmt, 1024);
1070 G4cout <<
"Data comment : "
1077 G4cout <<
"Voxel spacing : ("
1092 ofile.write((
char *)&nDoseDist, 4);
1095 for(
int i = 0; i < nDoseDist; i++) {
1105 G4cout <<
"Each pointer to data : "
1107 for(
int i = 0; i < nDoseDist; i++) {
1123 ofile.write((
char *)size, 3*
sizeof(
int));
1125 G4cout <<
"Modality image size : ("
1134 ofile.write((
char *)minmax, 4);
1137 char munit[13] =
"g/cm3 ";
1138 ofile.write((
char *)munit, 12);
1142 ofile.write((
char *)&scale, 4);
1144 G4cout <<
"Modality image min., max., scale : "
1145 << minmax[0] <<
", "
1146 << minmax[1] <<
", "
1151 int psize = size[0]*size[1];
1153 for(
int i = 0; i < size[2]; i++) {
1155 ofile.write((
char *)image, psize*
sizeof(
short));
1157 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1162 size_t msize = minmax[1] - minmax[0]+1;
1163 float * pdmap =
new float[msize];
1165 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1167 G4cout <<
"density map : " << std::ends;
1168 for(
int i = 0; i < (
int)msize; i+=50)
1181 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1183 kDose[ndose].getSize(size);
1184 ofile.write((
char *)size, 3*
sizeof(
int));
1186 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
1195 ofile.write((
char *)minmax, 2*2);
1206 scale = float(dscale);
1207 ofile.write((
char *)&scale, 4);
1209 G4cout <<
"Dose dist. [" << ndose
1210 <<
"] image min., max., scale : "
1211 << minmax[0] <<
", "
1212 << minmax[1] <<
", "
1217 int dsize = size[0]*size[1];
1218 short * dimage =
new short[dsize];
1219 for(
int z = 0; z < size[2]; z++) {
1221 ofile.write((
char *)dimage, dsize*2);
1224 for(
int j = 0; j < dsize; j++) {
1226 G4cout <<
"[" << j <<
"," << z <<
"]"
1227 << dimage[j] <<
", ";
1237 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1238 ofile.write((
char *)iCenter, 3*4);
1240 G4cout <<
"Dose dist. [" << ndose
1241 <<
"]image relative location : ("
1242 << iCenter[0] <<
", "
1243 << iCenter[1] <<
", "
1244 << iCenter[2] <<
")" <<
G4endl;
1252 kRoi[0].getSize(size);
1253 ofile.write((
char *)size, 3*
sizeof(
int));
1255 G4cout <<
"ROI image size : ("
1263 kRoi[0].getMinMax(minmax);
1264 ofile.write((
char *)minmax,
sizeof(
short)*2);
1267 scale = (float)
kRoi[0].getScale();
1268 ofile.write((
char *)&scale,
sizeof(
float));
1270 G4cout <<
"ROI image min., max., scale : "
1271 << minmax[0] <<
", "
1272 << minmax[1] <<
", "
1277 int rsize = size[0]*size[1];
1278 for(
int i = 0; i < size[2]; i++) {
1279 short * rimage =
kRoi[0].getImage(i);
1280 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1285 kRoi[0].getCenterPosition(fCenter);
1286 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1287 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1289 G4cout <<
"ROI image relative location : ("
1290 << iCenter[0] <<
", "
1291 << iCenter[1] <<
", "
1292 << iCenter[2] <<
")" <<
G4endl;
1298 int ntrk =
kSteps.size();
1299 ofile.write((
char *)&ntrk,
sizeof(
int));
1301 G4cout <<
"# of tracks : "
1305 for(
int i = 0; i < ntrk; i++) {
1307 ofile.write((
char *)tp,
sizeof(
float)*6);
1313 G4cout <<
"# of track color information must be the same as # of tracks."
1315 unsigned char white[3] = {255,255,255};
1316 for(
int i = 0; i < ntrk; i++) {
1319 ofile.write((
char *)tcolor, 3);
1321 ofile.write((
char *)white, 3);
1326 ofile.write(
"END", 3);
1348 std::ios_base::out|std::ios_base::binary);
1351 ofile.write(
"GRAPE ", 8);
1354 unsigned char ver = 0x02;
1355 ofile.write((
char *)&ver, 1);
1377 G4cout <<
"Voxel spacing : ("
1397 G4cout <<
"Each pointer to data : "
1413 ofile.write((
char *)size, 3*
sizeof(
int));
1415 G4cout <<
"Modality image size : ("
1424 ofile.write((
char *)minmax, 4);
1432 ofile.write((
char *)&scale, 4);
1434 G4cout <<
"Modality image min., max., scale : "
1435 << minmax[0] <<
", "
1436 << minmax[1] <<
", "
1441 int psize = size[0]*size[1];
1443 for(
int i = 0; i < size[2]; i++) {
1445 ofile.write((
char *)image, psize*
sizeof(
short));
1447 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1452 size_t msize = minmax[1] - minmax[0]+1;
1453 float * pdmap =
new float[msize];
1455 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1457 G4cout <<
"density map : " << std::ends;
1458 for(
int i = 0; i < (
int)msize; i+=50)
1471 kDose[0].getSize(size);
1472 ofile.write((
char *)size, 3*
sizeof(
int));
1474 G4cout <<
"Dose dist. image size : ("
1483 ofile.write((
char *)minmax,
sizeof(
short)*2);
1486 scale = (float)
kDose[0].getScale();
1487 ofile.write((
char *)&scale,
sizeof(
float));
1489 G4cout <<
"Dose dist. image min., max., scale : "
1490 << minmax[0] <<
", "
1491 << minmax[1] <<
", "
1496 int dsize = size[0]*size[1];
1497 short * dimage =
new short[dsize];
1498 for(
int z = 0; z < size[2]; z++) {
1500 ofile.write((
char *)dimage, dsize*
sizeof(
short));
1503 for(
int j = 0; j < dsize; j++) {
1505 G4cout <<
"[" << j <<
"," << z <<
"]"
1506 << dimage[j] <<
", ";
1515 kDose[0].getCenterPosition(fCenter);
1516 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1517 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1519 G4cout <<
"Dose dist. image relative location : ("
1520 << iCenter[0] <<
", "
1521 << iCenter[1] <<
", "
1522 << iCenter[2] <<
")" <<
G4endl;
1530 kRoi[0].getSize(size);
1531 ofile.write((
char *)size, 3*
sizeof(
int));
1533 G4cout <<
"ROI image size : ("
1541 kRoi[0].getMinMax(minmax);
1542 ofile.write((
char *)minmax,
sizeof(
short)*2);
1545 scale = (float)
kRoi[0].getScale();
1546 ofile.write((
char *)&scale,
sizeof(
float));
1548 G4cout <<
"ROI image min., max., scale : "
1549 << minmax[0] <<
", "
1550 << minmax[1] <<
", "
1555 int rsize = size[0]*size[1];
1556 for(
int i = 0; i < size[2]; i++) {
1557 short * rimage =
kRoi[0].getImage(i);
1558 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1563 kRoi[0].getCenterPosition(fCenter);
1564 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1565 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1567 G4cout <<
"ROI image relative location : ("
1568 << iCenter[0] <<
", "
1569 << iCenter[1] <<
", "
1570 << iCenter[2] <<
")" <<
G4endl;
1577 int ntrk =
kSteps.size();
1578 ofile.write((
char *)&ntrk,
sizeof(
int));
1580 G4cout <<
"# of tracks : "
1583 for(
int i = 0; i < ntrk; i++) {
1585 ofile.write((
char *)tp,
sizeof(
float)*6);
1590 ofile.write(
"END", 3);
1605 std::ifstream ifile(
kFileName.c_str(), std::ios_base::in|std::ios_base::binary);
1609 <<
" in G4GMocrenIO::retrieveData()." <<
G4endl;
1615 ifile.read((
char *)verid, 8);
1618 ifile.read((
char *)&ver, 1);
1621 if(std::strncmp(verid,
"gMocren", 7) == 0) {
1623 G4cout <<
">>>>>>> retrieve data (ver.3) <<<<<<<" <<
G4endl;
1626 }
else if (ver == 0x04) {
1627 G4cout <<
">>>>>>> retrieve data (ver.4) <<<<<<<" <<
G4endl;
1632 G4cout <<
"Error -- invalid file version : " << (
int)ver
1641 }
else if(std::strncmp(verid,
"GRAPE", 5) == 0) {
1642 G4cout <<
">>>>>>> retrieve data (ver.2) <<<<<<<" <<
G4endl;
1665 std::ifstream ifile(
kFileName.c_str(), std::ios_base::in|std::ios_base::binary);
1669 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
1678 ifile.read((
char *)verid, 8);
1682 ifile.read((
char *)&ver, 1);
1683 std::stringstream ss;
1701 ifile.read((
char *)ctmp, 4);
1705 ifile.read((
char *)cmt, clength);
1706 std::string scmt = cmt;
1710 G4cout <<
"Data comment : "
1715 ifile.read((
char *)ctmp, 12);
1720 G4cout <<
"Voxel spacing : ("
1729 ifile.read((
char *)ctmp, 4);
1733 ifile.read((
char *)ctmp, 4);
1738 for(
int i = 0; i < nDoseDist; i++) {
1739 ifile.read((
char *)ctmp, 4);
1746 ifile.read((
char *)ctmp, 4);
1750 ifile.read((
char *)ctmp, 4);
1754 ifile.read((
char *)ctmp, 4);
1758 G4cout <<
"Each pointer to data : "
1760 for(
int i = 0; i < nDoseDist; i++)
1793 ifile.read(ctmp, 3*
sizeof(
int));
1798 G4cout <<
"Modality image size : ("
1817 ifile.read((
char *)ctmp, 4);
1825 ifile.read((
char *)munit, 12);
1826 std::string smunit = munit;
1830 ifile.read((
char *)ctmp, 4);
1834 G4cout <<
"Modality image min., max., scale : "
1835 << minmax[0] <<
", "
1836 << minmax[1] <<
", "
1841 int psize = size[0]*size[1];
1842 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
1843 char * cimage =
new char[psize*
sizeof(short)];
1844 for(
int i = 0; i < size[2]; i++) {
1845 ifile.read((
char *)cimage, psize*
sizeof(
short));
1846 short * mimage =
new short[psize];
1847 for(
int j = 0; j < psize; j++) {
1852 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
1858 size_t msize = minmax[1]-minmax[0]+1;
1860 char * pdmap =
new char[msize*
sizeof(float)];
1861 ifile.read((
char *)pdmap, msize*
sizeof(
float));
1863 for(
int i = 0; i < (
int)msize; i++) {
1870 G4cout <<
"density map : " << std::ends;
1871 for(
int i = 0; i < 10; i++)
1874 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
1885 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1890 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1895 G4cout <<
"Dose dist. image size : ("
1901 kDose[ndose].setSize(size);
1904 ifile.read((
char *)ctmp,
sizeof(
short)*2);
1911 ifile.read((
char *)dunit, 12);
1912 std::string sdunit = dunit;
1919 ifile.read((
char *)ctmp, 4);
1921 kDose[ndose].setScale(dscale = scale);
1924 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
1925 kDose[ndose].setMinMax(dminmax);
1928 G4cout <<
"Dose dist. image min., max., scale : "
1929 << dminmax[0] <<
", "
1930 << dminmax[1] <<
", "
1935 int dsize = size[0]*size[1];
1936 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
1937 char * di =
new char[dsize*
sizeof(short)];
1938 short * shimage =
new short[dsize];
1939 for(
int z = 0; z < size[2]; z++) {
1940 ifile.read((
char *)di, dsize*
sizeof(
short));
1941 double * dimage =
new double[dsize];
1942 for(
int xy = 0; xy < dsize; xy++) {
1944 dimage[xy] = shimage[xy]*dscale;
1946 kDose[ndose].addImage(dimage);
1948 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
1951 for(
int j = 0; j < dsize; j++) {
1953 G4cout <<
"[" << j <<
"," << z <<
"]"
1954 << dimage[j] <<
", ";
1962 ifile.read((
char *)ctmp, 3*4);
1966 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
1967 kDose[ndose].setCenterPosition(fCenter);
1970 G4cout <<
"Dose dist. image relative location : ("
1971 << fCenter[0] <<
", "
1972 << fCenter[1] <<
", "
1973 << fCenter[2] <<
")" <<
G4endl;
1979 ifile.read((
char *)cname, 80);
1980 std::string dosename = cname;
1994 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1998 kRoi[0].setSize(size);
2000 G4cout <<
"ROI image size : ("
2008 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2011 kRoi[0].setMinMax(minmax);
2014 ifile.read((
char *)ctmp,
sizeof(
float));
2016 kRoi[0].setScale(dscale = scale);
2018 G4cout <<
"ROI image min., max., scale : "
2019 << minmax[0] <<
", "
2020 << minmax[1] <<
", "
2025 int rsize = size[0]*size[1];
2026 char * ri =
new char[rsize*
sizeof(short)];
2027 for(
int i = 0; i < size[2]; i++) {
2028 ifile.read((
char *)ri, rsize*
sizeof(
short));
2029 short * rimage =
new short[rsize];
2030 for(
int j = 0; j < rsize; j++) {
2033 kRoi[0].addImage(rimage);
2039 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2043 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2044 kRoi[0].setCenterPosition(fCenter);
2046 G4cout <<
"ROI image relative location : ("
2047 << fCenter[0] <<
", "
2048 << fCenter[1] <<
", "
2049 << fCenter[2] <<
")" <<
G4endl;
2058 ifile.read((
char *)ctmp,
sizeof(
int));
2066 unsigned char rgb[3];
2067 for(
int i = 0; i < ntrk; i++) {
2071 ifile.read((
char *)ctmp,
sizeof(
int));
2076 ifile.read((
char *)rgb, 3);
2078 std::vector<float *> steps;
2080 for(
int j = 0; j < nsteps; j++) {
2082 float * steppoint =
new float[6];
2083 ifile.read((
char *)ctmp,
sizeof(
float)*6);
2085 for(
int k = 0; k < 6; k++) {
2089 steps.push_back(steppoint);
2098 for(
int j = 0; j < 3; j++)
G4cout << steps[0][j] <<
" ";
2099 int nstp = steps.size();
2101 for(
int j = 3; j < 6; j++)
G4cout << steps[nstp-1][j] <<
" ";
2103 for(
int j = 0; j < 3; j++)
G4cout << (
int)rgb[j] <<
" ";
2117 ifile.read((
char *)ctmp,
sizeof(
int));
2122 G4cout <<
"# of detectors : "
2126 for(
int nd = 0; nd < ndet; nd++) {
2129 ifile.read((
char *)ctmp,
sizeof(
int));
2133 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
2137 std::vector<float *> detector;
2139 for(
int ne = 0; ne < nedges; ne++) {
2141 ifile.read((
char *)cftmp,
sizeof(
float)*6);
2142 float * edgePoints =
new float[6];
2143 for(
int j = 0; j < 6; j++)
convertEndian(&cftmp[
sizeof(
float)*j], edgePoints[j]);
2144 detector.push_back(edgePoints);
2149 G4cout <<
" first edge : (" << detector[0][0] <<
", "
2150 << detector[0][1] <<
", "
2151 << detector[0][2] <<
") - ("
2152 << detector[0][3] <<
", "
2153 << detector[0][4] <<
", "
2154 << detector[0][5] <<
")" <<
G4endl;
2158 unsigned char dcolor[3];
2159 ifile.read((
char *)dcolor, 3);
2161 G4cout <<
" detector color : rgb("
2162 << (
int)dcolor[0] <<
", "
2163 << (
int)dcolor[1] <<
", "
2164 << (
int)dcolor[2] << G4endl;
2170 ifile.read((
char *)cname, 80);
2171 std::string dname = cname;
2198 std::ifstream ifile(
kFileName.c_str(), std::ios_base::in|std::ios_base::binary);
2202 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
2211 ifile.read((
char *)verid, 8);
2215 ifile.read((
char *)&ver, 1);
2216 std::stringstream ss;
2234 ifile.read((
char *)ctmp, 4);
2238 ifile.read((
char *)cmt, clength);
2239 std::string scmt = cmt;
2242 G4cout <<
"Data comment : "
2247 ifile.read((
char *)ctmp, 12);
2252 G4cout <<
"Voxel spacing : ("
2261 ifile.read((
char *)ctmp, 4);
2265 ifile.read((
char *)ctmp, 4);
2270 for(
int i = 0; i < nDoseDist; i++) {
2271 ifile.read((
char *)ctmp, 4);
2278 ifile.read((
char *)ctmp, 4);
2282 ifile.read((
char *)ctmp, 4);
2285 G4cout <<
"Each pointer to data : "
2287 for(
int i = 0; i < nDoseDist; i++)
2316 ifile.read(ctmp, 3*
sizeof(
int));
2321 G4cout <<
"Modality image size : ("
2340 ifile.read((
char *)ctmp, 4);
2347 ifile.read((
char *)munit, 12);
2348 std::string smunit = munit;
2352 ifile.read((
char *)ctmp, 4);
2356 G4cout <<
"Modality image min., max., scale : "
2357 << minmax[0] <<
", "
2358 << minmax[1] <<
", "
2363 int psize = size[0]*size[1];
2364 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2365 char * cimage =
new char[psize*
sizeof(short)];
2366 for(
int i = 0; i < size[2]; i++) {
2367 ifile.read((
char *)cimage, psize*
sizeof(
short));
2368 short * mimage =
new short[psize];
2369 for(
int j = 0; j < psize; j++) {
2374 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2380 size_t msize = minmax[1]-minmax[0]+1;
2382 char * pdmap =
new char[msize*
sizeof(float)];
2383 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2385 for(
int i = 0; i < (
int)msize; i++) {
2391 G4cout <<
"density map : " << std::ends;
2392 for(
int i = 0; i < 10; i++)
2395 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2406 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
2411 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2416 G4cout <<
"Dose dist. image size : ("
2422 kDose[ndose].setSize(size);
2425 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2431 ifile.read((
char *)dunit, 12);
2432 std::string sdunit = dunit;
2439 ifile.read((
char *)ctmp, 4);
2441 kDose[ndose].setScale(dscale = scale);
2444 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2445 kDose[ndose].setMinMax(dminmax);
2448 G4cout <<
"Dose dist. image min., max., scale : "
2449 << dminmax[0] <<
", "
2450 << dminmax[1] <<
", "
2455 int dsize = size[0]*size[1];
2456 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2457 char * di =
new char[dsize*
sizeof(short)];
2458 short * shimage =
new short[dsize];
2459 for(
int z = 0; z < size[2]; z++) {
2460 ifile.read((
char *)di, dsize*
sizeof(
short));
2461 double * dimage =
new double[dsize];
2462 for(
int xy = 0; xy < dsize; xy++) {
2464 dimage[xy] = shimage[xy]*dscale;
2466 kDose[ndose].addImage(dimage);
2468 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2471 for(
int j = 0; j < dsize; j++) {
2473 G4cout <<
"[" << j <<
"," << z <<
"]"
2474 << dimage[j] <<
", ";
2482 ifile.read((
char *)ctmp, 3*4);
2486 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2487 kDose[ndose].setCenterPosition(fCenter);
2490 G4cout <<
"Dose dist. image relative location : ("
2491 << fCenter[0] <<
", "
2492 << fCenter[1] <<
", "
2493 << fCenter[2] <<
")" <<
G4endl;
2505 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2509 kRoi[0].setSize(size);
2511 G4cout <<
"ROI image size : ("
2519 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2522 kRoi[0].setMinMax(minmax);
2525 ifile.read((
char *)ctmp,
sizeof(
float));
2527 kRoi[0].setScale(dscale = scale);
2529 G4cout <<
"ROI image min., max., scale : "
2530 << minmax[0] <<
", "
2531 << minmax[1] <<
", "
2536 int rsize = size[0]*size[1];
2537 char * ri =
new char[rsize*
sizeof(short)];
2538 for(
int i = 0; i < size[2]; i++) {
2539 ifile.read((
char *)ri, rsize*
sizeof(
short));
2540 short * rimage =
new short[rsize];
2541 for(
int j = 0; j < rsize; j++) {
2544 kRoi[0].addImage(rimage);
2550 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2554 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2555 kRoi[0].setCenterPosition(fCenter);
2557 G4cout <<
"ROI image relative location : ("
2558 << fCenter[0] <<
", "
2559 << fCenter[1] <<
", "
2560 << fCenter[2] <<
")" <<
G4endl;
2569 ifile.read((
char *)ctmp,
sizeof(
int));
2577 std::vector<float *> trkv4;
2580 for(
int i = 0; i < ntrk; i++) {
2581 float *
tp =
new float[6];
2583 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2585 for(
int j = 0; j < 3; j++) {
2590 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2591 for(
int j = 0; j < 3; j++) {
2599 trkv4.push_back(tp);
2603 unsigned char trkcolorv4[3];
2606 for(
int i = 0; i < ntrk; i++) {
2607 unsigned char * rgb =
new unsigned char[3];
2608 ifile.read((
char *)rgb, 3);
2612 for(
int j = 0; j < 3; j++) trkcolorv4[j] = rgb[j];
2613 std::vector<float *> trk;
2614 trk.push_back(trkv4[i]);
2636 std::ifstream ifile(
kFileName.c_str(), std::ios_base::in|std::ios_base::binary);
2640 <<
" in G4GMocrenIO::retrieveData2()." <<
G4endl;
2649 ifile.read((
char *)verid, 8);
2653 ifile.read((
char *)&ver, 1);
2654 std::stringstream ss;
2661 ifile.read((
char *)idtmp,
IDLENGTH);
2679 ifile.read((
char *)ctmp, 12);
2684 G4cout <<
"Voxel spacing : ("
2693 ifile.read((
char *)ctmp, 4);
2698 ifile.read((
char *)ctmp, 4);
2703 ifile.read((
char *)ctmp, 4);
2707 ifile.read((
char *)ctmp, 4);
2710 G4cout <<
"Each pointer to data : "
2740 ifile.read(ctmp, 3*
sizeof(
int));
2745 G4cout <<
"Modality image size : ("
2764 ifile.read((
char *)ctmp, 4);
2770 ifile.read((
char *)ctmp, 4);
2774 G4cout <<
"Modality image min., max., scale : "
2775 << minmax[0] <<
", "
2776 << minmax[1] <<
", "
2781 int psize = size[0]*size[1];
2782 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2783 char * cimage =
new char[psize*
sizeof(short)];
2784 for(
int i = 0; i < size[2]; i++) {
2785 ifile.read((
char *)cimage, psize*
sizeof(
short));
2786 short * mimage =
new short[psize];
2787 for(
int j = 0; j < psize; j++) {
2792 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2798 size_t msize = minmax[1]-minmax[0]+1;
2800 char * pdmap =
new char[msize*
sizeof(float)];
2801 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2803 for(
int i = 0; i < (
int)msize; i++) {
2809 G4cout <<
"density map : " << std::ends;
2810 for(
int i = 0; i < 10; i++)
2813 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2829 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2834 G4cout <<
"Dose dist. image size : ("
2840 kDose[0].setSize(size);
2843 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2847 ifile.read((
char *)ctmp,
sizeof(
float));
2849 kDose[0].setScale(dscale = scale);
2852 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2853 kDose[0].setMinMax(dminmax);
2856 G4cout <<
"Dose dist. image min., max., scale : "
2857 << dminmax[0] <<
", "
2858 << dminmax[1] <<
", "
2863 int dsize = size[0]*size[1];
2864 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2865 char * di =
new char[dsize*
sizeof(short)];
2866 short * shimage =
new short[dsize];
2867 for(
int z = 0; z < size[2]; z++) {
2868 ifile.read((
char *)di, dsize*
sizeof(
short));
2869 double * dimage =
new double[dsize];
2870 for(
int xy = 0; xy < dsize; xy++) {
2872 dimage[xy] = shimage[xy]*dscale;
2874 kDose[0].addImage(dimage);
2876 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2879 for(
int j = 0; j < dsize; j++) {
2881 G4cout <<
"[" << j <<
"," << z <<
"]"
2882 << dimage[j] <<
", ";
2924 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2928 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2929 kDose[0].setCenterPosition(fCenter);
2932 G4cout <<
"Dose dist. image relative location : ("
2933 << fCenter[0] <<
", "
2934 << fCenter[1] <<
", "
2935 << fCenter[2] <<
")" <<
G4endl;
2947 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2951 kRoi[0].setSize(size);
2953 G4cout <<
"ROI image size : ("
2961 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2964 kRoi[0].setMinMax(minmax);
2967 ifile.read((
char *)ctmp,
sizeof(
float));
2969 kRoi[0].setScale(dscale = scale);
2971 G4cout <<
"ROI image min., max., scale : "
2972 << minmax[0] <<
", "
2973 << minmax[1] <<
", "
2978 int rsize = size[0]*size[1];
2979 char * ri =
new char[rsize*
sizeof(short)];
2980 for(
int i = 0; i < size[2]; i++) {
2981 ifile.read((
char *)ri, rsize*
sizeof(
short));
2982 short * rimage =
new short[rsize];
2983 for(
int j = 0; j < rsize; j++) {
2986 kRoi[0].addImage(rimage);
2992 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2996 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2997 kRoi[0].setCenterPosition(fCenter);
2999 G4cout <<
"ROI image relative location : ("
3000 << fCenter[0] <<
", "
3001 << fCenter[1] <<
", "
3002 << fCenter[2] <<
")" <<
G4endl;
3011 ifile.read((
char *)ctmp,
sizeof(
int));
3019 unsigned char trkcolorv4[3] = {255, 0, 0};
3021 for(
int i = 0; i < ntrk; i++) {
3022 float *
tp =
new float[6];
3024 std::vector<float *> trkv4;
3026 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3028 for(
int j = 0; j < 3; j++) {
3033 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3034 for(
int j = 0; j < 3; j++) {
3041 trkv4.push_back(tp);
3108 char cmonth[12][4] = {
"Jan",
"Feb",
"Mar",
"Apr",
3109 "May",
"Jun",
"Jul",
"Aug",
3110 "Sep",
"Oct",
"Nov",
"Dec"};
3111 std::stringstream ss;
3112 ss << std::setfill(
'0')
3114 << ti->tm_hour <<
":"
3116 << ti->tm_min <<
":"
3118 << ti->tm_sec <<
","
3119 << cmonth[ti->tm_mon] <<
"."
3121 << ti->tm_mday <<
","
3122 << ti->tm_year+1900;
3189 void G4GMocrenIO::calcPointers4() {
3192 unsigned int pointer = 1070;
3194 pointer += nDoseDist*4;
3204 int pmsize = 2*msize[0]*msize[1]*msize[2];
3205 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3206 pointer += 32 + pmsize + pmmap;
3209 if(nDoseDist == 0) {
3210 unsigned int pointer0 = 0;
3213 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3217 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2 + 80;
3226 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3227 pointer += 20 + prsize + 12;
3229 unsigned int pointer0 = 0;
3239 for(
int nt = 0; nt < ntrk; nt++) {
3240 int nsteps =
kTracks[nt].getNumberOfSteps();
3241 pointer += 4 + 3 + nsteps*(4*6);
3244 unsigned int pointer0 = 0;
3263 void G4GMocrenIO::calcPointers3() {
3266 unsigned int pointer = 1066;
3268 pointer += nDoseDist*4;
3278 int pmsize = 2*msize[0]*msize[1]*msize[2];
3279 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3280 pointer += 32 + pmsize + pmmap;
3283 if(nDoseDist == 0) {
3284 unsigned int pointer0 = 0;
3287 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3291 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2;
3300 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3301 pointer += 20 + prsize + 12;
3303 unsigned int pointer0 = 0;
3311 unsigned int pointer0 = 0;
3318 void G4GMocrenIO::calcPointers2() {
3321 unsigned int pointer = 65;
3329 int pmsize = 2*msize[0]*msize[1]*msize[2];
3330 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3331 pointer += 20 + pmsize + pmmap;
3338 int pdsize = 2*dsize[0]*dsize[1]*dsize[2];
3339 pointer += 20 + pdsize + 12;
3341 unsigned int pointer0 = 0;
3350 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3351 pointer += 20 + prsize + 12;
3354 unsigned int pointer0 = 0;
3362 unsigned int pointer0 = 0;
3419 for(
int i = 0; i < 2; i++) _minmax[i] = minmax[i];
3441 for(
int i = 0; i < 3; i++) _center[i] = 0;
3460 for(
int i = 0; i < nmap; i++) {
3463 rval = i + minmax[0];
3476 kDose.push_back(doseData);
3479 return (
int)
kDose.size();
3491 if(_unit.size() >
static_cast<size_t>(_num))
kDoseUnit = _unit;
3501 for(
int i = 0; i < 3; i++) _size[i] = 0;
3503 kDose[_num].getSize(_size);
3507 kDose[_num].setSize(_size);
3515 double scale =
kDose[_num].getScale();
3516 for(
int i = 0; i < 2; i++) minmax[i] = (
double)_minmax[i]*scale;
3517 kDose[_num].setMinMax(minmax);
3522 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3525 kDose[_num].getMinMax(minmax);
3526 double scale =
kDose[_num].getScale();
3527 for(
int i = 0; i < 2; i++) _minmax[i] = (
short)(minmax[i]/scale+0.5);
3532 kDose[_num].setMinMax(_minmax);
3537 for(
int i = 0; i < 2; i++) _minmax[i] = 0.;
3539 kDose[_num].getMinMax(_minmax);
3545 kDose[_num].setScale(_scale);
3552 return kDose[_num].getScale();
3567 kDose[_num].getSize(size);
3568 int dsize = size[0]*size[1];
3569 double * ddata =
new double[dsize];
3570 double scale =
kDose[_num].getScale();
3572 kDose[_num].getMinMax(minmax);
3573 for(
int xy = 0; xy < dsize; xy++) {
3574 ddata[xy] = _image[xy]*scale;
3575 if(ddata[xy] < minmax[0]) minmax[0] = ddata[xy];
3576 if(ddata[xy] > minmax[1]) minmax[1] = ddata[xy];
3578 kDose[_num].addImage(ddata);
3581 kDose[_num].setMinMax(minmax);
3587 G4cout <<
"In G4GMocrenIO::getShortDoseDist(), "
3588 <<
"first argument is NULL pointer. "
3589 <<
"The argument must be allocated array."
3598 kDose[_num].getSize(size);
3600 double * ddata =
kDose[_num].getImage(_z);
3601 double scale =
kDose[_num].getScale();
3602 for(
int xy = 0; xy < size[0]*size[1]; xy++) {
3603 _data[xy] = (short)(ddata[xy]/scale+0.5);
3607 double scale =
kDose[_num].getScale();
3609 kDose[_num].getMinMax(minmax);
3610 for(
int i = 0; i < 2; i++)
3611 _minmax[i] = (
short)(minmax[i]/scale+0.5);
3616 kDose[_num].addImage(_image);
3624 image =
kDose[_num].getImage(_z);
3645 std::vector<double *> dosedist =
kDose[_num].getImage();
3647 int nimg = size[0]*size[1];
3648 for(
int z = 0; z < size[2]; z++) {
3649 for(
int xy = 0; xy < nimg; xy++) {
3650 dosedist[z][xy] += _image[z][xy];
3660 kDose[_num].setCenterPosition(_center);
3665 for(
int i = 0; i < 3; i++) _center[i] = 0;
3667 kDose[_num].getCenterPosition(_center);
3672 kDose[_num].setName(_name);
3680 return kDose[_num].getName();
3684 std::vector<class GMocrenDataPrimitive<double> >::iterator itr;
3685 for(itr =
kDose.begin(); itr !=
kDose.end(); itr++) {
3686 _dose.push_back(*itr);
3691 if(
kDose.size() != _dose.size()) {
3693 G4cout <<
"G4GMocrenIO::mergeDoseDist() : Error" <<
G4endl;
3694 G4cout <<
" Unable to merge the dose distributions,"<<
G4endl;
3695 G4cout <<
" because of different size of dose maps."<<
G4endl;
3700 int num =
kDose.size();
3701 std::vector<class GMocrenDataPrimitive<double> >::iterator itr1 =
kDose.begin();
3702 std::vector<class GMocrenDataPrimitive<double> >::iterator itr2 = _dose.begin();
3703 for(
int i = 0; i < num; i++, itr1++, itr2++) {
3706 G4cout <<
"merged dose distribution [" << i <<
"]" <<
G4endl;
3739 for(
int i = 0; i < (
int)
kDose.size(); i++) {
3740 kDose[i].getMinMax(minmax);
3742 kDose[i].setScale(scale);
3752 kRoi.push_back(roiData);
3755 return (
int)
kRoi.size();
3761 kRoi[_num].setScale(_scale);
3768 return kRoi[_num].getScale();
3773 kRoi[_num].addImage(_image);
3780 return kRoi[_num].getImage(_z);
3785 return kRoi[_num].setSize(_size);
3790 for(
int i = 0; i < 3; i++) _size[i] = 0;
3792 return kRoi[_num].getSize(_size);
3797 kRoi[_num].setMinMax(_minmax);
3802 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3804 kRoi[_num].getMinMax(_minmax);
3809 kRoi[_num].setCenterPosition(_center);
3814 for(
int i = 0; i < 3; i++) _center[i] = 0;
3816 kRoi[_num].getCenterPosition(_center);
3844 return (
int)
kSteps.size();
3850 kSteps.push_back(_tracks);
3868 std::vector<unsigned char *> & _colors) {
3869 std::vector<float *>::iterator titr;
3870 for(titr =
kSteps.begin(); titr !=
kSteps.end(); titr++) {
3871 float * pts =
new float[6];
3872 for(
int i = 0; i < 6; i++) {
3873 pts[i] = (*titr)[i];
3875 _tracks.push_back(pts);
3878 std::vector<unsigned char *>::iterator citr;
3880 unsigned char * pts =
new unsigned char[3];
3881 for(
int i = 0; i < 3; i++) {
3882 pts[i] = (*citr)[i];
3884 _colors.push_back(pts);
3888 std::vector<unsigned char *> & _colors) {
3889 std::vector<float *>::iterator titr;
3890 for(titr = _tracks.begin(); titr != _tracks.end(); titr++) {
3894 std::vector<unsigned char *>::iterator citr;
3895 for(citr = _colors.begin(); citr != _colors.end(); citr++) {
3901 std::vector<float *>::iterator itr = _steps.begin();
3902 std::vector<struct GMocrenTrack::Step> steps;
3903 for(; itr != _steps.end(); itr++) {
3905 for(
int i = 0; i < 3; i++) {
3909 steps.push_back(step);
3918 std::vector<unsigned char *> & _color) {
3920 if(_num > (
int)
kTracks.size()) {
3922 G4cout <<
"ERROR in getTrack() : " << G4endl;
3927 unsigned char * color =
new unsigned char[3];
3928 kTracks[_num].getColor(color);
3929 _color.push_back(color);
3932 int nsteps =
kTracks[_num].getNumberOfSteps();
3933 for(
int isteps = 0; isteps < nsteps; isteps++) {
3934 float * stepPoints =
new float[6];
3935 kTracks[_num].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
3936 stepPoints[3], stepPoints[4], stepPoints[5],
3938 _steps.push_back(stepPoints);
3943 std::vector<class GMocrenTrack>::iterator itr =
kTracks.begin();
3944 for(; itr !=
kTracks.end(); itr++) {
3945 itr->translate(_translate);
3957 std::vector<float *> & _det,
3958 unsigned char _color[3]) {
3960 std::vector<float *>::iterator itr = _det.begin();
3961 std::vector<struct GMocrenDetector::Edge> edges;
3962 for(; itr != _det.end(); itr++) {
3964 for(
int i = 0; i < 3; i++) {
3968 edges.push_back(edge);
3979 std::vector<unsigned char *> & _color,
3980 std::string & _detName) {
3984 G4cout <<
"ERROR in getDetector() : " << G4endl;
3993 unsigned char * color =
new unsigned char[3];
3995 _color.push_back(color);
3998 int nedges =
kDetectors[_num].getNumberOfEdges();
3999 for(
int ne = 0; ne < nedges; ne++) {
4000 float * edgePoints =
new float[6];
4001 kDetectors[_num].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
4002 edgePoints[3], edgePoints[4], edgePoints[5],
4004 _edges.push_back(edgePoints);
4009 std::vector<class GMocrenDetector>::iterator itr =
kDetectors.begin();
4011 itr->translate(_translate);
4016 template <
typename T>
4022 const int SIZE =
sizeof(_rval);
4024 for(
int i = 0; i < SIZE/2; i++) {
4026 _val[i] = _val[SIZE - 1 - i];
4027 _val[SIZE - 1 - i] = ctemp;
4034 template <
typename T>
4037 const int SIZE =
sizeof(_rval);
4043 for(
int i = 0; i < SIZE; i++) {
4044 uni.cu[i] = _val[SIZE-1-i];
void getEdge(float &_startx, float &_starty, float &_startz, float &_endx, float &_endy, float &_endz, int _num)
void getModalityImageSize(int _size[3])
std::vector< T * > kImage
void convertEndian(char *, Type &)
unsigned int getPointerToTrackData()
static std::vector< float > kModalityImageDensityMap
void getModalityCenterPosition(float _center[3])
void setVerboseLevel(int _level)
short convertDensityToHU(float &_dens)
void setDoseDistUnit(std::string &_unit, int _num=0)
double getModalityImageScale()
unsigned int getPointerToROIData()
void setVersion(std::string &_version)
double getDoseDistScale(int _num=0)
void clearModalityImage()
static char kLittleEndianOutput
double getROIScale(int _num=0)
void setROI(short *_image, int _num=0)
void addTrack(float *_tracks)
std::vector< float > & getModalityImageDensityMap()
std::vector< float * > & getTracks()
unsigned int getPointerToModalityData()
void invertByteOrder(char *_val, T &_rval)
short * getROI(int _z, int _num=0)
void setDoseDistMinMax(short _minmax[2], int _num=0)
void setModalityImageUnit(std::string &_unit)
static std::vector< class GMocrenDataPrimitive< short > > kRoi
void setTrack(std::vector< struct Step > &_aTrack)
void setModalityImageSize(int _size[3])
void getShortDoseDist(short *_data, int _z, int _num=0)
bool addDoseDist(std::vector< double * > &_image, int _num=0)
void setComment(std::string &_comment)
short getModalityImageMax()
std::vector< struct Step > kTrack
std::vector< unsigned char * > & getTrackColors()
GMocrenDataPrimitive< T > & operator=(const GMocrenDataPrimitive< T > &_right)
static constexpr double g
void getROICenterPosition(float _center[3], int _num=0)
GMocrenDataPrimitive< T > & operator+(const GMocrenDataPrimitive< T > &_right)
static std::vector< class GMocrenDataPrimitive< double > > kDose
void translate(std::vector< float > &_tranlate)
void copyTracks(std::vector< float * > &_tracks, std::vector< unsigned char * > &_colors)
std::string getDoseDistName(int _num=0)
void setROIMinMax(short _minmax[2], int _num=0)
static std::vector< unsigned char * > kStepColors
void translateDetector(std::vector< float > &_translate)
void getDoseDistSize(int _size[3], int _num=0)
static std::vector< class GMocrenDetector > kDetectors
static float kVoxelSpacing[3]
void setDoseDist(double *_image, int _num=0)
double * getDoseDist(int _z, int _num=0)
void setColor(unsigned char _color[3])
void setPointerToROIData(unsigned int &_pointer)
void addTrackColor(unsigned char *_colors)
G4GLOB_DLL std::ostream G4cout
static char kLittleEndianInput
static std::string kVersion
std::vector< T * > & getImage()
void getShortDoseDistMinMax(short _minmax[2], int _num=0)
void setScale(double &_scale)
void mergeTracks(std::vector< float * > &_tracks, std::vector< unsigned char * > &_colors)
void getCenterPosition(float _center[3])
void setMinMax(T _minmax[2])
void setROICenterPosition(float _center[3], int _num=0)
static int kNumberOfEvents
GMocrenDataPrimitive< T > & operator+=(const GMocrenDataPrimitive< T > &_right)
void addEdge(float _startx, float _starty, float _startz, float _endx, float _endy, float _endz)
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void setImage(std::vector< T * > &_image)
void getROISize(int _size[3], int _num=0)
void setModalityImageMinMax(short _minmax[2])
std::string getDoseDistUnit(int _num=0)
std::string & getVersion()
void setModalityImage(short *_image)
static constexpr double cm3
void setCenterPosition(float _center[3])
void setVoxelSpacing(float _spacing[3])
void setSize(int _size[3])
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void copyDoseDist(std::vector< class GMocrenDataPrimitive< double > > &_dose)
static unsigned int kPointerToModalityData
void getTrack(int _num, std::vector< float * > &_steps, std::vector< unsigned char * > &_color)
static std::vector< class GMocrenTrack > kTracks
void setTrackColors(std::vector< unsigned char * > &_trackColors)
void getMinMax(T _minmax[2])
short * getModalityImage(int _z)
void getModalityImageMinMax(short _minmax[2])
void translate(std::vector< float > &_tranlate)
std::vector< struct Edge > kDetector
void getStep(float &_startx, float &_starty, float &_startz, float &_endx, float &_endy, float &_endz, int _num)
void setModalityImageScale(double &_scale)
static std::string kFileName
static std::string kDoseUnit
bool mergeDoseDist(std::vector< class GMocrenDataPrimitive< double > > &_dose)
void getVoxelSpacing(float _spacing[3])
void setDoseDistCenterPosition(float _center[3], int _num=0)
void translateTracks(std::vector< float > &_translateo)
unsigned int getPointerToDoseDistData(int _elem=0)
void setNumberOfEvents(int &_numberOfEvents)
static Verbosity GetVerbosity()
void setPointerToModalityData(unsigned int &_pointer)
void setName(std::string &_name)
void getROIMinMax(short _minmax[2], int _num=0)
int & getNumberOfEvents()
void setShortDoseDist(short *_image, int _num=0)
void setDoseDistScale(double &_scale, int _num=0)
void addDetector(std::string &_name, std::vector< float * > &_det, unsigned char _color[3])
void setLittleEndianInput(bool _little)
static class GMocrenDataPrimitive< short > kModality
void setColor(unsigned char _color[3])
void setDoseDistSize(int _size[3], int _num=0)
static std::string kComment
static std::vector< unsigned int > kPointerToDoseDistData
static unsigned int kPointerToDetectorData
void setModalityCenterPosition(float _center[3])
void getDetector(int _num, std::vector< float * > &_edges, std::vector< unsigned char * > &_color, std::string &_detectorName)
void setROISize(int _size[3], int _num=0)
void setDetector(std::vector< struct Edge > &_aDetector)
static std::vector< float * > kSteps
static constexpr double keV
void setROIScale(double &_scale, int _num=0)
void getDoseDistCenterPosition(float _center[3], int _num=0)
void getSize(int _size[3])
void setName(std::string &_name)
void setPointerToTrackData(unsigned int &_pointer)
void addPointerToDoseDistData(unsigned int &_pointer)
void setTracks(std::vector< float * > &_tracks)
void getDoseDistMinMax(short _minmax[2], int _num=0)
void setLittleEndianOutput(bool _little)
void setDoseDistName(std::string _name, int _num=0)
short getModalityImageMin()
int getNumberOfDetectors()
std::string getModalityImageUnit()
static std::string kModalityUnit
void setModalityImageDensityMap(std::vector< float > &_map)
void addStep(float _startx, float _starty, float _startz, float _endx, float _endy, float _endz)
static unsigned int kPointerToROIData
static unsigned int kPointerToTrackData