ROOT logo
ROOT » GEOM » GEOM » TGeoPolygon

class TGeoPolygon: public TObject

 TGeoPolygon - Arbitrary polygon class


 A polygon is a 2D shape defined by vertices in the XY plane. It is used by
 TGeoXtru class for computing Contains() and Safety(). Only the pointers to
 the actual lists of XY values are used - these are not owned by the class.

 To check if a point in XY plane is contained by a polygon, this is split
 into an outscribed convex polygon and the remaining polygons of its subtracton
 from the outscribed one. A point is INSIDE if it is
 contained by the outscribed polygon but NOT by the remaining ones. Since these
 can also be arbitrary polygons at their turn, a tree structure is formed:

  P = Pconvex - (Pconvex-P)           where (-) means 'subtraction'
  Pconvex-P = P1 + P2 + ...           where (+) means 'union'

  *Note that P1, P2, ... do not intersect each other and they are defined
   by subsets of the list of vertices of P. They can be split in the same
   way as P*

 Therefore, if C(P) represents the Boolean : 'does P contains a given point?',
 then:

 C(P) = C(Pconvex) .and. not(C(P1) | C(P2) | ...)

 For creating a polygon without TGeoXtru class, one has to call the constructor
 TGeoPolygon(nvert) and then SetXY(Double_t *x, Double_t *y) providing the
 arrays of X and Y vertex positions (defined clockwise) that have to 'live' longer
 than the polygon they will describe. This complication is due to efficiency reasons.
 At the end one has to call the FinishPolygon() method.

Function Members (Methods)

public:
TGeoPolygon()
TGeoPolygon(Int_t nvert)
TGeoPolygon(const TGeoPolygon&)
virtual~TGeoPolygon()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
Double_tArea() const
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
Bool_tContains(const Double_t* point) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidDraw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
voidFinishPolygon()
voidGetConvexVertices(Double_t* x, Double_t* y) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
Int_tGetNconvex() const
Int_tGetNvert() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
voidGetVertices(Double_t* x, Double_t* y) const
Double_t*GetX()
Double_t*GetY()
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
Bool_tIsClockwise() const
Bool_tIsConvex() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
Bool_tIsFinished() const
virtual Bool_tTObject::IsFolder() const
Bool_tIsIllegalCheck() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TGeoPolygon&operator=(const TGeoPolygon&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
Double_tSafety(const Double_t* point, Int_t& isegment) const
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
voidSetConvex(Bool_t flag = kTRUE)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetNextIndex(Int_t index = -1)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
voidSetXY(Double_t* x, Double_t* y)
virtual voidShowMembers(TMemberInspector&)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
voidConvexCheck()
Bool_tIsRightSided(const Double_t* point, Int_t ind1, Int_t ind2) const
Bool_tIsSegConvex(Int_t i1, Int_t i2 = -1) const
voidOutscribedConvex()

Data Members

public:
enum { kGeoConvex
kGeoFinishPolygon
kGeoACW
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TObjArray*fDaughterslist of concave daughters
Int_t*fInd[fNvert] list of vertex indices
Int_t*fIndc[fNconvex] indices of vertices of the outscribed convex polygon
Int_tfNconvexnumber of points of the outscribed convex polygon
Int_tfNvertnumber of vertices (must be defined clockwise in XY plane)
Double_t*fX! pointer to list of current X coordinates of vertices
Double_t*fY! pointer to list of current Y coordinates of vertices

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TGeoPolygon()
 Dummy constructor.
TGeoPolygon(Int_t nvert)
 Default constructor.
~TGeoPolygon()
 Destructor
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.
void ConvexCheck()
 Check polygon convexity.
void Draw(Option_t* option = "")
 Draw the polygon.
void FinishPolygon()
 Decompose polygon in a convex outscribed part and a list of daughter
 polygons that have to be substracted to get the actual one.
void GetVertices(Double_t* x, Double_t* y) const
 Fill list of vertices into provided arrays.
void GetConvexVertices(Double_t* x, Double_t* y) const
 Fill list of vertices of the convex outscribed polygon into provided arrays.
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.
Bool_t IsSegConvex(Int_t i1, Int_t i2 = -1) const
 Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.
Bool_t IsIllegalCheck() const
 Check for illegal crossings between non-consecutive segments
void OutscribedConvex()
 Compute indices for the outscribed convex polygon.
Double_t Safety(const Double_t* point, Int_t& isegment) const
 Compute minimum distance from POINT to any segment. Returns segment index.
void SetNextIndex(Int_t index = -1)
 Sets the next polygone index. If index<0 sets all indices consecutive
 in increasing order.
void SetXY(Double_t* x, Double_t* y)
 Set X/Y array pointer for the polygon and daughters.
TGeoPolygon()
 constructors
Int_t GetNvert() const
{return fNvert;}
Int_t GetNconvex() const
{return fNconvex;}
Double_t * GetX()
{return fX;}
Double_t * GetY()
{return fY;}
Bool_t IsClockwise() const
{return !TObject::TestBit(kGeoACW);}
Bool_t IsConvex() const
Bool_t IsFinished() const
void SetConvex(Bool_t flag = kTRUE)