 ROOT   Reference Guide TGeoPolygon.h
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Mihaela Gheata 05/01/04
3
4 /*************************************************************************
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 class TObjArray;
18
19 class TGeoPolygon : public TObject
20 {
21 public:
22  enum {
25  kGeoACW = BIT(11)
26  };
27 protected :
28 // data members
29  Int_t fNvert{0}; // number of vertices (must be defined clockwise in XY plane)
30  Int_t fNconvex{0}; // number of points of the outscribed convex polygon
31  Int_t *fInd{nullptr}; //[fNvert] list of vertex indices
32  Int_t *fIndc{nullptr}; //[fNconvex] indices of vertices of the outscribed convex polygon
33  Double_t *fX{nullptr}; //! pointer to list of current X coordinates of vertices
34  Double_t *fY{nullptr}; //! pointer to list of current Y coordinates of vertices
35  TObjArray *fDaughters{nullptr}; // 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
42  TGeoPolygon(const TGeoPolygon&) = delete;
43  TGeoPolygon &operator=(const TGeoPolygon&) = delete;
44 public:
45  // constructors
46  TGeoPolygon();
47  TGeoPolygon(Int_t nvert);
48  // destructor
49  virtual ~TGeoPolygon();
50  // methods
51  Double_t Area() const;
52  Bool_t Contains(const Double_t *point) const;
53  virtual void Draw(Option_t *option="");
54  void FinishPolygon();
55  Int_t GetNvert() const {return fNvert;}
56  Int_t GetNconvex() const {return fNconvex;}
57  Double_t *GetX() {return fX;}
58  Double_t *GetY() {return fY;}
59  void GetVertices(Double_t *x, Double_t *y) const;
60  void GetConvexVertices(Double_t *x, Double_t *y) const;
64  Bool_t IsIllegalCheck() const;
65  Double_t Safety(const Double_t *point, Int_t &isegment) const;
67  void SetXY(Double_t *x, Double_t *y);
68  void SetNextIndex(Int_t index=-1);
69
70  ClassDef(TGeoPolygon, 2) // class for handling arbitrary polygons
71 };
72
73 #endif
74
TGeoPolygon::GetX
Double_t * GetX()
Definition: TGeoPolygon.h:57
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGeoPolygon::kGeoConvex
@ kGeoConvex
Definition: TGeoPolygon.h:23
TGeoPolygon::Contains
Bool_t Contains(const Double_t *point) const
Check if a point given by X = point, Y = point is inside the polygon.
Definition: TGeoPolygon.cxx:130
TGeoPolygon::TGeoPolygon
TGeoPolygon(const TGeoPolygon &)=delete
TGeoPolygon::IsFinished
Bool_t IsFinished() const
Definition: TGeoPolygon.h:63
TGeoPolygon::SetNextIndex
void SetNextIndex(Int_t index=-1)
Sets the next polygone index.
Definition: TGeoPolygon.cxx:415
TGeoPolygon::GetConvexVertices
void GetConvexVertices(Double_t *x, Double_t *y) const
Fill list of vertices of the convex outscribed polygon into provided arrays.
Definition: TGeoPolygon.cxx:239
TGeoPolygon::TGeoPolygon
TGeoPolygon()
Dummy constructor.
Definition: TGeoPolygon.cxx:65
TGeoPolygon::ConvexCheck
void ConvexCheck()
Check polygon convexity.
Definition: TGeoPolygon.cxx:148
TGeoPolygon::IsConvex
Bool_t IsConvex() const
Definition: TGeoPolygon.h:62
TGeoPolygon::fIndc
Int_t * fIndc
Definition: TGeoPolygon.h:32
TGeoPolygon::Safety
Double_t Safety(const Double_t *point, Int_t &isegment) const
Compute minimum distance from POINT to any segment. Returns segment index.
Definition: TGeoPolygon.cxx:357
TGeoPolygon::kGeoFinishPolygon
@ kGeoFinishPolygon
Definition: TGeoPolygon.h:24
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TGeoPolygon::GetVertices
void GetVertices(Double_t *x, Double_t *y) const
Fill list of vertices into provided arrays.
Definition: TGeoPolygon.cxx:230
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
bool
TGeoPolygon::IsIllegalCheck
Bool_t IsIllegalCheck() const
Check for illegal crossings between non-consecutive segments.
Definition: TGeoPolygon.cxx:278
TGeoPolygon::kGeoACW
@ kGeoACW
Definition: TGeoPolygon.h:25
TGeoPolygon::GetNconvex
Int_t GetNconvex() const
Definition: TGeoPolygon.h:56
TGeoPolygon::operator=
TGeoPolygon & operator=(const TGeoPolygon &)=delete
TGeoPolygon::IsSegConvex
Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const
Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.
Definition: TGeoPolygon.cxx:262
TGeoPolygon
An arbitrary polygon defined by vertices.
Definition: TGeoPolygon.h:20
TGeoPolygon::SetXY
void SetXY(Double_t *x, Double_t *y)
Set X/Y array pointer for the polygon and daughters.
Definition: TGeoPolygon.cxx:439
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TGeoPolygon::GetNvert
Int_t GetNvert() const
Definition: TGeoPolygon.h:55
BIT
#define BIT(n)
Definition: Rtypes.h:85
y
Double_t y[n]
Definition: legend1.C:17
TGeoPolygon::SetConvex
void SetConvex(Bool_t flag=kTRUE)
Definition: TGeoPolygon.h:66
TGeoPolygon::IsRightSided
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.
Definition: TGeoPolygon.cxx:250
TGeoPolygon::fX
Double_t * fX
Definition: TGeoPolygon.h:33
TGeoPolygon::FinishPolygon
void FinishPolygon()
Decompose polygon in a convex outscribed part and a list of daughter polygons that have to be subtrac...
Definition: TGeoPolygon.cxx:179
TGeoPolygon::fInd
Int_t * fInd
Definition: TGeoPolygon.h:31
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoPolygon::OutscribedConvex
void OutscribedConvex()
Compute indices for the outscribed convex polygon.
Definition: TGeoPolygon.cxx:308
TObject.h
TGeoPolygon::fY
Double_t * fY
pointer to list of current X coordinates of vertices
Definition: TGeoPolygon.h:34
TGeoPolygon::fNconvex
Int_t fNconvex
Definition: TGeoPolygon.h:30
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGeoPolygon::IsClockwise
Bool_t IsClockwise() const
Definition: TGeoPolygon.h:61
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGeoPolygon::fNvert
Int_t fNvert
Definition: TGeoPolygon.h:29
TGeoPolygon::fDaughters
TObjArray * fDaughters
pointer to list of current Y coordinates of vertices
Definition: TGeoPolygon.h:35
TGeoPolygon::GetY
Double_t * GetY()
Definition: TGeoPolygon.h:58
TGeoPolygon::Area
Double_t Area() const
Computes area of the polygon in [length^2].
Definition: TGeoPolygon.cxx:114
TGeoPolygon::Draw
virtual void Draw(Option_t *option="")
Draw the polygon.
Definition: TGeoPolygon.cxx:169
TGeoPolygon::~TGeoPolygon
virtual ~TGeoPolygon()
Destructor.
Definition: TGeoPolygon.cxx:102
int