TGeoPolygon.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoPolygon.h 27466 2009-02-17 12:53:37Z brun $
00002 // Author: Mihaela Gheata   05/01/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGeoPolygon
00013 #define ROOT_TGeoPolygon
00014 
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018 
00019 #ifndef ROOT_TObjArray
00020 #include "TObjArray.h"
00021 #endif
00022 
00023 ////////////////////////////////////////////////////////////////////////////
00024 //                                                                        //
00025 // TGeoPolygon - An arbitrary polygon defined by vertices. The vertices   //
00026 //   have to be defined CLOCKWISE in the XY plane, making either a convex //
00027 //   or concave polygon. No test for malformed polygons is performed.     //
00028 //                                                                        //
00029 ////////////////////////////////////////////////////////////////////////////
00030 
00031 class TGeoPolygon : public TObject
00032 {
00033 public:
00034   enum {
00035       kGeoConvex        = BIT(9),
00036       kGeoFinishPolygon = BIT(10),
00037       kGeoACW           = BIT(11)
00038    };
00039 protected :
00040 // data members
00041    Int_t               fNvert;            // number of vertices (must be defined clockwise in XY plane)
00042    Int_t               fNconvex;          // number of points of the outscribed convex polygon 
00043    Int_t              *fInd;              //[fNvert] list of vertex indices
00044    Int_t              *fIndc;             //[fNconvex] indices of vertices of the outscribed convex polygon
00045    Double_t           *fX;                //! pointer to list of current X coordinates of vertices
00046    Double_t           *fY;                //! pointer to list of current Y coordinates of vertices
00047    TObjArray          *fDaughters;        // list of concave daughters
00048 private:
00049    void                ConvexCheck(); // force convexity checking
00050    Bool_t              IsSegConvex(Int_t i1, Int_t i2=-1) const;
00051    Bool_t              IsRightSided(Double_t *point, Int_t ind1, Int_t ind2) const;
00052    void                OutscribedConvex();
00053 public:
00054    // constructors
00055    TGeoPolygon();
00056    TGeoPolygon(Int_t nvert);
00057    // destructor
00058    virtual ~TGeoPolygon();
00059    // methods
00060    Double_t            Area() const;
00061    Bool_t              Contains(Double_t *point) const;
00062    void                FinishPolygon();
00063    Int_t               GetNvert() const {return fNvert;}
00064    Double_t           *GetX() {return fX;}
00065    Double_t           *GetY() {return fY;}
00066    Bool_t              IsClockwise() const {return !TObject::TestBit(kGeoACW);}
00067    Bool_t              IsConvex() const {return TObject::TestBit(kGeoConvex);}
00068    Bool_t              IsFinished() const {return TObject::TestBit(kGeoFinishPolygon);}
00069    Bool_t              IsIllegalCheck() const;
00070    Double_t            Safety(Double_t *point, Int_t &isegment) const;
00071    void                SetConvex(Bool_t flag=kTRUE) {TObject::SetBit(kGeoConvex,flag);}
00072    void                SetXY(Double_t *x, Double_t *y);   
00073    void                SetNextIndex(Int_t index=-1);
00074 
00075    ClassDef(TGeoPolygon, 2)         // class for handling arbitrary polygons
00076 };
00077 
00078 #endif
00079 

Generated on Tue Jul 5 14:12:19 2011 for ROOT_528-00b_version by  doxygen 1.5.1