51 #define LITTLE_ENDIAN 1234
52 #define BYTE_ORDER LITTLE_ENDIAN
74 if (
this == &_right)
return *
this;
75 for(
int i = 0; i < 3; i++) {
76 kSize[i] = _right.
kSize[i];
80 for(
int i = 0; i < 2; i++) kMinmax[i] = _right.
kMinmax[i];
81 int num = kSize[0]*kSize[1];
83 for(
int z = 0;
z < kSize[2];
z++) {
85 for(
int i = 0; i <
num; i++) img[i] =_right.
kImage[
z][i];
86 kImage.push_back(img);
96 for(
int i = 0; i < 3; i++) {
97 if(kSize[i] != _right.
kSize[i]) stat =
false;
98 if(kCenter[i] != _right.
kCenter[i]) stat =
false;
102 G4cout <<
"Warning: operator + "
103 <<
" Cannot do the operator +"
111 T mms[2] = {9e100,-9e100};
115 int num = kSize[0]*kSize[1];
116 for(
int z = 0;
z < kSize[2];
z++) {
117 T * img =
new T[
num];
118 for(
int xy = 0; xy <
num; xy++) {
119 img[xy] = kImage[
z][xy] + _right.
kImage[
z][xy];
120 if(mms[0] > img[xy]) mms[0] = img[xy];
121 if(mms[1] < img[xy]) mms[1] = img[xy];
137 for(
int i = 0; i < 3; i++) {
138 if(kSize[i] != _right.
kSize[i]) stat =
false;
139 if(kCenter[i] != _right.
kCenter[i]) stat =
false;
144 <<
" Cannot do the operator +="
149 if(kMinmax[0] > _right.
kMinmax[0]) kMinmax[0] = _right.
kMinmax[0];
150 if(kMinmax[1] < _right.
kMinmax[1]) kMinmax[1] = _right.
kMinmax[1];
152 int num = kSize[0]*kSize[1];
153 for(
int z = 0;
z < kSize[2];
z++) {
154 for(
int xy = 0; xy <
num; xy++) {
155 kImage[
z][xy] += _right.
kImage[
z][xy];
156 if(kMinmax[0] > kImage[
z][xy]) kMinmax[0] = kImage[
z][xy];
157 if(kMinmax[1] < kImage[
z][xy]) kMinmax[1] = kImage[
z][xy];
166 template <
typename T>
168 for(
int i = 0; i < 3; i++) {
173 kMinmax[0] = (
T)32109;
174 kMinmax[1] = (
T)-32109;
178 template <
typename T>
180 typename std::vector<T *>::iterator itr;
181 for(itr = kImage.begin(); itr != kImage.end(); itr++) {
186 template <
typename T>
188 for(
int i = 0; i < 3; i++) kSize[i] = _size[i];
190 template <
typename T>
192 for(
int i = 0; i < 3; i++) _size[i] = kSize[i];
194 template <
typename T>
198 template <
typename T>
202 template <
typename T>
204 for(
int i = 0; i < 2; i++) kMinmax[i] = _minmax[i];
206 template <
typename T>
208 for(
int i = 0; i < 2; i++) _minmax[i] = kMinmax[i];
211 template <
typename T>
215 template <
typename T>
217 kImage.push_back(_image);
219 template <
typename T>
223 template <
typename T>
225 if(_z >= (
int)kImage.size())
return 0;
228 template <
typename T>
230 for(
int i = 0; i < 3; i++) kCenter[i] = _center[i];
232 template <
typename T>
234 for(
int i = 0; i < 3; i++) _center[i] = kCenter[i];
236 template <
typename T>
240 template <
typename T>
251 for(
int i = 0; i < 3; i++)
kColor[i] = 0;
255 float _endx,
float _endy,
float _endz) {
266 float & _endx,
float & _endy,
float & _endz,
268 if(_num >= (
int)
kTrack.size()) {
270 G4cout <<
"GMocrenTrack::getStep(...) Error: "
271 <<
"invalid step # : " << _num <<
G4endl;
275 _startx =
kTrack[_num].startPoint[0];
276 _starty =
kTrack[_num].startPoint[1];
277 _startz =
kTrack[_num].startPoint[2];
278 _endx =
kTrack[_num].endPoint[0];
279 _endy =
kTrack[_num].endPoint[1];
280 _endz =
kTrack[_num].endPoint[2];
283 std::vector<struct Step>::iterator itr =
kTrack.begin();
284 for(; itr !=
kTrack.end(); itr++) {
285 for(
int i = 0; i < 3; i++ ) {
286 itr->startPoint[i] += _translate[i];
287 itr->endPoint[i] += _translate[i];
302 for(
int i = 0; i < 3; i++)
kColor[i] = 0;
306 float _endx,
float _endy,
float _endz) {
317 float & _endx,
float & _endy,
float & _endz,
321 G4cout <<
"GMocrenDetector::getEdge(...) Error: "
322 <<
"invalid edge # : " << _num <<
G4endl;
334 std::vector<struct Edge>::iterator itr =
kDetector.begin();
336 for(
int i = 0; i < 3; i++) {
337 itr->startPoint[i] += _translate[i];
338 itr->endPoint[i] += _translate[i];
357 #if BYTE_ORDER == LITTLE_ENDIAN
402 : kTracksWillBeStored(true) {
418 #if BYTE_ORDER == LITTLE_ENDIAN
440 std::vector<float *>::iterator itr;
441 for(itr =
kSteps.begin(); itr !=
kSteps.end(); itr++)
delete [] *itr;
443 std::vector<unsigned char *>::iterator citr;
466 G4cout <<
">>>>>>> store data (ver.4) <<<<<<<" <<
G4endl;
472 std::ios_base::out|std::ios_base::binary);
477 ofile.write(
"gMocren ", 8);
480 unsigned char ver = 0x04;
481 ofile.write((
char *)&ver, 1);
485 char littleEndian = 0x01;
486 ofile.write((
char *)&littleEndian,
sizeof(
char));
489 G4cout <<
"Endian: " << (
int)littleEndian << G4endl;
498 int commentLength = 1024;
500 ofile.write((
char *)&commentLength, 4);
503 ofile.write((
char *)itmp, 4);
508 std::strncpy(cmt,
kComment.c_str(), 1024);
510 ofile.write(cmt, 1024);
512 G4cout <<
"Data comment : "
520 for(
int j = 0; j < 3; j++)
522 ofile.write((
char *)ftmp, 12);
525 G4cout <<
"Voxel spacing : ("
540 ofile.write((
char *)itmp, 4);
547 ofile.write((
char *)&nDoseDist, 4);
550 ofile.write((
char *)itmp, 4);
555 for(
int i = 0; i < nDoseDist; i++) {
559 for(
int i = 0; i < nDoseDist; i++) {
561 ofile.write((
char *)itmp, 4);
570 ofile.write((
char *)itmp, 4);
578 ofile.write((
char *)itmp, 4);
586 ofile.write((
char *)itmp, 4);
590 G4cout <<
"Each pointer to data : "
592 for(
int i = 0; i < nDoseDist; i++) {
612 ofile.write((
char *)size, 3*
sizeof(
int));
614 for(
int j = 0; j < 3; j++)
616 ofile.write((
char *)itmp, 12);
620 G4cout <<
"Modality image size : ("
630 ofile.write((
char *)minmax, 4);
632 for(
int j = 0; j < 2; j++)
634 ofile.write((
char *)stmp, 4);
638 char munit[13] =
"g/cm3\0";
639 ofile.write((
char *)munit, 12);
644 ofile.write((
char *)&scale, 4);
647 ofile.write((
char *)ftmp, 4);
650 G4cout <<
"Modality image min., max., scale : "
657 int psize = size[0]*size[1];
659 for(
int i = 0; i < size[2]; i++) {
662 ofile.write((
char *)image, psize*
sizeof(
short));
664 for(
int j = 0; j < psize; j++) {
666 ofile.write((
char *)stmp, 2);
670 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
675 size_t msize = minmax[1] - minmax[0]+1;
677 G4cout <<
"modality image : " << minmax[0] <<
", " << minmax[1] <<
G4endl;
678 float * pdmap =
new float[msize];
682 ofile.write((
char *)pdmap, msize*
sizeof(
float));
684 for(
int j = 0; j < (
int)msize; j++) {
686 ofile.write((
char *)ftmp, 4);
691 G4cout <<
"density map : " << std::ends;
692 for(
int i = 0; i < (
int)msize; i+=50)
705 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
707 kDose[ndose].getSize(size);
709 ofile.write((
char *)size, 3*
sizeof(
int));
711 for(
int j = 0; j < 3; j++)
713 ofile.write((
char *)itmp, 12);
716 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
726 ofile.write((
char *)minmax, 2*2);
728 for(
int j = 0; j < 2; j++)
730 ofile.write((
char *)stmp, 4);
735 std::strncpy(cdunit,
kDoseUnit.c_str(), 12);
737 ofile.write(cdunit, 12);
745 scale = float(dscale);
747 ofile.write((
char *)&scale, 4);
750 ofile.write((
char *)ftmp, 4);
753 G4cout <<
"Dose dist. [" << ndose
754 <<
"] image min., max., scale : "
761 int dsize = size[0]*size[1];
762 short * dimage =
new short[dsize];
763 for(
int z = 0;
z < size[2];
z++) {
766 ofile.write((
char *)dimage, dsize*2);
768 for(
int j = 0; j < dsize; j++) {
770 ofile.write((
char *)stmp, 2);
775 for(
int j = 0; j < dsize; j++) {
777 G4cout <<
"[" << j <<
"," <<
z <<
"]"
778 << dimage[j] <<
", ";
788 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
790 ofile.write((
char *)iCenter, 3*4);
792 for(
int j = 0; j < 3; j++)
794 ofile.write((
char *)itmp, 12);
797 G4cout <<
"Dose dist. [" << ndose
798 <<
"]image relative location : ("
799 << iCenter[0] <<
", "
800 << iCenter[1] <<
", "
801 << iCenter[2] <<
")" <<
G4endl;
806 if(name.size() == 0) name =
"dose";
808 ofile.write((
char *)name.c_str(), 80);
819 kRoi[0].getSize(size);
821 ofile.write((
char *)size, 3*
sizeof(
int));
823 for(
int j = 0; j < 3; j++)
825 ofile.write((
char *)itmp, 12);
828 G4cout <<
"ROI image size : ("
836 kRoi[0].getMinMax(minmax);
838 ofile.write((
char *)minmax,
sizeof(
short)*2);
840 for(
int j = 0; j < 2; j++)
842 ofile.write((
char *)stmp, 4);
846 scale = (float)
kRoi[0].getScale();
848 ofile.write((
char *)&scale,
sizeof(
float));
851 ofile.write((
char *)ftmp, 4);
854 G4cout <<
"ROI image min., max., scale : "
861 int rsize = size[0]*size[1];
862 for(
int i = 0; i < size[2]; i++) {
863 short * rimage =
kRoi[0].getImage(i);
865 ofile.write((
char *)rimage, rsize*
sizeof(
short));
867 for(
int j = 0; j < rsize; j++) {
869 ofile.write((
char *)stmp, 2);
876 kRoi[0].getCenterPosition(fCenter);
877 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
879 ofile.write((
char *)iCenter, 3*
sizeof(
int));
881 for(
int j = 0; j < 3; j++)
883 ofile.write((
char *)itmp, 12);
886 G4cout <<
"ROI image relative location : ("
887 << iCenter[0] <<
", "
888 << iCenter[1] <<
", "
889 << iCenter[2] <<
")" <<
G4endl;
899 ofile.write((
char *)&ntrk,
sizeof(
int));
902 ofile.write((
char *)itmp, 4);
905 G4cout <<
"# of tracks : "
909 for(
int nt = 0; nt < ntrk; nt++) {
912 int nsteps =
kTracks[nt].getNumberOfSteps();
914 ofile.write((
char *)&nsteps,
sizeof(
int));
917 ofile.write((
char *)itmp, 4);
924 unsigned char tcolor[3];
926 ofile.write((
char *)tcolor, 3);
930 for(
int isteps = 0; isteps < nsteps; isteps++) {
931 kTracks[nt].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
932 stepPoints[3], stepPoints[4], stepPoints[5],
936 ofile.write((
char *)stepPoints,
sizeof(
float)*6);
938 for(
int j = 0; j < 6; j++)
940 ofile.write((
char *)ftmp, 24);
951 ofile.write((
char *)&ndet,
sizeof(
int));
954 ofile.write((
char *)itmp, 4);
957 G4cout <<
"# of detectors : "
961 for(
int nd = 0; nd < ndet; nd++) {
964 int nedges =
kDetectors[nd].getNumberOfEdges();
966 ofile.write((
char *)&nedges,
sizeof(
int));
969 ofile.write((
char *)itmp, 4);
972 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
977 for(
int ne = 0; ne < nedges; ne++) {
978 kDetectors[nd].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
979 edgePoints[3], edgePoints[4], edgePoints[5],
983 ofile.write((
char *)edgePoints,
sizeof(
float)*6);
985 for(
int j = 0; j < 6; j++)
987 ofile.write((
char *)ftmp, 24);
992 G4cout <<
" edge : (" << edgePoints[0] <<
", "
993 << edgePoints[1] <<
", "
994 << edgePoints[2] <<
") - ("
995 << edgePoints[3] <<
", "
996 << edgePoints[4] <<
", "
997 << edgePoints[5] <<
")" <<
G4endl;
1003 unsigned char dcolor[3];
1005 ofile.write((
char *)dcolor, 3);
1007 G4cout <<
" rgb : (" << (
int)dcolor[0] <<
", "
1008 << (
int)dcolor[1] <<
", "
1009 << (
int)dcolor[2] <<
")" << G4endl;
1013 std::string dname =
kDetectors[nd].getName();
1015 ofile.write((
char *)dname.c_str(), 80);
1024 ofile.write(
"END", 3);
1041 std::ios_base::out|std::ios_base::binary);
1044 ofile.write(
"gMocren ", 8);
1047 unsigned char ver = 0x03;
1048 ofile.write((
char *)&ver, 1);
1054 int commentLength = 1024;
1055 ofile.write((
char *)&commentLength, 4);
1059 std::strncpy(cmt,
kComment.c_str(), 1024);
1060 ofile.write((
char *)cmt, 1024);
1062 G4cout <<
"Data comment : "
1069 G4cout <<
"Voxel spacing : ("
1084 ofile.write((
char *)&nDoseDist, 4);
1087 for(
int i = 0; i < nDoseDist; i++) {
1097 G4cout <<
"Each pointer to data : "
1099 for(
int i = 0; i < nDoseDist; i++) {
1115 ofile.write((
char *)size, 3*
sizeof(
int));
1117 G4cout <<
"Modality image size : ("
1126 ofile.write((
char *)minmax, 4);
1129 char munit[13] =
"g/cm3 ";
1130 ofile.write((
char *)munit, 12);
1134 ofile.write((
char *)&scale, 4);
1136 G4cout <<
"Modality image min., max., scale : "
1137 << minmax[0] <<
", "
1138 << minmax[1] <<
", "
1143 int psize = size[0]*size[1];
1145 for(
int i = 0; i < size[2]; i++) {
1147 ofile.write((
char *)image, psize*
sizeof(
short));
1149 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1154 size_t msize = minmax[1] - minmax[0]+1;
1155 float * pdmap =
new float[msize];
1157 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1159 G4cout <<
"density map : " << std::ends;
1160 for(
int i = 0; i < (
int)msize; i+=50)
1173 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1175 kDose[ndose].getSize(size);
1176 ofile.write((
char *)size, 3*
sizeof(
int));
1178 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
1187 ofile.write((
char *)minmax, 2*2);
1198 scale = float(dscale);
1199 ofile.write((
char *)&scale, 4);
1201 G4cout <<
"Dose dist. [" << ndose
1202 <<
"] image min., max., scale : "
1203 << minmax[0] <<
", "
1204 << minmax[1] <<
", "
1209 int dsize = size[0]*size[1];
1210 short * dimage =
new short[dsize];
1211 for(
int z = 0;
z < size[2];
z++) {
1213 ofile.write((
char *)dimage, dsize*2);
1216 for(
int j = 0; j < dsize; j++) {
1218 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1219 << dimage[j] <<
", ";
1229 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1230 ofile.write((
char *)iCenter, 3*4);
1232 G4cout <<
"Dose dist. [" << ndose
1233 <<
"]image relative location : ("
1234 << iCenter[0] <<
", "
1235 << iCenter[1] <<
", "
1236 << iCenter[2] <<
")" <<
G4endl;
1244 kRoi[0].getSize(size);
1245 ofile.write((
char *)size, 3*
sizeof(
int));
1247 G4cout <<
"ROI image size : ("
1255 kRoi[0].getMinMax(minmax);
1256 ofile.write((
char *)minmax,
sizeof(
short)*2);
1259 scale = (float)
kRoi[0].getScale();
1260 ofile.write((
char *)&scale,
sizeof(
float));
1262 G4cout <<
"ROI image min., max., scale : "
1263 << minmax[0] <<
", "
1264 << minmax[1] <<
", "
1269 int rsize = size[0]*size[1];
1270 for(
int i = 0; i < size[2]; i++) {
1271 short * rimage =
kRoi[0].getImage(i);
1272 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1277 kRoi[0].getCenterPosition(fCenter);
1278 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1279 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1281 G4cout <<
"ROI image relative location : ("
1282 << iCenter[0] <<
", "
1283 << iCenter[1] <<
", "
1284 << iCenter[2] <<
")" <<
G4endl;
1290 int ntrk =
kSteps.size();
1291 ofile.write((
char *)&ntrk,
sizeof(
int));
1293 G4cout <<
"# of tracks : "
1297 for(
int i = 0; i < ntrk; i++) {
1299 ofile.write((
char *)tp,
sizeof(
float)*6);
1305 G4cout <<
"# of track color information must be the same as # of tracks."
1307 unsigned char white[3] = {255,255,255};
1308 for(
int i = 0; i < ntrk; i++) {
1311 ofile.write((
char *)tcolor, 3);
1313 ofile.write((
char *)white, 3);
1318 ofile.write(
"END", 3);
1340 std::ios_base::out|std::ios_base::binary);
1343 ofile.write(
"GRAPE ", 8);
1346 unsigned char ver = 0x02;
1347 ofile.write((
char *)&ver, 1);
1369 G4cout <<
"Voxel spacing : ("
1389 G4cout <<
"Each pointer to data : "
1405 ofile.write((
char *)size, 3*
sizeof(
int));
1407 G4cout <<
"Modality image size : ("
1416 ofile.write((
char *)minmax, 4);
1424 ofile.write((
char *)&scale, 4);
1426 G4cout <<
"Modality image min., max., scale : "
1427 << minmax[0] <<
", "
1428 << minmax[1] <<
", "
1433 int psize = size[0]*size[1];
1435 for(
int i = 0; i < size[2]; i++) {
1437 ofile.write((
char *)image, psize*
sizeof(
short));
1439 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1444 size_t msize = minmax[1] - minmax[0]+1;
1445 float * pdmap =
new float[msize];
1447 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1449 G4cout <<
"density map : " << std::ends;
1450 for(
int i = 0; i < (
int)msize; i+=50)
1463 kDose[0].getSize(size);
1464 ofile.write((
char *)size, 3*
sizeof(
int));
1466 G4cout <<
"Dose dist. image size : ("
1475 ofile.write((
char *)minmax,
sizeof(
short)*2);
1478 scale = (float)
kDose[0].getScale();
1479 ofile.write((
char *)&scale,
sizeof(
float));
1481 G4cout <<
"Dose dist. image min., max., scale : "
1482 << minmax[0] <<
", "
1483 << minmax[1] <<
", "
1488 int dsize = size[0]*size[1];
1489 short * dimage =
new short[dsize];
1490 for(
int z = 0;
z < size[2];
z++) {
1492 ofile.write((
char *)dimage, dsize*
sizeof(
short));
1495 for(
int j = 0; j < dsize; j++) {
1497 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1498 << dimage[j] <<
", ";
1507 kDose[0].getCenterPosition(fCenter);
1508 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1509 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1511 G4cout <<
"Dose dist. image relative location : ("
1512 << iCenter[0] <<
", "
1513 << iCenter[1] <<
", "
1514 << iCenter[2] <<
")" <<
G4endl;
1522 kRoi[0].getSize(size);
1523 ofile.write((
char *)size, 3*
sizeof(
int));
1525 G4cout <<
"ROI image size : ("
1533 kRoi[0].getMinMax(minmax);
1534 ofile.write((
char *)minmax,
sizeof(
short)*2);
1537 scale = (float)
kRoi[0].getScale();
1538 ofile.write((
char *)&scale,
sizeof(
float));
1540 G4cout <<
"ROI image min., max., scale : "
1541 << minmax[0] <<
", "
1542 << minmax[1] <<
", "
1547 int rsize = size[0]*size[1];
1548 for(
int i = 0; i < size[2]; i++) {
1549 short * rimage =
kRoi[0].getImage(i);
1550 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1555 kRoi[0].getCenterPosition(fCenter);
1556 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1557 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1559 G4cout <<
"ROI image relative location : ("
1560 << iCenter[0] <<
", "
1561 << iCenter[1] <<
", "
1562 << iCenter[2] <<
")" <<
G4endl;
1569 int ntrk =
kSteps.size();
1570 ofile.write((
char *)&ntrk,
sizeof(
int));
1572 G4cout <<
"# of tracks : "
1575 for(
int i = 0; i < ntrk; i++) {
1577 ofile.write((
char *)tp,
sizeof(
float)*6);
1582 ofile.write(
"END", 3);
1601 <<
" in G4GMocrenIO::retrieveData()." <<
G4endl;
1607 ifile.read((
char *)verid, 8);
1610 ifile.read((
char *)&ver, 1);
1613 if(std::strncmp(verid,
"gMocren", 7) == 0) {
1615 G4cout <<
">>>>>>> retrieve data (ver.3) <<<<<<<" <<
G4endl;
1618 }
else if (ver == 0x04) {
1619 G4cout <<
">>>>>>> retrieve data (ver.4) <<<<<<<" <<
G4endl;
1624 G4cout <<
"Error -- invalid file version : " << (
int)ver
1633 }
else if(std::strncmp(verid,
"GRAPE", 5) == 0) {
1634 G4cout <<
">>>>>>> retrieve data (ver.2) <<<<<<<" <<
G4endl;
1661 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
1670 ifile.read((
char *)verid, 8);
1674 ifile.read((
char *)&ver, 1);
1675 std::stringstream ss;
1693 ifile.read((
char *)ctmp, 4);
1697 ifile.read((
char *)cmt, clength);
1698 std::string scmt = cmt;
1702 G4cout <<
"Data comment : "
1707 ifile.read((
char *)ctmp, 12);
1712 G4cout <<
"Voxel spacing : ("
1721 ifile.read((
char *)ctmp, 4);
1725 ifile.read((
char *)ctmp, 4);
1730 for(
int i = 0; i < nDoseDist; i++) {
1731 ifile.read((
char *)ctmp, 4);
1738 ifile.read((
char *)ctmp, 4);
1742 ifile.read((
char *)ctmp, 4);
1746 ifile.read((
char *)ctmp, 4);
1750 G4cout <<
"Each pointer to data : "
1752 for(
int i = 0; i < nDoseDist; i++)
1785 ifile.read(ctmp, 3*
sizeof(
int));
1790 G4cout <<
"Modality image size : ("
1809 ifile.read((
char *)ctmp, 4);
1817 ifile.read((
char *)munit, 12);
1818 std::string smunit = munit;
1822 ifile.read((
char *)ctmp, 4);
1826 G4cout <<
"Modality image min., max., scale : "
1827 << minmax[0] <<
", "
1828 << minmax[1] <<
", "
1833 int psize = size[0]*size[1];
1834 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
1835 char * cimage =
new char[psize*
sizeof(short)];
1836 for(
int i = 0; i < size[2]; i++) {
1837 ifile.read((
char *)cimage, psize*
sizeof(
short));
1838 short * mimage =
new short[psize];
1839 for(
int j = 0; j < psize; j++) {
1844 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
1850 size_t msize = minmax[1]-minmax[0]+1;
1852 char * pdmap =
new char[msize*
sizeof(float)];
1853 ifile.read((
char *)pdmap, msize*
sizeof(
float));
1855 for(
int i = 0; i < (
int)msize; i++) {
1862 G4cout <<
"density map : " << std::ends;
1863 for(
int i = 0; i < 10; i++)
1866 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
1877 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1882 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1887 G4cout <<
"Dose dist. image size : ("
1893 kDose[ndose].setSize(size);
1896 ifile.read((
char *)ctmp,
sizeof(
short)*2);
1903 ifile.read((
char *)dunit, 12);
1904 std::string sdunit = dunit;
1911 ifile.read((
char *)ctmp, 4);
1913 kDose[ndose].setScale(dscale = scale);
1916 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
1917 kDose[ndose].setMinMax(dminmax);
1920 G4cout <<
"Dose dist. image min., max., scale : "
1921 << dminmax[0] <<
", "
1922 << dminmax[1] <<
", "
1927 int dsize = size[0]*size[1];
1928 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
1929 char * di =
new char[dsize*
sizeof(short)];
1930 short * shimage =
new short[dsize];
1931 for(
int z = 0;
z < size[2];
z++) {
1932 ifile.read((
char *)di, dsize*
sizeof(
short));
1933 double * dimage =
new double[dsize];
1934 for(
int xy = 0; xy < dsize; xy++) {
1936 dimage[xy] = shimage[xy]*dscale;
1938 kDose[ndose].addImage(dimage);
1940 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
1943 for(
int j = 0; j < dsize; j++) {
1945 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1946 << dimage[j] <<
", ";
1954 ifile.read((
char *)ctmp, 3*4);
1958 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
1959 kDose[ndose].setCenterPosition(fCenter);
1962 G4cout <<
"Dose dist. image relative location : ("
1963 << fCenter[0] <<
", "
1964 << fCenter[1] <<
", "
1965 << fCenter[2] <<
")" <<
G4endl;
1971 ifile.read((
char *)cname, 80);
1972 std::string dosename = cname;
1986 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1990 kRoi[0].setSize(size);
1992 G4cout <<
"ROI image size : ("
2000 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2003 kRoi[0].setMinMax(minmax);
2006 ifile.read((
char *)ctmp,
sizeof(
float));
2008 kRoi[0].setScale(dscale = scale);
2010 G4cout <<
"ROI image min., max., scale : "
2011 << minmax[0] <<
", "
2012 << minmax[1] <<
", "
2017 int rsize = size[0]*size[1];
2018 char * ri =
new char[rsize*
sizeof(short)];
2019 for(
int i = 0; i < size[2]; i++) {
2020 ifile.read((
char *)ri, rsize*
sizeof(
short));
2021 short * rimage =
new short[rsize];
2022 for(
int j = 0; j < rsize; j++) {
2025 kRoi[0].addImage(rimage);
2031 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2035 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2036 kRoi[0].setCenterPosition(fCenter);
2038 G4cout <<
"ROI image relative location : ("
2039 << fCenter[0] <<
", "
2040 << fCenter[1] <<
", "
2041 << fCenter[2] <<
")" <<
G4endl;
2050 ifile.read((
char *)ctmp,
sizeof(
int));
2058 unsigned char rgb[3];
2059 for(
int i = 0; i < ntrk; i++) {
2063 ifile.read((
char *)ctmp,
sizeof(
int));
2068 ifile.read((
char *)rgb, 3);
2070 std::vector<float *>
steps;
2072 for(
int j = 0; j < nsteps; j++) {
2074 float * steppoint =
new float[6];
2075 ifile.read((
char *)ctmp,
sizeof(
float)*6);
2077 for(
int k = 0;
k < 6;
k++) {
2081 steps.push_back(steppoint);
2090 for(
int j = 0; j < 3; j++)
G4cout << steps[0][j] <<
" ";
2091 int nstp = steps.size();
2093 for(
int j = 3; j < 6; j++)
G4cout << steps[nstp-1][j] <<
" ";
2095 for(
int j = 0; j < 3; j++)
G4cout << (
int)rgb[j] <<
" ";
2109 ifile.read((
char *)ctmp,
sizeof(
int));
2114 G4cout <<
"# of detectors : "
2118 for(
int nd = 0; nd < ndet; nd++) {
2121 ifile.read((
char *)ctmp,
sizeof(
int));
2125 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
2129 std::vector<float *> detector;
2131 for(
int ne = 0; ne < nedges; ne++) {
2133 ifile.read((
char *)cftmp,
sizeof(
float)*6);
2134 float * edgePoints =
new float[6];
2135 for(
int j = 0; j < 6; j++)
convertEndian(&cftmp[
sizeof(
float)*j], edgePoints[j]);
2136 detector.push_back(edgePoints);
2141 G4cout <<
" first edge : (" << detector[0][0] <<
", "
2142 << detector[0][1] <<
", "
2143 << detector[0][2] <<
") - ("
2144 << detector[0][3] <<
", "
2145 << detector[0][4] <<
", "
2146 << detector[0][5] <<
")" <<
G4endl;
2150 unsigned char dcolor[3];
2151 ifile.read((
char *)dcolor, 3);
2153 G4cout <<
" detector color : rgb("
2154 << (
int)dcolor[0] <<
", "
2155 << (
int)dcolor[1] <<
", "
2156 << (
int)dcolor[2] << G4endl;
2162 ifile.read((
char *)cname, 80);
2163 std::string dname = cname;
2194 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
2203 ifile.read((
char *)verid, 8);
2207 ifile.read((
char *)&ver, 1);
2208 std::stringstream ss;
2226 ifile.read((
char *)ctmp, 4);
2230 ifile.read((
char *)cmt, clength);
2231 std::string scmt = cmt;
2234 G4cout <<
"Data comment : "
2239 ifile.read((
char *)ctmp, 12);
2244 G4cout <<
"Voxel spacing : ("
2253 ifile.read((
char *)ctmp, 4);
2257 ifile.read((
char *)ctmp, 4);
2262 for(
int i = 0; i < nDoseDist; i++) {
2263 ifile.read((
char *)ctmp, 4);
2270 ifile.read((
char *)ctmp, 4);
2274 ifile.read((
char *)ctmp, 4);
2277 G4cout <<
"Each pointer to data : "
2279 for(
int i = 0; i < nDoseDist; i++)
2308 ifile.read(ctmp, 3*
sizeof(
int));
2313 G4cout <<
"Modality image size : ("
2332 ifile.read((
char *)ctmp, 4);
2339 ifile.read((
char *)munit, 12);
2340 std::string smunit = munit;
2344 ifile.read((
char *)ctmp, 4);
2348 G4cout <<
"Modality image min., max., scale : "
2349 << minmax[0] <<
", "
2350 << minmax[1] <<
", "
2355 int psize = size[0]*size[1];
2356 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2357 char * cimage =
new char[psize*
sizeof(short)];
2358 for(
int i = 0; i < size[2]; i++) {
2359 ifile.read((
char *)cimage, psize*
sizeof(
short));
2360 short * mimage =
new short[psize];
2361 for(
int j = 0; j < psize; j++) {
2366 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2372 size_t msize = minmax[1]-minmax[0]+1;
2374 char * pdmap =
new char[msize*
sizeof(float)];
2375 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2377 for(
int i = 0; i < (
int)msize; i++) {
2383 G4cout <<
"density map : " << std::ends;
2384 for(
int i = 0; i < 10; i++)
2387 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2398 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
2403 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2408 G4cout <<
"Dose dist. image size : ("
2414 kDose[ndose].setSize(size);
2417 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2423 ifile.read((
char *)dunit, 12);
2424 std::string sdunit = dunit;
2431 ifile.read((
char *)ctmp, 4);
2433 kDose[ndose].setScale(dscale = scale);
2436 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2437 kDose[ndose].setMinMax(dminmax);
2440 G4cout <<
"Dose dist. image min., max., scale : "
2441 << dminmax[0] <<
", "
2442 << dminmax[1] <<
", "
2447 int dsize = size[0]*size[1];
2448 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2449 char * di =
new char[dsize*
sizeof(short)];
2450 short * shimage =
new short[dsize];
2451 for(
int z = 0;
z < size[2];
z++) {
2452 ifile.read((
char *)di, dsize*
sizeof(
short));
2453 double * dimage =
new double[dsize];
2454 for(
int xy = 0; xy < dsize; xy++) {
2456 dimage[xy] = shimage[xy]*dscale;
2458 kDose[ndose].addImage(dimage);
2460 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2463 for(
int j = 0; j < dsize; j++) {
2465 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2466 << dimage[j] <<
", ";
2474 ifile.read((
char *)ctmp, 3*4);
2478 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2479 kDose[ndose].setCenterPosition(fCenter);
2482 G4cout <<
"Dose dist. image relative location : ("
2483 << fCenter[0] <<
", "
2484 << fCenter[1] <<
", "
2485 << fCenter[2] <<
")" <<
G4endl;
2497 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2501 kRoi[0].setSize(size);
2503 G4cout <<
"ROI image size : ("
2511 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2514 kRoi[0].setMinMax(minmax);
2517 ifile.read((
char *)ctmp,
sizeof(
float));
2519 kRoi[0].setScale(dscale = scale);
2521 G4cout <<
"ROI image min., max., scale : "
2522 << minmax[0] <<
", "
2523 << minmax[1] <<
", "
2528 int rsize = size[0]*size[1];
2529 char * ri =
new char[rsize*
sizeof(short)];
2530 for(
int i = 0; i < size[2]; i++) {
2531 ifile.read((
char *)ri, rsize*
sizeof(
short));
2532 short * rimage =
new short[rsize];
2533 for(
int j = 0; j < rsize; j++) {
2536 kRoi[0].addImage(rimage);
2542 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2546 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2547 kRoi[0].setCenterPosition(fCenter);
2549 G4cout <<
"ROI image relative location : ("
2550 << fCenter[0] <<
", "
2551 << fCenter[1] <<
", "
2552 << fCenter[2] <<
")" <<
G4endl;
2561 ifile.read((
char *)ctmp,
sizeof(
int));
2569 std::vector<float *> trkv4;
2572 for(
int i = 0; i < ntrk; i++) {
2573 float *
tp =
new float[6];
2575 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2577 for(
int j = 0; j < 3; j++) {
2582 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2583 for(
int j = 0; j < 3; j++) {
2591 trkv4.push_back(tp);
2595 unsigned char trkcolorv4[3];
2598 for(
int i = 0; i < ntrk; i++) {
2599 unsigned char * rgb =
new unsigned char[3];
2600 ifile.read((
char *)rgb, 3);
2604 for(
int j = 0; j < 3; j++) trkcolorv4[j] = rgb[j];
2605 std::vector<float *> trk;
2606 trk.push_back(trkv4[i]);
2632 <<
" in G4GMocrenIO::retrieveData2()." <<
G4endl;
2641 ifile.read((
char *)verid, 8);
2645 ifile.read((
char *)&ver, 1);
2646 std::stringstream ss;
2653 ifile.read((
char *)idtmp,
IDLENGTH);
2671 ifile.read((
char *)ctmp, 12);
2676 G4cout <<
"Voxel spacing : ("
2685 ifile.read((
char *)ctmp, 4);
2690 ifile.read((
char *)ctmp, 4);
2695 ifile.read((
char *)ctmp, 4);
2699 ifile.read((
char *)ctmp, 4);
2702 G4cout <<
"Each pointer to data : "
2732 ifile.read(ctmp, 3*
sizeof(
int));
2737 G4cout <<
"Modality image size : ("
2756 ifile.read((
char *)ctmp, 4);
2762 ifile.read((
char *)ctmp, 4);
2766 G4cout <<
"Modality image min., max., scale : "
2767 << minmax[0] <<
", "
2768 << minmax[1] <<
", "
2773 int psize = size[0]*size[1];
2774 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2775 char * cimage =
new char[psize*
sizeof(short)];
2776 for(
int i = 0; i < size[2]; i++) {
2777 ifile.read((
char *)cimage, psize*
sizeof(
short));
2778 short * mimage =
new short[psize];
2779 for(
int j = 0; j < psize; j++) {
2784 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2790 size_t msize = minmax[1]-minmax[0]+1;
2792 char * pdmap =
new char[msize*
sizeof(float)];
2793 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2795 for(
int i = 0; i < (
int)msize; i++) {
2801 G4cout <<
"density map : " << std::ends;
2802 for(
int i = 0; i < 10; i++)
2805 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2821 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2826 G4cout <<
"Dose dist. image size : ("
2832 kDose[0].setSize(size);
2835 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2839 ifile.read((
char *)ctmp,
sizeof(
float));
2841 kDose[0].setScale(dscale = scale);
2844 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2845 kDose[0].setMinMax(dminmax);
2848 G4cout <<
"Dose dist. image min., max., scale : "
2849 << dminmax[0] <<
", "
2850 << dminmax[1] <<
", "
2855 int dsize = size[0]*size[1];
2856 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2857 char * di =
new char[dsize*
sizeof(short)];
2858 short * shimage =
new short[dsize];
2859 for(
int z = 0;
z < size[2];
z++) {
2860 ifile.read((
char *)di, dsize*
sizeof(
short));
2861 double * dimage =
new double[dsize];
2862 for(
int xy = 0; xy < dsize; xy++) {
2864 dimage[xy] = shimage[xy]*dscale;
2866 kDose[0].addImage(dimage);
2868 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2871 for(
int j = 0; j < dsize; j++) {
2873 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2874 << dimage[j] <<
", ";
2916 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2920 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2921 kDose[0].setCenterPosition(fCenter);
2924 G4cout <<
"Dose dist. image relative location : ("
2925 << fCenter[0] <<
", "
2926 << fCenter[1] <<
", "
2927 << fCenter[2] <<
")" <<
G4endl;
2939 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2943 kRoi[0].setSize(size);
2945 G4cout <<
"ROI image size : ("
2953 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2956 kRoi[0].setMinMax(minmax);
2959 ifile.read((
char *)ctmp,
sizeof(
float));
2961 kRoi[0].setScale(dscale = scale);
2963 G4cout <<
"ROI image min., max., scale : "
2964 << minmax[0] <<
", "
2965 << minmax[1] <<
", "
2970 int rsize = size[0]*size[1];
2971 char * ri =
new char[rsize*
sizeof(short)];
2972 for(
int i = 0; i < size[2]; i++) {
2973 ifile.read((
char *)ri, rsize*
sizeof(
short));
2974 short * rimage =
new short[rsize];
2975 for(
int j = 0; j < rsize; j++) {
2978 kRoi[0].addImage(rimage);
2984 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2988 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2989 kRoi[0].setCenterPosition(fCenter);
2991 G4cout <<
"ROI image relative location : ("
2992 << fCenter[0] <<
", "
2993 << fCenter[1] <<
", "
2994 << fCenter[2] <<
")" <<
G4endl;
3003 ifile.read((
char *)ctmp,
sizeof(
int));
3011 unsigned char trkcolorv4[3] = {255, 0, 0};
3013 for(
int i = 0; i < ntrk; i++) {
3014 float *
tp =
new float[6];
3016 std::vector<float *> trkv4;
3018 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3020 for(
int j = 0; j < 3; j++) {
3025 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3026 for(
int j = 0; j < 3; j++) {
3033 trkv4.push_back(tp);
3100 char cmonth[12][4] = {
"Jan",
"Feb",
"Mar",
"Apr",
3101 "May",
"Jun",
"Jul",
"Aug",
3102 "Sep",
"Oct",
"Nov",
"Dec"};
3103 std::stringstream ss;
3104 ss << std::setfill(
'0')
3106 << ti->tm_hour <<
":"
3108 << ti->tm_min <<
":"
3110 << ti->tm_sec <<
","
3111 << cmonth[ti->tm_mon] <<
"."
3113 << ti->tm_mday <<
","
3114 << ti->tm_year+1900;
3184 unsigned int pointer = 1070;
3186 pointer += nDoseDist*4;
3196 int pmsize = 2*msize[0]*msize[1]*msize[2];
3197 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3198 pointer += 32 + pmsize + pmmap;
3201 if(nDoseDist == 0) {
3202 unsigned int pointer0 = 0;
3205 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3209 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2 + 80;
3218 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3219 pointer += 20 + prsize + 12;
3221 unsigned int pointer0 = 0;
3231 for(
int nt = 0; nt < ntrk; nt++) {
3232 int nsteps =
kTracks[nt].getNumberOfSteps();
3233 pointer += 4 + 3 + nsteps*(4*6);
3236 unsigned int pointer0 = 0;
3258 unsigned int pointer = 1066;
3260 pointer += nDoseDist*4;
3270 int pmsize = 2*msize[0]*msize[1]*msize[2];
3271 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3272 pointer += 32 + pmsize + pmmap;
3275 if(nDoseDist == 0) {
3276 unsigned int pointer0 = 0;
3279 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3283 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2;
3292 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3293 pointer += 20 + prsize + 12;
3295 unsigned int pointer0 = 0;
3303 unsigned int pointer0 = 0;
3313 unsigned int pointer = 65;
3321 int pmsize = 2*msize[0]*msize[1]*msize[2];
3322 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3323 pointer += 20 + pmsize + pmmap;
3330 int pdsize = 2*dsize[0]*dsize[1]*dsize[2];
3331 pointer += 20 + pdsize + 12;
3333 unsigned int pointer0 = 0;
3342 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3343 pointer += 20 + prsize + 12;
3346 unsigned int pointer0 = 0;
3354 unsigned int pointer0 = 0;
3411 for(
int i = 0; i < 2; i++) _minmax[i] = minmax[i];
3433 for(
int i = 0; i < 3; i++) _center[i] = 0;
3452 for(
int i = 0; i < nmap; i++) {
3455 rval = i + minmax[0];
3468 kDose.push_back(doseData);
3471 return (
int)
kDose.size();
3483 if(_unit.size() >
static_cast<size_t>(_num))
kDoseUnit = _unit;
3493 for(
int i = 0; i < 3; i++) _size[i] = 0;
3495 kDose[_num].getSize(_size);
3499 kDose[_num].setSize(_size);
3508 for(
int i = 0; i < 2; i++) minmax[i] = (
double)_minmax[i]*
scale;
3509 kDose[_num].setMinMax(minmax);
3514 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3517 kDose[_num].getMinMax(minmax);
3519 for(
int i = 0; i < 2; i++) _minmax[i] = (
short)(minmax[i]/scale+0.5);
3524 kDose[_num].setMinMax(_minmax);
3529 for(
int i = 0; i < 2; i++) _minmax[i] = 0.;
3531 kDose[_num].getMinMax(_minmax);
3537 kDose[_num].setScale(_scale);
3544 return kDose[_num].getScale();
3559 kDose[_num].getSize(size);
3560 int dsize = size[0]*size[1];
3561 double * ddata =
new double[dsize];
3564 kDose[_num].getMinMax(minmax);
3565 for(
int xy = 0; xy < dsize; xy++) {
3566 ddata[xy] = _image[xy]*
scale;
3567 if(ddata[xy] < minmax[0]) minmax[0] = ddata[xy];
3568 if(ddata[xy] > minmax[1]) minmax[1] = ddata[xy];
3570 kDose[_num].addImage(ddata);
3573 kDose[_num].setMinMax(minmax);
3579 G4cout <<
"In G4GMocrenIO::getShortDoseDist(), "
3580 <<
"first argument is NULL pointer. "
3581 <<
"The argument must be allocated array."
3590 kDose[_num].getSize(size);
3592 double * ddata =
kDose[_num].getImage(_z);
3594 for(
int xy = 0; xy < size[0]*size[1]; xy++) {
3595 _data[xy] = (short)(ddata[xy]/scale+0.5);
3601 kDose[_num].getMinMax(minmax);
3602 for(
int i = 0; i < 2; i++)
3603 _minmax[i] = (
short)(minmax[i]/scale+0.5);
3608 kDose[_num].addImage(_image);
3616 image =
kDose[_num].getImage(_z);
3637 std::vector<double *> dosedist =
kDose[_num].getImage();
3639 int nimg = size[0]*size[1];
3640 for(
int z = 0;
z < size[2];
z++) {
3641 for(
int xy = 0; xy < nimg; xy++) {
3642 dosedist[
z][xy] += _image[
z][xy];
3652 kDose[_num].setCenterPosition(_center);
3657 for(
int i = 0; i < 3; i++) _center[i] = 0;
3659 kDose[_num].getCenterPosition(_center);
3664 kDose[_num].setName(_name);
3672 return kDose[_num].getName();
3676 std::vector<class GMocrenDataPrimitive<double> >::iterator itr;
3677 for(itr =
kDose.begin(); itr !=
kDose.end(); itr++) {
3678 _dose.push_back(*itr);
3683 if(
kDose.size() != _dose.size()) {
3685 G4cout <<
"G4GMocrenIO::mergeDoseDist() : Error" <<
G4endl;
3686 G4cout <<
" Unable to merge the dose distributions,"<<
G4endl;
3687 G4cout <<
" because of different size of dose maps."<<
G4endl;
3693 std::vector<class GMocrenDataPrimitive<double> >::iterator itr1 =
kDose.begin();
3694 std::vector<class GMocrenDataPrimitive<double> >::iterator itr2 = _dose.begin();
3695 for(
int i = 0; i <
num; i++, itr1++, itr2++) {
3698 G4cout <<
"merged dose distribution [" << i <<
"]" <<
G4endl;
3731 for(
int i = 0; i < (
int)
kDose.size(); i++) {
3732 kDose[i].getMinMax(minmax);
3734 kDose[i].setScale(scale);
3744 kRoi.push_back(roiData);
3747 return (
int)
kRoi.size();
3753 kRoi[_num].setScale(_scale);
3760 return kRoi[_num].getScale();
3765 kRoi[_num].addImage(_image);
3772 return kRoi[_num].getImage(_z);
3777 return kRoi[_num].setSize(_size);
3782 for(
int i = 0; i < 3; i++) _size[i] = 0;
3784 return kRoi[_num].getSize(_size);
3789 kRoi[_num].setMinMax(_minmax);
3794 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3796 kRoi[_num].getMinMax(_minmax);
3801 kRoi[_num].setCenterPosition(_center);
3806 for(
int i = 0; i < 3; i++) _center[i] = 0;
3808 kRoi[_num].getCenterPosition(_center);
3836 return (
int)
kSteps.size();
3842 kSteps.push_back(_tracks);
3860 std::vector<unsigned char *> & _colors) {
3861 std::vector<float *>::iterator titr;
3862 for(titr =
kSteps.begin(); titr !=
kSteps.end(); titr++) {
3863 float * pts =
new float[6];
3864 for(
int i = 0; i < 6; i++) {
3865 pts[i] = (*titr)[i];
3867 _tracks.push_back(pts);
3870 std::vector<unsigned char *>::iterator citr;
3872 unsigned char * pts =
new unsigned char[3];
3873 for(
int i = 0; i < 3; i++) {
3874 pts[i] = (*citr)[i];
3876 _colors.push_back(pts);
3880 std::vector<unsigned char *> & _colors) {
3881 std::vector<float *>::iterator titr;
3882 for(titr = _tracks.begin(); titr != _tracks.end(); titr++) {
3886 std::vector<unsigned char *>::iterator citr;
3887 for(citr = _colors.begin(); citr != _colors.end(); citr++) {
3893 std::vector<float *>::iterator itr = _steps.begin();
3894 std::vector<struct GMocrenTrack::Step>
steps;
3895 for(; itr != _steps.end(); itr++) {
3897 for(
int i = 0; i < 3; i++) {
3901 steps.push_back(step);
3910 std::vector<unsigned char *> & _color) {
3912 if(_num > (
int)
kTracks.size()) {
3919 unsigned char *
color =
new unsigned char[3];
3920 kTracks[_num].getColor(color);
3921 _color.push_back(color);
3924 int nsteps =
kTracks[_num].getNumberOfSteps();
3925 for(
int isteps = 0; isteps < nsteps; isteps++) {
3926 float * stepPoints =
new float[6];
3927 kTracks[_num].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
3928 stepPoints[3], stepPoints[4], stepPoints[5],
3930 _steps.push_back(stepPoints);
3935 std::vector<class GMocrenTrack>::iterator itr =
kTracks.begin();
3936 for(; itr !=
kTracks.end(); itr++) {
3937 itr->translate(_translate);
3949 std::vector<float *> & _det,
3950 unsigned char _color[3]) {
3952 std::vector<float *>::iterator itr = _det.begin();
3953 std::vector<struct GMocrenDetector::Edge> edges;
3954 for(; itr != _det.end(); itr++) {
3956 for(
int i = 0; i < 3; i++) {
3960 edges.push_back(edge);
3971 std::vector<unsigned char *> & _color,
3972 std::string & _detName) {
3985 unsigned char *
color =
new unsigned char[3];
3987 _color.push_back(color);
3990 int nedges =
kDetectors[_num].getNumberOfEdges();
3991 for(
int ne = 0; ne < nedges; ne++) {
3992 float * edgePoints =
new float[6];
3993 kDetectors[_num].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
3994 edgePoints[3], edgePoints[4], edgePoints[5],
3996 _edges.push_back(edgePoints);
4001 std::vector<class GMocrenDetector>::iterator itr =
kDetectors.begin();
4003 itr->translate(_translate);
4008 template <
typename T>
4014 const int SIZE =
sizeof(_rval);
4016 for(
int i = 0; i < SIZE/2; i++) {
4018 _val[i] = _val[SIZE - 1 - i];
4019 _val[SIZE - 1 - i] = ctemp;
4026 template <
typename T>
4029 const int SIZE =
sizeof(_rval);
4035 for(
int i = 0; i < SIZE; i++) {
4036 uni.cu[i] = _val[SIZE-1-i];