00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGLIsoMesh
00013 #define ROOT_TGLIsoMesh
00014
00015 #include <vector>
00016
00017 #ifndef ROOT_Rtypes
00018 #include "Rtypes.h"
00019 #endif
00020 #ifndef ROOT_TAxis
00021 #include "TAxis.h"
00022 #endif
00023
00024 class TGLBoxCut;
00025
00026 namespace Rgl {
00027 namespace Mc {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 template<class V>
00042 class TIsoMesh {
00043 public:
00044 UInt_t AddVertex(const V *v)
00045 {
00046 const UInt_t index = UInt_t(fVerts.size() / 3);
00047 fVerts.push_back(v[0]);
00048 fVerts.push_back(v[1]);
00049 fVerts.push_back(v[2]);
00050
00051 return index;
00052 }
00053
00054 void AddNormal(const V *n)
00055 {
00056 fNorms.push_back(n[0]);
00057 fNorms.push_back(n[1]);
00058 fNorms.push_back(n[2]);
00059 }
00060
00061 UInt_t AddTriangle(const UInt_t *t)
00062 {
00063 const UInt_t index = UInt_t(fTris.size() / 3);
00064 fTris.push_back(t[0]);
00065 fTris.push_back(t[1]);
00066 fTris.push_back(t[2]);
00067
00068 return index;
00069 }
00070
00071 void Swap(TIsoMesh &rhs)
00072 {
00073 std::swap(fVerts, rhs.fVerts);
00074 std::swap(fNorms, rhs.fNorms);
00075 std::swap(fTris, rhs.fTris);
00076 }
00077
00078 void ClearMesh()
00079 {
00080 fVerts.clear();
00081 fNorms.clear();
00082 fTris.clear();
00083 }
00084
00085 std::vector<V> fVerts;
00086 std::vector<V> fNorms;
00087 std::vector<UInt_t> fTris;
00088 };
00089
00090
00091
00092
00093
00094 template<class V>
00095 class TGridGeometry {
00096 public:
00097 enum EVertexPosition{
00098 kBinCenter,
00099 kBinEdge
00100 };
00101
00102 TGridGeometry() : fMinX(0), fStepX(0),
00103 fMinY(0), fStepY(0),
00104 fMinZ(0), fStepZ(0),
00105 fXScaleInverted(1.),
00106 fYScaleInverted(1.),
00107 fZScaleInverted(1.)
00108 {
00109
00110 }
00111
00112 TGridGeometry(const TAxis *x, const TAxis *y, const TAxis *z,
00113 Double_t xs = 1., Double_t ys = 1., Double_t zs = 1.,
00114 EVertexPosition pos = kBinCenter)
00115 : fMinX(0), fStepX(0),
00116 fMinY(0), fStepY(0),
00117 fMinZ(0), fStepZ(0),
00118 fXScaleInverted(1.),
00119 fYScaleInverted(1.),
00120 fZScaleInverted(1.)
00121 {
00122
00123 if (pos == kBinCenter) {
00124 fMinX = V(x->GetBinCenter(x->GetFirst()));
00125 fStepX = V((x->GetBinCenter(x->GetLast()) - fMinX) / (x->GetNbins() - 1));
00126 fMinY = V(y->GetBinCenter(y->GetFirst()));
00127 fStepY = V((y->GetBinCenter(y->GetLast()) - fMinY) / (y->GetNbins() - 1));
00128 fMinZ = V(z->GetBinCenter(z->GetFirst()));
00129 fStepZ = V((z->GetBinCenter(z->GetLast()) - fMinZ) / (z->GetNbins() - 1));
00130
00131 fMinX *= xs, fStepX *= xs;
00132 fMinY *= ys, fStepY *= ys;
00133 fMinZ *= zs, fStepZ *= zs;
00134 } else if (pos == kBinEdge) {
00135 fMinX = V(x->GetBinLowEdge(x->GetFirst()));
00136 fStepX = V((x->GetBinUpEdge(x->GetLast()) - fMinX) / (x->GetNbins()));
00137 fMinY = V(y->GetBinLowEdge(y->GetFirst()));
00138 fStepY = V((y->GetBinUpEdge(y->GetLast()) - fMinY) / (y->GetNbins()));
00139 fMinZ = V(z->GetBinLowEdge(z->GetFirst()));
00140 fStepZ = V((z->GetBinUpEdge(z->GetLast()) - fMinZ) / (z->GetNbins()));
00141
00142 fMinX *= xs, fStepX *= xs;
00143 fMinY *= ys, fStepY *= ys;
00144 fMinZ *= zs, fStepZ *= zs;
00145 }
00146
00147 fXScaleInverted = 1. / xs;
00148 fYScaleInverted = 1. / ys;
00149 fZScaleInverted = 1. / zs;
00150 }
00151
00152 V fMinX;
00153 V fStepX;
00154
00155 V fMinY;
00156 V fStepY;
00157
00158 V fMinZ;
00159 V fStepZ;
00160
00161 V fXScaleInverted;
00162 V fYScaleInverted;
00163 V fZScaleInverted;
00164 };
00165
00166 }
00167
00168
00169 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
00170 const std::vector<UInt_t> &ts);
00171 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
00172 const std::vector<UInt_t> &ts);
00173
00174 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &fTS);
00175 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &fTS);
00176
00177 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<Float_t> &ns,
00178 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
00179 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
00180 const std::vector<UInt_t> &ts, const TGLBoxCut &box);
00181
00182 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
00183 const TGLBoxCut &box);
00184 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
00185 const TGLBoxCut &box);
00186
00187 void DrawMesh(const std::vector<Double_t> &vs, const std::vector<UInt_t> &ts,
00188 const TGLBoxCut &box);
00189 void DrawMesh(const std::vector<Float_t> &vs, const std::vector<UInt_t> &ts,
00190 const TGLBoxCut &box);
00191
00192 void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
00193 const std::vector<UInt_t> &ts);
00194 void DrawMapleMesh(const std::vector<Double_t> &vs, const std::vector<Double_t> &ns,
00195 const std::vector<UInt_t> &ts, const TGLBoxCut & box);
00196
00197 }
00198
00199 #endif