ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyG4Polyhedra.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyG4Polyhedra.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 // pyG4Polyhedra.cc
28 //
29 // 2007 Q
30 // ====================================================================
31 #include <boost/python.hpp>
32 #include <memory>
33 #include "G4Polyhedra.hh"
34 
35 using namespace boost::python;
36 
37 // ====================================================================
38 // thin wrappers
39 // ====================================================================
40 namespace pyG4Polyhedra {
41 
42 // create solid methods
43 
45  G4double phiStart, G4double phiTotal,
46  G4int numSide, G4int numZPlanes,
47  const std::vector<G4double>& zPlane,
48  const std::vector<G4double>& rInner,
49  const std::vector<G4double>& rOuter)
50 {
51  std::unique_ptr<G4double[]> zlist(new G4double[numZPlanes]);
52  std::unique_ptr<G4double[]> r0list(new G4double[numZPlanes]);
53  std::unique_ptr<G4double[]> r1list(new G4double[numZPlanes]);
54 
55  for (G4int i=0; i< numZPlanes; i++) {
56  zlist[i]= zPlane[i];
57  r0list[i]= rInner[i];
58  r1list[i]= rOuter[i];
59  }
60 
61  return new G4Polyhedra(name, phiStart, phiTotal, numSide, numZPlanes,
62  zlist.get(), r0list.get(), r1list.get());
63 }
64 
65 
67  G4double phiStart, G4double phiTotal,
68  G4int numSide, G4int numRZ,
69  const std::vector<G4double>& r,
70  const std::vector<G4double>& z)
71 {
72  std::unique_ptr<G4double[]> zlist(new G4double[numRZ]);
73  std::unique_ptr<G4double[]> rlist(new G4double[numRZ]);
74 
75  for (G4int i=0; i< numRZ; i++) {
76  zlist[i]= z[i];
77  rlist[i]= r[i];
78  }
79 
80  return new G4Polyhedra(name, phiStart, phiTotal, numSide, numRZ,
81  rlist.get(), zlist.get());
82 
83 }
84 
85 }
86 
87 using namespace pyG4Polyhedra;
88 
89 // ====================================================================
90 // module definition
91 // ====================================================================
93 {
94  class_<G4Polyhedra, G4Polyhedra*, bases<G4VSolid> >
95  ("G4Polyhedra", "Polyhedra solid class", no_init)
96  // ---
97  .def("GetStartPhi", &G4Polyhedra::GetStartPhi)
98  .def("GetEndPhi", &G4Polyhedra::GetEndPhi)
99  .def("GetNumSide", &G4Polyhedra::GetNumSide)
100  .def("GetNumRZCorner", &G4Polyhedra::GetNumRZCorner)
101  .def("IsOpen", &G4Polyhedra::IsOpen)
102  .def("IsGeneric", &G4Polyhedra::IsGeneric)
103 
104  // operators
105  .def(self_ns::str(self))
106  ;
107 
108  // Create solid
109  def("CreatePolyhedra", f1_CreatePolyhedra,
110  return_value_policy<manage_new_object>());
111  def("CreatePolyhedra", f2_CreatePolyhedra,
112  return_value_policy<manage_new_object>());
113 }
114