00001 // @(#)root/eve:$Id: TEvePolygonSetProjected.h 37192 2010-12-02 15:54:26Z matevz $ 00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2007, 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_TEvePolygonSetProjected 00013 #define ROOT_TEvePolygonSetProjected 00014 00015 #include "TEveVector.h" 00016 #include "TEveShape.h" 00017 00018 class TBuffer3D; 00019 00020 class TEvePolygonSetProjected : public TEveShape, 00021 public TEveProjected 00022 { 00023 friend class TEvePolygonSetProjectedGL; 00024 friend class TEvePolygonSetProjectedEditor; 00025 00026 private: 00027 TEvePolygonSetProjected(const TEvePolygonSetProjected&); // Not implemented 00028 TEvePolygonSetProjected& operator=(const TEvePolygonSetProjected&); // Not implemented 00029 00030 protected: 00031 struct Polygon_t 00032 { 00033 Int_t fNPnts; // number of points 00034 Int_t* fPnts; // point indices 00035 00036 Polygon_t() : fNPnts(0), fPnts(0) {} 00037 virtual ~Polygon_t() { delete [] fPnts; fNPnts=0; fPnts=0; } 00038 00039 Polygon_t& operator=(const Polygon_t& x) 00040 { fNPnts = x.fNPnts; fPnts = x.fPnts; return *this; } 00041 00042 Int_t FindPoint(Int_t pi) 00043 { 00044 for (Int_t i=0; i<fNPnts; ++i) { 00045 if (fPnts[i] == pi) return i; 00046 } 00047 return -1; 00048 } 00049 }; 00050 00051 typedef std::list<Polygon_t> vpPolygon_t; 00052 typedef vpPolygon_t::iterator vpPolygon_i; 00053 typedef vpPolygon_t::const_iterator vpPolygon_ci; 00054 00055 private: 00056 TBuffer3D* fBuff; // buffer of projectable object 00057 00058 Bool_t IsFirstIdxHead(Int_t s0, Int_t s1); 00059 Float_t AddPolygon(std::list<Int_t, std::allocator<Int_t> >& pp, std::list<Polygon_t, std::allocator<Polygon_t> >& p); 00060 00061 Int_t* ProjectAndReducePoints(); 00062 Float_t MakePolygonsFromBP(Int_t* idxMap); 00063 Float_t MakePolygonsFromBS(Int_t* idxMap); 00064 00065 protected: 00066 vpPolygon_t fPols; // polygons 00067 vpPolygon_t fPolsBS; // polygons build from TBuffer3D segments 00068 vpPolygon_t fPolsBP; // polygons build from TBuffer3D polygons 00069 00070 Int_t fNPnts; // number of reduced and projected points 00071 TEveVector* fPnts; // reduced and projected points 00072 00073 virtual void SetDepthLocal(Float_t d); 00074 00075 Float_t PolygonSurfaceXY(const Polygon_t& poly) const; 00076 00077 public: 00078 TEvePolygonSetProjected(const char* n="TEvePolygonSetProjected", const char* t=""); 00079 virtual ~TEvePolygonSetProjected(); 00080 00081 virtual void ComputeBBox(); 00082 00083 virtual void SetProjection(TEveProjectionManager* mng, TEveProjectable* model); 00084 virtual void UpdateProjection(); 00085 virtual TEveElement* GetProjectedAsElement() { return this; } 00086 00087 void ProjectBuffer3D(); 00088 00089 virtual void DumpPolys() const; 00090 void DumpBuffer3D(); 00091 00092 ClassDef(TEvePolygonSetProjected,0); // Set of projected polygons with outline; typically produced from a TBuffer3D. 00093 00094 }; 00095 00096 #endif