Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ViewFEMesh Class Reference

Draw the mesh of a field-map component. More...

#include <ViewFEMesh.hh>

Inheritance diagram for Garfield::ViewFEMesh:
Garfield::ViewBase

Public Member Functions

 ViewFEMesh ()
 Default constructor.
 ViewFEMesh (Component *cmp)
 Constructor.
 ~ViewFEMesh ()
 Destructor.
void SetComponent (Component *cmp)
 Set the component from which to retrieve the mesh and field.
void SetPlane (const double fx, const double fy, const double fz, const double x0, const double y0, const double z0) override
 Set the projection (viewing plane), if applicable.
void SetPlane (const double fx, const double fy, const double fz, const double x0, const double y0, const double z0, const double hx, const double hy, const double hz) override
 Set the projection plane specifying a hint for the in-plane x axis.
void SetXaxis (TGaxis *ax)
void SetYaxis (TGaxis *ay)
void SetXaxisTitle (const std::string &xtitle)
void SetYaxisTitle (const std::string &ytitle)
void EnableAxes ()
void DisableAxes ()
bool Plot (const bool twod=true, const bool outline=false)
 Plot method to be called by user.
void SetFillMesh (const bool f)
 Element fill switch; 2D only, set false for wireframe mesh.
void SetDrawViewRegion (bool do_draw)
 Display intersection of projection plane with viewing area.
bool GetDrawViewRegion (void) const
void SetColor (int matID, int colorID)
 Associate a color with each element material map ID.
void SetColors (const std::map< int, int > &colors)
void SetFillColor (int matID, int colorID)
void SetFillColors (const std::map< int, int > &colors)
void SetViewDrift (ViewDrift *vd)
 Set the optional associated ViewDrift.
void SetFillMeshWithBorders ()
 Show filled mesh elements.
void CreateDefaultAxes ()
 Create a default set of custom-made axes.
void DisableMaterial (int materialID)
 Disable a material so that its mesh cells are not drawn.
Public Member Functions inherited from Garfield::ViewBase
 ViewBase ()=delete
 Default constructor.
 ViewBase (const std::string &name)
 Constructor.
virtual ~ViewBase ()=default
 Destructor.
void SetCanvas (TPad *pad)
 Set the canvas to be painted on.
void SetCanvas ()
 Unset an external canvas.
TPad * GetCanvas ()
 Retrieve the canvas.
void SetArea (const double xmin, const double ymin, const double xmax, const double ymax)
 Set the x- and y-axis limits (in local coordinates of the current viewing plane, if applicable).
