ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyEzgeom.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyEzgeom.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 // 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 {
54  runMgr-> SetUserInitialization(new EzDetectorConstruction);
55 }
56 
58 {
59  G4EzWorld::Reset(dx, dy, dz);
60 }
61 
63 {
64  G4EzWorld::Resize(dx, dy, dz);
65 }
66 
67 
68 void SetWorldMaterial(G4Material* amaterial)
69 {
70  G4EzWorld::SetMaterial(amaterial);
71 }
72 
73 
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 }