52 #define LITTLE_ENDIAN 1234
53 #define BYTE_ORDER LITTLE_ENDIAN
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 for(
int i = 0; i < 1025; i++) cmt[i] =
'\0';
510 const char * cmnt =
kComment.c_str();
511 size_t lcm = std::strlen(cmnt);
512 if(lcm > 1024) lcm = 1024;
513 std::strncpy(cmt, cmnt, lcm);
514 ofile.write((
char *)cmt, 1024);
516 G4cout <<
"Data comment : "
524 for(
int j = 0; j < 3; j++)
526 ofile.write((
char *)ftmp, 12);
529 G4cout <<
"Voxel spacing : ("
544 ofile.write((
char *)itmp, 4);
551 ofile.write((
char *)&nDoseDist, 4);
554 ofile.write((
char *)itmp, 4);
559 for(
int i = 0; i < nDoseDist; i++) {
563 for(
int i = 0; i < nDoseDist; i++) {
565 ofile.write((
char *)itmp, 4);
574 ofile.write((
char *)itmp, 4);
582 ofile.write((
char *)itmp, 4);
590 ofile.write((
char *)itmp, 4);
594 G4cout <<
"Each pointer to data : "
596 for(
int i = 0; i < nDoseDist; i++) {
616 ofile.write((
char *)size, 3*
sizeof(
int));
618 for(
int j = 0; j < 3; j++)
620 ofile.write((
char *)itmp, 12);
624 G4cout <<
"Modality image size : ("
634 ofile.write((
char *)minmax, 4);
636 for(
int j = 0; j < 2; j++)
638 ofile.write((
char *)stmp, 4);
642 char munit[13] =
"g/cm3\0";
643 ofile.write((
char *)munit, 12);
648 ofile.write((
char *)&scale, 4);
651 ofile.write((
char *)ftmp, 4);
654 G4cout <<
"Modality image min., max., scale : "
661 int psize = size[0]*size[1];
663 for(
int i = 0; i < size[2]; i++) {
666 ofile.write((
char *)image, psize*
sizeof(
short));
668 for(
int j = 0; j < psize; j++) {
670 ofile.write((
char *)stmp, 2);
674 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
679 size_t msize = minmax[1] - minmax[0]+1;
681 G4cout <<
"modality image : " << minmax[0] <<
", " << minmax[1] <<
G4endl;
682 float * pdmap =
new float[msize];
686 ofile.write((
char *)pdmap, msize*
sizeof(
float));
688 for(
int j = 0; j < (
int)msize; j++) {
690 ofile.write((
char *)ftmp, 4);
695 G4cout <<
"density map : " << std::ends;
696 for(
int i = 0; i < (
int)msize; i+=50)
709 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
711 kDose[ndose].getSize(size);
713 ofile.write((
char *)size, 3*
sizeof(
int));
715 for(
int j = 0; j < 3; j++)
717 ofile.write((
char *)itmp, 12);
720 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
730 ofile.write((
char *)minmax, 2*2);
732 for(
int j = 0; j < 2; j++)
734 ofile.write((
char *)stmp, 4);
739 for(
int i = 0; i < 13; i++) cdunit[i] =
'\0';
741 size_t lcu = std::strlen(cu);
742 if(lcu > 1024) lcu = 1024;
743 std::strncpy(cdunit, cu, lcu);
744 ofile.write((
char *)cdunit, 12);
752 scale = float(dscale);
754 ofile.write((
char *)&scale, 4);
757 ofile.write((
char *)ftmp, 4);
760 G4cout <<
"Dose dist. [" << ndose
761 <<
"] image min., max., scale : "
768 int dsize = size[0]*size[1];
769 short * dimage =
new short[dsize];
770 for(
int z = 0;
z < size[2];
z++) {
773 ofile.write((
char *)dimage, dsize*2);
775 for(
int j = 0; j < dsize; j++) {
777 ofile.write((
char *)stmp, 2);
782 for(
int j = 0; j < dsize; j++) {
784 G4cout <<
"[" << j <<
"," <<
z <<
"]"
785 << dimage[j] <<
", ";
795 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
797 ofile.write((
char *)iCenter, 3*4);
799 for(
int j = 0; j < 3; j++)
801 ofile.write((
char *)itmp, 12);
804 G4cout <<
"Dose dist. [" << ndose
805 <<
"]image relative location : ("
806 << iCenter[0] <<
", "
807 << iCenter[1] <<
", "
808 << iCenter[2] <<
")" <<
G4endl;
813 if(name.size() == 0) name =
"dose";
815 ofile.write((
char *)name.c_str(), 80);
826 kRoi[0].getSize(size);
828 ofile.write((
char *)size, 3*
sizeof(
int));
830 for(
int j = 0; j < 3; j++)
832 ofile.write((
char *)itmp, 12);
835 G4cout <<
"ROI image size : ("
843 kRoi[0].getMinMax(minmax);
845 ofile.write((
char *)minmax,
sizeof(
short)*2);
847 for(
int j = 0; j < 2; j++)
849 ofile.write((
char *)stmp, 4);
853 scale = (float)
kRoi[0].getScale();
855 ofile.write((
char *)&scale,
sizeof(
float));
858 ofile.write((
char *)ftmp, 4);
861 G4cout <<
"ROI image min., max., scale : "
868 int rsize = size[0]*size[1];
869 for(
int i = 0; i < size[2]; i++) {
870 short * rimage =
kRoi[0].getImage(i);
872 ofile.write((
char *)rimage, rsize*
sizeof(
short));
874 for(
int j = 0; j < rsize; j++) {
876 ofile.write((
char *)stmp, 2);
883 kRoi[0].getCenterPosition(fCenter);
884 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
886 ofile.write((
char *)iCenter, 3*
sizeof(
int));
888 for(
int j = 0; j < 3; j++)
890 ofile.write((
char *)itmp, 12);
893 G4cout <<
"ROI image relative location : ("
894 << iCenter[0] <<
", "
895 << iCenter[1] <<
", "
896 << iCenter[2] <<
")" <<
G4endl;
906 ofile.write((
char *)&ntrk,
sizeof(
int));
909 ofile.write((
char *)itmp, 4);
912 G4cout <<
"# of tracks : "
916 for(
int nt = 0;
nt < ntrk;
nt++) {
919 int nsteps =
kTracks[
nt].getNumberOfSteps();
921 ofile.write((
char *)&nsteps,
sizeof(
int));
924 ofile.write((
char *)itmp, 4);
931 unsigned char tcolor[3];
933 ofile.write((
char *)tcolor, 3);
937 for(
int isteps = 0; isteps < nsteps; isteps++) {
938 kTracks[
nt].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
939 stepPoints[3], stepPoints[4], stepPoints[5],
943 ofile.write((
char *)stepPoints,
sizeof(
float)*6);
945 for(
int j = 0; j < 6; j++)
947 ofile.write((
char *)ftmp, 24);
958 ofile.write((
char *)&ndet,
sizeof(
int));
961 ofile.write((
char *)itmp, 4);
964 G4cout <<
"# of detectors : "
968 for(
int nd = 0; nd < ndet; nd++) {
971 int nedges =
kDetectors[nd].getNumberOfEdges();
973 ofile.write((
char *)&nedges,
sizeof(
int));
976 ofile.write((
char *)itmp, 4);
979 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
984 for(
int ne = 0; ne < nedges; ne++) {
985 kDetectors[nd].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
986 edgePoints[3], edgePoints[4], edgePoints[5],
990 ofile.write((
char *)edgePoints,
sizeof(
float)*6);
992 for(
int j = 0; j < 6; j++)
994 ofile.write((
char *)ftmp, 24);
999 G4cout <<
" edge : (" << edgePoints[0] <<
", "
1000 << edgePoints[1] <<
", "
1001 << edgePoints[2] <<
") - ("
1002 << edgePoints[3] <<
", "
1003 << edgePoints[4] <<
", "
1004 << edgePoints[5] <<
")" <<
G4endl;
1010 unsigned char dcolor[3];
1012 ofile.write((
char *)dcolor, 3);
1014 G4cout <<
" rgb : (" << (
int)dcolor[0] <<
", "
1015 << (
int)dcolor[1] <<
", "
1016 << (
int)dcolor[2] <<
")" << G4endl;
1020 std::string dname =
kDetectors[nd].getName();
1022 ofile.write((
char *)dname.c_str(), 80);
1031 ofile.write(
"END", 3);
1048 std::ios_base::out|std::ios_base::binary);
1051 ofile.write(
"gMocren ", 8);
1054 unsigned char ver = 0x03;
1055 ofile.write((
char *)&ver, 1);
1061 int commentLength = 1024;
1062 ofile.write((
char *)&commentLength, 4);
1066 std::strncpy(cmt,
kComment.c_str(), 1024);
1067 ofile.write((
char *)cmt, 1024);
1069 G4cout <<
"Data comment : "
1076 G4cout <<
"Voxel spacing : ("
1091 ofile.write((
char *)&nDoseDist, 4);
1094 for(
int i = 0; i < nDoseDist; i++) {
1104 G4cout <<
"Each pointer to data : "
1106 for(
int i = 0; i < nDoseDist; i++) {
1122 ofile.write((
char *)size, 3*
sizeof(
int));
1124 G4cout <<
"Modality image size : ("
1133 ofile.write((
char *)minmax, 4);
1136 char munit[13] =
"g/cm3 ";
1137 ofile.write((
char *)munit, 12);
1141 ofile.write((
char *)&scale, 4);
1143 G4cout <<
"Modality image min., max., scale : "
1144 << minmax[0] <<
", "
1145 << minmax[1] <<
", "
1150 int psize = size[0]*size[1];
1152 for(
int i = 0; i < size[2]; i++) {
1154 ofile.write((
char *)image, psize*
sizeof(
short));
1156 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1161 size_t msize = minmax[1] - minmax[0]+1;
1162 float * pdmap =
new float[msize];
1164 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1166 G4cout <<
"density map : " << std::ends;
1167 for(
int i = 0; i < (
int)msize; i+=50)
1180 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1182 kDose[ndose].getSize(size);
1183 ofile.write((
char *)size, 3*
sizeof(
int));
1185 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
1194 ofile.write((
char *)minmax, 2*2);
1205 scale = float(dscale);
1206 ofile.write((
char *)&scale, 4);
1208 G4cout <<
"Dose dist. [" << ndose
1209 <<
"] image min., max., scale : "
1210 << minmax[0] <<
", "
1211 << minmax[1] <<
", "
1216 int dsize = size[0]*size[1];
1217 short * dimage =
new short[dsize];
1218 for(
int z = 0;
z < size[2];
z++) {
1220 ofile.write((
char *)dimage, dsize*2);
1223 for(
int j = 0; j < dsize; j++) {
1225 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1226 << dimage[j] <<
", ";
1236 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1237 ofile.write((
char *)iCenter, 3*4);
1239 G4cout <<
"Dose dist. [" << ndose
1240 <<
"]image relative location : ("
1241 << iCenter[0] <<
", "
1242 << iCenter[1] <<
", "
1243 << iCenter[2] <<
")" <<
G4endl;
1251 kRoi[0].getSize(size);
1252 ofile.write((
char *)size, 3*
sizeof(
int));
1254 G4cout <<
"ROI image size : ("
1262 kRoi[0].getMinMax(minmax);
1263 ofile.write((
char *)minmax,
sizeof(
short)*2);
1266 scale = (float)
kRoi[0].getScale();
1267 ofile.write((
char *)&scale,
sizeof(
float));
1269 G4cout <<
"ROI image min., max., scale : "
1270 << minmax[0] <<
", "
1271 << minmax[1] <<
", "
1276 int rsize = size[0]*size[1];
1277 for(
int i = 0; i < size[2]; i++) {
1278 short * rimage =
kRoi[0].getImage(i);
1279 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1284 kRoi[0].getCenterPosition(fCenter);
1285 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1286 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1288 G4cout <<
"ROI image relative location : ("
1289 << iCenter[0] <<
", "
1290 << iCenter[1] <<
", "
1291 << iCenter[2] <<
")" <<
G4endl;
1297 int ntrk =
kSteps.size();
1298 ofile.write((
char *)&ntrk,
sizeof(
int));
1300 G4cout <<
"# of tracks : "
1304 for(
int i = 0; i < ntrk; i++) {
1306 ofile.write((
char *)tp,
sizeof(
float)*6);
1312 G4cout <<
"# of track color information must be the same as # of tracks."
1314 unsigned char white[3] = {255,255,255};
1315 for(
int i = 0; i < ntrk; i++) {
1318 ofile.write((
char *)tcolor, 3);
1320 ofile.write((
char *)white, 3);
1325 ofile.write(
"END", 3);
1347 std::ios_base::out|std::ios_base::binary);
1350 ofile.write(
"GRAPE ", 8);
1353 unsigned char ver = 0x02;
1354 ofile.write((
char *)&ver, 1);
1376 G4cout <<
"Voxel spacing : ("
1396 G4cout <<
"Each pointer to data : "
1412 ofile.write((
char *)size, 3*
sizeof(
int));
1414 G4cout <<
"Modality image size : ("
1423 ofile.write((
char *)minmax, 4);
1431 ofile.write((
char *)&scale, 4);
1433 G4cout <<
"Modality image min., max., scale : "
1434 << minmax[0] <<
", "
1435 << minmax[1] <<
", "
1440 int psize = size[0]*size[1];
1442 for(
int i = 0; i < size[2]; i++) {
1444 ofile.write((
char *)image, psize*
sizeof(
short));
1446 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1451 size_t msize = minmax[1] - minmax[0]+1;
1452 float * pdmap =
new float[msize];
1454 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1456 G4cout <<
"density map : " << std::ends;
1457 for(
int i = 0; i < (
int)msize; i+=50)
1470 kDose[0].getSize(size);
1471 ofile.write((
char *)size, 3*
sizeof(
int));
1473 G4cout <<
"Dose dist. image size : ("
1482 ofile.write((
char *)minmax,
sizeof(
short)*2);
1485 scale = (float)
kDose[0].getScale();
1486 ofile.write((
char *)&scale,
sizeof(
float));
1488 G4cout <<
"Dose dist. image min., max., scale : "
1489 << minmax[0] <<
", "
1490 << minmax[1] <<
", "
1495 int dsize = size[0]*size[1];
1496 short * dimage =
new short[dsize];
1497 for(
int z = 0;
z < size[2];
z++) {
1499 ofile.write((
char *)dimage, dsize*
sizeof(
short));
1502 for(
int j = 0; j < dsize; j++) {
1504 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1505 << dimage[j] <<
", ";
1514 kDose[0].getCenterPosition(fCenter);
1515 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1516 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1518 G4cout <<
"Dose dist. image relative location : ("
1519 << iCenter[0] <<
", "
1520 << iCenter[1] <<
", "
1521 << iCenter[2] <<
")" <<
G4endl;
1529 kRoi[0].getSize(size);
1530 ofile.write((
char *)size, 3*
sizeof(
int));
1532 G4cout <<
"ROI image size : ("
1540 kRoi[0].getMinMax(minmax);
1541 ofile.write((
char *)minmax,
sizeof(
short)*2);
1544 scale = (float)
kRoi[0].getScale();
1545 ofile.write((
char *)&scale,
sizeof(
float));
1547 G4cout <<
"ROI image min., max., scale : "
1548 << minmax[0] <<
", "
1549 << minmax[1] <<
", "
1554 int rsize = size[0]*size[1];
1555 for(
int i = 0; i < size[2]; i++) {
1556 short * rimage =
kRoi[0].getImage(i);
1557 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1562 kRoi[0].getCenterPosition(fCenter);
1563 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1564 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1566 G4cout <<
"ROI image relative location : ("
1567 << iCenter[0] <<
", "
1568 << iCenter[1] <<
", "
1569 << iCenter[2] <<
")" <<
G4endl;
1576 int ntrk =
kSteps.size();
1577 ofile.write((
char *)&ntrk,
sizeof(
int));
1579 G4cout <<
"# of tracks : "
1582 for(
int i = 0; i < ntrk; i++) {
1584 ofile.write((
char *)tp,
sizeof(
float)*6);
1589 ofile.write(
"END", 3);
1608 <<
" in G4GMocrenIO::retrieveData()." <<
G4endl;
1614 ifile.read((
char *)verid, 8);
1617 ifile.read((
char *)&ver, 1);
1620 if(std::strncmp(verid,
"gMocren", 7) == 0) {
1622 G4cout <<
">>>>>>> retrieve data (ver.3) <<<<<<<" <<
G4endl;
1625 }
else if (ver == 0x04) {
1626 G4cout <<
">>>>>>> retrieve data (ver.4) <<<<<<<" <<
G4endl;
1631 G4cout <<
"Error -- invalid file version : " << (
int)ver
1637 }
else if(std::strncmp(verid,
"GRAPE", 5) == 0) {
1638 G4cout <<
">>>>>>> retrieve data (ver.2) <<<<<<<" <<
G4endl;
1665 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
1674 ifile.read((
char *)verid, 8);
1678 ifile.read((
char *)&ver, 1);
1679 std::stringstream ss;
1697 ifile.read((
char *)ctmp, 4);
1701 ifile.read((
char *)cmt, clength);
1702 std::string scmt = cmt;
1706 G4cout <<
"Data comment : "
1711 ifile.read((
char *)ctmp, 12);
1716 G4cout <<
"Voxel spacing : ("
1725 ifile.read((
char *)ctmp, 4);
1729 ifile.read((
char *)ctmp, 4);
1734 for(
int i = 0; i < nDoseDist; i++) {
1735 ifile.read((
char *)ctmp, 4);
1742 ifile.read((
char *)ctmp, 4);
1746 ifile.read((
char *)ctmp, 4);
1750 ifile.read((
char *)ctmp, 4);
1754 G4cout <<
"Each pointer to data : "
1756 for(
int i = 0; i < nDoseDist; i++)
1789 ifile.read(ctmp, 3*
sizeof(
int));
1794 G4cout <<
"Modality image size : ("
1813 ifile.read((
char *)ctmp, 4);
1821 ifile.read((
char *)munit, 12);
1822 std::string smunit = munit;
1826 ifile.read((
char *)ctmp, 4);
1830 G4cout <<
"Modality image min., max., scale : "
1831 << minmax[0] <<
", "
1832 << minmax[1] <<
", "
1837 int psize = size[0]*size[1];
1838 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
1839 char * cimage =
new char[psize*
sizeof(short)];
1840 for(
int i = 0; i < size[2]; i++) {
1841 ifile.read((
char *)cimage, psize*
sizeof(
short));
1842 short * mimage =
new short[psize];
1843 for(
int j = 0; j < psize; j++) {
1848 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
1854 size_t msize = minmax[1]-minmax[0]+1;
1856 char * pdmap =
new char[msize*
sizeof(float)];
1857 ifile.read((
char *)pdmap, msize*
sizeof(
float));
1859 for(
int i = 0; i < (
int)msize; i++) {
1866 G4cout <<
"density map : " << std::ends;
1867 for(
int i = 0; i < 10; i++)
1870 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
1881 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1886 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1891 G4cout <<
"Dose dist. image size : ("
1897 kDose[ndose].setSize(size);
1900 ifile.read((
char *)ctmp,
sizeof(
short)*2);
1907 ifile.read((
char *)dunit, 12);
1908 std::string sdunit = dunit;
1915 ifile.read((
char *)ctmp, 4);
1917 kDose[ndose].setScale(dscale = scale);
1920 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
1921 kDose[ndose].setMinMax(dminmax);
1924 G4cout <<
"Dose dist. image min., max., scale : "
1925 << dminmax[0] <<
", "
1926 << dminmax[1] <<
", "
1931 int dsize = size[0]*size[1];
1932 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
1933 char * di =
new char[dsize*
sizeof(short)];
1934 short * shimage =
new short[dsize];
1935 for(
int z = 0;
z < size[2];
z++) {
1936 ifile.read((
char *)di, dsize*
sizeof(
short));
1937 double * dimage =
new double[dsize];
1938 for(
int xy = 0; xy < dsize; xy++) {
1940 dimage[xy] = shimage[xy]*dscale;
1942 kDose[ndose].addImage(dimage);
1944 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
1947 for(
int j = 0; j < dsize; j++) {
1949 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1950 << dimage[j] <<
", ";
1958 ifile.read((
char *)ctmp, 3*4);
1962 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
1963 kDose[ndose].setCenterPosition(fCenter);
1966 G4cout <<
"Dose dist. image relative location : ("
1967 << fCenter[0] <<
", "
1968 << fCenter[1] <<
", "
1969 << fCenter[2] <<
")" <<
G4endl;
1975 ifile.read((
char *)cname, 80);
1976 std::string dosename = cname;
1990 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1994 kRoi[0].setSize(size);
1996 G4cout <<
"ROI image size : ("
2004 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2007 kRoi[0].setMinMax(minmax);
2010 ifile.read((
char *)ctmp,
sizeof(
float));
2012 kRoi[0].setScale(dscale = scale);
2014 G4cout <<
"ROI image min., max., scale : "
2015 << minmax[0] <<
", "
2016 << minmax[1] <<
", "
2021 int rsize = size[0]*size[1];
2022 char * ri =
new char[rsize*
sizeof(short)];
2023 for(
int i = 0; i < size[2]; i++) {
2024 ifile.read((
char *)ri, rsize*
sizeof(
short));
2025 short * rimage =
new short[rsize];
2026 for(
int j = 0; j < rsize; j++) {
2029 kRoi[0].addImage(rimage);
2035 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2039 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2040 kRoi[0].setCenterPosition(fCenter);
2042 G4cout <<
"ROI image relative location : ("
2043 << fCenter[0] <<
", "
2044 << fCenter[1] <<
", "
2045 << fCenter[2] <<
")" <<
G4endl;
2054 ifile.read((
char *)ctmp,
sizeof(
int));
2062 unsigned char rgb[3];
2063 for(
int i = 0; i < ntrk; i++) {
2067 ifile.read((
char *)ctmp,
sizeof(
int));
2072 ifile.read((
char *)rgb, 3);
2074 std::vector<float *> steps;
2076 for(
int j = 0; j < nsteps; j++) {
2078 float * steppoint =
new float[6];
2079 ifile.read((
char *)ctmp,
sizeof(
float)*6);
2081 for(
int k = 0; k < 6; k++) {
2085 steps.push_back(steppoint);
2094 for(
int j = 0; j < 3; j++)
G4cout << steps[0][j] <<
" ";
2095 int nstp = steps.size();
2097 for(
int j = 3; j < 6; j++)
G4cout << steps[nstp-1][j] <<
" ";
2099 for(
int j = 0; j < 3; j++)
G4cout << (
int)rgb[j] <<
" ";
2113 ifile.read((
char *)ctmp,
sizeof(
int));
2118 G4cout <<
"# of detectors : "
2122 for(
int nd = 0; nd < ndet; nd++) {
2125 ifile.read((
char *)ctmp,
sizeof(
int));
2129 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
2133 std::vector<float *> detector;
2135 for(
int ne = 0; ne < nedges; ne++) {
2137 ifile.read((
char *)cftmp,
sizeof(
float)*6);
2138 float * edgePoints =
new float[6];
2139 for(
int j = 0; j < 6; j++)
convertEndian(&cftmp[
sizeof(
float)*j], edgePoints[j]);
2140 detector.push_back(edgePoints);
2145 G4cout <<
" first edge : (" << detector[0][0] <<
", "
2146 << detector[0][1] <<
", "
2147 << detector[0][2] <<
") - ("
2148 << detector[0][3] <<
", "
2149 << detector[0][4] <<
", "
2150 << detector[0][5] <<
")" <<
G4endl;
2154 unsigned char dcolor[3];
2155 ifile.read((
char *)dcolor, 3);
2157 G4cout <<
" detector color : rgb("
2158 << (
int)dcolor[0] <<
", "
2159 << (
int)dcolor[1] <<
", "
2160 << (
int)dcolor[2] << G4endl;
2166 ifile.read((
char *)cname, 80);
2167 std::string dname = cname;
2198 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
2207 ifile.read((
char *)verid, 8);
2211 ifile.read((
char *)&ver, 1);
2212 std::stringstream ss;
2230 ifile.read((
char *)ctmp, 4);
2234 ifile.read((
char *)cmt, clength);
2235 std::string scmt = cmt;
2238 G4cout <<
"Data comment : "
2243 ifile.read((
char *)ctmp, 12);
2248 G4cout <<
"Voxel spacing : ("
2257 ifile.read((
char *)ctmp, 4);
2261 ifile.read((
char *)ctmp, 4);
2266 for(
int i = 0; i < nDoseDist; i++) {
2267 ifile.read((
char *)ctmp, 4);
2274 ifile.read((
char *)ctmp, 4);
2278 ifile.read((
char *)ctmp, 4);
2281 G4cout <<
"Each pointer to data : "
2283 for(
int i = 0; i < nDoseDist; i++)
2312 ifile.read(ctmp, 3*
sizeof(
int));
2317 G4cout <<
"Modality image size : ("
2336 ifile.read((
char *)ctmp, 4);
2343 ifile.read((
char *)munit, 12);
2344 std::string smunit = munit;
2348 ifile.read((
char *)ctmp, 4);
2352 G4cout <<
"Modality image min., max., scale : "
2353 << minmax[0] <<
", "
2354 << minmax[1] <<
", "
2359 int psize = size[0]*size[1];
2360 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2361 char * cimage =
new char[psize*
sizeof(short)];
2362 for(
int i = 0; i < size[2]; i++) {
2363 ifile.read((
char *)cimage, psize*
sizeof(
short));
2364 short * mimage =
new short[psize];
2365 for(
int j = 0; j < psize; j++) {
2370 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2376 size_t msize = minmax[1]-minmax[0]+1;
2378 char * pdmap =
new char[msize*
sizeof(float)];
2379 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2381 for(
int i = 0; i < (
int)msize; i++) {
2387 G4cout <<
"density map : " << std::ends;
2388 for(
int i = 0; i < 10; i++)
2391 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2402 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
2407 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2412 G4cout <<
"Dose dist. image size : ("
2418 kDose[ndose].setSize(size);
2421 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2427 ifile.read((
char *)dunit, 12);
2428 std::string sdunit = dunit;
2435 ifile.read((
char *)ctmp, 4);
2437 kDose[ndose].setScale(dscale = scale);
2440 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2441 kDose[ndose].setMinMax(dminmax);
2444 G4cout <<
"Dose dist. image min., max., scale : "
2445 << dminmax[0] <<
", "
2446 << dminmax[1] <<
", "
2451 int dsize = size[0]*size[1];
2452 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2453 char * di =
new char[dsize*
sizeof(short)];
2454 short * shimage =
new short[dsize];
2455 for(
int z = 0;
z < size[2];
z++) {
2456 ifile.read((
char *)di, dsize*
sizeof(
short));
2457 double * dimage =
new double[dsize];
2458 for(
int xy = 0; xy < dsize; xy++) {
2460 dimage[xy] = shimage[xy]*dscale;
2462 kDose[ndose].addImage(dimage);
2464 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2467 for(
int j = 0; j < dsize; j++) {
2469 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2470 << dimage[j] <<
", ";
2478 ifile.read((
char *)ctmp, 3*4);
2482 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2483 kDose[ndose].setCenterPosition(fCenter);
2486 G4cout <<
"Dose dist. image relative location : ("
2487 << fCenter[0] <<
", "
2488 << fCenter[1] <<
", "
2489 << fCenter[2] <<
")" <<
G4endl;
2501 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2505 kRoi[0].setSize(size);
2507 G4cout <<
"ROI image size : ("
2515 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2518 kRoi[0].setMinMax(minmax);
2521 ifile.read((
char *)ctmp,
sizeof(
float));
2523 kRoi[0].setScale(dscale = scale);
2525 G4cout <<
"ROI image min., max., scale : "
2526 << minmax[0] <<
", "
2527 << minmax[1] <<
", "
2532 int rsize = size[0]*size[1];
2533 char * ri =
new char[rsize*
sizeof(short)];
2534 for(
int i = 0; i < size[2]; i++) {
2535 ifile.read((
char *)ri, rsize*
sizeof(
short));
2536 short * rimage =
new short[rsize];
2537 for(
int j = 0; j < rsize; j++) {
2540 kRoi[0].addImage(rimage);
2546 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2550 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2551 kRoi[0].setCenterPosition(fCenter);
2553 G4cout <<
"ROI image relative location : ("
2554 << fCenter[0] <<
", "
2555 << fCenter[1] <<
", "
2556 << fCenter[2] <<
")" <<
G4endl;
2565 ifile.read((
char *)ctmp,
sizeof(
int));
2573 std::vector<float *> trkv4;
2576 for(
int i = 0; i < ntrk; i++) {
2577 float * tp =
new float[6];
2579 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2581 for(
int j = 0; j < 3; j++) {
2586 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2587 for(
int j = 0; j < 3; j++) {
2595 trkv4.push_back(tp);
2599 unsigned char trkcolorv4[3];
2602 for(
int i = 0; i < ntrk; i++) {
2603 unsigned char * rgb =
new unsigned char[3];
2604 ifile.read((
char *)rgb, 3);
2608 for(
int j = 0; j < 3; j++) trkcolorv4[j] = rgb[j];
2609 std::vector<float *> trk;
2610 trk.push_back(trkv4[i]);
2636 <<
" in G4GMocrenIO::retrieveData2()." <<
G4endl;
2645 ifile.read((
char *)verid, 8);
2649 ifile.read((
char *)&ver, 1);
2650 std::stringstream ss;
2657 ifile.read((
char *)idtmp,
IDLENGTH);
2675 ifile.read((
char *)ctmp, 12);
2680 G4cout <<
"Voxel spacing : ("
2689 ifile.read((
char *)ctmp, 4);
2694 ifile.read((
char *)ctmp, 4);
2699 ifile.read((
char *)ctmp, 4);
2703 ifile.read((
char *)ctmp, 4);
2706 G4cout <<
"Each pointer to data : "
2736 ifile.read(ctmp, 3*
sizeof(
int));
2741 G4cout <<
"Modality image size : ("
2760 ifile.read((
char *)ctmp, 4);
2766 ifile.read((
char *)ctmp, 4);
2770 G4cout <<
"Modality image min., max., scale : "
2771 << minmax[0] <<
", "
2772 << minmax[1] <<
", "
2777 int psize = size[0]*size[1];
2778 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2779 char * cimage =
new char[psize*
sizeof(short)];
2780 for(
int i = 0; i < size[2]; i++) {
2781 ifile.read((
char *)cimage, psize*
sizeof(
short));
2782 short * mimage =
new short[psize];
2783 for(
int j = 0; j < psize; j++) {
2788 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2794 size_t msize = minmax[1]-minmax[0]+1;
2796 char * pdmap =
new char[msize*
sizeof(float)];
2797 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2799 for(
int i = 0; i < (
int)msize; i++) {
2805 G4cout <<
"density map : " << std::ends;
2806 for(
int i = 0; i < 10; i++)
2809 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2825 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2830 G4cout <<
"Dose dist. image size : ("
2836 kDose[0].setSize(size);
2839 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2843 ifile.read((
char *)ctmp,
sizeof(
float));
2845 kDose[0].setScale(dscale = scale);
2848 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2849 kDose[0].setMinMax(dminmax);
2852 G4cout <<
"Dose dist. image min., max., scale : "
2853 << dminmax[0] <<
", "
2854 << dminmax[1] <<
", "
2859 int dsize = size[0]*size[1];
2860 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2861 char * di =
new char[dsize*
sizeof(short)];
2862 short * shimage =
new short[dsize];
2863 for(
int z = 0;
z < size[2];
z++) {
2864 ifile.read((
char *)di, dsize*
sizeof(
short));
2865 double * dimage =
new double[dsize];
2866 for(
int xy = 0; xy < dsize; xy++) {
2868 dimage[xy] = shimage[xy]*dscale;
2870 kDose[0].addImage(dimage);
2872 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2875 for(
int j = 0; j < dsize; j++) {
2877 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2878 << dimage[j] <<
", ";
2920 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2924 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2925 kDose[0].setCenterPosition(fCenter);
2928 G4cout <<
"Dose dist. image relative location : ("
2929 << fCenter[0] <<
", "
2930 << fCenter[1] <<
", "
2931 << fCenter[2] <<
")" <<
G4endl;
2943 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2947 kRoi[0].setSize(size);
2949 G4cout <<
"ROI image size : ("
2957 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2960 kRoi[0].setMinMax(minmax);
2963 ifile.read((
char *)ctmp,
sizeof(
float));
2965 kRoi[0].setScale(dscale = scale);
2967 G4cout <<
"ROI image min., max., scale : "
2968 << minmax[0] <<
", "
2969 << minmax[1] <<
", "
2974 int rsize = size[0]*size[1];
2975 char * ri =
new char[rsize*
sizeof(short)];
2976 for(
int i = 0; i < size[2]; i++) {
2977 ifile.read((
char *)ri, rsize*
sizeof(
short));
2978 short * rimage =
new short[rsize];
2979 for(
int j = 0; j < rsize; j++) {
2982 kRoi[0].addImage(rimage);
2988 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2992 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2993 kRoi[0].setCenterPosition(fCenter);
2995 G4cout <<
"ROI image relative location : ("
2996 << fCenter[0] <<
", "
2997 << fCenter[1] <<
", "
2998 << fCenter[2] <<
")" <<
G4endl;
3007 ifile.read((
char *)ctmp,
sizeof(
int));
3015 unsigned char trkcolorv4[3] = {255, 0, 0};
3017 for(
int i = 0; i < ntrk; i++) {
3018 float * tp =
new float[6];
3020 std::vector<float *> trkv4;
3022 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3024 for(
int j = 0; j < 3; j++) {
3029 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3030 for(
int j = 0; j < 3; j++) {
3037 trkv4.push_back(tp);
3104 char cmonth[12][4] = {
"Jan",
"Feb",
"Mar",
"Apr",
3105 "May",
"Jun",
"Jul",
"Aug",
3106 "Sep",
"Oct",
"Nov",
"Dec"};
3107 std::stringstream ss;
3108 ss << std::setfill(
'0')
3110 << ti->tm_hour <<
":"
3112 << ti->tm_min <<
":"
3114 << ti->tm_sec <<
","
3115 << cmonth[ti->tm_mon] <<
"."
3117 << ti->tm_mday <<
","
3118 << ti->tm_year+1900;
3185 void G4GMocrenIO::calcPointers4() {
3188 unsigned int pointer = 1070;
3190 pointer += nDoseDist*4;
3200 int pmsize = 2*msize[0]*msize[1]*msize[2];
3201 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3202 pointer += 32 + pmsize + pmmap;
3205 if(nDoseDist == 0) {
3206 unsigned int pointer0 = 0;
3209 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3213 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2 + 80;
3222 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3223 pointer += 20 + prsize + 12;
3225 unsigned int pointer0 = 0;
3235 for(
int nt = 0;
nt < ntrk;
nt++) {
3236 int nsteps =
kTracks[
nt].getNumberOfSteps();
3237 pointer += 4 + 3 + nsteps*(4*6);
3240 unsigned int pointer0 = 0;
3259 void G4GMocrenIO::calcPointers3() {
3262 unsigned int pointer = 1066;
3264 pointer += nDoseDist*4;
3274 int pmsize = 2*msize[0]*msize[1]*msize[2];
3275 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3276 pointer += 32 + pmsize + pmmap;
3279 if(nDoseDist == 0) {
3280 unsigned int pointer0 = 0;
3283 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3287 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2;
3296 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3297 pointer += 20 + prsize + 12;
3299 unsigned int pointer0 = 0;
3307 unsigned int pointer0 = 0;
3314 void G4GMocrenIO::calcPointers2() {
3317 unsigned int pointer = 65;
3325 int pmsize = 2*msize[0]*msize[1]*msize[2];
3326 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3327 pointer += 20 + pmsize + pmmap;
3334 int pdsize = 2*dsize[0]*dsize[1]*dsize[2];
3335 pointer += 20 + pdsize + 12;
3337 unsigned int pointer0 = 0;
3346 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3347 pointer += 20 + prsize + 12;
3350 unsigned int pointer0 = 0;
3358 unsigned int pointer0 = 0;
3415 for(
int i = 0; i < 2; i++) _minmax[i] = minmax[i];
3437 for(
int i = 0; i < 3; i++) _center[i] = 0;
3456 for(
int i = 0; i < nmap; i++) {
3459 rval = i + minmax[0];
3472 kDose.push_back(doseData);
3475 return (
int)
kDose.size();
3487 if(_unit.size() >
static_cast<size_t>(_num))
kDoseUnit = _unit;
3497 for(
int i = 0; i < 3; i++) _size[i] = 0;
3499 kDose[_num].getSize(_size);
3503 kDose[_num].setSize(_size);
3512 for(
int i = 0; i < 2; i++) minmax[i] = (
double)_minmax[i]*
scale;
3513 kDose[_num].setMinMax(minmax);
3518 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3521 kDose[_num].getMinMax(minmax);
3523 for(
int i = 0; i < 2; i++) _minmax[i] = (
short)(minmax[i]/scale+0.5);
3528 kDose[_num].setMinMax(_minmax);
3533 for(
int i = 0; i < 2; i++) _minmax[i] = 0.;
3535 kDose[_num].getMinMax(_minmax);
3541 kDose[_num].setScale(_scale);
3548 return kDose[_num].getScale();
3563 kDose[_num].getSize(size);
3564 int dsize = size[0]*size[1];
3565 double * ddata =
new double[dsize];
3568 kDose[_num].getMinMax(minmax);
3569 for(
int xy = 0; xy < dsize; xy++) {
3570 ddata[xy] = _image[xy]*
scale;
3571 if(ddata[xy] < minmax[0]) minmax[0] = ddata[xy];
3572 if(ddata[xy] > minmax[1]) minmax[1] = ddata[xy];
3574 kDose[_num].addImage(ddata);
3577 kDose[_num].setMinMax(minmax);
3583 G4cout <<
"In G4GMocrenIO::getShortDoseDist(), "
3584 <<
"first argument is NULL pointer. "
3585 <<
"The argument must be allocated array."
3591 kDose[_num].getSize(size);
3593 double * ddata =
kDose[_num].getImage(_z);
3595 for(
int xy = 0; xy < size[0]*size[1]; xy++) {
3596 _data[xy] = (short)(ddata[xy]/scale+0.5);
3602 kDose[_num].getMinMax(minmax);
3603 for(
int i = 0; i < 2; i++)
3604 _minmax[i] = (
short)(minmax[i]/scale+0.5);
3609 kDose[_num].addImage(_image);
3617 image =
kDose[_num].getImage(_z);
3638 std::vector<double *> dosedist =
kDose[_num].getImage();
3640 int nimg = size[0]*size[1];
3641 for(
int z = 0;
z < size[2];
z++) {
3642 for(
int xy = 0; xy < nimg; xy++) {
3643 dosedist[
z][xy] += _image[
z][xy];
3653 kDose[_num].setCenterPosition(_center);
3658 for(
int i = 0; i < 3; i++) _center[i] = 0;
3660 kDose[_num].getCenterPosition(_center);
3665 kDose[_num].setName(_name);
3673 return kDose[_num].getName();
3677 std::vector<class GMocrenDataPrimitive<double> >::iterator itr;
3678 for(itr =
kDose.begin(); itr !=
kDose.end(); itr++) {
3679 _dose.push_back(*itr);
3684 if(
kDose.size() != _dose.size()) {
3686 G4cout <<
"G4GMocrenIO::mergeDoseDist() : Error" <<
G4endl;
3687 G4cout <<
" Unable to merge the dose distributions,"<<
G4endl;
3688 G4cout <<
" because of different size of dose maps."<<
G4endl;
3693 int num =
kDose.size();
3694 std::vector<class GMocrenDataPrimitive<double> >::iterator itr1 =
kDose.begin();
3695 std::vector<class GMocrenDataPrimitive<double> >::iterator itr2 = _dose.begin();
3696 for(
int i = 0; i < num; i++, itr1++, itr2++) {
3699 G4cout <<
"merged dose distribution [" << i <<
"]" <<
G4endl;
3732 for(
int i = 0; i < (
int)
kDose.size(); i++) {
3733 kDose[i].getMinMax(minmax);
3735 kDose[i].setScale(scale);
3745 kRoi.push_back(roiData);
3748 return (
int)
kRoi.size();
3754 kRoi[_num].setScale(_scale);
3761 return kRoi[_num].getScale();
3766 kRoi[_num].addImage(_image);
3773 return kRoi[_num].getImage(_z);
3778 return kRoi[_num].setSize(_size);
3783 for(
int i = 0; i < 3; i++) _size[i] = 0;
3785 return kRoi[_num].getSize(_size);
3790 kRoi[_num].setMinMax(_minmax);
3795 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3797 kRoi[_num].getMinMax(_minmax);
3802 kRoi[_num].setCenterPosition(_center);
3807 for(
int i = 0; i < 3; i++) _center[i] = 0;
3809 kRoi[_num].getCenterPosition(_center);
3837 return (
int)
kSteps.size();
3843 kSteps.push_back(_tracks);
3861 std::vector<unsigned char *> & _colors) {
3862 std::vector<float *>::iterator titr;
3863 for(titr =
kSteps.begin(); titr !=
kSteps.end(); titr++) {
3864 float * pts =
new float[6];
3865 for(
int i = 0; i < 6; i++) {
3866 pts[i] = (*titr)[i];
3868 _tracks.push_back(pts);
3871 std::vector<unsigned char *>::iterator citr;
3873 unsigned char * pts =
new unsigned char[3];
3874 for(
int i = 0; i < 3; i++) {
3875 pts[i] = (*citr)[i];
3877 _colors.push_back(pts);
3881 std::vector<unsigned char *> & _colors) {
3882 std::vector<float *>::iterator titr;
3883 for(titr = _tracks.begin(); titr != _tracks.end(); titr++) {
3887 std::vector<unsigned char *>::iterator citr;
3888 for(citr = _colors.begin(); citr != _colors.end(); citr++) {
3894 std::vector<float *>::iterator itr = _steps.begin();
3895 std::vector<struct GMocrenTrack::Step> steps;
3896 for(; itr != _steps.end(); itr++) {
3898 for(
int i = 0; i < 3; i++) {
3902 steps.push_back(step);
3911 std::vector<unsigned char *> & _color) {
3913 if(_num > (
int)
kTracks.size()) {
3915 G4cout <<
"ERROR in getTrack() : " << G4endl;
3918 unsigned char * color =
new unsigned char[3];
3919 kTracks[_num].getColor(color);
3920 _color.push_back(color);
3923 int nsteps =
kTracks[_num].getNumberOfSteps();
3924 for(
int isteps = 0; isteps < nsteps; isteps++) {
3925 float * stepPoints =
new float[6];
3926 kTracks[_num].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
3927 stepPoints[3], stepPoints[4], stepPoints[5],
3929 _steps.push_back(stepPoints);
3934 std::vector<class GMocrenTrack>::iterator itr =
kTracks.begin();
3935 for(; itr !=
kTracks.end(); itr++) {
3936 itr->translate(_translate);
3948 std::vector<float *> & _det,
3949 unsigned char _color[3]) {
3951 std::vector<float *>::iterator itr = _det.begin();
3952 std::vector<struct GMocrenDetector::Edge> edges;
3953 for(; itr != _det.end(); itr++) {
3955 for(
int i = 0; i < 3; i++) {
3959 edges.push_back(edge);
3970 std::vector<unsigned char *> & _color,
3971 std::string & _detName) {
3975 G4cout <<
"ERROR in getDetector() : " << G4endl;
3981 unsigned char * color =
new unsigned char[3];
3983 _color.push_back(color);
3986 int nedges =
kDetectors[_num].getNumberOfEdges();
3987 for(
int ne = 0; ne < nedges; ne++) {
3988 float * edgePoints =
new float[6];
3989 kDetectors[_num].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
3990 edgePoints[3], edgePoints[4], edgePoints[5],
3992 _edges.push_back(edgePoints);
3997 std::vector<class GMocrenDetector>::iterator itr =
kDetectors.begin();
3999 itr->translate(_translate);
4004 template <
typename T>
4010 const int SIZE =
sizeof(_rval);
4012 for(
int i = 0; i < SIZE/2; i++) {
4014 _val[i] = _val[SIZE - 1 - i];
4015 _val[SIZE - 1 - i] = ctemp;
4022 template <
typename T>
4025 const int SIZE =
sizeof(_rval);
4031 for(
int i = 0; i < SIZE; i++) {
4032 uni.cu[i] = _val[SIZE-1-i];