library: libGeom
#include "TGeoPolygon.h"

TGeoPolygon


class description - source file - inheritance tree (.pdf)

class TGeoPolygon : public TObject

Inheritance Chart:
TObject
<-
TGeoPolygon
    private:
void ConvexCheck() Bool_t IsRightSided(Double_t* point, Int_t ind1, Int_t ind2) const Bool_t IsSegConvex(Int_t i1, Int_t i2 = -1) const void OutscribedConvex() public:
TGeoPolygon() TGeoPolygon(Int_t nvert) TGeoPolygon(const TGeoPolygon&) virtual ~TGeoPolygon() static TClass* Class() Bool_t Contains(Double_t* point) const void FinishPolygon() Int_t GetNvert() const Double_t* GetX() Double_t* GetY() virtual TClass* IsA() const Bool_t IsConvex() const Bool_t IsFinished() const TGeoPolygon& operator=(const TGeoPolygon&) Double_t Safety(Double_t* point, Int_t& isegment) const void SetConvex(Bool_t flag = kTRUE) void SetNextIndex(Int_t index = -1) void SetXY(Double_t* x, Double_t* y) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members


    protected:
Int_t fNvert number of vertices (must be defined clockwise in XY plane) Int_t fNconvex number of points of the outscribed convex polygon Int_t* fInd [fNvert] list of vertex indices Int_t* fIndc [fNconvex] indices of vertices of the outscribed convex polygon Double_t* fX ! pointer to list of current X coordinates of vertices Double_t* fY ! pointer to list of current Y coordinates of vertices TObjArray* fDaughters list of concave daughters public:
static const enum TGeoPolygon:: kGeoConvex static const enum TGeoPolygon:: kGeoFinishPolygon

Class Description

 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 splitted
 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 splitted 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.

TGeoPolygon()
 Dummy constructor.

TGeoPolygon(Int_t nvert)
 Default constructor.

~TGeoPolygon()
 Destructor

Bool_t Contains(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 FinishPolygon()

Bool_t IsRightSided(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) const
 Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.

void OutscribedConvex()
 Compute indices for the outscribed convex polygon.

Double_t Safety(Double_t *point, Int_t &isegment) const
 Compute minimum distance from POINT to any segment. Returns segment index.

void SetNextIndex(Int_t index)
 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.



Inline Functions


               Int_t GetNvert() const
           Double_t* GetX()
           Double_t* GetY()
              Bool_t IsConvex() const
              Bool_t IsFinished() const
                void SetConvex(Bool_t flag = kTRUE)
             TClass* Class()
             TClass* IsA() const
                void ShowMembers(TMemberInspector& insp, char* parent)
                void Streamer(TBuffer& b)
                void StreamerNVirtual(TBuffer& b)
         TGeoPolygon TGeoPolygon(const TGeoPolygon&)
        TGeoPolygon& operator=(const TGeoPolygon&)


Author: Mihaela Gheata 5/01/04
Last update: root/geom:$Name: $:$Id: TGeoPolygon.cxx,v 1.4 2005/05/17 12:00:23 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.