File indexing completed on 2025-01-18 10:11:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGLIsoMesh
0013 #define ROOT_TGLIsoMesh
0014
0015 #include <vector>
0016
0017 #include "RtypesCore.h"
0018 #include "TAxis.h"
0019
0020 class TGLBoxCut;
0021
0022 namespace Rgl {
0023 namespace Mc {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 template<class V>
0038 class TIsoMesh {
0039 public:
0040 UInt_t AddVertex(const V *v)
0041 {
0042 const UInt_t index = UInt_t(fVerts.size() / 3);
0043 fVerts.push_back(v[0]);
0044 fVerts.push_back(v[1]);
0045 fVerts.push_back(v[2]);
0046
0047 return index;
0048 }
0049
0050 void AddNormal(const V *n)
0051 {
0052 fNorms.push_back(n[0]);
0053 fNorms.push_back(n[1]);
0054 fNorms.push_back(n[2]);
0055 }
0056
0057 UInt_t AddTriangle(const UInt_t *t)
0058 {
0059 const UInt_t index = UInt_t(fTris.size() / 3);
0060 fTris.push_back(t[0]);
0061 fTris.push_back(t[1]);
0062 fTris.push_back(t[2]);
0063
0064 return index;
0065 }
0066
0067 void Swap(TIsoMesh &rhs)
0068 {
0069 std::swap(fVerts, rhs.fVerts);
0070 std::swap(fNorms, rhs.fNorms);
0071 std::swap(fTris, rhs.fTris);
0072 }
0073
0074 void ClearMesh()
0075 {
0076 fVerts.clear();
0077 fNorms.clear();
0078 fTris.clear();
0079 }
0080
0081 std::vector<V> fVerts;
0082 std::vector<V> fNorms;
0083 std::vector<UInt_t> fTris;
0084 };
0085
0086
0087
0088
0089
0090 template<class V>
0091 class TGridGeometry {
0092 public:
0093 enum EVertexPosition{
0094 kBinCenter,
0095 kBinEdge
0096 };
0097
0098 TGridGeometry() : fMinX(0), fStepX(0),
0099 fMinY(0), fStepY(0),
0100 fMinZ(0), fStepZ(0),
0101 fXScaleInverted(1.),
0102 fYScaleInverted(1.),
0103 fZScaleInverted(1.)
0104 {
0105
0106 }
0107
0108 TGridGeometry(const TAxis *x, const TAxis *y, const TAxis *z,
0109 Double_t xs = 1., Double_t ys = 1., Double_t zs = 1.,
0110 EVertexPosition pos = kBinCenter)
0111 : fMinX(0), fStepX(0),
0112 fMinY(0), fStepY(0),
0113 fMinZ(0), fStepZ(0),
0114 fXScaleInverted(1.),
0115 fYScaleInverted(1.),
0116 fZScaleInverted(1.)
0117 {
0118
0119 if (pos == kBinCenter) {
0120 fMinX = V(x->GetBinCenter(x->GetFirst()));
0121 fStepX = V((x->GetBinCenter(x->GetLast()) - fMinX) / (x->GetNbins() - 1));
0122 fMinY = V(y->GetBinCenter(y->GetFirst()));
0123 fStepY = V((y->GetBinCenter(y->GetLast()) - fMinY) / (y->GetNbins() - 1));
0124 fMinZ = V(z->GetBinCenter(z->GetFirst()));
0125 fStepZ = V((z->GetBinCenter(z->GetLast()) - fMinZ) / (z->GetNbins() - 1));
0126
0127 fMinX *= xs, fStepX *= xs;
0128 fMinY *= ys, fStepY *= ys;
0129 fMinZ *= zs, fStepZ *= zs;
0130 } else if (pos == kBinEdge) {
0131 fMinX = V(x->GetBinLowEdge(x->GetFirst()));
0132 fStepX = V((x->GetBinUpEdge(x->GetLast()) - fMinX) / (x->GetNbins()));
0133 fMinY = V(y->GetBinLowEdge(y->GetFirst()));
0134 fStepY = V((y->GetBinUpEdge(y->GetLast()) - fMinY) / (y->GetNbins()));
0135 fMinZ = V(z->GetBinLowEdge(z->GetFirst()));
0136 fStepZ = V((z->GetBinUpEdge(z->GetLast()) - fMinZ) / (z->GetNbins()));
0137
0138 fMinX *= xs, fStepX *= xs;
0139 fMinY *= ys, fStepY *= ys;
0140 fMinZ *= zs, fStepZ *= zs;
0141 }
0142
0143 fXScaleInverted = 1. / xs;
0144 fYScaleInverted = 1. / ys;
0145 fZScaleInverted = 1. / zs;
0146 }
0147
0148 V fMinX;
0149 V fStepX;
0150
0151 V fMinY;
0152 V fStepY;
0153
0154 V fMinZ;
0155 V fStepZ;
0156
0157 V fXScaleInverted;
0158 V fYScaleInverted;
0159 V fZScaleInverted;
0160 };
0161
0162 }
0163
0164
0165 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
0166 const std::vector<UInt_t> &ts);
0167 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
0168 const std::vector<UInt_t> &ts);
0169
0170 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &fTS);
0171 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &fTS);
0172
0173 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
0174 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
0175 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
0176 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
0177
0178 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
0179 const TGLBoxCut &box);
0180 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
0181 const TGLBoxCut &box);
0182
0183 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
0184 const TGLBoxCut &box);
0185 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
0186 const TGLBoxCut &box);
0187
0188 void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
0189 const std::vector<UInt_t> &ts);
0190 void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
0191 const std::vector<UInt_t> &ts, const TGLBoxCut & box);
0192
0193 }
0194
0195 #endif