virtual void SetArea (const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
 Set a bounding box (if applicable).
void SetArea ()
 Use default x- and y-axis limits (based on the bounding box of the sensor/component, if applicable).
void Rotate (const double angle)
 Rotate the viewing plane (angle in radian).
void SetPlaneXY ()
 Set the viewing plane to x-y.
void SetPlaneXZ ()
 Set the viewing plane to x-z.
void SetPlaneYZ ()
 Set the viewing plane to y-z.
void SetPlaneZX ()
 Set the viewing plane to z-x.
void SetPlaneZY ()
 Set the viewing plane to z-y.
void EnableDebugging (const bool on=true)
 Switch on/off debugging output.

Private Types

typedef std::vector< size_t > Facet

Private Member Functions

void DrawElements2d ()
void DrawElements3d ()
void DrawCST (ComponentCST *componentCST)
void DrawBorders2d ()
void DrawBorders3d ()
void AddFacets (const size_t i, const std::vector< std::vector< Facet > > &elementFacets, const std::map< Facet, std::vector< size_t > > &facetElements, std::vector< Facet > &facets, std::vector< bool > &done) const
bool FacetSign (const Facet &f, const size_t element) const
void DrawDriftLines2d ()
void DrawDriftLines3d ()
bool GetPlotLimits ()
bool InView (const double x, const double y) const
 Return true if the specified point is in the view region.
bool LinesCrossed (double x1, double y1, double x2, double y2, double u1, double v1, double u2, double v2, double &xc, double &yc) const
bool IntersectPlaneArea (double &xmin, double &ymin, double &xmax, double &ymax)
bool OnLine (double x1, double y1, double x2, double y2, double u, double v) const
void RemoveCrossings (std::vector< double > &x, std::vector< double > &y)
bool PlaneCut (double x1, double y1, double z1, double x2, double y2, double z2, TMatrixD &xMat)
void ClipToView (std::vector< double > &px, std::vector< double > &py, std::vector< double > &cx, std::vector< double > &cy)
bool IsInPolygon (double x, double y, const std::vector< double > &px, const std::vector< double > &py, bool &edge) const
void Reset ()

Private Attributes

bool m_fillMesh = false
bool m_drawViewRegion = false
std::vector< double > m_viewRegionX
std::vector< double > m_viewRegionY
Component * m_cmp = nullptr
ViewDriftm_viewDrift = nullptr
bool m_plotMeshBorders = false
TGaxis * m_xaxis = nullptr
TGaxis * m_yaxis = nullptr
std::string m_xaxisTitle = ""
std::string m_yaxisTitle = ""
bool m_drawAxes = false
std::map< int, int > m_colorMap
std::map< int, int > m_colorMap_fill
std::map< int, bool > m_disabledMaterial
std::vector< TGeoVolume * > m_volumes
std::vector< TGeoMedium * > m_media
std::unique_ptr< TGeoManager > m_geoManager

Additional Inherited Members

Static Public Member Functions inherited from Garfield::ViewBase
static std::string FindUnusedFunctionName (const std::string &s)
 Find an unused function name.
static std::string FindUnusedHistogramName (const std::string &s)
 Find an unused histogram name.
static std::string FindUnusedCanvasName (const std::string &s)
 Find an unused canvas name.
Protected Member Functions inherited from Garfield::ViewBase
void UpdateProjectionMatrix ()
template<typename T>
void ToPlane (const T x, const T y, const T z, T &xp, T &yp) const
template<typename T>
bool InBox (const std::array< T, 3 > &x) const
void Clip (const std::array< float, 3 > &x0, const std::array< float, 3 > &x1, std::array< float, 3 > &xc) const
void DrawLine (const std::vector< std::array< float, 3 > > &xl, const short col, const short lw)
std::string LabelX ()
std::string LabelY ()
std::string PlaneDescription ()
bool PlotLimits (Sensor *sensor, double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimits (Component *cmp, double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimitsFromUserBox (double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimits (std::array< double, 3 > &bbmin, std::array< double, 3 > &bbmax, double &xmin, double &ymin, double &xmax, double &ymax) const
Static Protected Member Functions inherited from Garfield::ViewBase
static bool RangeSet (TVirtualPad *)
static void SetRange (TVirtualPad *pad, const double x0, const double y0, const double x1, const double y1)
Protected Attributes inherited from Garfield::ViewBase
std::string m_className = "ViewBase"
bool m_debug = false
bool m_userPlotLimits = false
double m_xMinPlot = -1.
double m_xMaxPlot = 1.
double m_yMinPlot = -1.
double m_yMaxPlot = 1.
bool m_userBox = false
double m_xMinBox = -1.
double m_xMaxBox = 1.
double m_yMinBox = -1.
double m_yMaxBox = 1.
double m_zMinBox = -1.
double m_zMaxBox = 1.
std::array< std::array< double, 3 >, 3 > m_proj
std::array< double, 4 > m_plane {{0, 0, 1, 0}}
std::array< std::array< double, 3 >, 3 > m_prmat

Detailed Description

Draw the mesh of a field-map component.

Definition at line 25 of file ViewFEMesh.hh.

Member Typedef Documentation

◆ Facet

typedef std::vector<size_t> Garfield::ViewFEMesh::Facet
private

Definition at line 131 of file ViewFEMesh.hh.

Constructor & Destructor Documentation

◆ ViewFEMesh() [1/2]

Garfield::ViewFEMesh::ViewFEMesh ( )
inline

Default constructor.

Definition at line 28 of file ViewFEMesh.hh.

28: ViewFEMesh(nullptr) {}
ViewFEMesh()
Default constructor.
Definition ViewFEMesh.hh:28

◆ ViewFEMesh() [2/2]

Garfield::ViewFEMesh::ViewFEMesh ( Component * cmp)

Constructor.

◆ ~ViewFEMesh()

Garfield::ViewFEMesh::~ViewFEMesh ( )

Destructor.

Member Function Documentation

◆ AddFacets()

void Garfield::ViewFEMesh::AddFacets ( const size_t i,
const std::vector< std::vector< Facet > > & elementFacets,
const std::map< Facet, std::vector< size_t > > & facetElements,
std::vector< Facet > & facets,
std::vector< bool > & done ) const
private

◆ ClipToView()

void Garfield::ViewFEMesh::ClipToView ( std::vector< double > & px,
std::vector< double > & py,
std::vector< double > & cx,
std::vector< double > & cy )
private

◆ CreateDefaultAxes()

void Garfield::ViewFEMesh::CreateDefaultAxes ( )

Create a default set of custom-made axes.

◆ DisableAxes()

void Garfield::ViewFEMesh::DisableAxes ( )
inline

Definition at line 49 of file ViewFEMesh.hh.

49{ m_drawAxes = false; }

◆ DisableMaterial()

void Garfield::ViewFEMesh::DisableMaterial ( int materialID)
inline

Disable a material so that its mesh cells are not drawn.

Definition at line 86 of file ViewFEMesh.hh.

86 {
87 m_disabledMaterial[materialID] = true;
88 }
std::map< int, bool > m_disabledMaterial

◆ DrawBorders2d()

void Garfield::ViewFEMesh::DrawBorders2d ( )
private

◆ DrawBorders3d()

void Garfield::ViewFEMesh::DrawBorders3d ( )
private

◆ DrawCST()

void Garfield::ViewFEMesh::DrawCST ( ComponentCST * componentCST)
private

◆ DrawDriftLines2d()

void Garfield::ViewFEMesh::DrawDriftLines2d ( )
private

◆ DrawDriftLines3d()

void Garfield::ViewFEMesh::DrawDriftLines3d ( )
private

◆ DrawElements2d()

void Garfield::ViewFEMesh::DrawElements2d ( )
private

◆ DrawElements3d()

void Garfield::ViewFEMesh::DrawElements3d ( )
private

◆ EnableAxes()

void Garfield::ViewFEMesh::EnableAxes ( )
inline

Definition at line 48 of file ViewFEMesh.hh.

48{ m_drawAxes = true; }

◆ FacetSign()

bool Garfield::ViewFEMesh::FacetSign ( const Facet & f,
const size_t element ) const
private

◆ GetDrawViewRegion()

bool Garfield::ViewFEMesh::GetDrawViewRegion ( void ) const
inline

Definition at line 59 of file ViewFEMesh.hh.

59{ return m_drawViewRegion; }

◆ GetPlotLimits()

bool Garfield::ViewFEMesh::GetPlotLimits ( )
private

◆ IntersectPlaneArea()

bool Garfield::ViewFEMesh::IntersectPlaneArea ( double & xmin,
double & ymin,
double & xmax,
double & ymax )
private

◆ InView()

bool Garfield::ViewFEMesh::InView ( const double x,
const double y ) const
private

Return true if the specified point is in the view region.

◆ IsInPolygon()

bool Garfield::ViewFEMesh::IsInPolygon ( double x,
double y,
const std::vector< double > & px,
const std::vector< double > & py,
bool & edge ) const
private

◆ LinesCrossed()

bool Garfield::ViewFEMesh::LinesCrossed ( double x1,
double y1,
double x2,
double y2,
double u1,
double v1,
double u2,
double v2,
double & xc,
double & yc ) const
private

◆ OnLine()

bool Garfield::ViewFEMesh::OnLine ( double x1,
double y1,
double x2,
double y2,
double u,
double v ) const
private

◆ PlaneCut()

bool Garfield::ViewFEMesh::PlaneCut ( double x1,
double y1,
double z1,
double x2,
double y2,
double z2,
TMatrixD & xMat )
private

◆ Plot()

bool Garfield::ViewFEMesh::Plot ( const bool twod = true,
const bool outline = false )

Plot method to be called by user.

◆ RemoveCrossings()

void Garfield::ViewFEMesh::RemoveCrossings ( std::vector< double > & x,
std::vector< double > & y )
private

◆ Reset()

void Garfield::ViewFEMesh::Reset ( )
private

◆ SetColor()

void Garfield::ViewFEMesh::SetColor ( int matID,
int colorID )
inline

Associate a color with each element material map ID.

Uses ROOT color numberings.

Definition at line 63 of file ViewFEMesh.hh.

63{ m_colorMap[matID] = colorID; }
std::map< int, int > m_colorMap

◆ SetColors()

void Garfield::ViewFEMesh::SetColors ( const std::map< int, int > & colors)
inline

Definition at line 64 of file ViewFEMesh.hh.

64 {
65 for (const auto& c : colors) SetColor(c.first, c.second);
66 }
void SetColor(int matID, int colorID)
Associate a color with each element material map ID.
Definition ViewFEMesh.hh:63

◆ SetComponent()

void Garfield::ViewFEMesh::SetComponent ( Component * cmp)

Set the component from which to retrieve the mesh and field.

◆ SetDrawViewRegion()

void Garfield::ViewFEMesh::SetDrawViewRegion ( bool do_draw)
inline

Display intersection of projection plane with viewing area.

Definition at line 58 of file ViewFEMesh.hh.

58{ m_drawViewRegion = do_draw; }

◆ SetFillColor()

void Garfield::ViewFEMesh::SetFillColor ( int matID,
int colorID )
inline

Definition at line 67 of file ViewFEMesh.hh.

67 {
68 m_colorMap_fill[matID] = colorID;
69 }
std::map< int, int > m_colorMap_fill

◆ SetFillColors()

void Garfield::ViewFEMesh::SetFillColors ( const std::map< int, int > & colors)
inline

Definition at line 70 of file ViewFEMesh.hh.

70 {
71 for (const auto& c : colors) SetFillColor(c.first, c.second);
72 }
void SetFillColor(int matID, int colorID)
Definition ViewFEMesh.hh:67

◆ SetFillMesh()

void Garfield::ViewFEMesh::SetFillMesh ( const bool f)
inline

Element fill switch; 2D only, set false for wireframe mesh.

Definition at line 55 of file ViewFEMesh.hh.

55{ m_fillMesh = f; }

◆ SetFillMeshWithBorders()

void Garfield::ViewFEMesh::SetFillMeshWithBorders ( )
inline

Show filled mesh elements.

Definition at line 77 of file ViewFEMesh.hh.

77 {
78 m_plotMeshBorders = true;
79 m_fillMesh = true;
80 }

◆ SetPlane() [1/2]

void Garfield::ViewFEMesh::SetPlane ( const double fx,
const double fy,
const double fz,
const double x0,
const double y0,
const double z0 )
overridevirtual

Set the projection (viewing plane), if applicable.

Parameters
fx,fy,fznormal vector
x0,y0,z0in-plane point

Reimplemented from Garfield::ViewBase.

◆ SetPlane() [2/2]

void Garfield::ViewFEMesh::SetPlane ( const double fx,
const double fy,
const double fz,
const double x0,
const double y0,
const double z0,
const double hx,
const double hy,
const double hz )
overridevirtual

Set the projection plane specifying a hint for the in-plane x axis.

Reimplemented from Garfield::ViewBase.

◆ SetViewDrift()

void Garfield::ViewFEMesh::SetViewDrift ( ViewDrift * vd)
inline

Set the optional associated ViewDrift.

Definition at line 74 of file ViewFEMesh.hh.

74{ m_viewDrift = vd; }
ViewDrift * m_viewDrift

◆ SetXaxis()

void Garfield::ViewFEMesh::SetXaxis ( TGaxis * ax)

◆ SetXaxisTitle()

void Garfield::ViewFEMesh::SetXaxisTitle ( const std::string & xtitle)
inline

Definition at line 46 of file ViewFEMesh.hh.

46{ m_xaxisTitle = xtitle; }
std::string m_xaxisTitle

◆ SetYaxis()

void Garfield::ViewFEMesh::SetYaxis ( TGaxis * ay)

◆ SetYaxisTitle()

void Garfield::ViewFEMesh::SetYaxisTitle ( const std::string & ytitle)
inline

Definition at line 47 of file ViewFEMesh.hh.

47{ m_yaxisTitle = ytitle; }
std::string m_yaxisTitle

Member Data Documentation

◆ m_cmp

Component* Garfield::ViewFEMesh::m_cmp = nullptr
private

Definition at line 100 of file ViewFEMesh.hh.

◆ m_colorMap

std::map<int, int> Garfield::ViewFEMesh::m_colorMap
private

Definition at line 114 of file ViewFEMesh.hh.

◆ m_colorMap_fill

std::map<int, int> Garfield::ViewFEMesh::m_colorMap_fill
private

Definition at line 115 of file ViewFEMesh.hh.

◆ m_disabledMaterial

std::map<int, bool> Garfield::ViewFEMesh::m_disabledMaterial
private

Definition at line 118 of file ViewFEMesh.hh.

◆ m_drawAxes

bool Garfield::ViewFEMesh::m_drawAxes = false
private

Definition at line 111 of file ViewFEMesh.hh.

◆ m_drawViewRegion

bool Garfield::ViewFEMesh::m_drawViewRegion = false
private

Definition at line 95 of file ViewFEMesh.hh.

◆ m_fillMesh

bool Garfield::ViewFEMesh::m_fillMesh = false
private

Definition at line 92 of file ViewFEMesh.hh.

◆ m_geoManager

std::unique_ptr<TGeoManager> Garfield::ViewFEMesh::m_geoManager
private

Definition at line 122 of file ViewFEMesh.hh.

◆ m_media

std::vector<TGeoMedium*> Garfield::ViewFEMesh::m_media
private

Definition at line 121 of file ViewFEMesh.hh.

◆ m_plotMeshBorders

bool Garfield::ViewFEMesh::m_plotMeshBorders = false
private

Definition at line 104 of file ViewFEMesh.hh.

◆ m_viewDrift

ViewDrift* Garfield::ViewFEMesh::m_viewDrift = nullptr
private

Definition at line 103 of file ViewFEMesh.hh.

◆ m_viewRegionX

std::vector<double> Garfield::ViewFEMesh::m_viewRegionX
private

Definition at line 96 of file ViewFEMesh.hh.

◆ m_viewRegionY

std::vector<double> Garfield::ViewFEMesh::m_viewRegionY
private

Definition at line 97 of file ViewFEMesh.hh.

◆ m_volumes

std::vector<TGeoVolume*> Garfield::ViewFEMesh::m_volumes
private

Definition at line 120 of file ViewFEMesh.hh.

◆ m_xaxis

TGaxis* Garfield::ViewFEMesh::m_xaxis = nullptr
private

Definition at line 107 of file ViewFEMesh.hh.

◆ m_xaxisTitle

std::string Garfield::ViewFEMesh::m_xaxisTitle = ""
private

Definition at line 109 of file ViewFEMesh.hh.

◆ m_yaxis

TGaxis* Garfield::ViewFEMesh::m_yaxis = nullptr
private

Definition at line 108 of file ViewFEMesh.hh.

◆ m_yaxisTitle

std::string Garfield::ViewFEMesh::m_yaxisTitle = ""
private

Definition at line 110 of file ViewFEMesh.hh.


The documentation for this class was generated from the following file: