Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: pyEzgeom.cc,v 1.1 2008-12-01 07:07:34 kmura Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // pyEZgeom.cc
30 //
31 // [ezgeom]
32 // a site-module of Geant4Py
33 //
34 // An easy way to build geometry
35 //
36 // 2005 Q
37 // ====================================================================
38 #include <boost/python.hpp>
40 #include "G4EzWorld.hh"
41 #include "G4EzVolume.hh"
42 #include "G4RunManager.hh"
43 #include "G4VSensitiveDetector.hh"
44 
45 using namespace boost::python;
46 
47 // ====================================================================
48 // thin wrappers
49 // ====================================================================
50 namespace pyEZgeom {
51 
52 // methods in global namespace
53 void Construct()
54 {
56  runMgr-> SetUserInitialization(new EzDetectorConstruction);
57 }
58 
60 {
61  G4EzWorld::Reset(dx, dy, dz);
62 }
63 
65 {
66  G4EzWorld::Resize(dx, dy, dz);
67 }
68 
69 
70 void SetWorldMaterial(G4Material* amaterial)
71 {
72  G4EzWorld::SetMaterial(amaterial);
73 }
74 
75 
77 {
79 }
80 
81 
82 // CreateTubeVolume
83 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume,
84  CreateTubeVolume, 4, 6);
85 
86 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume,
87  CreateConeVolume, 6, 8);
88 
89 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateSphereVolume,
90  CreateSphereVolume, 3, 7);
91 
92 // PlaceIt
93 G4VPhysicalVolume*(G4EzVolume::*f1_PlaceIt)
94  (const G4ThreeVector&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
95 
96 G4VPhysicalVolume*(G4EzVolume::*f2_PlaceIt)
97  (const G4Transform3D&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
98 
99 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_PlaceIt, PlaceIt, 1, 3);
100 
101 // ReplicateIt
102 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ReplicateIt, ReplicateIt, 4, 5);
103 
104 // SetColor
105 void (G4EzVolume::*f1_SetColor)(const G4Color&) = &G4EzVolume::SetColor;
108 
109 };
110 
111 using namespace pyEZgeom;
112 
113 // ====================================================================
114 // Expose to Python
115 // ====================================================================
116 
118 
119  class_<G4EzVolume>("G4EzVolume", "an easy way of geometry configuration")
120  .def(init<const G4String&>())
121  // ---
122  .def("CreateBoxVolume", &G4EzVolume::CreateBoxVolume)
123  .def("CreateTubeVolume", &G4EzVolume::CreateTubeVolume,
124  f_CreateTubeVolume())
125  .def("CreateConeVolume", &G4EzVolume::CreateConeVolume,
126  f_CreateConeVolume())
127  .def("CreateShpereVolume", &G4EzVolume::CreateSphereVolume,
128  f_CreateSphereVolume())
129  .def("CreateOrbVolume", &G4EzVolume::CreateOrbVolume)
130  // ---
131  .def("SetSold", &G4EzVolume::SetSolid)
132  .def("GetSold", &G4EzVolume::GetSolid,
133  return_value_policy<reference_existing_object>())
134  .def("SetMaterial", &G4EzVolume::SetMaterial)
135  .def("GetMaterial", &G4EzVolume::GetMaterial,
136  return_value_policy<reference_existing_object>())
137  // ---
138  .def("PlaceIt", f1_PlaceIt,
139  f_PlaceIt()[return_value_policy<reference_existing_object>()])
140  .def("PlaceIt", f2_PlaceIt,
141  f_PlaceIt()[return_value_policy<reference_existing_object>()])
142  .def("ReplicateIt", &G4EzVolume::ReplicateIt,
143  f_ReplicateIt()[return_value_policy<reference_existing_object>()])
144  .def("VoxelizeIt", &G4EzVolume::VoxelizeIt)
145  // ---
146  .def("SetSensitiveDetector", &G4EzVolume::SetSensitiveDetector)
147  // ---
148  .def("SetColor", f1_SetColor)
149  .def("SetColor", f2_SetColor)
150  .def("SetVisibility", &G4EzVolume::SetVisibility)
151  ;
152 
153  // -------------------------------------------------------------------
154  def("Construct", Construct);
155  def("ResetWorld", ResetWorld);
156  def("ResizeWorld", ResizeWorld);
157  def("SetWorldMaterial", SetWorldMaterial);
158  def("SetWorldVisibility", SetWorldVisibility);
159 
160 }