Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeoPolygon.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Mihaela Gheata 05/01/04
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGeoPolygon
13 #define ROOT_TGeoPolygon
14 
15 #include "TObject.h"
16 
17 #include "TObjArray.h"
18 
19 class TGeoPolygon : public TObject
20 {
21 public:
22  enum {
23  kGeoConvex = BIT(9),
24  kGeoFinishPolygon = BIT(10),
25  kGeoACW = BIT(11)
26  };
27 protected :
28 // data members
29  Int_t fNvert; // number of vertices (must be defined clockwise in XY plane)
30  Int_t fNconvex; // number of points of the outscribed convex polygon
31  Int_t *fInd; //[fNvert] list of vertex indices
32  Int_t *fIndc; //[fNconvex] indices of vertices of the outscribed convex polygon
33  Double_t *fX; //! pointer to list of current X coordinates of vertices
34  Double_t *fY; //! pointer to list of current Y coordinates of vertices
35  TObjArray *fDaughters; // list of concave daughters
36 private:
37  void ConvexCheck(); // force convexity checking
38  Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const;
39  Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const;
40  void OutscribedConvex();
41 public:
42  // constructors
43  TGeoPolygon();
44  TGeoPolygon(Int_t nvert);
45  // destructor
46  virtual ~TGeoPolygon();
47  // methods
48  Double_t Area() const;
49  Bool_t Contains(const Double_t *point) const;
50  virtual void Draw(Option_t *option="");
51  void FinishPolygon();
52  Int_t GetNvert() const {return fNvert;}
53  Int_t GetNconvex() const {return fNconvex;}
54  Double_t *GetX() {return fX;}
55  Double_t *GetY() {return fY;}
56  void GetVertices(Double_t *x, Double_t *y) const;
57  void GetConvexVertices(Double_t *x, Double_t *y) const;
58  Bool_t IsClockwise() const {return !TObject::TestBit(kGeoACW);}
59  Bool_t IsConvex() const {return TObject::TestBit(kGeoConvex);}
60  Bool_t IsFinished() const {return TObject::TestBit(kGeoFinishPolygon);}
61  Bool_t IsIllegalCheck() const;
62  Double_t Safety(const Double_t *point, Int_t &isegment) const;
63  void SetConvex(Bool_t flag=kTRUE) {TObject::SetBit(kGeoConvex,flag);}
64  void SetXY(Double_t *x, Double_t *y);
65  void SetNextIndex(Int_t index=-1);
66 
67  ClassDef(TGeoPolygon, 2) // class for handling arbitrary polygons
68 };
69 
70 #endif
71