Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:54

0001 // @(#)root/geom:$Id$
0002 // Author: Mihaela Gheata   05/01/04
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGeoPolygon
0013 #define ROOT_TGeoPolygon
0014 
0015 #include "TObject.h"
0016 
0017 class TObjArray;
0018 
0019 class TGeoPolygon : public TObject {
0020 public:
0021    enum { kGeoConvex = BIT(9), kGeoFinishPolygon = BIT(10), kGeoACW = BIT(11) };
0022 
0023 protected:
0024    // data members
0025    Int_t fNvert{0};                // number of vertices (must be defined clockwise in XY plane)
0026    Int_t fNconvex{0};              // number of points of the outscribed convex polygon
0027    Int_t *fInd{nullptr};           //[fNvert] list of vertex indices
0028    Int_t *fIndc{nullptr};          //[fNconvex] indices of vertices of the outscribed convex polygon
0029    Double_t *fX{nullptr};          //! pointer to list of current X coordinates of vertices
0030    Double_t *fY{nullptr};          //! pointer to list of current Y coordinates of vertices
0031    TObjArray *fDaughters{nullptr}; // list of concave daughters
0032 private:
0033    void ConvexCheck(); // force convexity checking
0034    Bool_t IsSegConvex(Int_t i1, Int_t i2 = -1) const;
0035    Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const;
0036    void OutscribedConvex();
0037 
0038    TGeoPolygon(const TGeoPolygon &) = delete;
0039    TGeoPolygon &operator=(const TGeoPolygon &) = delete;
0040 
0041 public:
0042    // constructors
0043    TGeoPolygon();
0044    TGeoPolygon(Int_t nvert);
0045    // destructor
0046    ~TGeoPolygon() override;
0047    // methods
0048    Double_t Area() const;
0049    Bool_t Contains(const Double_t *point) const;
0050    void Draw(Option_t *option = "") override;
0051    void FinishPolygon();
0052    Int_t GetNvert() const { return fNvert; }
0053    Int_t GetNconvex() const { return fNconvex; }
0054    Double_t *GetX() { return fX; }
0055    Double_t *GetY() { return fY; }
0056    void GetVertices(Double_t *x, Double_t *y) const;
0057    void GetConvexVertices(Double_t *x, Double_t *y) const;
0058    Bool_t IsClockwise() const { return !TObject::TestBit(kGeoACW); }
0059    Bool_t IsConvex() const { return TObject::TestBit(kGeoConvex); }
0060    Bool_t IsFinished() const { return TObject::TestBit(kGeoFinishPolygon); }
0061    Bool_t IsIllegalCheck() const;
0062    Double_t Safety(const Double_t *point, Int_t &isegment) const;
0063    void SetConvex(Bool_t flag = kTRUE) { TObject::SetBit(kGeoConvex, flag); }
0064    void SetXY(Double_t *x, Double_t *y);
0065    void SetNextIndex(Int_t index = -1);
0066 
0067    ClassDefOverride(TGeoPolygon, 2) // class for handling arbitrary polygons
0068 };
0069 
0070 #endif