Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEvePolygonSetProjected.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TEvePolygonSetProjected
13 #define ROOT_TEvePolygonSetProjected
14 
15 #include "TEveVector.h"
16 #include "TEveShape.h"
17 
18 class TBuffer3D;
19 
20 class TEvePolygonSetProjected : public TEveShape,
21  public TEveProjected
22 {
23  friend class TEvePolygonSetProjectedGL;
24  friend class TEvePolygonSetProjectedEditor;
25 
26 private:
27  TEvePolygonSetProjected(const TEvePolygonSetProjected&); // Not implemented
28  TEvePolygonSetProjected& operator=(const TEvePolygonSetProjected&); // Not implemented
29 
30 protected:
31  struct Polygon_t
32  {
33  Int_t fNPnts; // number of points
34  Int_t* fPnts; // point indices
35 
36  Polygon_t() : fNPnts(0), fPnts(0) {}
37  virtual ~Polygon_t() { delete [] fPnts; fNPnts=0; fPnts=0; }
38 
39  Polygon_t& operator=(const Polygon_t& x)
40  { fNPnts = x.fNPnts; fPnts = x.fPnts; return *this; }
41 
42  Int_t FindPoint(Int_t pi)
43  {
44  for (Int_t i=0; i<fNPnts; ++i) {
45  if (fPnts[i] == pi) return i;
46  }
47  return -1;
48  }
49  };
50 
51  typedef std::list<Polygon_t> vpPolygon_t;
52  typedef vpPolygon_t::iterator vpPolygon_i;
53  typedef vpPolygon_t::const_iterator vpPolygon_ci;
54 
55 private:
56  TBuffer3D* fBuff; // buffer of projectable object
57 
58  Bool_t IsFirstIdxHead(Int_t s0, Int_t s1);
59  Float_t AddPolygon(std::list<Int_t, std::allocator<Int_t> >& pp, std::list<Polygon_t, std::allocator<Polygon_t> >& p);
60 
61  Int_t* ProjectAndReducePoints();
62  Float_t MakePolygonsFromBP(Int_t* idxMap);
63  Float_t MakePolygonsFromBS(Int_t* idxMap);
64 
65 protected:
66  vpPolygon_t fPols; // polygons
67  vpPolygon_t fPolsBS; // polygons build from TBuffer3D segments
68  vpPolygon_t fPolsBP; // polygons build from TBuffer3D polygons
69 
70  Int_t fNPnts; // number of reduced and projected points
71  TEveVector* fPnts; // reduced and projected points
72 
73  virtual void SetDepthLocal(Float_t d);
74 
75  Float_t PolygonSurfaceXY(const Polygon_t& poly) const;
76 
77 public:
78  TEvePolygonSetProjected(const char* n="TEvePolygonSetProjected", const char* t="");
79  virtual ~TEvePolygonSetProjected();
80 
81  virtual void ComputeBBox();
82 
83  virtual void SetProjection(TEveProjectionManager* mng, TEveProjectable* model);
84  virtual void UpdateProjection();
85  virtual TEveElement* GetProjectedAsElement() { return this; }
86 
87  void ProjectBuffer3D();
88 
89  virtual void DumpPolys() const;
90  void DumpBuffer3D();
91 
92  ClassDef(TEvePolygonSetProjected,0); // Set of projected polygons with outline; typically produced from a TBuffer3D.
93 
94 };
95 
96 #endif