Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveGeoShape.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Author: Matevz Tadel 2007, 1018
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_REveGeoShape
13 #define ROOT7_REveGeoShape
14 
15 #include <ROOT/REveShape.hxx>
16 
17 class TGeoShape;
18 class TGeoHMatrix;
19 class TGeoCompositeShape;
20 class TBuffer3D;
21 
22 namespace ROOT {
23 namespace Experimental {
24 
25 class REveGeoShapeExtract;
26 
27 // ==========================================================================================
28 // REveGeoShape
29 // Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted
30 // TGeoShape's (without an active TGeoManager) and simplified geometries (needed for NLT projections).
31 // ==========================================================================================
32 
33 class REveGeoShape : public REveShape,
34  public REveProjectable
35 {
36 private:
37  REveGeoShape(const REveGeoShape &); // Not implemented
38  REveGeoShape &operator=(const REveGeoShape &); // Not implemented
39 
40 protected:
41  Int_t fNSegments{0};
42  TGeoShape *fShape{nullptr};
43  TGeoCompositeShape *fCompositeShape{nullptr}; //! Temporary holder (if passed shape is composite shape).
44 
45  static TGeoManager *fgGeoManager;
46 
47  static REveGeoShape *SubImportShapeExtract(REveGeoShapeExtract *gse, REveElement *parent);
48  REveGeoShapeExtract *DumpShapeTree(REveGeoShape *geon, REveGeoShapeExtract *parent = nullptr);
49 
50  TGeoShape *MakePolyShape();
51 
52 public:
53  REveGeoShape(const std::string &name = "REveGeoShape", const std::string &title = "");
54  virtual ~REveGeoShape();
55 
56  Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
57  void BuildRenderData() override;
58 
59  Int_t GetNSegments() const { return fNSegments; }
60  TGeoShape *GetShape() const { return fShape; }
61  void SetNSegments(Int_t s);
62  void SetShape(TGeoShape *s);
63 
64  void ComputeBBox() override;
65 
66  void SaveExtract(const char *file, const char *name);
67  void WriteExtract(const char *name);
68 
69  static REveGeoShape *ImportShapeExtract(REveGeoShapeExtract *gse, REveElement *parent = nullptr);
70 
71  // GeoProjectable
72  virtual std::unique_ptr<TBuffer3D> MakeBuffer3D();
73  TClass *ProjectedClass(const REveProjection *p) const override;
74 
75  static TGeoManager *GetGeoManager();
76  static TGeoHMatrix *GetGeoHMatrixIdentity();
77 };
78 
79 //------------------------------------------------------------------------------
80 
81 // ==========================================================================================
82 // REveGeoShapeProjected
83 // ==========================================================================================
84 
85 class REveGeoShapeProjected : public REveShape, public REveProjected {
86 private:
87  REveGeoShapeProjected(const REveGeoShapeProjected &); // Not implemented
88  REveGeoShapeProjected &operator=(const REveGeoShapeProjected &); // Not implemented
89 
90 protected:
91  std::unique_ptr<TBuffer3D> fBuff; //! 3d buffer
92 
93  void SetDepthLocal(Float_t d) override;
94 
95 public:
96  REveGeoShapeProjected();
97  virtual ~REveGeoShapeProjected();
98 
99  void SetProjection(REveProjectionManager *proj, REveProjectable *model) override;
100  void UpdateProjection() override;
101  REveElement *GetProjectedAsElement() override { return this; }
102 
103  void ComputeBBox() override;
104 };
105 
106 } // namespace Experimental
107 } // namespace ROOT
108 
109 #endif