GeoModel - GeoModelCore
GeoShapeSubtraction.cxx
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoModelKernel/GeoShapeSubtraction.h"
6 #include "GeoModelKernel/GeoShapeAction.h"
7 #include "GeoModelKernel/GeoPolyhedrizeAction.h"
8 #include "GeoModelKernel/GeoPolyhedron.h"
9 #include <stdexcept>
10 
11 const std::string GeoShapeSubtraction::s_classType = "Subtraction";
12 const ShapeType GeoShapeSubtraction::s_classTypeID = 0x02;
13 
14 GeoShapeSubtraction::GeoShapeSubtraction (const GeoShape* A, const GeoShape* B)
15  : m_opA (A)
16  , m_opB (B)
17 {
18  m_opA->ref ();
19  m_opB->ref ();
20 }
21 
22 GeoShapeSubtraction::~GeoShapeSubtraction()
23 {
24  m_opA->unref ();
25  m_opB->unref ();
26 }
27 
28 double GeoShapeSubtraction::volume () const
29 {
31  exec(&a);
32  const GeoPolyhedron *poly = a.getPolyhedron();
33  double vol = poly->GetVolume ();
34  return vol;
35 }
36 
37 const std::string & GeoShapeSubtraction::type () const
38 {
39  return s_classType;
40 }
41 
42 ShapeType GeoShapeSubtraction::typeID () const
43 {
44  return s_classTypeID;
45 }
46 
47 const GeoShape* GeoShapeSubtraction::getOpA () const
48 {
49  return m_opA;
50 }
51 
52 const GeoShape* GeoShapeSubtraction::getOpB () const
53 {
54  return m_opB;
55 }
56 
57 void GeoShapeSubtraction::exec (GeoShapeAction *action) const
58 {
59  action->getPath ()->push (this);
60  action->handleSubtraction (this);
61  if (action->shouldTerminate ())
62  {
63  action->getPath ()->pop ();
64  return;
65  }
66 
67  if (action->getDepthLimit ().isValid ()
68  && action->getPath ()->getLength () > action->getDepthLimit ())
69  {
70  }
71 
72  else
73  {
74  m_opA->exec(action);
75  if (action->shouldTerminate ())
76  {
77  action->getPath ()->pop ();
78  return;
79  }
80  m_opB->exec(action);
81  if (action->shouldTerminate ())
82  {
83  action->getPath ()->pop ();
84  return;
85  }
86  }
87  action->getPath()->pop();
88 }
This action polyhedrizes a shape. This includes, for example, boolean shapes. A polhyedral representa...
This class is a visitor for shapes. It allows a navigation of the boolean expression tree for shapes...
This class describes a Shape. Shapes will be able to do the following things:
Definition: GeoShape.h:38