]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDPolygon.h
5884e05d50007b68995a68f20b990669c3a34c3d
[u/mrichter/AliRoot.git] / FMD / AliFMDPolygon.h
1 // -*- mode: C++ -*-
2 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
3  * reserved. 
4  *
5  * Latest changes by Christian Holm Christensen <cholm@nbi.dk>
6  *
7  * See cxx source for full Copyright notice                               
8  */
9 #ifndef ALIFMDPOLYGON_H
10 #define ALIFMDPOLYGON_H
11 #ifndef ROOT_TVector2
12 # include <TVector2.h>
13 #endif
14 #ifndef ROOT_TObjArray
15 # include <TObjArray.h>
16 #endif
17
18 class AliFMDPolygon : public TObject 
19 {
20 private:
21   enum {
22     kUnknown, 
23     kConvex, 
24     kConcave
25   };
26   mutable Int_t fState;
27   // List of coordinates 
28   TObjArray fVerticies;
29   // Force convexity check 
30   bool ConvexCheck() const;
31   // Check if a point is at the right-hand side of a segment 
32   bool IsOnLeftHand(const TVector2* c, size_t i1, size_t i2) const;
33 public:
34   // Construct a alipolygon with N sides
35   AliFMDPolygon();
36   virtual ~AliFMDPolygon();
37
38   // Clear the polygon 
39   void Clear(Option_t* option="");
40   
41   // Add a vertex 
42   bool AddVertex(TVector2* c);
43   bool AddVertex(double x, double y);
44
45   // Get a vertex point 
46   const TVector2& GetVertex(size_t i) const;
47   
48   // Check if a point is inside the polygon 
49   bool Contains(const TVector2* c) const;
50   bool Contains(double x, double y) const;
51   
52   // Get the number of verticies 
53   size_t GetNVerticies() const { return fVerticies.GetEntries(); }  
54   // Get the coordinates 
55   const TObjArray& GetVerticies() const { return fVerticies; }
56   
57   void Draw(const char* option="PL", const char* name=0) const;
58
59   ClassDef(AliFMDPolygon,1) // Polygon parameters
60 };
61
62 #endif
63 //
64 // EOF
65 //
66
67   
68