Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ViewFEMesh.hh
Go to the documentation of this file.
1// Some functionality for this class was copied/modified from ViewField.hh
2#ifndef G_VIEW_FE_MESH
3#define G_VIEW_FE_MESH
4
5#include <string>
6#ifndef __CINT__
7#include <map>
8#endif
9
10#include <TCanvas.h>
11#include <TMatrixD.h>
12#include <TArrayD.h>
13#include <TGaxis.h>
14#include <TPolyLine.h>
15#include <TPolyLine3D.h>
16#include <TString.h>
17#include <TH2D.h>
18
19#include "ViewDrift.hh"
20#include "ComponentFieldMap.hh"
21#include "ComponentCST.hh"
22
23namespace Garfield {
24
26
27 public:
28 // Constructor
29 ViewFEMesh();
30 // Destructor
32
33 TCanvas* GetCanvas();
34
35 void SetCanvas(TCanvas* c);
37
38 // Set area to be plotted
39 void SetArea();
40 void SetArea(double xmin, double ymin, double zmin, double xmax, double ymax,
41 double zmax);
42
43 // Projection plane
45 void SetPlane(double fx, double fy, double fz, double x0, double y0,
46 double z0);
47
48 // Axes
49 void SetXaxis(TGaxis* ax);
50 void SetYaxis(TGaxis* ay);
51 void SetXaxisTitle(const char* xtitle);
52 void SetYaxisTitle(const char* ytitle);
53 void EnableAxes() { drawAxes = true; }
54 void DisableAxes() { drawAxes = false; }
55
56 // Plot method to be called by user
57 bool Plot();
58
59 // Element fill switch; 2D only, set false for wireframe mesh
60 void SetFillMesh(bool f) { fillMesh = f; }
61
62 // Associate a color with each element material map ID;
63 // Uses ROOT color numberings
64 void SetColor(int matID, int colorID) { colorMap[matID] = colorID; }
65 void SetFillColor(int matID, int colorID) { colorMap_fill[matID] = colorID; }
66
67 // Set the optional associated ViewDrift
68 void SetViewDrift(ViewDrift* vd) { viewDrift = vd; }
69
70 // Show filled mesh elements
72 plotMeshBorders = true;
73 fillMesh = true;
74 }
75
76 // Debugging switch
77 void EnableDebugging() { debug = true; }
78 void DisableDebugging() { debug = false; }
79
80 // Create a default set of custom-made axes.
81 void CreateDefaultAxes();
82
83 // Disable a material so that its mesh cells are not drawn
84 void DisableMaterial(int materialID) { disabledMaterial[materialID] = true; }
85
86 private:
87 std::string className;
88 std::string label;
89
90 // Options
91 bool debug;
92 bool fillMesh;
93
94 // Canvas
95 TCanvas* canvas;
96 bool hasExternalCanvas;
97
98 // Viewing plane
99 double project[3][3];
100 double plane[4];
101
102 // Box dimensions
103 bool hasUserArea;
104 double xMin, yMin, zMin, xMax, yMax, zMax;
105
106 // The field map object
107 ComponentFieldMap* component;
108
109 // Optional associated ViewDrift object
110 ViewDrift* viewDrift;
111 bool plotMeshBorders;
112
113 // Axes
114 TGaxis* xaxis, *yaxis;
115 TH2D* axes;
116 bool drawAxes;
117
118 // The mesh, stored as a vector of TPolyLine(3D) objects
119 std::vector<TPolyLine*> mesh;
120 std::vector<TPolyLine*> driftLines;
121
122// The color map
123#ifndef __CINT__
124 std::map<int, int> colorMap;
125 std::map<int, int> colorMap_fill;
126
127 // Disabled materials -> not shown in the mesh view
128 std::map<int, bool> disabledMaterial;
129#endif
130 // Element plotting methods
131 void DrawElements();
132 void DrawCST(ComponentCST* componentCST);
133 bool InView(double x, double y);
134 bool LinesCrossed(double x1, double y1, double x2, double y2, double u1,
135 double v1, double u2, double v2, double& xc, double& yc);
136 bool OnLine(double x1, double y1, double x2, double y2, double u, double v);
137 void RemoveCrossings(std::vector<double>& x, std::vector<double>& y);
138 bool PlaneCut(double x1, double y1, double z1, double x2, double y2,
139 double z2, TMatrixD& xMat);
140 bool PlaneCoords(double x, double y, double z, const TMatrixD& projMat,
141 TMatrixD& xMat);
142 void ClipToView(std::vector<double>& px, std::vector<double>& py,
143 std::vector<double>& cx, std::vector<double>& cy);
144 bool IsInPolygon(double x, double y, std::vector<double>& px,
145 std::vector<double>& py, bool& edge);
146
147 // Plot method to be called by Plot() for CST cubic elements
148 // available are "xy", "yz" and "xz"
149};
150}
151#endif
void SetXaxisTitle(const char *xtitle)
Definition: ViewFEMesh.cc:212
void SetCanvas(TCanvas *c)
Definition: ViewFEMesh.cc:61
void SetComponent(ComponentFieldMap *comp)
Definition: ViewFEMesh.cc:50
void SetFillMeshWithBorders()
Definition: ViewFEMesh.hh:71
void SetViewDrift(ViewDrift *vd)
Definition: ViewFEMesh.hh:68
TCanvas * GetCanvas()
Definition: ViewFEMesh.cc:72
void SetFillColor(int matID, int colorID)
Definition: ViewFEMesh.hh:65
void DisableMaterial(int materialID)
Definition: ViewFEMesh.hh:84
void SetYaxisTitle(const char *ytitle)
Definition: ViewFEMesh.cc:217
void SetPlane(double fx, double fy, double fz, double x0, double y0, double z0)
Definition: ViewFEMesh.cc:145
void SetFillMesh(bool f)
Definition: ViewFEMesh.hh:60
void SetColor(int matID, int colorID)
Definition: ViewFEMesh.hh:64
void SetXaxis(TGaxis *ax)
Definition: ViewFEMesh.cc:206
void SetYaxis(TGaxis *ay)
Definition: ViewFEMesh.cc:209