Logo ROOT   6.21/01
Reference Guide
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 
31  public REveProjected
32 {
33 private:
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 
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
Float_t MakePolygonsFromBP(std::vector< Int_t > &idxMap)
Build polygons from list of buffer polygons.
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
void DumpBuffer3D()
Dump information about currently projected buffer.
virtual void DumpPolys() const
Dump information about built polygons.
Float_t MakePolygonsFromBS(std::vector< Int_t > &idxMap)
Build polygons from the set of buffer segments.
Returns the available number of logical cores.
Definition: StringConv.hxx:21
vpPolygon_t fPolsBP
! polygons build from TBuffer3D polygons
float Float_t
Definition: RtypesCore.h:53
#define s0(x)
Definition: RSha256.hxx:90
void ComputeBBox() override
Override of virtual method from TAttBBox.
std::vector< REveVector > fPnts
! reduced and projected points
REveElement * GetProjectedAsElement() override
Returns this projected dynamic-casted to REveElement.
Bool_t IsFirstIdxHead(Int_t s0, Int_t s1)
Compare the two segments and check if the first index of first segment is starting.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Float_t PolygonSurfaceXY(const Polygon_t &poly) const
Calculate XY surface of a polygon.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Fill core part of JSON representation.
void SetProjection(REveProjectionManager *mng, REveProjectable *model) override
This is virtual method from base-class REveProjected.
REvePolygonSetProjected(const REvePolygonSetProjected &)=delete
void UpdateProjection() override
This is virtual method from base-class REveProjected.
vpPolygon_t fPolsBS
! polygons build from TBuffer3D segments
REveProjectionManager Manager class for steering of projections and managing projected objects...
Generic 3D primitive description class.
Definition: TBuffer3D.h:17
#define s1(x)
Definition: RSha256.hxx:91
void BuildRenderData() override
Crates representation for rendering.
#define d(i)
Definition: RSha256.hxx:102
void SetDepthLocal(Float_t d) override
Set depth (z-coordinate) of the projected points.
std::vector< Int_t > ProjectAndReducePoints()
Project and reduce buffer points.
static constexpr double pi
REvePolygonSetProjected & operator=(const REvePolygonSetProjected &)=delete
const Int_t n
Definition: legend1.C:16
Float_t AddPolygon(std::list< Int_t > &pp, std::list< Polygon_t > &p)
Check if polygon has dimensions above REveProjection::fgEps and add it to a list if it is not a dupli...