Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:14:38

0001 // #include "Utilities/Configuration/interface/Architecture.h"
0002 
0003 #include "MagneticField/VolumeGeometry/interface/FourPointPlaneBounds.h"
0004 #include "DataFormats/GeometrySurface/interface/GeomExceptions.h"
0005 #include <algorithm>
0006 #include <iostream>
0007 
0008 FourPointPlaneBounds::FourPointPlaneBounds(const LocalPoint& a,
0009                                            const LocalPoint& b,
0010                                            const LocalPoint& c,
0011                                            const LocalPoint& d) {
0012   corners_[0] = Local2DPoint(a.x(), a.y());
0013   corners_[1] = Local2DPoint(b.x(), b.y());
0014   corners_[2] = Local2DPoint(c.x(), c.y());
0015   corners_[3] = Local2DPoint(d.x(), d.y());
0016 
0017   // check for convexity
0018   for (int i = 0; i < 4; ++i) {
0019     if (checkSide(i, corner(i + 2)) * checkSide(i, corner(i + 3)) < 0) {  // not on same side
0020       throw GeometryError("FourPointPlaneBounds: coners not in order or not convex");
0021     }
0022   }
0023 
0024   double side = checkSide(0, corners_[2]);  // - for clockwise corners, + for counterclockwise
0025   if (side < 0) {
0026     std::cout << "FourPointPlaneBounds: Changing order of corners to counterclockwise" << std::endl;
0027     std::swap(corners_[1], corners_[3]);
0028   }
0029 }
0030 
0031 double FourPointPlaneBounds::checkSide(int i, const Local2DPoint& lp) const { return checkSide(i, lp.x(), lp.y()); }
0032 
0033 bool FourPointPlaneBounds::inside(const Local3DPoint& lp) const {
0034   for (int i = 0; i < 4; ++i) {
0035     if (checkSide(i, lp.x(), lp.y()) < 0)
0036       return false;
0037   }
0038   return true;
0039 }
0040 
0041 float FourPointPlaneBounds::length() const { return 0; }
0042 float FourPointPlaneBounds::width() const { return 0; }
0043 float FourPointPlaneBounds::thickness() const { return 0; }