CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Plane.h
Go to the documentation of this file.
1 #ifndef Geom_Plane_H
2 #define Geom_Plane_H
3 
15 #include "boost/intrusive_ptr.hpp"
16 
17 class Plane : public Surface {
18 public:
19 #ifndef CMS_NOCXX11
20  template<typename... Args>
21  Plane(Args&& ... args) :
22  Surface(std::forward<Args>(args)...){setPosPrec();computeSpan();}
23 #endif
24 
29 
30 
31 #ifndef CMS_NOCXX11
32  template<typename... Args>
36  static PlanePointer build(Args&& ... args) {
37  return PlanePointer(new Plane(std::forward<Args>(args)...));
38  }
39 #endif
40 
41  ~Plane(){}
42 
43 // extension of Surface interface for planes
44 
45  GlobalVector normalVector() const { return GlobalVector(rotation().z()); }
46 
49  float localZ (const GlobalPoint& gp) const {
50  return normalVector().dot(gp-position());
51  }
52 
53 #ifndef CMS_NOCXX11
54  float localZclamped (const GlobalPoint& gp) const {
55  auto d = localZ(gp);
56  return std::abs(d) > posPrec() ? d : 0;
57  }
58 #endif
59 
61  float localZ (const GlobalVector& gv) const {
62  return normalVector().dot(gv);
63  }
64 
65  // precision on position
66  float posPrec() const { return m_posPrec;}
67 
68  void computeSpan() { if(theBounds) theBounds->computeSpan(*this);}
69 
70 
71 // implementation of Surface interface
72 
73  virtual SurfaceOrientation::Side side( const LocalPoint& p, Scalar toler) const GCC11_FINAL {
74  return (std::abs(p.z())<toler) ? SurfaceOrientation::onSurface :
76  }
77 
78  virtual SurfaceOrientation::Side side( const GlobalPoint& p, Scalar toler) const GCC11_FINAL {
79  Scalar lz = localZ(p);
80  return (std::abs(lz)<toler ? SurfaceOrientation::onSurface :
82  }
83 
86 
89 
90 private:
91  void setPosPrec() {
92 #ifndef CMS_NOCXX11
94  auto p = position();
95  float l = std::max(std::max(std::abs(p.x()),std::abs(p.y())),std::abs(p.z()));
96  m_posPrec = std::abs(l-::nextafterf(l,maxf)); // LSB (can be multiplied by 4 or divided by 4 for safety depending on usage)
97 #endif
98  }
99 
100  Scalar m_posPrec; // the precision on the actual global position
101 
102 };
103 #ifndef CMS_NOCXX11
104 using BoundPlane = Plane;
105 #endif
106 
107 #endif
void computeSpan()
Definition: Plane.h:68
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const
tangent plane to surface from global point
Definition: Plane.cc:6
ConstReferenceCountingPointer< Plane > ConstBoundPlanePointer
Definition: Plane.h:28
#define GCC11_FINAL
float localZ(const GlobalVector &gv) const
Fast access to component perpendicular to plane for a vector.
Definition: Plane.h:61
ConstReferenceCountingPointer< Plane > ConstPlanePointer
Definition: Plane.h:26
virtual SurfaceOrientation::Side side(const GlobalPoint &p, Scalar toler) const
Definition: Plane.h:78
GlobalVector normalVector() const
Definition: Plane.h:45
Scalar m_posPrec
Definition: Plane.h:100
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:49
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
float posPrec() const
Definition: Plane.h:66
Vector3DBase< float, GlobalTag > GlobalVector
Definition: Plane.h:17
#define constexpr
float float float z
void setPosPrec()
Definition: Plane.h:91
Surface()
Definition: Surface.h:59
ReferenceCountingPointer< Plane > BoundPlanePointer
Definition: Plane.h:27
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
string const
Definition: compareJSON.py:14
#define private
Definition: FWFileEntry.h:17
ReferenceCountingPointer< Plane > PlanePointer
Definition: Plane.h:25
virtual SurfaceOrientation::Side side(const LocalPoint &p, Scalar toler) const
Definition: Plane.h:73
const RotationType & rotation() const
const PositionType & position() const
void computeSpan(Surface const &plane)
Definition: Bounds.h:74
Bounds * theBounds
Definition: Surface.h:152
~Plane()
Definition: Plane.h:41