Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
surface.h
Go to the documentation of this file.
1#ifndef SURFACE_H
2#define SURFACE_H
3#include <iostream>
6/*
7Volume building from surfaces.
8
9Copyright (c) 2000 Igor B. Smirnov
10
11The file can be used, copied, modified, and distributed
12according to the terms of GNU Lesser General Public License version 2.1
13as published by the Free Software Foundation,
14and provided that the above copyright notice, this permission notice,
15and notices about any modifications of the original text
16appear in all copies and in supporting documentation.
17The file is provided "as is" without express or implied warranty.
18*/
19
20namespace Heed {
21
22// **** surface ****
23// surface is not meant to be derivative of volume.
24// Thus, the surfaces should be contained in derivative of volume
25
26const int pqqsurf = 10;
27const int pqcrossurf = 4;
28
30 public:
32 virtual ~surface() {}
33 virtual int check_point_inside(const point& fpt, const vec& dir,
34 vfloat fprec) const = 0;
35 // If two volumes are exactly adjusted, it may happens that the point
36 // belongs to both volumes, to their borders. If dir != dv0,
37 // the exiting volume is ignored.
38
39 virtual int check_point_inside1(const point& fpt, int s_ext,
40 vfloat fprec) const = 0;
41 // s_ext=0 - entering
42 // 1 - exiting
43
44 virtual int range(const trajestep& fts, vfloat* crange, point* cpt,
45 int* s_ext) const = 0;
46 // Does not change fts
47 // If no cross or cross father than fts.mrange,
48 // returns 0 and does not change fts
49 // If there are crosses nearer than fts.mrange,
50 // returns number of crosses and assign crange, cpt, and s_ext.
51 // crange and cpt should be arranged.
52 // s_ext: 0 - entry to inside
53 // 1 - exit from inside
54 // 2 - uncertain
55 // The last crossing are then ignored.
56 // The following case should be excluded:
57 // The point is approximately on the surface.
58 // dir is directed outside from the inside space.
59 //
60 // if surface is unlimited like a plane, and point is exactly on the plane,
61 // the range is 0, s_ext is taken from direction.
62 // In case of parallel to border, s_ext=2.
63
64 virtual int cross(const polyline& fpl, point* cntrpt, int& qcntrpt,
65 vfloat prec) const = 0;
66 virtual void print(std::ostream& file, int l) const = 0;
67
68};
69
70// **** splane ****
71
72class splane : public surface {
73 public:
75 vec dir_ins; // direction to inside, supposed to be unit length (What for?)
76 protected:
77 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
78 static absref(absref::* aref_splane[2]);
79
80 public:
81 /// Constructors
82 splane(void) : pn() {}
83 splane(const splane& fsp) : surface(fsp), pn(fsp.pn), dir_ins(fsp.dir_ins) {}
84 splane(const plane& fpn, const vec& fdir_ins)
85 : pn(fpn), dir_ins(unit_vec(fdir_ins)) {}
87 /// Destructor
88 virtual ~splane() {}
89
90 int check_point_inside(const point& fpt, const vec& dir, vfloat fprec) const;
91 int check_point_inside1(const point& fpt, int s_ext, vfloat fprec) const;
92 // s_ext=0 - entering
93 // 1 - exiting
94 // 15.02.2006: Remark on check_point_inside vs. check_point_inside1.
95 // check_point_inside1 allows one to override the behaviour when
96 // the point is exactly on the surface.
97 // If the moving point is entering one surface and simultaneously exiting
98 // another one, it would not be recognized as entering the volume.
99 // This virtually prohibits the creation of the control surfaces: volumes
100 // with zero width, where the particle makes stop in order to be registered
101 // in user check_point function.
102 // Therefore when the function ulsvolume::range_ext checks that the
103 // entry point is inside the volume, it calls check_point_inside1
104 // with s_ext == 0, implying that the particle is entering
105 // all the surfaces, thus faking the entering even if the particle is
106 // actually exiting. This allows to make a stop there.
107
108 int range(const trajestep& fts, vfloat* crange, point* cpt, int* s_ext) const;
109 // Does not change fts
110 // If no cross, returns 0 a
111 // If there are crosses, returns number of them and
112 // assign crange and cpt
113
114 int cross(const polyline& fpl, point* cntrpt, int& qcntrpt,
115 vfloat prec) const {
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 }
122 virtual void print(std::ostream& file, int l) const;
123
124};
125
126// **** ulsvolume ****
127
128class ulsvolume : public absvol {
129 // unlimited surfaces volume
130 // It is volume constructed by unlimited surfaces.
131 // The surface itself can be not convex.
132 // But that part of surface which is border of the volume
133 // must be from the right internal side from the other surfaces.
134 // It can be formulated by the other way: neigbouring crossing surfaces
135 // should cross only in the corners of the shape.
136 // This allows to formulate algorithm of finding nearest cross of a track
137 // with border of this type of volume:
138 // For tracks coming (entering) from outside:
139 // Nearest entering crossing point of track with a surface
140 // which is from inside of the other surfaces.
141 // For tracks exiting from inside:
142 // Nearest crossing point of track with a surface for exiting track.
143 // For each crossing point we know whether or not the track exits or
144 // enters to inside of this surface.
145 // This allows to reject that crossing points which are exiting for
146 // track going from outside volume.
147 // It allows to make cylinders, tubes and many other complicated shapes.
148
149 public:
150 int qsurf;
151 ActivePtr<surface> surf[pqqsurf];
153
154 protected:
155 surface* adrsurf[pqqsurf]; // used only for get_components
156 virtual void get_components(ActivePtr<absref_transmit>& aref_tran);
157
158 public:
159 /// Constructors
160 ulsvolume(void);
161 ulsvolume(surface* fsurf[pqqsurf], int fqsurf, char* fname, vfloat fprec);
163 ulsvolume(const ulsvolume& fv);
165 /// Destructor
166 virtual ~ulsvolume() {}
167
168 int check_point_inside(const point& fpt, const vec& dir) const;
169
170 int range_ext(trajestep& fts, int s_ext) const;
171 // If no cross, returns 0 and does not change fts
172 // If there is cross, returns 1 and assign fts.mrange and fts.mpoint
173 void ulsvolume_init(surface* fsurf[pqqsurf], int fqsurf, const String& fname,
174 vfloat fprec);
175
176 virtual void income(gparticle* /*gp*/) {}
177 virtual void chname(char* nm) const {
178#ifdef USE_STLSTRING
179 strcpy(nm, "ulsvolume: ");
180 strcat(nm, name.c_str());
181#else
182 strcpy(nm, "ulsvolume: ");
183 strcat(nm, name);
184#endif
185 }
186 virtual void print(std::ostream& file, int l) const;
187 virtual int mandatory(void) const { return 0; }
188
189};
190
191class manip_ulsvolume : virtual public manip_absvol, public ulsvolume {
192 public:
193 /// Constructors
199 /// Destructor
200 virtual ~manip_ulsvolume() {}
201
202 virtual absvol* Gavol(void) const { return (ulsvolume*)this; }
203 virtual void chname(char* nm) const {
204#ifdef USE_STLSTRING
205 strcpy(nm, "manip_ulsvolume: ");
206 strcat(nm, name.c_str());
207#else
208 strcpy(nm, "manip_ulsvolume: ");
209 strcat(nm, name);
210#endif
211 }
212 virtual void print(std::ostream& file, int l) const;
213
214};
215
216}
217
218#endif
#define virt_common_base_pcomma
Definition: AbsPtr.h:245
std::string String
Definition: String.h:75
virtual ~manip_ulsvolume()
Destructor.
Definition: surface.h:200
virtual void print(std::ostream &file, int l) const
manip_ulsvolume(void)
Constructors.
Definition: surface.h:194
manip_ulsvolume(manip_ulsvolume &f)
virtual void chname(char *nm) const
Definition: surface.h:203
macro_copy_header(manip_ulsvolume)
virtual absvol * Gavol(void) const
Definition: surface.h:202
manip_ulsvolume(const ulsvolume &f)
Definition: surface.h:197
point cross(const straight &sl) const
Definition: plane.cpp:77
int Gqsl(void) const
Definition: polyline.h:44
macro_copy_total(splane)
plane pn
Definition: surface.h:74
virtual ~splane()
Destructor.
Definition: surface.h:88
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: surface.cpp:22
splane(const plane &fpn, const vec &fdir_ins)
Definition: surface.h:84
int range(const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const
Definition: surface.cpp:60
int check_point_inside1(const point &fpt, int s_ext, vfloat fprec) const
Definition: surface.cpp:48
vec dir_ins
Definition: surface.h:75
splane(void)
Constructors.
Definition: surface.h:82
virtual void print(std::ostream &file, int l) const
Definition: surface.cpp:180
splane(const splane &fsp)
Definition: surface.h:83
static absrefabsref::*[2] aref_splane
Definition: surface.h:78
int check_point_inside(const point &fpt, const vec &dir, vfloat fprec) const
Definition: surface.cpp:26
int cross(const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const
Definition: surface.h:114
virtual int range(const trajestep &fts, vfloat *crange, point *cpt, int *s_ext) const =0
virtual int check_point_inside1(const point &fpt, int s_ext, vfloat fprec) const =0
virtual void print(std::ostream &file, int l) const =0
virtual ~surface()
Definition: surface.h:32
virtual int cross(const polyline &fpl, point *cntrpt, int &qcntrpt, vfloat prec) const =0
macro_copy_total_zero(surface)
virtual int check_point_inside(const point &fpt, const vec &dir, vfloat fprec) const =0
void ulsvolume_init(surface *fsurf[pqqsurf], int fqsurf, const String &fname, vfloat fprec)
Definition: surface.cpp:339
virtual void income(gparticle *)
Definition: surface.h:176
macro_copy_header(ulsvolume)
String name
Definition: surface.h:152
surface * adrsurf[pqqsurf]
Definition: surface.h:155
virtual void print(std::ostream &file, int l) const
virtual void chname(char *nm) const
Definition: surface.h:177
ulsvolume(void)
Constructors.
Definition: surface.cpp:337
int check_point_inside(const point &fpt, const vec &dir) const
Definition: surface.cpp:196
int range_ext(trajestep &fts, int s_ext) const
Definition: surface.cpp:214
virtual void get_components(ActivePtr< absref_transmit > &aref_tran)
Definition: surface.cpp:191
virtual int mandatory(void) const
Definition: surface.h:187
virtual ~ulsvolume()
Destructor.
Definition: surface.h:166
ActivePtr< surface > surf[pqqsurf]
Definition: surface.h:151
Definition: vec.h:134
Definition: volume.h:91
Definition: vec.h:477
Definition: vec.h:248
Definition: BGMesh.cpp:3
const int pqqsurf
Definition: surface.h:26
const int pqcrossurf
Definition: surface.h:27
double vfloat
Definition: vfloat.h:15