Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REvePolygonSetProjected.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, 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 ROOT7_REvePolygonSetProjected
13 #define ROOT7_REvePolygonSetProjected
14 
15 #include <ROOT/REveVector.hxx>
16 #include <ROOT/REveShape.hxx>
17 
18 #include <vector>
19 
20 class TBuffer3D;
21 
22 namespace ROOT {
23 namespace Experimental {
24 
25 // =========================================================================
26 // REvePolygonSetProjected
27 // Set of projected polygons with outline; typically produced from a TBuffer3D.
28 // =========================================================================
29 
30 class REvePolygonSetProjected : public REveShape,
31  public REveProjected
32 {
33 private:
34  REvePolygonSetProjected(const REvePolygonSetProjected &); // Not implemented
35  REvePolygonSetProjected &operator=(const REvePolygonSetProjected &); // Not implemented
36 
37 protected:
38  struct Polygon_t {
39  std::vector<int> fPnts; // point indices
40 
41  Polygon_t() = default;
42  Polygon_t(std::vector<int> &&pnts) : fPnts(pnts){};
43  ~Polygon_t() = default;
44 
45  int NPoints() const { return (int)fPnts.size(); }
46 
47  int FindPoint(int pi)
48  {
49  auto dist = std::distance(fPnts.begin(), std::find(fPnts.begin(), fPnts.end(), pi));
50  return (dist >= (int) fPnts.size()) ? -1 : (int) dist;
51  }
52  };
53 
54  typedef std::list<Polygon_t> vpPolygon_t;
55 
56 private:
57  std::unique_ptr<TBuffer3D> fBuff; // buffer of projectable object
58 
59  Bool_t IsFirstIdxHead(Int_t s0, Int_t s1);
60  Float_t AddPolygon(std::list<Int_t> &pp, std::list<Polygon_t> &p);
61 
62  std::vector<Int_t> ProjectAndReducePoints();
63  Float_t MakePolygonsFromBP(std::vector<Int_t> &idxMap);
64  Float_t MakePolygonsFromBS(std::vector<Int_t> &idxMap);
65 
66 protected:
67  vpPolygon_t fPols; ///<! polygons
68  vpPolygon_t fPolsBS; ///<! polygons build from TBuffer3D segments
69  vpPolygon_t fPolsBP; ///<! polygons build from TBuffer3D polygons
70 
71  std::vector<REveVector> fPnts; ///<! reduced and projected points
72 
73  void SetDepthLocal(Float_t d) override;
74 
75  Float_t PolygonSurfaceXY(const Polygon_t &poly) const;
76 
77 public:
78  REvePolygonSetProjected(const std::string &n = "REvePolygonSetProjected", const std::string &t = "");
79  virtual ~REvePolygonSetProjected();
80 
81  void ComputeBBox() override;
82  // TClass* ProjectedClass() same as for REveShape
83 
84  void SetProjection(REveProjectionManager *mng, REveProjectable *model) override;
85  void UpdateProjection() override;
86  REveElement *GetProjectedAsElement() override { return this; }
87 
88  void ProjectBuffer3D();
89 
90  virtual void DumpPolys() const;
91  void DumpBuffer3D();
92 
93  Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
94  void BuildRenderData() override;
95 };
96 
97 } // namespace Experimental
98 } // namespace ROOT
99 
100 #endif