Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Heed::splane Class Reference

#include <surface.h>

+ Inheritance diagram for Heed::splane:

Public Member Functions

 splane ()
 Default constructor.
 
 splane (const splane &fsp)
 
 splane (const plane &fpn, const vec &fdir_ins)
 
virtual ~splane ()
 Destructor.
 
int check_point_inside (const point &fpt, const vec &dir, vfloat fprec) const
 
int check_point_inside1 (const point &fpt, int s_ext, vfloat fprec) const
 
int range (const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const
 
int cross (const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const
 
virtual void print (std::ostream &file, int l) const
 
virtual splanecopy () const
 
- Public Member Functions inherited from Heed::surface
virtual surfacecopy () const =0
 
virtual ~surface ()
 
virtual int check_point_inside (const point &fpt, const vec &dir, vfloat fprec) const =0
 
virtual int check_point_inside1 (const point &fpt, int s_ext, vfloat fprec) const =0
 
virtual int range (const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const =0
 
virtual int cross (const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const =0
 
virtual void print (std::ostream &file, int l) const =0
 
- Public Member Functions inherited from Heed::absref
virtual ~absref ()
 Destructor.
 
virtual void down (const abssyscoor *fasc)
 Convert numbering representation of object to basical system of fasc.
 
virtual void up (const abssyscoor *fasc)
 Convert numbering representation of objects to new system.
 
virtual void turn (const vec &dir, vfloat angle)
 Turn around axis doing via center of coordinate system along dir.
 
virtual void shift (const vec &dir)
 

Public Attributes

plane pn
 
vec dir_ins
 

Protected Member Functions

virtual void get_components (ActivePtr< absref_transmit > &aref_tran)
 

Static Protected Attributes

static absrefabsref::*[2] aref_splane
 

Detailed Description

Definition at line 69 of file surface.h.

Constructor & Destructor Documentation

◆ splane() [1/3]

Heed::splane::splane ( )
inline

Default constructor.

Definition at line 79 of file surface.h.

79: pn() {}
plane pn
Definition: surface.h:71

Referenced by copy().

◆ splane() [2/3]

Heed::splane::splane ( const splane fsp)
inline

Definition at line 80 of file surface.h.

80: surface(fsp), pn(fsp.pn), dir_ins(fsp.dir_ins) {}
vec dir_ins
Definition: surface.h:72

◆ splane() [3/3]

Heed::splane::splane ( const plane fpn,
const vec fdir_ins 
)
inline

Definition at line 81 of file surface.h.

82 : pn(fpn), dir_ins(unit_vec(fdir_ins)) {}

◆ ~splane()

virtual Heed::splane::~splane ( )
inlinevirtual

Destructor.

Definition at line 84 of file surface.h.

84{}

Member Function Documentation

◆ check_point_inside()

int Heed::splane::check_point_inside ( const point fpt,
const vec dir,
vfloat  fprec 
) const
virtual

Implements Heed::surface.

Definition at line 25 of file surface.cpp.

26 {
28 "int splane::check_point_inside(const point& fpt, const vec& dir, "
29 "vfloat fprec)");
30 if (dir == dv0) {
31 // this is not useful
32 if (fpt == pn.Gpiv()) return 1;
33 vec v = fpt - pn.Gpiv();
34 if (cos2vec(dir_ins, v) >= -vprecision) return 1;
35 return 0;
36 }
37 if (pn.check_point_in(fpt, fprec) == 1) {
38 vfloat ca = cos2vec(dir, dir_ins);
39 if (ca < 0) return 0;
40 return 1;
41 }
42 vec v = fpt - pn.Gpiv();
43 if (cos2vec(dir_ins, v) >= 0) return 1;
44 return 0;
45}
#define mfunname(string)
Definition: FunNameStack.h:45
point Gpiv(void) const
Definition: plane.h:32
int check_point_in(const point &fp, vfloat prec) const
Definition: plane.cpp:67
vec dv0(0, 0, 0)
Definition: vec.h:314
vfloat cos2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:66
const vfloat vprecision
Definition: vfloat.h:17
double vfloat
Definition: vfloat.h:16

◆ check_point_inside1()

int Heed::splane::check_point_inside1 ( const point fpt,
int  s_ext,
vfloat  fprec 
) const
virtual

Implements Heed::surface.

Definition at line 47 of file surface.cpp.

48 {
49 if (pn.check_point_in(fpt, fprec) == 1) {
50 if (s_ext == 1) return 0;
51 return 1;
52 }
53 vec v = fpt - pn.Gpiv();
54 if (cos2vec(dir_ins, v) > 0) return 1;
55 return 0;
56}

◆ copy()

virtual splane * Heed::splane::copy ( ) const
inlinevirtual

Implements Heed::surface.

Definition at line 119 of file surface.h.

119{ return new splane(*this); }
splane()
Default constructor.
Definition: surface.h:79

◆ cross()

int Heed::splane::cross ( const polyline fpl,
point cntrpt,
int &  qcntrpt,
vfloat  prec 
) const
inlinevirtual

Implements Heed::surface.

Definition at line 110 of file surface.h.

111 {
112 polyline* plh = new polyline[fpl.Gqsl()];
113 int qplh;
114 int i = pn.cross(fpl, cntrpt, qcntrpt, plh, qplh, prec);
115 delete[] plh;
116 return i;
117 }
point cross(const straight &sl) const
Definition: plane.cpp:74

◆ get_components()

void Heed::splane::get_components ( ActivePtr< absref_transmit > &  aref_tran)
protectedvirtual

Reimplemented from Heed::absref.

Definition at line 21 of file surface.cpp.

21 {
22 aref_tran.pass(new absref_transmit(2, aref_splane));
23}
static absrefabsref::*[2] aref_splane
Definition: surface.h:75

◆ print()

void Heed::splane::print ( std::ostream &  file,
int  l 
) const
virtual

Implements Heed::surface.

Definition at line 178 of file surface.cpp.

178 {
179 if (l > 0) {
180 Ifile << "splane:\n";
181 indn.n += 2;
182 file << pn;
183 Ifile << "dir_ins: " << noindent << dir_ins << '\n';
184 indn.n -= 2;
185 }
186}
std::ostream & noindent(std::ostream &f)
Definition: prstream.cpp:17
indentation indn
Definition: prstream.cpp:15
#define Ifile
Definition: prstream.h:196

◆ range()

int Heed::splane::range ( const trajestep fts,
vfloat crange,
point cpt,
int *  s_ext 
) const
virtual

Implements Heed::surface.

Definition at line 58 of file surface.cpp.

59 {
60 mfunname("int splane::range(...)");
61 if (fts.s_range_cf == 0) {
62 // straight line
63 point pt = pn.cross(straight(fts.currpos, fts.dir));
64 if (vecerror != 0) {
65 vecerror = 0;
66 return 0;
67 }
68 vfloat rng = (pt - fts.currpos).length();
69 if (pt == fts.currpos || check_par(pt - fts.currpos, fts.dir, 0.01) == 1) {
70 // looks like not matter ^
71 // otherwise the point is behind plane
72 if (fts.mrange >= rng) {
73 // otherwise it can not reach the plane
74 cpt[0] = pt;
75 crange[0] = rng;
76 vfloat t = cos2vec(fts.dir, dir_ins);
77 if (t < 0)
78 s_ext[0] = 1;
79 else if (t > 0)
80 s_ext[0] = 0;
81 else
82 s_ext[0] = 2;
83 return 1;
84 }
85 return 0;
86 } else
87 return 0;
88 } else {
89 point pt[2];
90 circumf cf(fts.currpos + fts.relcen,
91 fts.dir || fts.relcen, // if to us, moving against clock
92 fts.relcen.length());
93 int q = cf.cross(pn, pt, 0.0);
94 if (q == -1) // total circle lyes in the plane
95 {
96 cpt[0] = fts.currpos;
97 crange[0] = 0.0;
98 s_ext[0] = 2;
99 return 1;
100 }
101 if (q == 0) return 0;
102 if (q == 1) {
103 vec r1 = -fts.relcen;
104 vec r2 = pt[0] - cf.Gpiv();
105 vfloat angle = ang2projvec(r1, r2, cf.Gdir());
106 vfloat rng = cf.Grad() * angle;
107 if (fts.mrange >= rng) {
108 cpt[0] = pt[0];
109 crange[0] = rng;
110 vfloat c = cos2vec(dir_ins, fts.relcen);
111 if (angle == 0.0) {
112 // cross in the current point
113 if (c > 0)
114 s_ext[0] = 0;
115 else if (c < 0)
116 s_ext[0] = 1;
117 else
118 s_ext[0] = 2;
119 } else {
120 if (c > 0)
121 s_ext[0] = 1;
122 else if (c < 0)
123 s_ext[0] = 0;
124 else
125 s_ext[0] = 2;
126 }
127 return 1;
128 } else
129 return 0;
130 }
131 if (q == 2) {
132 int qq = 0;
133 vec r = -fts.relcen;
134 vec vcr[2];
135 vcr[0] = pt[0] - cf.Gpiv();
136 vcr[1] = pt[1] - cf.Gpiv();
137 vfloat angle[2];
138 angle[0] = ang2projvec(r, vcr[0], cf.Gdir());
139 angle[1] = ang2projvec(r, vcr[1], cf.Gdir());
140 if (angle[0] > angle[1]) { // ordering
141 vfloat a = angle[0];
142 angle[0] = angle[1];
143 angle[1] = a;
144 point p = pt[0];
145 pt[0] = pt[1];
146 pt[1] = p;
147 }
148 vfloat rng;
149 rng = cf.Grad() * angle[0];
150 if (fts.mrange >= rng) {
151 // find out what the first point means
152 int ins = 0; // 1 if the point inside and exits
153 vec td = fts.dir;
154 td.turn(cf.Gdir(), angle[0]); // local dir in the crossing point
155 vfloat t = cos2vec(td, dir_ins);
156 if (t < 0)
157 ins = 1; // means the point was inside and now exiting
158 else
159 ins = 0;
160 cpt[0] = pt[0];
161 crange[0] = rng;
162 s_ext[0] = ins;
163 qq++;
164 rng = cf.Grad() * angle[1];
165 if (fts.mrange >= rng) {
166 cpt[1] = pt[1];
167 crange[1] = rng;
168 s_ext[1] = (ins == 0 ? 1 : 0);
169 qq++;
170 }
171 }
172 return qq;
173 }
174 }
175 return 0;
176}
vfloat ang2projvec(const vec &r1, const vec &r2, const vec &normal)
Definition: vec.cpp:136
int vecerror
Definition: vec.cpp:29

Member Data Documentation

◆ aref_splane

absref absref::* Heed::splane::aref_splane
staticprotected
Initial value:
= {(absref absref::*)&splane::pn,
(absref absref::*)&splane::dir_ins}

Definition at line 75 of file surface.h.

Referenced by get_components().

◆ dir_ins

vec Heed::splane::dir_ins

Definition at line 72 of file surface.h.

Referenced by check_point_inside(), check_point_inside1(), print(), and range().

◆ pn

plane Heed::splane::pn

Definition at line 71 of file surface.h.

Referenced by check_point_inside(), check_point_inside1(), cross(), print(), and range().


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