839{
842
844 G4cout <<
"G4GMocrenFileSceneHandler::AddSolid(const G4Box&) : "
846
847
848 if( !IsVisible() ) { return ; }
849
850
852
853
854
860
863
864 for(
G4int i = 0; i < 12; i++) {
866 if(next == 0) break;
867 G4cout <<
" (" << v1.
x() <<
", "
872 << v2.
z() <<
") [" << next <<
"]"
874 }
875 delete poly;
876 }
877
878
879
881
882
883 if(kFlagParameterization != 2) {
885 if(pScrMan) {
888 if(pScBox != NULL) bMesh = true;
889 if(bMesh) kFlagParameterization = 2;
891 << volName <<
" - " << bMesh <<
G4endl;
892 }
893 }
894
896 if (!pv_model) { return ; }
899 if (!pPVModel) { return ; }
900
901
902
911 G4cout <<
" density : " << dens <<
" [g/cm3]" <<
G4endl;
917 }
918
919
921
923
931 }
932 kVolumeTrans3D = kVolumeTrans3D*trot;
934
935
936
937
940 if(!pv[0]) {
941 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
943 }
944 G4int dirAxis[3] = {-1,-1,-1};
945 G4int nDaughters[3] = {0,0,0};
946
949 nDaughters[0] = nReplicas;
950 switch(axis) {
951 case kXAxis: dirAxis[0] = 0;
break;
952 case kYAxis: dirAxis[0] = 1;
break;
953 case kZAxis: dirAxis[0] = 2;
break;
954 default:
955 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
957 }
958 kNestedVolumeNames.push_back(pv[0]->
GetName());
961 <<
" # : " << nDaughters[0] <<
G4endl;
962
963
965 if(pv[0]->GetLogicalVolume()->GetNoDaughters()) {
966 G4cout <<
"# of daughters : "
968 } else {
969
970
971 }
972 }
973
974
977 if(pv[0]->GetLogicalVolume()->GetNoDaughters() == 0) {
978 kFlagParameterization = 1;
979
980
981 }
982
983 if(kFlagParameterization == 0) {
984
986 if(pv[1]) {
988 nDaughters[1] = nReplicas;
989 switch(axis) {
990 case kXAxis: dirAxis[1] = 0;
break;
991 case kYAxis: dirAxis[1] = 1;
break;
992 case kZAxis: dirAxis[1] = 2;
break;
993 default:
994 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
996 }
997 kNestedVolumeNames.push_back(pv[1]->
GetName());
1000 <<
" # : " << nDaughters[1]<<
G4endl;
1001
1002
1004 if(pv[2]) {
1006 kNestedVolumeNames.push_back(pv[2]->
GetName());
1009 <<
" # : " << nDaughters[2] <<
G4endl;
1010
1011 if(nDaughters[2] > 1) {
1014 if(nestPara == NULL)
1015 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1017
1024 G4cout << trans0 <<
" - " << trans1 <<
" - " << diff <<
G4endl;
1025
1026 if(diff.x() != 0.) dirAxis[2] = 0;
1027 else if(diff.y() != 0.) dirAxis[2] = 1;
1028 else if(diff.z() != 0.) dirAxis[2] = 2;
1029 else
1030 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1031 "gMocren0009",
FatalException,
"Unexpected nested parameterisation");
1032 }
1033 }
1034 }
1035
1036 for(
G4int i = 0; i < 3; i++) {
1037 kNestedVolumeDimension[i] = nDaughters[i];
1038
1039 kNestedVolumeDirAxis[i] = dirAxis[i];
1040 }
1041
1042
1043
1044
1047 if(nestPara != NULL) {
1048 G4double prexyz[3] = {0.,0.,0.}, xyz[3] = {0.,0.,0.};
1049 for(
G4int n0 = 0; n0 < nDaughters[0]; n0++) {
1050 for(
G4int n1 = 0; n1 < nDaughters[1]; n1++) {
1051 for(
G4int n2 = 0; n2 < nDaughters[2]; n2++) {
1052
1055 G4cout <<
" retrieve volume : copy # : " << n0
1056 <<
", " << n1 <<
", " << n2 <<
G4endl;
1058 delete touch;
1060
1062 G4cout <<
" density :" << dens <<
" [g/cm3]" <<
G4endl;
1063
1066 xyz[0] = tbox.GetXHalfLength()/mm;
1067 xyz[1] = tbox.GetYHalfLength()/mm;
1068 xyz[2] = tbox.GetZHalfLength()/mm;
1069 if(n0 != 0 || n1 != 0 || n2 != 0) {
1070 for(
G4int i = 0; i < 3; i++) {
1071 if(xyz[i] != prexyz[i])
1072 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1074 }
1075 }
1077 G4cout <<
" size : " << tbox.GetXHalfLength()/mm <<
" x "
1078 << tbox.GetYHalfLength()/mm << " x "
1079 << tbox.GetZHalfLength()/mm <<
" [mm3]" <<
G4endl;
1080
1082 idx[dirAxis[0]] = n0;
1083 idx[dirAxis[1]] = n1;
1084 idx[dirAxis[2]] = n2;
1085 Index3D i3d(idx[0],idx[1],idx[2]);
1086 kNestedModality[i3d] = dens;
1088 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1089 <<
" density: " << dens <<
G4endl;
1090
1091 for(
G4int i = 0; i < 3; i++) prexyz[i] = xyz[i];
1092 }
1093 }
1094 }
1095
1099
1100 if(!kbSetModalityVoxelSize) {
1102 static_cast<G4float>(2*xyz[1]),
1103 static_cast<G4float>(2*xyz[2])};
1105 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1106 kbSetModalityVoxelSize = true;
1107 }
1108
1109 } else {
1112 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1114 }
1115
1116
1117
1118
1123
1124
1126 G4cout <<
" physical volume node id : "
1127 << "size: " << npvp << ", PV name: ";
1128 for(
G4int i = 0; i < npvp; i++) {
1130 << " [param:"
1131 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsParameterised()
1132 << ",rep:"
1133 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->IsReplicated();
1134 if(pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()) {
1136 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetParameterisation()->IsNested();
1137 }
1139 << pPVModel->
GetDrawnPVPath()[i].GetPhysicalVolume()->GetCopyNo();
1141 }
1143
1144
1148 G4Box * pbox =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1149 if(pbox) {
1153 G4cout <<
" mother size ["
1154 << pPVModel->
GetDrawnPVPath()[npvp-2].GetPhysicalVolume()->GetName()
1155 << "] : "
1156 << pareDims[0] << " x "
1157 << pareDims[1] << " x "
1158 << pareDims[2] << " [mm3]"
1160 }
1162 G4Box * boxP =
dynamic_cast<G4Box *
>(pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetLogicalVolume()->GetSolid());
1163 if(boxP) {
1167 G4cout <<
" parameterised volume? ["
1168 << pPVModel->
GetDrawnPVPath()[npvp-1].GetPhysicalVolume()->GetName()
1169 << "] : "
1170 << paraDims[0] << " x "
1171 << paraDims[1] << " x "
1172 << paraDims[2] << " [mm3] : "
1173 <<
G4int(pareDims[0]/paraDims[0]) <<
" x "
1174 <<
G4int(pareDims[1]/paraDims[1]) <<
" x "
1176 } else {
1178 <<
" isn't a G4Box." <<
G4endl;
1179 }
1180 }
1181 }
1182
1183
1184 } else if(kFlagParameterization == 1) {
1185
1186
1189 if(phantomPara == NULL) {
1190 G4Exception(
"G4GMocrenFileSceneHandler::AddSolid( const G4Box& box )",
1192 } else {
1193 ;
1194 }
1195
1199 kNestedVolumeDirAxis[0] = 0;
1200 kNestedVolumeDirAxis[1] = 1;
1201 kNestedVolumeDirAxis[2] = 2;
1202
1203
1204 G4int nX = kNestedVolumeDimension[0];
1205 G4int nXY = kNestedVolumeDimension[0]*kNestedVolumeDimension[1];
1206
1207 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1208 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1209 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1210
1211 G4int repNo = n0 + n1*nX + n2*nXY;
1214
1215
1217 idx[kNestedVolumeDirAxis[0]] = n0;
1218 idx[kNestedVolumeDirAxis[1]] = n1;
1219 idx[kNestedVolumeDirAxis[2]] = n2;
1220 Index3D i3d(idx[0],idx[1],idx[2]);
1221 kNestedModality[i3d] = dens;
1222
1224 G4cout <<
" index: " << idx[0] <<
", " << idx[1] <<
", " << idx[2]
1225 <<
" density: " << dens <<
G4endl;
1226
1227 }
1228 }
1229 }
1230
1234
1235
1236 if(!kbSetModalityVoxelSize) {
1241 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1242 kbSetModalityVoxelSize = true;
1243 }
1244 }
1245
1246 }
1247
1248
1249
1250 if(!kFlagProcessedInteractiveScorer) {
1251
1252
1253
1255
1256 if(pScrMan) {
1259
1260 if(scoringBox) {
1261
1262
1263
1266
1267 kNestedVolumeDimension[0] = nVoxels[2];
1268 kNestedVolumeDimension[1] = nVoxels[1];
1269 kNestedVolumeDimension[2] = nVoxels[0];
1270 kNestedVolumeDirAxis[0] = 2;
1271 kNestedVolumeDirAxis[1] = 1;
1272 kNestedVolumeDirAxis[2] = 0;
1273
1274
1275 for(
G4int n0 = 0; n0 < kNestedVolumeDimension[0]; n0++) {
1276 for(
G4int n1 = 0; n1 < kNestedVolumeDimension[1]; n1++) {
1277 for(
G4int n2 = 0; n2 < kNestedVolumeDimension[2]; n2++) {
1278
1280
1282 idx[kNestedVolumeDirAxis[0]] = n0;
1283 idx[kNestedVolumeDirAxis[1]] = n1;
1284 idx[kNestedVolumeDirAxis[2]] = n2;
1285 Index3D i3d(idx[0],idx[1],idx[2]);
1286 kNestedModality[i3d] = dens;
1287
1288 }
1289 }
1290 }
1291
1294 G4cout <<
"Interactive Scorer : size - "
1295 << boxSize.
x()/cm <<
" x "
1296 << boxSize.
y()/cm <<
" x "
1297 << boxSize.
z()/cm <<
" [cm3]" <<
G4endl;
1298 G4cout <<
"Interactive Scorer : # voxels - "
1299 << nVoxels[0] << " x "
1300 << nVoxels[1] << " x "
1302 }
1303 kVolumeSize.
set(boxSize.
x()*2,
1306
1307
1308 if(!kbSetModalityVoxelSize) {
1310 static_cast<G4float>(boxSize.
y()*2/nVoxels[1]),
1311 static_cast<G4float>(boxSize.
z()*2/nVoxels[2])};
1312
1314 kVoxelDimension.
set(spacing[0], spacing[1], spacing[2]);
1315 kbSetModalityVoxelSize = true;
1316
1317 }
1318
1319
1321
1322
1325 kVolumeTrans3D = kVolumeTrans3D*sbtranslate;
1326
1327
1333 kVolumeTrans3D = kVolumeTrans3D*sbrotate;
1334 }
1335
1336
1337
1344
1345 kVolumeTrans3D = kVolumeTrans3D*trotY*trotZ;
1346
1347 }
1348 }
1349
1350 kFlagProcessedInteractiveScorer = true;
1351 }
1352
1353
1357 }
1358
1359
1362
1363 if(kFlagParameterization == 0) {
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382 if(volName == box.
GetName()) {
1383 bAddDet = false;
1384 }
1385
1386 std::vector<G4String>::iterator itr = kNestedVolumeNames.begin();
1387 for(; itr != kNestedVolumeNames.end(); itr++) {
1389 bAddDet = false;
1390 break;
1391 }
1392 }
1393 } else if(kFlagParameterization == 1) {
1394
1396 if(volPV) {
1399 }
1400
1401
1402
1403
1404 if(volDSolidName == box.
GetName()) {
1405 bAddDet = false;
1406 }
1407
1408 } else if(kFlagParameterization == 2) {
1409
1410 }
1411
1412 }
1413 if(bAddDet) AddDetector(box);
1414
1415
1416}
void set(double x, double y, double z)
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4Polyhedron * CreatePolyhedron() const
void setVoxelSpacing(float _spacing[3])
virtual G4bool getDrawVolumeGrid()
virtual G4String getVolumeName()
std::size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const std::size_t i) const
G4double GetDensity() const
const G4String & GetName() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=nullptr)
G4double GetVoxelHalfZ() const
std::size_t GetNoVoxelsX() const
G4double GetVoxelHalfY() const
G4double GetVoxelHalfX() const
std::size_t GetNoVoxelsZ() const
std::size_t GetNoVoxelsY() const
const std::vector< G4PhysicalVolumeNodeID > & GetDrawnPVPath() const
G4VPhysicalVolume * GetTopPhysicalVolume() const
G4Material * GetCurrentMaterial() const
G4int GetCurrentDepth() const
static G4ScoringManager * GetScoringManager()
G4VScoringMesh * FindMesh(G4VHitsCollection *map)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
virtual void ComputeTransformation(const G4int no, G4VPhysicalVolume *currentPV) const =0
virtual G4Material * ComputeMaterial(G4VPhysicalVolume *currentVol, const G4int repNo, const G4VTouchable *parentTouch=nullptr)=0
virtual G4bool IsNested() const
virtual G4bool IsReplicated() const =0
virtual G4int GetMultiplicity() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
virtual G4int GetCopyNo() const =0
virtual G4VPVParameterisation * GetParameterisation() const =0
G4ThreeVector GetObjectTranslation() const
virtual G4bool IsParameterised() const =0
G4VModel * GetModel() const
G4Transform3D fObjectTransformation
G4ThreeVector GetTranslation() const
G4ThreeVector GetSize() const
void GetNumberOfSegments(G4int nSegment[3])
G4RotationMatrix GetRotationMatrix() const
HepPolyhedron & Transform(const G4Transform3D &t)
G4bool GetNextEdge(G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
const char * name(G4int ptype)