ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TObject
16 #include "TObject.h"
17 #endif
18 
19 #ifndef ROOT_TObjArray
20 #include "TObjArray.h"
21 #endif
22 
23 ////////////////////////////////////////////////////////////////////////////
24 // //
25 // TGeoPolygon - An arbitrary polygon defined by vertices. The vertices //
26 // have to be defined CLOCKWISE in the XY plane, making either a convex //
27 // or concave polygon. No test for malformed polygons is performed. //
28 // //
29 ////////////////////////////////////////////////////////////////////////////
30 
31 class TGeoPolygon : public TObject
32 {
33 public:
34  enum {
37  kGeoACW = BIT(11)
38  };
39 protected :
40 // data members
41  Int_t fNvert; // number of vertices (must be defined clockwise in XY plane)
42  Int_t fNconvex; // number of points of the outscribed convex polygon
43  Int_t *fInd; //[fNvert] list of vertex indices
44  Int_t *fIndc; //[fNconvex] indices of vertices of the outscribed convex polygon
45  Double_t *fX; //! pointer to list of current X coordinates of vertices
46  Double_t *fY; //! pointer to list of current Y coordinates of vertices
47  TObjArray *fDaughters; // list of concave daughters
48 private:
49  void ConvexCheck(); // force convexity checking
50  Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const;
51  Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const;
52  void OutscribedConvex();
53 public:
54  // constructors
55  TGeoPolygon();
56  TGeoPolygon(Int_t nvert);
57  // destructor
58  virtual ~TGeoPolygon();
59  // methods
60  Double_t Area() const;
61  Bool_t Contains(const Double_t *point) const;
62  virtual void Draw(Option_t *option="");
63  void FinishPolygon();
64  Int_t GetNvert() const {return fNvert;}
65  Int_t GetNconvex() const {return fNconvex;}
66  Double_t *GetX() {return fX;}
67  Double_t *GetY() {return fY;}
68  void GetVertices(Double_t *x, Double_t *y) const;
69  void GetConvexVertices(Double_t *x, Double_t *y) const;
73  Bool_t IsIllegalCheck() const;
74  Double_t Safety(const Double_t *point, Int_t &isegment) const;
76  void SetXY(Double_t *x, Double_t *y);
77  void SetNextIndex(Int_t index=-1);
78 
79  ClassDef(TGeoPolygon, 2) // class for handling arbitrary polygons
80 };
81 
82 #endif
83 
Double_t Area() const
Computes area of the polygon in [length^2].
Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const
Check if POINT is right-sided with respect to the segment defined by IND1 and IND2.
virtual void Draw(Option_t *option="")
Draw the polygon.
An array of TObjects.
Definition: TObjArray.h:39
Double_t * GetX()
Definition: TGeoPolygon.h:66
void SetNextIndex(Int_t index=-1)
Sets the next polygone index.
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:120
void ConvexCheck()
Check polygon convexity.
void GetVertices(Double_t *x, Double_t *y) const
Fill list of vertices into provided arrays.
Int_t * fIndc
Definition: TGeoPolygon.h:44
Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const
Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
Bool_t IsFinished() const
Definition: TGeoPolygon.h:72
Bool_t IsIllegalCheck() const
Check for illegal crossings between non-consecutive segments.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t GetNconvex() const
Definition: TGeoPolygon.h:65
void GetConvexVertices(Double_t *x, Double_t *y) const
Fill list of vertices of the convex outscribed polygon into provided arrays.
void SetXY(Double_t *x, Double_t *y)
Set X/Y array pointer for the polygon and daughters.
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
Double_t * fX
Definition: TGeoPolygon.h:45
void SetConvex(Bool_t flag=kTRUE)
Definition: TGeoPolygon.h:75
void OutscribedConvex()
Compute indices for the outscribed convex polygon.
Bool_t IsConvex() const
Definition: TGeoPolygon.h:71
Double_t Safety(const Double_t *point, Int_t &isegment) const
Compute minimum distance from POINT to any segment. Returns segment index.
double Double_t
Definition: RtypesCore.h:55
Double_t * fY
pointer to list of current X coordinates of vertices
Definition: TGeoPolygon.h:46
void FinishPolygon()
Decompose polygon in a convex outscribed part and a list of daughter polygons that have to be substra...
Int_t * fInd
Definition: TGeoPolygon.h:43
Double_t y[n]
Definition: legend1.C:17
Bool_t IsClockwise() const
Definition: TGeoPolygon.h:70
Mother of all ROOT objects.
Definition: TObject.h:58
TObjArray * fDaughters
pointer to list of current Y coordinates of vertices
Definition: TGeoPolygon.h:47
Double_t * GetY()
Definition: TGeoPolygon.h:67
Int_t fNconvex
Definition: TGeoPolygon.h:42
Bool_t Contains(const Double_t *point) const
Check if a point given by X = point[0], Y = point[1] is inside the polygon.
Int_t fNvert
Definition: TGeoPolygon.h:41
Int_t GetNvert() const
Definition: TGeoPolygon.h:64
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual ~TGeoPolygon()
Destructor.
Definition: TGeoPolygon.cxx:93