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
105 #endif
106 
107 #endif
void computeSpan()
Definition: Plane.h:68
ConstReferenceCountingPointer< Plane > ConstBoundPlanePointer
Definition: Plane.h:28
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 LocalPoint &p, Scalar toler) const GCC11_FINAL
Definition: Plane.h:73
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
float float float z
void setPosPrec()
Definition: Plane.h:91
const T & max(const T &a, const T &b)
ReferenceCountingPointer< Plane > BoundPlanePointer
Definition: Plane.h:27
static PlanePointer build(Args &&...args)
Definition: Plane.h:36
Plane(Args &&...args)
Definition: Plane.h:21
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float localZclamped(const GlobalPoint &gp) const
Definition: Plane.h:54
string const
Definition: compareJSON.py:14
virtual ReferenceCountingPointer< TangentPlane > tangentPlane(const GlobalPoint &) const GCC11_FINAL
tangent plane to surface from global point
Definition: Plane.cc:6
#define private
Definition: FWFileEntry.h:17
ReferenceCountingPointer< Plane > PlanePointer
Definition: Plane.h:25
extstd::clone_ptr< Bounds > theBounds
Definition: Surface.h:150
const RotationType & rotation() const
const PositionType & position() const
#define constexpr
virtual SurfaceOrientation::Side side(const GlobalPoint &p, Scalar toler) const GCC11_FINAL
Definition: Plane.h:78
~Plane()
Definition: Plane.h:41
Unlimited (trivial) bounds.