Polygon.hh

Deil Christoph, 10/11/2012 01:53 PM

Download (1.59 KB)

 
1
#ifndef _TOOLS_POLYGON_H_
2
#define _TOOLS_POLYGON_H_
3

    
4
#include <vector>
5

    
6
#include <TGeoPolygon.h>
7

    
8
#include <stash/Coordinate.hh>
9
#include <stash/Lambda.hh>
10
#include <TArrayD.h>
11

    
12

    
13
#include "Region.hh"
14

    
15

    
16
namespace Tools {
17

    
18
  /**
19
   * A polygonal region, defined by a set of vertex coordinates (clockwise)
20
   */
21
  class Polygon : public Region
22
  {
23
  public:
24
    Polygon( std::vector<Stash::Coordinate> vertices, 
25
             std::string name="poly");
26
    Polygon(const Tools::Polygon &cpy);
27
    Polygon();
28
                      
29
    
30
    virtual double GetArea() const;
31
    virtual bool IsInside( const Stash::Coordinate& dir ) const;
32
    virtual std::string AsFITSRegionString() const;
33
    virtual VertexList AsVertexList() const;
34
    virtual double GetBound1() const;
35
    virtual double GetBound2() const;
36
    virtual double GetRadialBound()const;
37
    virtual ~Polygon();
38
    virtual Tools::Polygon* GrowBoundary(const double degrees,
39
                                        const std::string name="_grown") const;
40
    virtual void MoveTo( Stash::Coordinate newpos );
41
    
42
    /**
43
     * Move the internal "center" position to the Center-of-gravity
44
     * (doesn't move the region itself, just the point from which
45
     * bounding boxes are calculated.) Use MoveTo() instead to move the region
46
     */
47
    void RecenterOnCOG() { fCentre = GetCentreOfGravity(); }
48

    
49
    int GetNumVertices() { return fPoly->GetNvert(); }
50
    TGeoPolygon* GetPoly() {return fPoly; }
51

    
52
  private:
53
    void UpdatePoly();
54
    TGeoPolygon* fPoly;  
55
    TArrayD *fX; // needed for TGeoPolygon
56
    TArrayD *fY; // needed for TGeoPolygon
57

    
58
    ClassDef(Tools::Polygon, 4);
59

    
60
  };
61

    
62
}
63

    
64
#endif /* _TOOLS_POLYGON_H_ */
65

    
66