CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/MagneticField/VolumeGeometry/src/FourPointPlaneBounds.cc

Go to the documentation of this file.
00001 // #include "Utilities/Configuration/interface/Architecture.h"
00002 
00003 #include "MagneticField/VolumeGeometry/interface/FourPointPlaneBounds.h"
00004 #include "DataFormats/GeometrySurface/interface/GeomExceptions.h"
00005 #include <algorithm>
00006 #include <iostream>
00007 
00008 FourPointPlaneBounds::FourPointPlaneBounds( const LocalPoint& a, const LocalPoint& b, 
00009                                             const LocalPoint& c, const LocalPoint& d) {
00010     corners_[0] = Local2DPoint( a.x(), a.y());
00011     corners_[1] = Local2DPoint( b.x(), b.y());
00012     corners_[2] = Local2DPoint( c.x(), c.y());
00013     corners_[3] = Local2DPoint( d.x(), d.y());
00014 
00015 // check for convexity
00016     for (int i=0; i<4; ++i) {
00017         if (checkSide( i, corner(i+2)) *  checkSide( i, corner(i+3)) < 0) { // not on same side
00018             throw GeometryError("FourPointPlaneBounds: coners not in order or not convex");
00019         }
00020     }
00021 
00022     double side = checkSide( 0, corners_[2]); // - for clockwise corners, + for counterclockwise
00023     if (side < 0) {
00024         std::cout << "FourPointPlaneBounds: Changing order of corners to counterclockwise" << std::endl;
00025         std::swap( corners_[1], corners_[3]);
00026     }
00027 }
00028 
00029 double FourPointPlaneBounds::checkSide( int i, const Local2DPoint& lp) const {
00030     return checkSide(i, lp.x(), lp.y());
00031 }
00032 
00033 bool FourPointPlaneBounds::inside( const Local3DPoint& lp) const
00034 {
00035     for (int i=0; i<4; ++i) {
00036         if (checkSide(i,lp.x(),lp.y()) < 0) return false;
00037     }
00038     return true;
00039 }
00040 
00041 float FourPointPlaneBounds::length() const {return 0;}
00042 float FourPointPlaneBounds::width() const {return 0;}
00043 float FourPointPlaneBounds::thickness() const {return 0;}