GeoModel - GeoModelCore
GeoPcon.cxx
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoModelKernel/GeoPcon.h"
6 #include "GeoModelKernel/GeoShapeAction.h"
7 #include <cmath>
8 #include <stdexcept>
9 
10 const std::string GeoPcon::s_classType = "Pcon";
11 const ShapeType GeoPcon::s_classTypeID = 0x13;
12 
13 GeoPcon::GeoPcon (double SPhi, double DPhi)
14  : m_sPhi (SPhi)
15  , m_dPhi (DPhi)
16 {
17 }
18 
19 GeoPcon::~GeoPcon()
20 {
21 }
22 
23 double GeoPcon::volume () const
24 {
25  if (!isValid ())
26  throw std::runtime_error ("Volume requested for incomplete polycone");
27  double v = 0;
28  for (size_t s = 0; s < getNPlanes () - 1; s++)
29  {
30  double fDz = fabs (getZPlane (s + 1) - getZPlane (s)) / 2.0;
31  double fRmin1 = getRMinPlane (s + 1);
32  double fRmin2 = getRMinPlane (s);
33  double fRmax1 = getRMaxPlane (s + 1);
34  double fRmax2 = getRMaxPlane (s);
35  v +=
36  (m_dPhi * (1./3)) * fDz * (fRmax1 * fRmax1 + fRmax2 * fRmax2 +
37  fRmax1 * fRmax2 - fRmin1 * fRmin1 -
38  fRmin2 * fRmin2 - fRmin1 * fRmin2);
39  }
40  return v;
41 }
42 
43 const std::string & GeoPcon::type () const
44 {
45  return s_classType;
46 }
47 
48 ShapeType GeoPcon::typeID () const
49 {
50  return s_classTypeID;
51 }
52 
53 void GeoPcon::addPlane (double ZPlane, double RMinPlane, double RMaxPlane)
54 {
55  m_zPlane.push_back (ZPlane);
56  m_rMinPlane.push_back (RMinPlane);
57  m_rMaxPlane.push_back (RMaxPlane);
58 }
59 
60 void GeoPcon::exec (GeoShapeAction *action) const
61 {
62  action->handlePcon(this);
63 }
64 
This class is a visitor for shapes. It allows a navigation of the boolean expression tree for shapes...