Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveGeoPolyShape.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Author: Matevz Tadel 2007, 2018
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_REveGeoPolyShape
13 #define ROOT7_REveGeoPolyShape
14 
15 #include "TGeoBBox.h"
16 
17 #include <vector>
18 
19 class TBuffer3D;
20 class TGeoCompositeShape;
21 class TGeoShape;
22 
23 namespace ROOT {
24 namespace Experimental {
25 
26 class REveRenderData;
27 
28 class REveGeoPolyShape : public TGeoBBox
29 {
30 private:
31  REveGeoPolyShape(const REveGeoPolyShape&); // Not implemented
32  REveGeoPolyShape& operator=(const REveGeoPolyShape&); // Not implemented
33 
34 protected:
35  std::vector<Double_t> fVertices;
36  std::vector<Double_t> fNormals;
37  std::vector<Int_t> fPolyDesc;
38  Int_t fNbPols{0};
39 
40  virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const;
41 
42  void SetFromBuff3D(const TBuffer3D &buffer);
43 
44  Int_t CheckPoints(const Int_t *source, Int_t *dest) const;
45 
46  static Bool_t Eq(const Double_t *p1, const Double_t *p2);
47 
48  struct Edge_t
49  {
50  Int_t fI, fJ;
51  Edge_t(Int_t i, Int_t j)
52  {
53  if (i <= j) { fI = i; fJ = j; }
54  else { fI = j; fJ = i; }
55  }
56 
57  bool operator<(const Edge_t& e) const
58  {
59  if (fI == e.fI) return fJ < e.fJ;
60  else return fI < e.fI;
61  }
62  };
63 
64  static Bool_t fgAutoEnforceTriangles;
65  static Bool_t fgAutoCalculateNormals;
66 
67 public:
68  REveGeoPolyShape() = default;
69 
70  virtual ~REveGeoPolyShape() = default;
71 
72  Int_t GetNumFaces() const { return fNbPols; }
73 
74  void FillRenderData(REveRenderData &rd);
75 
76  void BuildFromComposite(TGeoCompositeShape *cshp, Int_t n_seg = 60);
77  void BuildFromShape(TGeoShape *shape, Int_t n_seg = 60);
78 
79  void EnforceTriangles();
80  void CalculateNormals();
81 
82  virtual const TBuffer3D& GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
83  virtual TBuffer3D *MakeBuffer3D() const;
84 
85  static void SetAutoEnforceTriangles(Bool_t f);
86  static Bool_t GetAutoEnforceTriangles();
87  static void SetAutoCalculateNormals(Bool_t f);
88  static Bool_t GetAutoCalculateNormals();
89 
90  ClassDef(REveGeoPolyShape, 1); // A shape with arbitrary tesselation for visualization of CSG shapes.
91 };
92 
93 }}
94 
95 #endif