#ifndef ROOT_TPCON
#define ROOT_TPCON

//+SEQ,CopyRight,T=NOINCLUDE.

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TPCON                                                                  //
//                                                                        //
// PCON is a polycone. It has at least 9 parameters, the lower phi limit, //
// the range in phi, the number (at least two) of z planes where the      //
// radius is changing for each z boundary and the z coordinate, the       //
// minimum radius and the maximum radius.                                 //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TShape
//*KEEP,TShape.
#include "TShape.h"
//*KEND.
#endif


const Int_t kDiv = 20;               //default number of divisions


class TPCON : public TShape {

    private:
       Double_t   *fSiTab;     // Table of sin(fPhi1) .... sin(fPhil+fDphi1)
       Double_t   *fCoTab;     // Table of cos(fPhi1) .... cos(fPhil+fDphi1)

    protected:
        Float_t fPhi1;         // lower phi limit
        Float_t fDphi1;        // range in phi
        Int_t   fNz;           // number of z segments
        Float_t *fRmin;        // pointer to array of inside radiuses
        Float_t *fRmax;        // pointer to array of outside radiuses
        Float_t *fDz;          // pointer to array of half lengths in z
        Int_t   fNdiv;         // number of divisions
        virtual void    MakeTableOfCoSin();  // Create the table of the fSiTab; fCoTab
        virtual void    PaintGLPoints(Float_t *vertex);

    public:
        TPCON();
        TPCON(Text_t *name, Text_t *title, Text_t *material, Float_t phi1, Float_t dphi1, Int_t nz);
        virtual ~TPCON();

        virtual void    DefineSection(Int_t secNum, Float_t z, Float_t rmin, Float_t rmax);
        virtual Int_t   DistancetoPrimitive(Int_t px, Int_t py);
        virtual Int_t   GetNumberOfDivisions () const {if (fNdiv) return fNdiv; else return kDiv;}
        virtual Float_t GetPhi1()  {return fPhi1;}
        virtual Float_t GetDhi1()  {return fDphi1;}
        virtual Int_t   GetNz()    {return fNz;}
        virtual Float_t *GetRmin() {return fRmin;}
        virtual Float_t *GetRmax() {return fRmax;}
        virtual Float_t *GetDz()   {return fDz;}
        virtual Int_t   GetNdiv()  {return fNdiv;}
        virtual void    Paint(Option_t *option);
        virtual void    SetNumberOfDivisions (Int_t p);
        virtual void    SetPoints(Float_t *buff);
        virtual void    Sizeof3D() const;

        ClassDef(TPCON,1)  //PCON shape
};

#endif