File indexing completed on 2026-09-09 09:09:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 #ifndef G4PHYSICALVOLUMEMODEL_HH
0062 #define G4PHYSICALVOLUMEMODEL_HH
0063
0064 #include "G4VModel.hh"
0065 #include "G4ModelingParameters.hh"
0066
0067 #include "G4NavigationHistory.hh"
0068 #include "G4Transform3D.hh"
0069 #include "G4Plane3D.hh"
0070 #include <iostream>
0071 #include <vector>
0072 #include <map>
0073
0074 class G4VPhysicalVolume;
0075 class G4LogicalVolume;
0076 class G4VSolid;
0077 class G4Material;
0078 class G4VisAttributes;
0079 class G4AttDef;
0080 class G4AttValue;
0081
0082 class G4PhysicalVolumeModel: public G4VModel {
0083
0084 public:
0085
0086 enum {UNLIMITED = -1};
0087
0088 enum ClippingMode {subtraction, intersection};
0089
0090
0091 class G4PhysicalVolumeNodeID {
0092 public:
0093 G4PhysicalVolumeNodeID
0094 (G4VPhysicalVolume* pPV = 0,
0095 G4int iCopyNo = 0,
0096 G4int depth = 0,
0097 const G4Transform3D& transform = G4Transform3D(),
0098 G4bool drawn = true):
0099 fpPV(pPV),
0100 fCopyNo(iCopyNo),
0101 fNonCulledDepth(depth),
0102 fTransform(transform),
0103 fDrawn(drawn) {}
0104 G4VPhysicalVolume* GetPhysicalVolume() const {return fpPV;}
0105 G4int GetCopyNo() const {return fCopyNo;}
0106 G4int GetNonCulledDepth() const {return fNonCulledDepth;}
0107 const G4Transform3D& GetTransform() const {return fTransform;}
0108 G4bool GetDrawn() const {return fDrawn;}
0109 void SetPhysicalVolume(G4VPhysicalVolume* v) {fpPV = v;}
0110 void SetCopyNo (G4int n) {fCopyNo = n;}
0111 void SetNonCulledDepth(G4int d) {fNonCulledDepth = d;}
0112 void SetTransform (const G4Transform3D& t) {fTransform = t;}
0113 void SetDrawn (G4bool b) {fDrawn = b;}
0114 G4bool operator< (const G4PhysicalVolumeNodeID& right) const;
0115 G4bool operator!= (const G4PhysicalVolumeNodeID& right) const;
0116 G4bool operator== (const G4PhysicalVolumeNodeID& right) const {
0117 return !operator!= (right);
0118 }
0119 private:
0120 G4VPhysicalVolume* fpPV;
0121 G4int fCopyNo;
0122 G4int fNonCulledDepth;
0123 G4Transform3D fTransform;
0124 G4bool fDrawn;
0125 };
0126
0127
0128 struct TouchableProperties {
0129 TouchableProperties(): fpTouchablePV(nullptr), fCopyNo(0) {}
0130 G4ModelingParameters::PVNameCopyNoPath fTouchablePath;
0131 G4VPhysicalVolume* fpTouchablePV;
0132 G4int fCopyNo;
0133 G4Transform3D fTouchableGlobalTransform;
0134 std::vector<G4PhysicalVolumeNodeID> fTouchableBaseFullPVPath;
0135 std::vector<G4PhysicalVolumeNodeID> fTouchableFullPVPath;
0136 };
0137
0138 G4PhysicalVolumeModel
0139 (G4VPhysicalVolume* = 0,
0140 G4int requestedDepth = UNLIMITED,
0141 const G4Transform3D& modelTransformation = G4Transform3D(),
0142 const G4ModelingParameters* = 0,
0143 G4bool useFullExtent = false,
0144 const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath =
0145 std::vector<G4PhysicalVolumeNodeID>());
0146
0147 virtual ~G4PhysicalVolumeModel ();
0148
0149 void DescribeYourselfTo (G4VGraphicsScene&);
0150
0151
0152
0153
0154 G4String GetCurrentDescription () const;
0155
0156
0157 G4String GetCurrentTag () const;
0158
0159
0160 G4VPhysicalVolume* GetTopPhysicalVolume () const {return fpTopPV;}
0161
0162 G4int GetRequestedDepth () const {return fRequestedDepth;}
0163
0164 const G4VSolid* GetClippingSolid () const
0165 {return fpClippingSolid;}
0166
0167 G4int GetCurrentDepth() const {return fCurrentDepth;}
0168
0169
0170 const G4Transform3D& GetTransformation() const {return fTransform;}
0171
0172
0173 G4VPhysicalVolume* GetCurrentPV() const {return fpCurrentPV;}
0174
0175
0176 G4int GetCurrentPVCopyNo() const {return fCurrentPVCopyNo;}
0177
0178
0179 G4LogicalVolume* GetCurrentLV() const {return fpCurrentLV;}
0180
0181
0182 G4Material* GetCurrentMaterial() const {return fpCurrentMaterial;}
0183
0184
0185 const G4Transform3D& GetCurrentTransform() const {return fCurrentTransform;}
0186
0187
0188 const std::vector<G4PhysicalVolumeNodeID>& GetBaseFullPVPath() const
0189 {return fBaseFullPVPath;}
0190
0191
0192
0193
0194
0195 const std::vector<G4PhysicalVolumeNodeID>& GetFullPVPath() const
0196 {return fFullPVPath;}
0197
0198
0199
0200
0201
0202 const std::vector<G4PhysicalVolumeNodeID>& GetDrawnPVPath() const
0203 {return fDrawnPVPath;}
0204
0205
0206
0207
0208
0209 static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath
0210 (const std::vector<G4PhysicalVolumeNodeID>&);
0211
0212
0213 static G4String GetPVNamePathString(const std::vector<G4PhysicalVolumeNodeID>&);
0214
0215
0216
0217 const std::map<G4String,G4AttDef>* GetAttDefs() const;
0218
0219
0220 std::vector<G4AttValue>* CreateCurrentAttValues() const;
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 const std::map<G4int,G4int>& GetMapOfDrawnTouchables() const {return fMapDrawnTouchables;}
0231
0232
0233 G4int GetTotalDrawnTouchables () {return fTotalDrawnTouchables;}
0234
0235
0236 G4int GetMaxFullDepth () const {return fMaxFullDepth;}
0237
0238
0239 const std::map<G4int,G4int>& GetMapOfAllTouchables() const {return fMapAllTouchables;}
0240
0241
0242 G4int GetTotalAllTouchables () {return fTotalAllTouchables;}
0243
0244
0245 void SetRequestedDepth (G4int requestedDepth) {
0246 fRequestedDepth = requestedDepth;
0247 }
0248
0249 void SetClippingSolid (G4VSolid* pClippingSolid) {
0250 fpClippingSolid = pClippingSolid;
0251 }
0252
0253 void SetClippingMode (ClippingMode mode) {
0254 fClippingMode = mode;
0255 }
0256
0257 G4bool Validate (G4bool warn);
0258
0259
0260 void Abort () const {fAbort = true;}
0261
0262
0263 void CurtailDescent() const {fCurtailDescent = true;}
0264
0265
0266 void CalculateExtent ();
0267
0268 protected:
0269
0270 void VisitGeometryAndGetVisReps (G4VPhysicalVolume*,
0271 G4int requestedDepth,
0272 const G4Transform3D&,
0273 G4VGraphicsScene&);
0274
0275 void DescribeAndDescend (G4VPhysicalVolume*,
0276 G4int requestedDepth,
0277 G4LogicalVolume*,
0278 G4VSolid*,
0279 G4Material*,
0280 const G4Transform3D&,
0281 G4VGraphicsScene&);
0282
0283 virtual void DescribeSolid (const G4Transform3D& theAT,
0284 G4VSolid* pSol,
0285 const G4VisAttributes* pVisAttribs,
0286 G4VGraphicsScene& sceneHandler);
0287
0288
0289
0290
0291 G4VPhysicalVolume* fpTopPV;
0292 G4String fTopPVName;
0293 G4int fTopPVCopyNo;
0294 G4int fRequestedDepth;
0295
0296 G4bool fUseFullExtent;
0297 G4Transform3D fTransform;
0298 G4int fCurrentDepth;
0299 G4VPhysicalVolume* fpCurrentPV;
0300 G4int fCurrentPVCopyNo;
0301 G4LogicalVolume* fpCurrentLV;
0302 G4Material* fpCurrentMaterial;
0303 G4Transform3D fCurrentTransform;
0304 std::vector<G4PhysicalVolumeNodeID> fBaseFullPVPath;
0305 std::vector<G4PhysicalVolumeNodeID> fFullPVPath;
0306 std::vector<G4PhysicalVolumeNodeID> fDrawnPVPath;
0307 G4NavigationHistory fNavigationHistory;
0308 mutable G4bool fAbort;
0309 mutable G4bool fCurtailDescent;
0310 G4VSolid* fpClippingSolid;
0311 ClippingMode fClippingMode;
0312 G4int fNClippers;
0313 std::map<G4int,G4int> fMapDrawnTouchables;
0314 G4int fTotalDrawnTouchables;
0315 std::map<G4int,G4int> fMapAllTouchables;
0316 G4int fTotalAllTouchables;
0317 G4int fMaxFullDepth;
0318
0319
0320 private:
0321
0322
0323
0324 G4PhysicalVolumeModel (const G4PhysicalVolumeModel&);
0325 G4PhysicalVolumeModel& operator = (const G4PhysicalVolumeModel&);
0326 };
0327
0328 std::ostream& operator<<
0329 (std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID&);
0330
0331 std::ostream& operator<<
0332 (std::ostream& os, const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&);
0333
0334 #endif