LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pyEzgeom.cc
Go to the documentation of this file.
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 // pyEZgeom.cc
28 //
29 // [ezgeom]
30 // a site-module of Geant4Py
31 //
32 // An easy way to build geometry
33 //
34 // 2005 Q
35 // ====================================================================
36 #include <boost/python.hpp>
38 #include "G4EzWorld.hh"
39 #include "G4EzVolume.hh"
40 #include "G4RunManager.hh"
41 #include "G4VSensitiveDetector.hh"
42 
43 using namespace boost::python;
44 
45 // ====================================================================
46 // thin wrappers
47 // ====================================================================
48 namespace pyEZgeom {
49 
50 // methods in global namespace
51 void Construct()
52 {
53  G4RunManager* runMgr= G4RunManager::GetRunManager();
54  runMgr-> SetUserInitialization(new EzDetectorConstruction);
55 }
56 
57 void ResetWorld(G4double dx, G4double dy, G4double dz)
58 {
59  G4EzWorld::Reset(dx, dy, dz);
60 }
61 
62 void ResizeWorld(G4double dx, G4double dy, G4double dz)
63 {
64  G4EzWorld::Resize(dx, dy, dz);
65 }
66 
67 
68 void SetWorldMaterial(G4Material* amaterial)
69 {
70  G4EzWorld::SetMaterial(amaterial);
71 }
72 
73 
74 void SetWorldVisibility(G4bool qvis)
75 {
77 }
78 
79 
80 // CreateTubeVolume
82  CreateTubeVolume, 4, 6)
83 
86 
87 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateSphereVolume,
88  CreateSphereVolume, 3, 7)
89 
90 // PlaceIt
91 G4VPhysicalVolume*(G4EzVolume::*f1_PlaceIt)
92  (const G4ThreeVector&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
93 
94 G4VPhysicalVolume*(G4EzVolume::*f2_PlaceIt)
95  (const G4Transform3D&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
96 
97 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_PlaceIt, PlaceIt, 1, 3)
98 
99 // ReplicateIt
100 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ReplicateIt, ReplicateIt, 4, 5)
101 
102 // SetColor
103 void (G4EzVolume::*f1_SetColor)(const G4Color&) = &G4EzVolume::SetColor;
104 void (G4EzVolume::*f2_SetColor)(G4double, G4double, G4double)
105  = &G4EzVolume::SetColor;
106 
107 }
108 
109 using namespace pyEZgeom;
110 
111 // ====================================================================
112 // Expose to Python
113 // ====================================================================
114 
116 
117  class_<G4EzVolume>("G4EzVolume", "an easy way of geometry configuration")
118  .def(init<const G4String&>())
119  // ---
120  .def("CreateBoxVolume", &G4EzVolume::CreateBoxVolume)
121  .def("CreateTubeVolume", &G4EzVolume::CreateTubeVolume,
122  f_CreateTubeVolume())
123  .def("CreateConeVolume", &G4EzVolume::CreateConeVolume,
124  f_CreateConeVolume())
125  .def("CreateShpereVolume", &G4EzVolume::CreateSphereVolume,
126  f_CreateSphereVolume())
127  .def("CreateOrbVolume", &G4EzVolume::CreateOrbVolume)
128  // ---
129  .def("SetSold", &G4EzVolume::SetSolid)
130  .def("GetSold", &G4EzVolume::GetSolid,
131  return_value_policy<reference_existing_object>())
132  .def("SetMaterial", &G4EzVolume::SetMaterial)
133  .def("GetMaterial", &G4EzVolume::GetMaterial,
134  return_value_policy<reference_existing_object>())
135  // ---
136  .def("PlaceIt", f1_PlaceIt,
137  f_PlaceIt()[return_value_policy<reference_existing_object>()])
138  .def("PlaceIt", f2_PlaceIt,
139  f_PlaceIt()[return_value_policy<reference_existing_object>()])
140  .def("ReplicateIt", &G4EzVolume::ReplicateIt,
141  f_ReplicateIt()[return_value_policy<reference_existing_object>()])
142  .def("VoxelizeIt", &G4EzVolume::VoxelizeIt)
143  // ---
144  .def("SetSensitiveDetector", &G4EzVolume::SetSensitiveDetector)
145  // ---
146  .def("SetColor", f1_SetColor)
147  .def("SetColor", f2_SetColor)
148  .def("SetVisibility", &G4EzVolume::SetVisibility)
149  ;
150 
151  // -------------------------------------------------------------------
152  def("Construct", Construct);
153  def("ResetWorld", ResetWorld);
154  def("ResizeWorld", ResizeWorld);
155  def("SetWorldMaterial", SetWorldMaterial);
156  def("SetWorldVisibility", SetWorldVisibility);
157 
158 }
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume, CreateTubeVolume, 4, 6) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume
G4ThreeVector VoxelizeIt(G4int nx, G4int ny, G4int nz)
Definition: G4EzVolume.cc:256
void SetSensitiveDetector(G4VSensitiveDetector *asd)
Definition: G4EzVolume.cc:300
static void Resize(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:108
static void Reset(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:96
CreateConeVolume
Definition: pyEzgeom.cc:85
void SetWorldMaterial(G4Material *amaterial)
Definition: pyEzgeom.cc:68
void CreateTubeVolume(G4Material *amaterial, G4double rmin, G4double rmax, G4double dz, G4double phi0=0., G4double dphi=360 *deg)
Definition: G4EzVolume.cc:100
void CreateConeVolume(G4Material *amaterial, G4double rmin1, G4double rmax1, G4double rmin2, G4double rmax2, G4double dz, G4double phi0=0., G4double dphi=360.*deg)
Definition: G4EzVolume.cc:121
void Construct()
Definition: pyEzgeom.cc:51
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateSphereVolume, CreateSphereVolume, 3, 7) G4VPhysicalVolume *(G4EzVolume G4VPhysicalVolume *(G4EzVolume::* f2_PlaceIt)(const G4Transform3D &, G4int, G4EzVolume *)
Definition: pyEzgeom.cc:95
void CreateOrbVolume(G4Material *amaterial, G4double rmax)
Definition: G4EzVolume.cc:167
G4Material * GetMaterial() const
Definition: G4EzVolume.hh:142
void SetSolid(G4VSolid *asolid)
Definition: G4EzVolume.hh:132
void SetVisibility(G4bool qvisible)
Definition: G4EzVolume.hh:150
const G4VSolid * GetSolid() const
Definition: G4EzVolume.hh:134
void CreateBoxVolume(G4Material *amaterial, G4double dx, G4double dy, G4double dz)
Definition: G4EzVolume.cc:80
void SetWorldVisibility(G4bool qvis)
Definition: pyEzgeom.cc:74
void CreateSphereVolume(G4Material *amaterial, G4double rmin, G4double rmax, G4double phi0=0., G4double dphi=360.*deg, G4double theta0=0., G4double dtheta=180.*deg)
Definition: G4EzVolume.cc:145
void SetMaterial(G4Material *amaterial)
Definition: G4EzVolume.hh:136
BOOST_PYTHON_MODULE(ezgeom)
Definition: pyEzgeom.cc:115
void(G4EzVolume::* f1_SetColor)(const G4Color &)
Definition: pyEzgeom.cc:103
void ResizeWorld(G4double dx, G4double dy, G4double dz)
Definition: pyEzgeom.cc:62
static void SetVisibility(G4bool qvis)
Definition: G4EzWorld.cc:130
void ResetWorld(G4double dx, G4double dy, G4double dz)
Definition: pyEzgeom.cc:57
void(G4EzVolume::* f2_SetColor)(G4double, G4double, G4double)
Definition: pyEzgeom.cc:104
static void SetMaterial(G4Material *amaterial)
Definition: G4EzWorld.cc:122
G4VPhysicalVolume * ReplicateIt(G4EzVolume *parent, EAxis pAxis, G4int nReplicas, G4double width, G4double offset=0)
Definition: G4EzVolume.cc:236