EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicCompositeShape.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicCompositeShape.h
1 //
2 // AYK (ayk@bnl.gov), 2014/03/11; revamped in Oct'2017;
3 //
4 // EicRoot CompositeShape ROOT shape; basically TGeoCompositeShape with
5 // graphics buffer handling replaced by input from STL representation of
6 // the object during half-space cut manipulation routines;
7 //
8 
9 #include <stdlib.h>
10 
11 #include <TGeoCompositeShape.h>
12 
13 class TopoDS_Shape;
14 
15 #ifndef _EIC_COMPOSITE_SHAPE_
16 #define _EIC_COMPOSITE_SHAPE_
17 
18 // Well, do not want to depend on how TBuffer3D is arranged, so do not use TBuffer3D as
19 // a base class; it looks like TBuffer3D constructor has Init() call which resets everything
20 // to a virgin state; even if this observation is wrong, declare a separate class here
21 // where mimic TBuffer3D functionality in the required part (data storage);
22 class EicBuffer3D: public TObject {
23  friend class EicCompositeShape;
24 
25  public:
26  EicBuffer3D(): fNbPnts(0), fNbSegs(0), fNbPols(0), fPnts(0), fSegs(0), fPols(0) {};
28 
29  UInt_t NbPnts() { return fNbPnts;};
30  UInt_t NbSegs() { return fNbSegs;};
31  UInt_t NbPols() { return fNbPols;};
32 
33  private:
34  // Well, I could perhaps save just an OpenCascade-created STL binary buffer
35  // here; this would require parsing (and perhaps healing) this buffer every time
36  // when "eve" started; prefer to store parsed data arrays right away here;
38 
39  Double_t xMin, yMin, zMin, xMax, yMax, zMax; // limits defining bounding box
40 
41  // NB: format here is different compared to TBuffer3D variables (triangular
42  // facets only; color is not stored);
43  Double_t *fPnts; //[fPntsCapacity] x0, y0, z0, x1, y1, z1, ..... ..... ....
44  Int_t *fSegs; //[fSegsCapacity] p0, q0, p1, q1, ..... ..... ....
45  Int_t *fPols; //[fPolsCapacity] s0, t0, u0, s1, t1, u1, ..... ..... ....
46 
47  ClassDef(EicBuffer3D,9)
48 };
49 
50 class EicCompositeShape: public TGeoCompositeShape {
51  public:
52  EicCompositeShape(): TGeoCompositeShape(), mLocalBuffer3D(0), mSolid(0) {};
53  EicCompositeShape(const char* name, const char* expression, const TopoDS_Shape *solid):
54  TGeoCompositeShape(name, expression) {
56  mSolid = solid;
57  };
59 
60  // Leave only those methods, which I see called; in fact may remove them as
61  // weel, since they simplay call the base class methods;
62  Double_t Capacity() const { return TGeoCompositeShape::Capacity(); };
63  void ClearThreadData() const { TGeoCompositeShape::ClearThreadData(); };
64  TGeoBoolNode *GetBoolNode() const { return TGeoCompositeShape::GetBoolNode(); };
65  void GetMeshNumbers(Int_t& nvert, Int_t& nsegs, Int_t& npols) const {
66  TGeoCompositeShape::GetMeshNumbers(nvert, nsegs, npols);
67  };
68  Int_t GetNmeshVertices() const { return TGeoCompositeShape::GetNmeshVertices(); };
69  Bool_t GetPointsOnSegments(Int_t iq, Double_t* dq) const {
70  return TGeoCompositeShape::GetPointsOnSegments(iq, dq);
71  };
72  Bool_t IsComposite() const { return TGeoCompositeShape::IsComposite(); };
73  void SetPoints(Double_t* points) const { TGeoCompositeShape::SetPoints(points); };
74 
75  // Well, so these are THE ESSENTIAL CALLS, which replace the original
76  // TGeoCompositeShape functionality;
77  Bool_t PaintComposite(Option_t* option = "") const;
78  void FillBuffer3D(TBuffer3D & buffer, Int_t reqSections, Bool_t localFrame) const;
79  const TBuffer3D &GetBuffer3D(Int_t reqSections, Bool_t localFrame) const;
80 
81  // This guy is called from EicCadFile::DumpAsRootSolid() right after creating the
82  // EicCompositeShape instance;
83  int LocalFillBuffer3D(double stl_quality_coefficient);
84 
85  // THINK: well, should not I in fact replace TGeoCompositeShape SetPoints() and
86  // SetSegsAndPols() calls?;
87  void LocalSetPoints(Double_t *points) const;
88  void LocalSetSegsAndPols(TBuffer3D &buff) const;
89 
90  private:
92  const TopoDS_Shape *mSolid;
93 
94  ClassDef(EicCompositeShape,8)
95 };
96 
97 #endif
98