Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4LogicalVolumeModel.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4LogicalVolumeModel.cc 110480 2018-05-25 07:25:18Z gcosmo $
28 //
29 //
30 // John Allison 26th July 1999.
31 // Model for logical volumes.
32 
33 #include "G4LogicalVolumeModel.hh"
34 
35 #include "G4VSolid.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4ModelingParameters.hh"
39 #include "G4VGraphicsScene.hh"
40 #include "G4DrawVoxels.hh"
41 #include "G4VSensitiveDetector.hh"
42 #include "G4VReadOutGeometry.hh"
43 
46  G4int soughtDepth,
47  G4bool booleans,
48  G4bool voxels,
49  G4bool readout,
50  G4bool checkOverlaps,
51  const G4Transform3D& modelTransformation,
52  const G4ModelingParameters* pMP):
53  // Instantiate a G4PhysicalVolumeModel with a G4PVPlacement to
54  // represent this logical volume. It has no rotation and a null
55  // translation so that the logical volume will be seen in its own
56  // reference system. It will be added to the physical volume store
57  // but it will not be part of the normal geometry heirarchy so it
58  // has no mother.
60 (new G4PVPlacement (0, // No rotation.
61  G4ThreeVector(), // Null traslation.
62  "PhysVol representation of LogVol " + pLV -> GetName (),
63  pLV,
64  0, // No mother.
65  false, // Not "MANY".
66  0), // Copy number.
67  soughtDepth,
68  modelTransformation,
69  pMP,
70  true), // Use full extent.
71  fpLV (pLV),
72  fBooleans (booleans),
73  fVoxels (voxels),
74  fReadout (readout),
75  fCheckOverlaps(checkOverlaps)
76 {
77  fType = "G4LogicalVolumeModel";
78  fGlobalTag = fpLV -> GetName ();
79  fGlobalDescription = "G4LogicalVolumeModel " + fGlobalTag;
80 }
81 
83 
85 (G4VGraphicsScene& sceneHandler) {
86 
87  // Store current modeling parameters and ensure nothing is culled.
88  const G4ModelingParameters* tmpMP = fpMP;
89  G4ModelingParameters nonCulledMP;
90  if (fpMP) nonCulledMP = *fpMP;
91  nonCulledMP.SetCulling (false);
92  fpMP = &nonCulledMP;
94  fpMP = tmpMP;
95 
96  if (fVoxels) {
97  if (fpTopPV->GetLogicalVolume()->GetVoxelHeader()) {
98  // Add Voxels.
99  G4DrawVoxels dv;
100  G4PlacedPolyhedronList* pPPL =
101  dv.CreatePlacedPolyhedra (fpTopPV -> GetLogicalVolume ());
102  for (size_t i = 0; i < pPPL -> size (); i++) {
103  const G4Transform3D& transform = (*pPPL)[i].GetTransform ();
104  const G4Polyhedron& polyhedron = (*pPPL)[i].GetPolyhedron ();
105  sceneHandler.BeginPrimitives (transform);
106  sceneHandler.AddPrimitive (polyhedron);
107  sceneHandler.EndPrimitives ();
108  }
109  delete pPPL;
110  }
111  }
112 
113  if (fReadout) {
114  // Draw readout geometry...
115  G4VSensitiveDetector* sd = fpLV->GetSensitiveDetector();
116  if (sd) {
117  G4VReadOutGeometry* roGeom = sd->GetROgeometry();
118  if (roGeom) {
119  G4VPhysicalVolume* roWorld = roGeom->GetROWorld();
120  G4cout << "Readout geometry \"" << roGeom->GetName()
121  << "\" with top physical volume \""
122  << roWorld->GetName()
123  << "\"" << G4endl;
124  G4PhysicalVolumeModel pvModel(roWorld);
125  pvModel.SetModelingParameters(fpMP);
126  pvModel.DescribeYourselfTo(sceneHandler);
127  }
128  }
129  }
130 
131  if (fCheckOverlaps) {
132  G4LogicalVolume* lv = fpTopPV->GetLogicalVolume();
133  G4int nSisters = lv->GetNoDaughters();
134  for (G4int iSister = 0; iSister < nSisters; ++iSister) {
135  G4PVPlacement* placement = dynamic_cast<G4PVPlacement*>(lv->GetDaughter(iSister));
136  if (placement) placement->CheckOverlaps();
137  }
138  }
139 }
140 
141 // This called from G4PhysicalVolumeModel::DescribeAndDescend by the
142 // virtual function mechanism.
144 (const G4Transform3D& theAT,
145  G4VSolid* pSol,
146  const G4VisAttributes* pVisAttribs,
147  G4VGraphicsScene& sceneHandler) {
148 
149  if (fBooleans) {
150  // Look for "constituents". Could be a Boolean solid.
151  G4VSolid* pSol0 = pSol -> GetConstituentSolid (0);
152  if (pSol0) { // Composite solid...
153  G4VSolid* pSol1 = pSol -> GetConstituentSolid (1);
154  if (!pSol1) {
156  ("G4PhysicalVolumeModel::DescribeSolid",
157  "modeling0001", FatalException,
158  "2nd component solid in Boolean is missing.");
159  }
160  // Draw these constituents white and "forced wireframe"...
161  G4VisAttributes constituentAttributes;
162  constituentAttributes.SetForceWireframe(true);
163  DescribeSolid (theAT, pSol0, &constituentAttributes, sceneHandler);
164  DescribeSolid (theAT, pSol1, &constituentAttributes, sceneHandler);
165  }
166  }
167 
168  // In any case draw the original/resultant solid...
169  sceneHandler.PreAddSolid (theAT, *pVisAttribs);
170  pSol -> DescribeYourselfTo (sceneHandler);
171  sceneHandler.PostAddSolid ();
172 }
CLHEP::Hep3Vector G4ThreeVector
void DescribeYourselfTo(G4VGraphicsScene &)
G4VPhysicalVolume * GetROWorld() const
#define G4endl
Definition: G4ios.hh:61
virtual void EndPrimitives()=0
G4int GetNoDaughters() const
void DescribeYourselfTo(G4VGraphicsScene &)
G4PlacedPolyhedronList * CreatePlacedPolyhedra(const G4LogicalVolume *) const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation=G4Transform3D())=0
void SetModelingParameters(const G4ModelingParameters *)
bool G4bool
Definition: G4Types.hh:79
G4VReadOutGeometry * GetROgeometry() const
G4String GetName() const
std::vector< G4PlacedPolyhedron > G4PlacedPolyhedronList
virtual void AddPrimitive(const G4Polyline &)=0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4LogicalVolumeModel(G4LogicalVolume *, G4int soughtDepth=1, G4bool booleans=true, G4bool voxels=true, G4bool readout=true, G4bool checkOverlaps=true, const G4Transform3D &modelTransformation=G4Transform3D(), const G4ModelingParameters *=0)
int G4int
Definition: G4Types.hh:78
virtual void PostAddSolid()=0
G4GLOB_DLL std::ostream G4cout
void SetForceWireframe(G4bool=true)
void SetCulling(G4bool)
const G4String & GetName() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int maxErr=1)
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &visAttribs)=0
void DescribeSolid(const G4Transform3D &theAT, G4VSolid *pSol, const G4VisAttributes *pVisAttribs, G4VGraphicsScene &sceneHandler)