00001 #ifndef RectangularPadRowLayout_h
00002 #define RectangularPadRowLayout_h 1
00003
00004 #include <vector>
00005 #include "gear/PadRowLayout2D.h"
00006
00007
00008 namespace gear {
00009
00010
00011
00026 class RectangularPadRowLayout : public PadRowLayout2D {
00027
00028 public:
00029
00031 struct Row{
00032 int NPad ;
00033 double PadWidth ;
00034 double PadHeight ;
00035 double Height ;
00036 double LeftOffset ;
00037 double RightOffset ;
00038 double Center ;
00039 double WidthPerPad ;
00040 } ;
00041
00042
00043 protected:
00044 int _nRow ;
00045 int _nPad ;
00046 int _repeatRows ;
00047 std::vector<Row> _rows ;
00048 std::vector<double> _extent ;
00049 mutable std::vector< std::vector<int>* > _padIndices ;
00050 std::vector<unsigned> _nRows ;
00051
00052 public:
00053
00058 RectangularPadRowLayout( double xMin, double xMax , double yMin=0.0) ;
00059
00061 virtual ~RectangularPadRowLayout() ;
00062
00063
00066 virtual void addRow( int nRow, int nPad , double padWidth , double padHeight ,
00067 double rowHeight =0.0, double leftOffset =0.0 ,
00068 double rightOffset =0.0 );
00069
00070
00075 virtual void repeatRows(unsigned count) ;
00076
00079 int getRepeatRowCount() const { return _repeatRows ; }
00080
00081
00084 virtual int getPadLayoutType() const { return PadRowLayout2D::CARTESIAN ; }
00085
00088 virtual int getPadShape() const { return PadRowLayout2D::RECTANGLE ; }
00089
00092 virtual int getNPads() const { return _nPad ; }
00093
00096 virtual int getNRows() const ;
00097
00100 virtual double getRowHeight(int rowNumber) const ;
00101
00104 virtual double getPadHeight(int padIndex) const ;
00105
00108 virtual double getPadWidth(int padIndex) const ;
00109
00112 virtual Point2D getPadCenter(int padIndex) const;
00113
00114
00118 virtual const std::vector<int>& getPadsInRow(int rowNumber) const ;
00119
00123 virtual const std::vector<double>& getPlaneExtent() const { return _extent ; }
00124
00127 virtual int getRowNumber(int padIndex) const ;
00128
00131 virtual int getPadNumber(int padIndex) const { return ( 0x0000ffff & padIndex ) ; }
00132
00135 virtual int getPadIndex(int rowNum, int padNum) const;
00136
00140 virtual int getNearestPad(double x, double y) const;
00141
00144 virtual int getRightNeighbour(int padIndex) const;
00145
00148 virtual int getLeftNeighbour(int padIndex) const;
00149
00152 virtual bool isInsidePad(double x, double y, int padIndex) const;
00153
00156 virtual bool isInsidePad(double x, double y) const;
00157
00158
00160 const std::vector<unsigned>& equalRowNumbers() const { return _nRows ; }
00161
00163 const std::vector<Row>& rows() const { return _rows ; }
00164
00165
00166 protected:
00167
00171 double distanceToBox( const Point2D& p , double xMin, double yMin, double xMax, double yMax ) const ;
00172
00173 };
00174
00175 }
00176 #endif // ifndef RectangularPadRowLayout_h