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 std::strncpy(cmt,
kComment.c_str(), 1024);
511 ofile.write(cmt, 1024);
513 G4cout <<
"Data comment : "
521 for(
int j = 0; j < 3; j++)
523 ofile.write((
char *)ftmp, 12);
526 G4cout <<
"Voxel spacing : ("
541 ofile.write((
char *)itmp, 4);
548 ofile.write((
char *)&nDoseDist, 4);
551 ofile.write((
char *)itmp, 4);
556 for(
int i = 0; i < nDoseDist; i++) {
560 for(
int i = 0; i < nDoseDist; i++) {
562 ofile.write((
char *)itmp, 4);
571 ofile.write((
char *)itmp, 4);
579 ofile.write((
char *)itmp, 4);
587 ofile.write((
char *)itmp, 4);
591 G4cout <<
"Each pointer to data : "
593 for(
int i = 0; i < nDoseDist; i++) {
613 ofile.write((
char *)size, 3*
sizeof(
int));
615 for(
int j = 0; j < 3; j++)
617 ofile.write((
char *)itmp, 12);
621 G4cout <<
"Modality image size : ("
631 ofile.write((
char *)minmax, 4);
633 for(
int j = 0; j < 2; j++)
635 ofile.write((
char *)stmp, 4);
639 char munit[13] =
"g/cm3\0";
640 ofile.write((
char *)munit, 12);
645 ofile.write((
char *)&scale, 4);
648 ofile.write((
char *)ftmp, 4);
651 G4cout <<
"Modality image min., max., scale : "
658 int psize = size[0]*size[1];
660 for(
int i = 0; i < size[2]; i++) {
663 ofile.write((
char *)image, psize*
sizeof(
short));
665 for(
int j = 0; j < psize; j++) {
667 ofile.write((
char *)stmp, 2);
671 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
676 size_t msize = minmax[1] - minmax[0]+1;
678 G4cout <<
"modality image : " << minmax[0] <<
", " << minmax[1] <<
G4endl;
679 float * pdmap =
new float[msize];
683 ofile.write((
char *)pdmap, msize*
sizeof(
float));
685 for(
int j = 0; j < (
int)msize; j++) {
687 ofile.write((
char *)ftmp, 4);
692 G4cout <<
"density map : " << std::ends;
693 for(
int i = 0; i < (
int)msize; i+=50)
706 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
708 kDose[ndose].getSize(size);
710 ofile.write((
char *)size, 3*
sizeof(
int));
712 for(
int j = 0; j < 3; j++)
714 ofile.write((
char *)itmp, 12);
717 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
727 ofile.write((
char *)minmax, 2*2);
729 for(
int j = 0; j < 2; j++)
731 ofile.write((
char *)stmp, 4);
736 std::strncpy(cdunit,
kDoseUnit.c_str(), 12);
738 ofile.write(cdunit, 12);
746 scale = float(dscale);
748 ofile.write((
char *)&scale, 4);
751 ofile.write((
char *)ftmp, 4);
754 G4cout <<
"Dose dist. [" << ndose
755 <<
"] image min., max., scale : "
762 int dsize = size[0]*size[1];
763 short * dimage =
new short[dsize];
764 for(
int z = 0;
z < size[2];
z++) {
767 ofile.write((
char *)dimage, dsize*2);
769 for(
int j = 0; j < dsize; j++) {
771 ofile.write((
char *)stmp, 2);
776 for(
int j = 0; j < dsize; j++) {
778 G4cout <<
"[" << j <<
"," <<
z <<
"]"
779 << dimage[j] <<
", ";
789 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
791 ofile.write((
char *)iCenter, 3*4);
793 for(
int j = 0; j < 3; j++)
795 ofile.write((
char *)itmp, 12);
798 G4cout <<
"Dose dist. [" << ndose
799 <<
"]image relative location : ("
800 << iCenter[0] <<
", "
801 << iCenter[1] <<
", "
802 << iCenter[2] <<
")" <<
G4endl;
807 if(name.size() == 0) name =
"dose";
809 ofile.write((
char *)name.c_str(), 80);
820 kRoi[0].getSize(size);
822 ofile.write((
char *)size, 3*
sizeof(
int));
824 for(
int j = 0; j < 3; j++)
826 ofile.write((
char *)itmp, 12);
829 G4cout <<
"ROI image size : ("
837 kRoi[0].getMinMax(minmax);
839 ofile.write((
char *)minmax,
sizeof(
short)*2);
841 for(
int j = 0; j < 2; j++)
843 ofile.write((
char *)stmp, 4);
847 scale = (float)
kRoi[0].getScale();
849 ofile.write((
char *)&scale,
sizeof(
float));
852 ofile.write((
char *)ftmp, 4);
855 G4cout <<
"ROI image min., max., scale : "
862 int rsize = size[0]*size[1];
863 for(
int i = 0; i < size[2]; i++) {
864 short * rimage =
kRoi[0].getImage(i);
866 ofile.write((
char *)rimage, rsize*
sizeof(
short));
868 for(
int j = 0; j < rsize; j++) {
870 ofile.write((
char *)stmp, 2);
877 kRoi[0].getCenterPosition(fCenter);
878 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
880 ofile.write((
char *)iCenter, 3*
sizeof(
int));
882 for(
int j = 0; j < 3; j++)
884 ofile.write((
char *)itmp, 12);
887 G4cout <<
"ROI image relative location : ("
888 << iCenter[0] <<
", "
889 << iCenter[1] <<
", "
890 << iCenter[2] <<
")" <<
G4endl;
900 ofile.write((
char *)&ntrk,
sizeof(
int));
903 ofile.write((
char *)itmp, 4);
906 G4cout <<
"# of tracks : "
910 for(
int nt = 0; nt < ntrk; nt++) {
913 int nsteps =
kTracks[nt].getNumberOfSteps();
915 ofile.write((
char *)&nsteps,
sizeof(
int));
918 ofile.write((
char *)itmp, 4);
925 unsigned char tcolor[3];
927 ofile.write((
char *)tcolor, 3);
931 for(
int isteps = 0; isteps < nsteps; isteps++) {
932 kTracks[nt].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
933 stepPoints[3], stepPoints[4], stepPoints[5],
937 ofile.write((
char *)stepPoints,
sizeof(
float)*6);
939 for(
int j = 0; j < 6; j++)
941 ofile.write((
char *)ftmp, 24);
952 ofile.write((
char *)&ndet,
sizeof(
int));
955 ofile.write((
char *)itmp, 4);
958 G4cout <<
"# of detectors : "
962 for(
int nd = 0; nd < ndet; nd++) {
965 int nedges =
kDetectors[nd].getNumberOfEdges();
967 ofile.write((
char *)&nedges,
sizeof(
int));
970 ofile.write((
char *)itmp, 4);
973 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
978 for(
int ne = 0; ne < nedges; ne++) {
979 kDetectors[nd].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
980 edgePoints[3], edgePoints[4], edgePoints[5],
984 ofile.write((
char *)edgePoints,
sizeof(
float)*6);
986 for(
int j = 0; j < 6; j++)
988 ofile.write((
char *)ftmp, 24);
993 G4cout <<
" edge : (" << edgePoints[0] <<
", "
994 << edgePoints[1] <<
", "
995 << edgePoints[2] <<
") - ("
996 << edgePoints[3] <<
", "
997 << edgePoints[4] <<
", "
998 << edgePoints[5] <<
")" <<
G4endl;
1004 unsigned char dcolor[3];
1006 ofile.write((
char *)dcolor, 3);
1008 G4cout <<
" rgb : (" << (
int)dcolor[0] <<
", "
1009 << (
int)dcolor[1] <<
", "
1010 << (
int)dcolor[2] <<
")" << G4endl;
1014 std::string dname =
kDetectors[nd].getName();
1016 ofile.write((
char *)dname.c_str(), 80);
1025 ofile.write(
"END", 3);
1042 std::ios_base::out|std::ios_base::binary);
1045 ofile.write(
"gMocren ", 8);
1048 unsigned char ver = 0x03;
1049 ofile.write((
char *)&ver, 1);
1055 int commentLength = 1024;
1056 ofile.write((
char *)&commentLength, 4);
1060 std::strncpy(cmt,
kComment.c_str(), 1024);
1061 ofile.write((
char *)cmt, 1024);
1063 G4cout <<
"Data comment : "
1070 G4cout <<
"Voxel spacing : ("
1085 ofile.write((
char *)&nDoseDist, 4);
1088 for(
int i = 0; i < nDoseDist; i++) {
1098 G4cout <<
"Each pointer to data : "
1100 for(
int i = 0; i < nDoseDist; i++) {
1116 ofile.write((
char *)size, 3*
sizeof(
int));
1118 G4cout <<
"Modality image size : ("
1127 ofile.write((
char *)minmax, 4);
1130 char munit[13] =
"g/cm3 ";
1131 ofile.write((
char *)munit, 12);
1135 ofile.write((
char *)&scale, 4);
1137 G4cout <<
"Modality image min., max., scale : "
1138 << minmax[0] <<
", "
1139 << minmax[1] <<
", "
1144 int psize = size[0]*size[1];
1146 for(
int i = 0; i < size[2]; i++) {
1148 ofile.write((
char *)image, psize*
sizeof(
short));
1150 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1155 size_t msize = minmax[1] - minmax[0]+1;
1156 float * pdmap =
new float[msize];
1158 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1160 G4cout <<
"density map : " << std::ends;
1161 for(
int i = 0; i < (
int)msize; i+=50)
1174 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1176 kDose[ndose].getSize(size);
1177 ofile.write((
char *)size, 3*
sizeof(
int));
1179 G4cout <<
"Dose dist. [" << ndose <<
"] image size : ("
1188 ofile.write((
char *)minmax, 2*2);
1199 scale = float(dscale);
1200 ofile.write((
char *)&scale, 4);
1202 G4cout <<
"Dose dist. [" << ndose
1203 <<
"] image min., max., scale : "
1204 << minmax[0] <<
", "
1205 << minmax[1] <<
", "
1210 int dsize = size[0]*size[1];
1211 short * dimage =
new short[dsize];
1212 for(
int z = 0;
z < size[2];
z++) {
1214 ofile.write((
char *)dimage, dsize*2);
1217 for(
int j = 0; j < dsize; j++) {
1219 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1220 << dimage[j] <<
", ";
1230 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1231 ofile.write((
char *)iCenter, 3*4);
1233 G4cout <<
"Dose dist. [" << ndose
1234 <<
"]image relative location : ("
1235 << iCenter[0] <<
", "
1236 << iCenter[1] <<
", "
1237 << iCenter[2] <<
")" <<
G4endl;
1245 kRoi[0].getSize(size);
1246 ofile.write((
char *)size, 3*
sizeof(
int));
1248 G4cout <<
"ROI image size : ("
1256 kRoi[0].getMinMax(minmax);
1257 ofile.write((
char *)minmax,
sizeof(
short)*2);
1260 scale = (float)
kRoi[0].getScale();
1261 ofile.write((
char *)&scale,
sizeof(
float));
1263 G4cout <<
"ROI image min., max., scale : "
1264 << minmax[0] <<
", "
1265 << minmax[1] <<
", "
1270 int rsize = size[0]*size[1];
1271 for(
int i = 0; i < size[2]; i++) {
1272 short * rimage =
kRoi[0].getImage(i);
1273 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1278 kRoi[0].getCenterPosition(fCenter);
1279 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1280 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1282 G4cout <<
"ROI image relative location : ("
1283 << iCenter[0] <<
", "
1284 << iCenter[1] <<
", "
1285 << iCenter[2] <<
")" <<
G4endl;
1291 int ntrk =
kSteps.size();
1292 ofile.write((
char *)&ntrk,
sizeof(
int));
1294 G4cout <<
"# of tracks : "
1298 for(
int i = 0; i < ntrk; i++) {
1300 ofile.write((
char *)tp,
sizeof(
float)*6);
1306 G4cout <<
"# of track color information must be the same as # of tracks."
1308 unsigned char white[3] = {255,255,255};
1309 for(
int i = 0; i < ntrk; i++) {
1312 ofile.write((
char *)tcolor, 3);
1314 ofile.write((
char *)white, 3);
1319 ofile.write(
"END", 3);
1341 std::ios_base::out|std::ios_base::binary);
1344 ofile.write(
"GRAPE ", 8);
1347 unsigned char ver = 0x02;
1348 ofile.write((
char *)&ver, 1);
1370 G4cout <<
"Voxel spacing : ("
1390 G4cout <<
"Each pointer to data : "
1406 ofile.write((
char *)size, 3*
sizeof(
int));
1408 G4cout <<
"Modality image size : ("
1417 ofile.write((
char *)minmax, 4);
1425 ofile.write((
char *)&scale, 4);
1427 G4cout <<
"Modality image min., max., scale : "
1428 << minmax[0] <<
", "
1429 << minmax[1] <<
", "
1434 int psize = size[0]*size[1];
1436 for(
int i = 0; i < size[2]; i++) {
1438 ofile.write((
char *)image, psize*
sizeof(
short));
1440 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << image[(size_t)(psize*0.55)] <<
", ";
1445 size_t msize = minmax[1] - minmax[0]+1;
1446 float * pdmap =
new float[msize];
1448 ofile.write((
char *)pdmap, msize*
sizeof(
float));
1450 G4cout <<
"density map : " << std::ends;
1451 for(
int i = 0; i < (
int)msize; i+=50)
1464 kDose[0].getSize(size);
1465 ofile.write((
char *)size, 3*
sizeof(
int));
1467 G4cout <<
"Dose dist. image size : ("
1476 ofile.write((
char *)minmax,
sizeof(
short)*2);
1479 scale = (float)
kDose[0].getScale();
1480 ofile.write((
char *)&scale,
sizeof(
float));
1482 G4cout <<
"Dose dist. image min., max., scale : "
1483 << minmax[0] <<
", "
1484 << minmax[1] <<
", "
1489 int dsize = size[0]*size[1];
1490 short * dimage =
new short[dsize];
1491 for(
int z = 0;
z < size[2];
z++) {
1493 ofile.write((
char *)dimage, dsize*
sizeof(
short));
1496 for(
int j = 0; j < dsize; j++) {
1498 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1499 << dimage[j] <<
", ";
1508 kDose[0].getCenterPosition(fCenter);
1509 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1510 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1512 G4cout <<
"Dose dist. image relative location : ("
1513 << iCenter[0] <<
", "
1514 << iCenter[1] <<
", "
1515 << iCenter[2] <<
")" <<
G4endl;
1523 kRoi[0].getSize(size);
1524 ofile.write((
char *)size, 3*
sizeof(
int));
1526 G4cout <<
"ROI image size : ("
1534 kRoi[0].getMinMax(minmax);
1535 ofile.write((
char *)minmax,
sizeof(
short)*2);
1538 scale = (float)
kRoi[0].getScale();
1539 ofile.write((
char *)&scale,
sizeof(
float));
1541 G4cout <<
"ROI image min., max., scale : "
1542 << minmax[0] <<
", "
1543 << minmax[1] <<
", "
1548 int rsize = size[0]*size[1];
1549 for(
int i = 0; i < size[2]; i++) {
1550 short * rimage =
kRoi[0].getImage(i);
1551 ofile.write((
char *)rimage, rsize*
sizeof(
short));
1556 kRoi[0].getCenterPosition(fCenter);
1557 for(
int i = 0; i < 3; i++) iCenter[i] = (
int)fCenter[i];
1558 ofile.write((
char *)iCenter, 3*
sizeof(
int));
1560 G4cout <<
"ROI image relative location : ("
1561 << iCenter[0] <<
", "
1562 << iCenter[1] <<
", "
1563 << iCenter[2] <<
")" <<
G4endl;
1570 int ntrk =
kSteps.size();
1571 ofile.write((
char *)&ntrk,
sizeof(
int));
1573 G4cout <<
"# of tracks : "
1576 for(
int i = 0; i < ntrk; i++) {
1578 ofile.write((
char *)tp,
sizeof(
float)*6);
1583 ofile.write(
"END", 3);
1602 <<
" in G4GMocrenIO::retrieveData()." <<
G4endl;
1608 ifile.read((
char *)verid, 8);
1611 ifile.read((
char *)&ver, 1);
1614 if(std::strncmp(verid,
"gMocren", 7) == 0) {
1616 G4cout <<
">>>>>>> retrieve data (ver.3) <<<<<<<" <<
G4endl;
1619 }
else if (ver == 0x04) {
1620 G4cout <<
">>>>>>> retrieve data (ver.4) <<<<<<<" <<
G4endl;
1625 G4cout <<
"Error -- invalid file version : " << (
int)ver
1634 }
else if(std::strncmp(verid,
"GRAPE", 5) == 0) {
1635 G4cout <<
">>>>>>> retrieve data (ver.2) <<<<<<<" <<
G4endl;
1662 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
1671 ifile.read((
char *)verid, 8);
1675 ifile.read((
char *)&ver, 1);
1676 std::stringstream
ss;
1694 ifile.read((
char *)ctmp, 4);
1698 ifile.read((
char *)cmt, clength);
1699 std::string scmt = cmt;
1703 G4cout <<
"Data comment : "
1708 ifile.read((
char *)ctmp, 12);
1713 G4cout <<
"Voxel spacing : ("
1722 ifile.read((
char *)ctmp, 4);
1726 ifile.read((
char *)ctmp, 4);
1731 for(
int i = 0; i < nDoseDist; i++) {
1732 ifile.read((
char *)ctmp, 4);
1739 ifile.read((
char *)ctmp, 4);
1743 ifile.read((
char *)ctmp, 4);
1747 ifile.read((
char *)ctmp, 4);
1751 G4cout <<
"Each pointer to data : "
1753 for(
int i = 0; i < nDoseDist; i++)
1786 ifile.read(ctmp, 3*
sizeof(
int));
1791 G4cout <<
"Modality image size : ("
1810 ifile.read((
char *)ctmp, 4);
1818 ifile.read((
char *)munit, 12);
1819 std::string smunit = munit;
1823 ifile.read((
char *)ctmp, 4);
1827 G4cout <<
"Modality image min., max., scale : "
1828 << minmax[0] <<
", "
1829 << minmax[1] <<
", "
1834 int psize = size[0]*size[1];
1835 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
1836 char * cimage =
new char[psize*
sizeof(short)];
1837 for(
int i = 0; i < size[2]; i++) {
1838 ifile.read((
char *)cimage, psize*
sizeof(
short));
1839 short * mimage =
new short[psize];
1840 for(
int j = 0; j < psize; j++) {
1845 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
1851 size_t msize = minmax[1]-minmax[0]+1;
1853 char * pdmap =
new char[msize*
sizeof(float)];
1854 ifile.read((
char *)pdmap, msize*
sizeof(
float));
1856 for(
int i = 0; i < (
int)msize; i++) {
1863 G4cout <<
"density map : " << std::ends;
1864 for(
int i = 0; i < 10; i++)
1867 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
1878 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
1883 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1888 G4cout <<
"Dose dist. image size : ("
1894 kDose[ndose].setSize(size);
1897 ifile.read((
char *)ctmp,
sizeof(
short)*2);
1904 ifile.read((
char *)dunit, 12);
1905 std::string sdunit = dunit;
1912 ifile.read((
char *)ctmp, 4);
1914 kDose[ndose].setScale(dscale = scale);
1917 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
1918 kDose[ndose].setMinMax(dminmax);
1921 G4cout <<
"Dose dist. image min., max., scale : "
1922 << dminmax[0] <<
", "
1923 << dminmax[1] <<
", "
1928 int dsize = size[0]*size[1];
1929 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
1930 char * di =
new char[dsize*
sizeof(short)];
1931 short * shimage =
new short[dsize];
1932 for(
int z = 0;
z < size[2];
z++) {
1933 ifile.read((
char *)di, dsize*
sizeof(
short));
1934 double * dimage =
new double[dsize];
1935 for(
int xy = 0; xy < dsize; xy++) {
1937 dimage[xy] = shimage[xy]*dscale;
1939 kDose[ndose].addImage(dimage);
1941 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
1944 for(
int j = 0; j < dsize; j++) {
1946 G4cout <<
"[" << j <<
"," <<
z <<
"]"
1947 << dimage[j] <<
", ";
1955 ifile.read((
char *)ctmp, 3*4);
1959 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
1960 kDose[ndose].setCenterPosition(fCenter);
1963 G4cout <<
"Dose dist. image relative location : ("
1964 << fCenter[0] <<
", "
1965 << fCenter[1] <<
", "
1966 << fCenter[2] <<
")" <<
G4endl;
1972 ifile.read((
char *)cname, 80);
1973 std::string dosename = cname;
1987 ifile.read((
char *)ctmp, 3*
sizeof(
int));
1991 kRoi[0].setSize(size);
1993 G4cout <<
"ROI image size : ("
2001 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2004 kRoi[0].setMinMax(minmax);
2007 ifile.read((
char *)ctmp,
sizeof(
float));
2009 kRoi[0].setScale(dscale = scale);
2011 G4cout <<
"ROI image min., max., scale : "
2012 << minmax[0] <<
", "
2013 << minmax[1] <<
", "
2018 int rsize = size[0]*size[1];
2019 char * ri =
new char[rsize*
sizeof(short)];
2020 for(
int i = 0; i < size[2]; i++) {
2021 ifile.read((
char *)ri, rsize*
sizeof(
short));
2022 short * rimage =
new short[rsize];
2023 for(
int j = 0; j < rsize; j++) {
2026 kRoi[0].addImage(rimage);
2032 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2036 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2037 kRoi[0].setCenterPosition(fCenter);
2039 G4cout <<
"ROI image relative location : ("
2040 << fCenter[0] <<
", "
2041 << fCenter[1] <<
", "
2042 << fCenter[2] <<
")" <<
G4endl;
2051 ifile.read((
char *)ctmp,
sizeof(
int));
2059 unsigned char rgb[3];
2060 for(
int i = 0; i < ntrk; i++) {
2064 ifile.read((
char *)ctmp,
sizeof(
int));
2069 ifile.read((
char *)rgb, 3);
2071 std::vector<float *> steps;
2073 for(
int j = 0; j < nsteps; j++) {
2075 float * steppoint =
new float[6];
2076 ifile.read((
char *)ctmp,
sizeof(
float)*6);
2078 for(
int k = 0; k < 6; k++) {
2082 steps.push_back(steppoint);
2091 for(
int j = 0; j < 3; j++)
G4cout << steps[0][j] <<
" ";
2092 int nstp = steps.size();
2094 for(
int j = 3; j < 6; j++)
G4cout << steps[nstp-1][j] <<
" ";
2096 for(
int j = 0; j < 3; j++)
G4cout << (
int)rgb[j] <<
" ";
2110 ifile.read((
char *)ctmp,
sizeof(
int));
2115 G4cout <<
"# of detectors : "
2119 for(
int nd = 0; nd < ndet; nd++) {
2122 ifile.read((
char *)ctmp,
sizeof(
int));
2126 G4cout <<
"# of edges in a detector : " << nedges <<
G4endl;
2130 std::vector<float *> detector;
2132 for(
int ne = 0; ne < nedges; ne++) {
2134 ifile.read((
char *)cftmp,
sizeof(
float)*6);
2135 float * edgePoints =
new float[6];
2136 for(
int j = 0; j < 6; j++)
convertEndian(&cftmp[
sizeof(
float)*j], edgePoints[j]);
2137 detector.push_back(edgePoints);
2142 G4cout <<
" first edge : (" << detector[0][0] <<
", "
2143 << detector[0][1] <<
", "
2144 << detector[0][2] <<
") - ("
2145 << detector[0][3] <<
", "
2146 << detector[0][4] <<
", "
2147 << detector[0][5] <<
")" <<
G4endl;
2151 unsigned char dcolor[3];
2152 ifile.read((
char *)dcolor, 3);
2154 G4cout <<
" detector color : rgb("
2155 << (
int)dcolor[0] <<
", "
2156 << (
int)dcolor[1] <<
", "
2157 << (
int)dcolor[2] << G4endl;
2163 ifile.read((
char *)cname, 80);
2164 std::string dname = cname;
2195 <<
" in G4GMocrenIO::retrieveData3()." <<
G4endl;
2204 ifile.read((
char *)verid, 8);
2208 ifile.read((
char *)&ver, 1);
2209 std::stringstream
ss;
2227 ifile.read((
char *)ctmp, 4);
2231 ifile.read((
char *)cmt, clength);
2232 std::string scmt = cmt;
2235 G4cout <<
"Data comment : "
2240 ifile.read((
char *)ctmp, 12);
2245 G4cout <<
"Voxel spacing : ("
2254 ifile.read((
char *)ctmp, 4);
2258 ifile.read((
char *)ctmp, 4);
2263 for(
int i = 0; i < nDoseDist; i++) {
2264 ifile.read((
char *)ctmp, 4);
2271 ifile.read((
char *)ctmp, 4);
2275 ifile.read((
char *)ctmp, 4);
2278 G4cout <<
"Each pointer to data : "
2280 for(
int i = 0; i < nDoseDist; i++)
2309 ifile.read(ctmp, 3*
sizeof(
int));
2314 G4cout <<
"Modality image size : ("
2333 ifile.read((
char *)ctmp, 4);
2340 ifile.read((
char *)munit, 12);
2341 std::string smunit = munit;
2345 ifile.read((
char *)ctmp, 4);
2349 G4cout <<
"Modality image min., max., scale : "
2350 << minmax[0] <<
", "
2351 << minmax[1] <<
", "
2356 int psize = size[0]*size[1];
2357 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2358 char * cimage =
new char[psize*
sizeof(short)];
2359 for(
int i = 0; i < size[2]; i++) {
2360 ifile.read((
char *)cimage, psize*
sizeof(
short));
2361 short * mimage =
new short[psize];
2362 for(
int j = 0; j < psize; j++) {
2367 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2373 size_t msize = minmax[1]-minmax[0]+1;
2375 char * pdmap =
new char[msize*
sizeof(float)];
2376 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2378 for(
int i = 0; i < (
int)msize; i++) {
2384 G4cout <<
"density map : " << std::ends;
2385 for(
int i = 0; i < 10; i++)
2388 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2399 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
2404 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2409 G4cout <<
"Dose dist. image size : ("
2415 kDose[ndose].setSize(size);
2418 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2424 ifile.read((
char *)dunit, 12);
2425 std::string sdunit = dunit;
2432 ifile.read((
char *)ctmp, 4);
2434 kDose[ndose].setScale(dscale = scale);
2437 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2438 kDose[ndose].setMinMax(dminmax);
2441 G4cout <<
"Dose dist. image min., max., scale : "
2442 << dminmax[0] <<
", "
2443 << dminmax[1] <<
", "
2448 int dsize = size[0]*size[1];
2449 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2450 char * di =
new char[dsize*
sizeof(short)];
2451 short * shimage =
new short[dsize];
2452 for(
int z = 0;
z < size[2];
z++) {
2453 ifile.read((
char *)di, dsize*
sizeof(
short));
2454 double * dimage =
new double[dsize];
2455 for(
int xy = 0; xy < dsize; xy++) {
2457 dimage[xy] = shimage[xy]*dscale;
2459 kDose[ndose].addImage(dimage);
2461 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2464 for(
int j = 0; j < dsize; j++) {
2466 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2467 << dimage[j] <<
", ";
2475 ifile.read((
char *)ctmp, 3*4);
2479 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2480 kDose[ndose].setCenterPosition(fCenter);
2483 G4cout <<
"Dose dist. image relative location : ("
2484 << fCenter[0] <<
", "
2485 << fCenter[1] <<
", "
2486 << fCenter[2] <<
")" <<
G4endl;
2498 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2502 kRoi[0].setSize(size);
2504 G4cout <<
"ROI image size : ("
2512 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2515 kRoi[0].setMinMax(minmax);
2518 ifile.read((
char *)ctmp,
sizeof(
float));
2520 kRoi[0].setScale(dscale = scale);
2522 G4cout <<
"ROI image min., max., scale : "
2523 << minmax[0] <<
", "
2524 << minmax[1] <<
", "
2529 int rsize = size[0]*size[1];
2530 char * ri =
new char[rsize*
sizeof(short)];
2531 for(
int i = 0; i < size[2]; i++) {
2532 ifile.read((
char *)ri, rsize*
sizeof(
short));
2533 short * rimage =
new short[rsize];
2534 for(
int j = 0; j < rsize; j++) {
2537 kRoi[0].addImage(rimage);
2543 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2547 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2548 kRoi[0].setCenterPosition(fCenter);
2550 G4cout <<
"ROI image relative location : ("
2551 << fCenter[0] <<
", "
2552 << fCenter[1] <<
", "
2553 << fCenter[2] <<
")" <<
G4endl;
2562 ifile.read((
char *)ctmp,
sizeof(
int));
2570 std::vector<float *> trkv4;
2573 for(
int i = 0; i < ntrk; i++) {
2574 float *
tp =
new float[6];
2576 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2578 for(
int j = 0; j < 3; j++) {
2583 ifile.read((
char *)ctmp,
sizeof(
float)*3);
2584 for(
int j = 0; j < 3; j++) {
2592 trkv4.push_back(tp);
2596 unsigned char trkcolorv4[3];
2599 for(
int i = 0; i < ntrk; i++) {
2600 unsigned char * rgb =
new unsigned char[3];
2601 ifile.read((
char *)rgb, 3);
2605 for(
int j = 0; j < 3; j++) trkcolorv4[j] = rgb[j];
2606 std::vector<float *> trk;
2607 trk.push_back(trkv4[i]);
2633 <<
" in G4GMocrenIO::retrieveData2()." <<
G4endl;
2642 ifile.read((
char *)verid, 8);
2646 ifile.read((
char *)&ver, 1);
2647 std::stringstream
ss;
2654 ifile.read((
char *)idtmp,
IDLENGTH);
2672 ifile.read((
char *)ctmp, 12);
2677 G4cout <<
"Voxel spacing : ("
2686 ifile.read((
char *)ctmp, 4);
2691 ifile.read((
char *)ctmp, 4);
2696 ifile.read((
char *)ctmp, 4);
2700 ifile.read((
char *)ctmp, 4);
2703 G4cout <<
"Each pointer to data : "
2733 ifile.read(ctmp, 3*
sizeof(
int));
2738 G4cout <<
"Modality image size : ("
2757 ifile.read((
char *)ctmp, 4);
2763 ifile.read((
char *)ctmp, 4);
2767 G4cout <<
"Modality image min., max., scale : "
2768 << minmax[0] <<
", "
2769 << minmax[1] <<
", "
2774 int psize = size[0]*size[1];
2775 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Modality image (" << psize <<
"): ";
2776 char * cimage =
new char[psize*
sizeof(short)];
2777 for(
int i = 0; i < size[2]; i++) {
2778 ifile.read((
char *)cimage, psize*
sizeof(
short));
2779 short * mimage =
new short[psize];
2780 for(
int j = 0; j < psize; j++) {
2785 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" << i <<
"]" << mimage[(size_t)(psize*0.55)] <<
", ";
2791 size_t msize = minmax[1]-minmax[0]+1;
2793 char * pdmap =
new char[msize*
sizeof(float)];
2794 ifile.read((
char *)pdmap, msize*
sizeof(
float));
2796 for(
int i = 0; i < (
int)msize; i++) {
2802 G4cout <<
"density map : " << std::ends;
2803 for(
int i = 0; i < 10; i++)
2806 for(
int i = 0; i < 10; i++)
G4cout <<
"..";
2822 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2827 G4cout <<
"Dose dist. image size : ("
2833 kDose[0].setSize(size);
2836 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2840 ifile.read((
char *)ctmp,
sizeof(
float));
2842 kDose[0].setScale(dscale = scale);
2845 for(
int i = 0; i < 2; i++) dminmax[i] = minmax[i]*dscale;
2846 kDose[0].setMinMax(dminmax);
2849 G4cout <<
"Dose dist. image min., max., scale : "
2850 << dminmax[0] <<
", "
2851 << dminmax[1] <<
", "
2856 int dsize = size[0]*size[1];
2857 if(DEBUG ||
kVerbose > 0)
G4cout <<
"Dose dist. (" << dsize <<
"): ";
2858 char * di =
new char[dsize*
sizeof(short)];
2859 short * shimage =
new short[dsize];
2860 for(
int z = 0;
z < size[2];
z++) {
2861 ifile.read((
char *)di, dsize*
sizeof(
short));
2862 double * dimage =
new double[dsize];
2863 for(
int xy = 0; xy < dsize; xy++) {
2865 dimage[xy] = shimage[xy]*dscale;
2867 kDose[0].addImage(dimage);
2869 if(DEBUG ||
kVerbose > 0)
G4cout <<
"[" <<
z <<
"]" << dimage[(size_t)(dsize*0.55)] <<
", ";
2872 for(
int j = 0; j < dsize; j++) {
2874 G4cout <<
"[" << j <<
"," <<
z <<
"]"
2875 << dimage[j] <<
", ";
2917 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2921 for(
int i = 0; i < 3; i++) fCenter[i] = (
float)iCenter[i];
2922 kDose[0].setCenterPosition(fCenter);
2925 G4cout <<
"Dose dist. image relative location : ("
2926 << fCenter[0] <<
", "
2927 << fCenter[1] <<
", "
2928 << fCenter[2] <<
")" <<
G4endl;
2940 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2944 kRoi[0].setSize(size);
2946 G4cout <<
"ROI image size : ("
2954 ifile.read((
char *)ctmp,
sizeof(
short)*2);
2957 kRoi[0].setMinMax(minmax);
2960 ifile.read((
char *)ctmp,
sizeof(
float));
2962 kRoi[0].setScale(dscale = scale);
2964 G4cout <<
"ROI image min., max., scale : "
2965 << minmax[0] <<
", "
2966 << minmax[1] <<
", "
2971 int rsize = size[0]*size[1];
2972 char * ri =
new char[rsize*
sizeof(short)];
2973 for(
int i = 0; i < size[2]; i++) {
2974 ifile.read((
char *)ri, rsize*
sizeof(
short));
2975 short * rimage =
new short[rsize];
2976 for(
int j = 0; j < rsize; j++) {
2979 kRoi[0].addImage(rimage);
2985 ifile.read((
char *)ctmp, 3*
sizeof(
int));
2989 for(
int i = 0; i < 3; i++) fCenter[i] = iCenter[i];
2990 kRoi[0].setCenterPosition(fCenter);
2992 G4cout <<
"ROI image relative location : ("
2993 << fCenter[0] <<
", "
2994 << fCenter[1] <<
", "
2995 << fCenter[2] <<
")" <<
G4endl;
3004 ifile.read((
char *)ctmp,
sizeof(
int));
3012 unsigned char trkcolorv4[3] = {255, 0, 0};
3014 for(
int i = 0; i < ntrk; i++) {
3015 float *
tp =
new float[6];
3017 std::vector<float *> trkv4;
3019 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3021 for(
int j = 0; j < 3; j++) {
3026 ifile.read((
char *)ctmp,
sizeof(
float)*3);
3027 for(
int j = 0; j < 3; j++) {
3034 trkv4.push_back(tp);
3101 char cmonth[12][4] = {
"Jan",
"Feb",
"Mar",
"Apr",
3102 "May",
"Jun",
"Jul",
"Aug",
3103 "Sep",
"Oct",
"Nov",
"Dec"};
3104 std::stringstream
ss;
3105 ss << std::setfill(
'0')
3107 << ti->tm_hour <<
":"
3109 << ti->tm_min <<
":"
3111 << ti->tm_sec <<
","
3112 << cmonth[ti->tm_mon] <<
"."
3114 << ti->tm_mday <<
","
3115 << ti->tm_year+1900;
3185 unsigned int pointer = 1070;
3187 pointer += nDoseDist*4;
3197 int pmsize = 2*msize[0]*msize[1]*msize[2];
3198 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3199 pointer += 32 + pmsize + pmmap;
3202 if(nDoseDist == 0) {
3203 unsigned int pointer0 = 0;
3206 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3210 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2 + 80;
3219 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3220 pointer += 20 + prsize + 12;
3222 unsigned int pointer0 = 0;
3232 for(
int nt = 0; nt < ntrk; nt++) {
3233 int nsteps =
kTracks[nt].getNumberOfSteps();
3234 pointer += 4 + 3 + nsteps*(4*6);
3237 unsigned int pointer0 = 0;
3259 unsigned int pointer = 1066;
3261 pointer += nDoseDist*4;
3271 int pmsize = 2*msize[0]*msize[1]*msize[2];
3272 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3273 pointer += 32 + pmsize + pmmap;
3276 if(nDoseDist == 0) {
3277 unsigned int pointer0 = 0;
3280 for(
int ndose = 0; ndose < nDoseDist; ndose++) {
3284 pointer += 44 + dsize[0]*dsize[1]*dsize[2]*2;
3293 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3294 pointer += 20 + prsize + 12;
3296 unsigned int pointer0 = 0;
3304 unsigned int pointer0 = 0;
3314 unsigned int pointer = 65;
3322 int pmsize = 2*msize[0]*msize[1]*msize[2];
3323 int pmmap = 4*(mminmax[1] - mminmax[0] + 1);
3324 pointer += 20 + pmsize + pmmap;
3331 int pdsize = 2*dsize[0]*dsize[1]*dsize[2];
3332 pointer += 20 + pdsize + 12;
3334 unsigned int pointer0 = 0;
3343 int prsize = 2*rsize[0]*rsize[1]*rsize[2];
3344 pointer += 20 + prsize + 12;
3347 unsigned int pointer0 = 0;
3355 unsigned int pointer0 = 0;
3412 for(
int i = 0; i < 2; i++) _minmax[i] = minmax[i];
3434 for(
int i = 0; i < 3; i++) _center[i] = 0;
3453 for(
int i = 0; i < nmap; i++) {
3456 rval = i + minmax[0];
3469 kDose.push_back(doseData);
3472 return (
int)
kDose.size();
3484 if(_unit.size() >
static_cast<size_t>(_num))
kDoseUnit = _unit;
3494 for(
int i = 0; i < 3; i++) _size[i] = 0;
3496 kDose[_num].getSize(_size);
3500 kDose[_num].setSize(_size);
3509 for(
int i = 0; i < 2; i++) minmax[i] = (
double)_minmax[i]*
scale;
3510 kDose[_num].setMinMax(minmax);
3515 for(
int i = 0; i < 2; i++) _minmax[i] = 0;
3518 kDose[_num].getMinMax(minmax);
3520 for(
int i = 0; i < 2; i++) _minmax[i] = (
short)(minmax[i]/scale+0.5);
3525 kDose[_num].setMinMax(_minmax);
3530 for(
int i = 0; i < 2; i++) _minmax[i] = 0.;
3532 kDose[_num].getMinMax(_minmax);
3538 kDose[_num].setScale(_scale);
3545 return kDose[_num].getScale();
3560 kDose[_num].getSize(size);
3561 int dsize = size[0]*size[1];
3562 double * ddata =
new double[dsize];
3565 kDose[_num].getMinMax(minmax);
3566 for(
int xy = 0; xy < dsize; xy++) {
3567 ddata[xy] = _image[xy]*
scale;
3568 if(ddata[xy] < minmax[0]) minmax[0] = ddata[xy];
3569 if(ddata[xy] > minmax[1]) minmax[1] = ddata[xy];
3571 kDose[_num].addImage(ddata);
3574 kDose[_num].setMinMax(minmax);
3580 G4cout <<
"In G4GMocrenIO::getShortDoseDist(), "
3581 <<
"first argument is NULL pointer. "
3582 <<
"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()) {
3920 unsigned char * color =
new unsigned char[3];
3921 kTracks[_num].getColor(color);
3922 _color.push_back(color);
3925 int nsteps =
kTracks[_num].getNumberOfSteps();
3926 for(
int isteps = 0; isteps < nsteps; isteps++) {
3927 float * stepPoints =
new float[6];
3928 kTracks[_num].getStep(stepPoints[0], stepPoints[1], stepPoints[2],
3929 stepPoints[3], stepPoints[4], stepPoints[5],
3931 _steps.push_back(stepPoints);
3936 std::vector<class GMocrenTrack>::iterator itr =
kTracks.begin();
3937 for(; itr !=
kTracks.end(); itr++) {
3938 itr->translate(_translate);
3950 std::vector<float *> & _det,
3951 unsigned char _color[3]) {
3953 std::vector<float *>::iterator itr = _det.begin();
3954 std::vector<struct GMocrenDetector::Edge> edges;
3955 for(; itr != _det.end(); itr++) {
3957 for(
int i = 0; i < 3; i++) {
3961 edges.push_back(edge);
3972 std::vector<unsigned char *> & _color,
3973 std::string & _detName) {
3986 unsigned char * color =
new unsigned char[3];
3988 _color.push_back(color);
3991 int nedges =
kDetectors[_num].getNumberOfEdges();
3992 for(
int ne = 0; ne < nedges; ne++) {
3993 float * edgePoints =
new float[6];
3994 kDetectors[_num].getEdge(edgePoints[0], edgePoints[1], edgePoints[2],
3995 edgePoints[3], edgePoints[4], edgePoints[5],
3997 _edges.push_back(edgePoints);
4002 std::vector<class GMocrenDetector>::iterator itr =
kDetectors.begin();
4004 itr->translate(_translate);
4009 template <
typename T>
4015 const int SIZE =
sizeof(_rval);
4017 for(
int i = 0; i < SIZE/2; i++) {
4019 _val[i] = _val[SIZE - 1 - i];
4020 _val[SIZE - 1 - i] = ctemp;
4027 template <
typename T>
4030 const int SIZE =
sizeof(_rval);
4036 for(
int i = 0; i < SIZE; i++) {
4037 uni.cu[i] = _val[SIZE-1-i];
static std::string kFileName
int getNumberOfDetectors()
void getROISize(int _size[3], int _num=0)
void setTrack(std::vector< struct Step > &_aTrack)
void setPointerToTrackData(unsigned int &_pointer)
double getROIScale(int _num=0)
static std::string kComment
void getCenterPosition(float _center[3])
void copyTracks(std::vector< float * > &_tracks, std::vector< unsigned char * > &_colors)
void setPointerToROIData(unsigned int &_pointer)
void setROIMinMax(short _minmax[2], int _num=0)
static class GMocrenDataPrimitive< short > kModality
static unsigned int kPointerToTrackData
void setROIScale(double &_scale, int _num=0)
void setModalityImageMinMax(short _minmax[2])
std::vector< unsigned char * > & getTrackColors()
void convertEndian(char *, Type &)
static constexpr double keV
void setDoseDistMinMax(short _minmax[2], int _num=0)
void setScale(double &_scale)
unsigned int getPointerToDoseDistData(int _elem=0)
void clearModalityImage()
short convertDensityToHU(float &_dens)
void addPointerToDoseDistData(unsigned int &_pointer)
void getROIMinMax(short _minmax[2], int _num=0)
unsigned int getPointerToROIData()
std::vector< struct Step > kTrack
void setDoseDistCenterPosition(float _center[3], int _num=0)
std::string getDoseDistName(int _num=0)
void setColor(unsigned char _color[3])
std::string getDoseDistUnit(int _num=0)
void setModalityImageSize(int _size[3])
double * getDoseDist(int _z, int _num=0)
void setModalityImage(short *_image)
void setDoseDistScale(double &_scale, int _num=0)
double getModalityImageScale()
static std::vector< unsigned int > kPointerToDoseDistData
void getEdge(float &_startx, float &_starty, float &_startz, float &_endx, float &_endy, float &_endz, int _num)
void setTrackColors(std::vector< unsigned char * > &_trackColors)
void setROI(short *_image, int _num=0)
static std::string kModalityUnit
bool addDoseDist(std::vector< double * > &_image, int _num=0)
void setComment(std::string &_comment)
std::vector< T * > kImage
void addTrackColor(unsigned char *_colors)
std::string & getVersion()
void setDoseDist(double *_image, int _num=0)
void setName(std::string &_name)
void getModalityCenterPosition(float _center[3])
static constexpr double g
bool mergeDoseDist(std::vector< class GMocrenDataPrimitive< double > > &_dose)
unsigned int getPointerToModalityData()
std::vector< struct Edge > kDetector
static unsigned int kPointerToROIData
GMocrenDataPrimitive< T > & operator+(const GMocrenDataPrimitive< T > &_right)
void setModalityImageUnit(std::string &_unit)
void getVoxelSpacing(float _spacing[3])
void translateTracks(std::vector< float > &_translateo)
static std::vector< class GMocrenDataPrimitive< short > > kRoi
short * getModalityImage(int _z)
void getStep(float &_startx, float &_starty, float &_startz, float &_endx, float &_endy, float &_endz, int _num)
static std::vector< float * > kSteps
void setVerboseLevel(int _level)
void getDoseDistSize(int _size[3], int _num=0)
short getModalityImageMax()
void addEdge(float _startx, float _starty, float _startz, float _endx, float _endy, float _endz)
double getDoseDistScale(int _num=0)
void mergeTracks(std::vector< float * > &_tracks, std::vector< unsigned char * > &_colors)
void setLittleEndianInput(bool _little)
void copyDoseDist(std::vector< class GMocrenDataPrimitive< double > > &_dose)
void getDoseDistMinMax(short _minmax[2], int _num=0)
unsigned int getPointerToTrackData()
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
static char kLittleEndianOutput
void setShortDoseDist(short *_image, int _num=0)
static Verbosity GetVerbosity()
void setSize(int _size[3])
void setImage(std::vector< T * > &_image)
static float kVoxelSpacing[3]
void translateDetector(std::vector< float > &_translate)
void setROISize(int _size[3], int _num=0)
static unsigned int kPointerToModalityData
const G4ThreeVector const G4double const
void getModalityImageSize(int _size[3])
static std::vector< class GMocrenDetector > kDetectors
void setModalityImageScale(double &_scale)
static char kLittleEndianInput
void getModalityImageMinMax(short _minmax[2])
void getDetector(int _num, std::vector< float * > &_edges, std::vector< unsigned char * > &_color, std::string &_detectorName)
void getSize(int _size[3])
void setPointerToModalityData(unsigned int &_pointer)
short getModalityImageMin()
void translate(std::vector< float > &_tranlate)
void getShortDoseDistMinMax(short _minmax[2], int _num=0)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void setVoxelSpacing(float _spacing[3])
void setLittleEndianOutput(bool _little)
void addDetector(std::string &_name, std::vector< float * > &_det, unsigned char _color[3])
static int kNumberOfEvents
void setDetector(std::vector< struct Edge > &_aDetector)
void setCenterPosition(float _center[3])
void getShortDoseDist(short *_data, int _z, int _num=0)
void setDoseDistName(std::string _name, int _num=0)
void translate(std::vector< float > &_tranlate)
static std::vector< unsigned char * > kStepColors
static std::string kVersion
static std::vector< class GMocrenTrack > kTracks
G4GLOB_DLL std::ostream G4cout
GMocrenDataPrimitive< T > & operator+=(const GMocrenDataPrimitive< T > &_right)
void setNumberOfEvents(int &_numberOfEvents)
void setROICenterPosition(float _center[3], int _num=0)
void setDoseDistUnit(std::string &_unit, int _num=0)
void setDoseDistSize(int _size[3], int _num=0)
void setVersion(std::string &_version)
void setModalityImageDensityMap(std::vector< float > &_map)
std::vector< float * > & getTracks()
short * getROI(int _z, int _num=0)
GMocrenDataPrimitive< T > & operator=(const GMocrenDataPrimitive< T > &_right)
static std::vector< float > kModalityImageDensityMap
void getMinMax(T _minmax[2])
void getTrack(int _num, std::vector< float * > &_steps, std::vector< unsigned char * > &_color)
void getDoseDistCenterPosition(float _center[3], int _num=0)
static constexpr double cm3
void setMinMax(T _minmax[2])
static std::vector< class GMocrenDataPrimitive< double > > kDose
std::string getModalityImageUnit()
void addTrack(float *_tracks)
void addStep(float _startx, float _starty, float _startz, float _endx, float _endy, float _endz)
std::vector< float > & getModalityImageDensityMap()
static std::string kDoseUnit
void setColor(unsigned char _color[3])
static unsigned int kPointerToDetectorData
void invertByteOrder(char *_val, T &_rval)
void getROICenterPosition(float _center[3], int _num=0)
void setTracks(std::vector< float * > &_tracks)
std::vector< T * > & getImage()
void setName(std::string &_name)
int & getNumberOfEvents()
void setModalityCenterPosition(float _center[3])