Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
17class TObjArray;
18
19class TGeoPolygon : public TObject {
20public:
21 enum { kGeoConvex = BIT(9), kGeoFinishPolygon = BIT(10), kGeoACW = BIT(11) };
22
23protected:
24 // data members
25 Int_t fNvert{0}; // number of vertices (must be defined clockwise in XY plane)
26 Int_t fNconvex{0}; // number of points of the outscribed convex polygon
27 Int_t *fInd{nullptr}; //[fNvert] list of vertex indices
28 Int_t *fIndc{nullptr}; //[fNconvex] indices of vertices of the outscribed convex polygon
29 Double_t *fX{nullptr}; //! pointer to list of current X coordinates of vertices
30 Double_t *fY{nullptr}; //! pointer to list of current Y coordinates of vertices
31 TObjArray *fDaughters{nullptr}; // list of concave daughters
32private:
33 void ConvexCheck(); // force convexity checking
34 Bool_t IsSegConvex(Int_t i1, Int_t i2 = -1) const;
35 Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const;
36 void OutscribedConvex();
37
38 TGeoPolygon(const TGeoPolygon &) = delete;
39 TGeoPolygon &operator=(const TGeoPolygon &) = delete;
40
41public:
42 // constructors
44 TGeoPolygon(Int_t nvert);
45 // destructor
46 ~TGeoPolygon() override;
47 // methods
48 Double_t Area() const;
49 Bool_t Contains(const Double_t *point) const;
50 void Draw(Option_t *option = "") override;
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;
61 Bool_t IsIllegalCheck() const;
62 Double_t Safety(const Double_t *point, Int_t &isegment) const;
64 void SetXY(Double_t *x, Double_t *y);
65 void SetNextIndex(Int_t index = -1);
66
67 ClassDefOverride(TGeoPolygon, 2) // class for handling arbitrary polygons
68};
69
70#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
An arbitrary polygon defined by vertices.
Definition TGeoPolygon.h:19
Bool_t IsConvex() const
Definition TGeoPolygon.h:59
Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const
Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.
TGeoPolygon & operator=(const TGeoPolygon &)=delete
TGeoPolygon()
Dummy constructor.
Int_t GetNconvex() const
Definition TGeoPolygon.h:53
Double_t * GetY()
Definition TGeoPolygon.h:55
Double_t Safety(const Double_t *point, Int_t &isegment) const
Compute minimum distance from POINT to any segment. Returns segment index.
void SetXY(Double_t *x, Double_t *y)
Set X/Y array pointer for the polygon and daughters.
Bool_t IsFinished() const
Definition TGeoPolygon.h:60
Double_t Area() const
Computes area of the polygon in [length^2].
Bool_t Contains(const Double_t *point) const
Check if a point given by X = point[0], Y = point[1] is inside the polygon.
Bool_t IsIllegalCheck() const
Check for illegal crossings between non-consecutive segments.
Int_t fNconvex
Definition TGeoPolygon.h:26
void GetVertices(Double_t *x, Double_t *y) const
Fill list of vertices into provided arrays.
Int_t GetNvert() const
Definition TGeoPolygon.h:52
void SetNextIndex(Int_t index=-1)
Sets the next polygone index.
Int_t * fInd
Definition TGeoPolygon.h:27
Double_t * fY
pointer to list of current X coordinates of vertices
Definition TGeoPolygon.h:30
Double_t * GetX()
Definition TGeoPolygon.h:54
Bool_t IsClockwise() const
Definition TGeoPolygon.h:58
void OutscribedConvex()
Compute indices for the outscribed convex polygon.
Double_t * fX
Definition TGeoPolygon.h:29
~TGeoPolygon() override
Destructor.
Int_t * fIndc
Definition TGeoPolygon.h:28
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.
void ConvexCheck()
Check polygon convexity.
TObjArray * fDaughters
pointer to list of current Y coordinates of vertices
Definition TGeoPolygon.h:31
TGeoPolygon(const TGeoPolygon &)=delete
void GetConvexVertices(Double_t *x, Double_t *y) const
Fill list of vertices of the convex outscribed polygon into provided arrays.
void FinishPolygon()
Decompose polygon in a convex outscribed part and a list of daughter polygons that have to be subtrac...
void SetConvex(Bool_t flag=kTRUE)
Definition TGeoPolygon.h:63
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:786
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
th1 Draw()