Garfield++ v1r0
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 (void)
 Constructors.
 
 splane (const splane &fsp)
 
 splane (const plane &fpn, const vec &fdir_ins)
 
 macro_copy_total (splane)
 
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
 
- Public Member Functions inherited from Heed::surface
 macro_copy_total_zero (surface)
 
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 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 72 of file surface.h.

Constructor & Destructor Documentation

◆ splane() [1/3]

Heed::splane::splane ( void  )
inline

Constructors.

Definition at line 82 of file surface.h.

82: pn() {}
plane pn
Definition: surface.h:74

◆ splane() [2/3]

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

Definition at line 83 of file surface.h.

83: surface(fsp), pn(fsp.pn), dir_ins(fsp.dir_ins) {}
vec dir_ins
Definition: surface.h:75

◆ splane() [3/3]

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

Definition at line 84 of file surface.h.

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

◆ ~splane()

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

Destructor.

Definition at line 88 of file surface.h.

88{}

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 26 of file surface.cpp.

27 {
28 mfunname("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
46}
#define mfunname(string)
Definition: FunNameStack.h:67
point Gpiv(void) const
Definition: plane.h:31
int check_point_in(const point &fp, vfloat prec) const
Definition: plane.cpp:70
Definition: vec.h:248
vec dv0(0, 0, 0)
vfloat cos2vec(const vec &r1, const vec &r2)
Definition: vec.cpp:142
double vfloat
Definition: vfloat.h:15
const vfloat vprecision
Definition: vfloat.h:17

◆ 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 48 of file surface.cpp.

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

◆ cross()

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

Implements Heed::surface.

Definition at line 114 of file surface.h.

115 {
116 polyline* plh = new polyline[fpl.Gqsl()];
117 int qplh;
118 int i = pn.cross(fpl, cntrpt, qcntrpt, plh, qplh, prec);
119 delete plh;
120 return i;
121 }
point cross(const straight &sl) const
Definition: plane.cpp:77

◆ get_components()

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

Definition at line 22 of file surface.cpp.

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

◆ macro_copy_total()

Heed::splane::macro_copy_total ( splane  )

◆ print()

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

Implements Heed::surface.

Definition at line 180 of file surface.cpp.

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

◆ range()

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

Implements Heed::surface.

Definition at line 60 of file surface.cpp.

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

Member Data Documentation

◆ aref_splane

absref absref::* Heed::splane::aref_splane
staticprotected
Initial value:

Definition at line 78 of file surface.h.

Referenced by get_components().

◆ dir_ins

vec Heed::splane::dir_ins

Definition at line 75 of file surface.h.

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

◆ pn

plane Heed::splane::pn

Definition at line 74 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: