Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
volume.h
Go to the documentation of this file.
1#ifndef VOLUME_H
2#define VOLUME_H
3#include <iostream>
4#include <vector>
5#include <cstring>
6
9
10/*
11The main definitions related to volume.
12
13Copyright (c) 2000 Igor B. Smirnov
14
15The file can be used, copied, modified, and distributed
16according to the terms of GNU Lesser General Public License version 2.1
17as published by the Free Software Foundation,
18and provided that the above copyright notice, this permission notice,
19and notices about any modifications of the original text
20appear in all copies and in supporting documentation.
21The file is provided "as is" without express or implied warranty.
22*/
23
24namespace Heed {
25
26class gparticle;
27class manip_absvol;
28class volume;
29class absvol;
30
31/// Service class (array of manip_absvol).
33 public:
34 /// Constructor
36 /// List of volumes
37 std::vector<manip_absvol*> eid;
38 /// Get last address of manipulator
40 return eid.empty() ? nullptr : eid.back();
41 }
42 /// Get last address of volume
43 absvol* G_lavol() const;
44
45 friend int operator==(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
46 friend int operator!=(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
47 // The following two functions change reference frame of any object
48 // derivative from absref
49 void down_absref(absref* f);
50 void up_absref(absref* f);
51
52 // The following returns 1 if registered and 0 otherwise
53 // Registered means that the route includes this manip_absvol,
54 // not necessary the last volume.
57 void print(std::ostream& file, int l) const;
58};
59
60int operator==(manip_absvol_treeid& tid1, manip_absvol_treeid& tid2);
62 if (tid1 == tid2) return 0;
63 return 1;
64}
65
66/// Abstract base class for volumes.
67/// The functions accept and return parameters expressed in the internal
68/// coordinate system inherent to this volume.
69/// For interface with external system please use manip_absvol.
70class absvol : virtual public absref {
71 public:
74
75 /// Destructor
76 virtual ~absvol() {}
77
78 /// Check if a point is inside the volume.
79 /// If two volumes are adjacent, it may happen that a point belongs to both.
80 /// To avoid this confusion the parameter dir is used.
81 /// If dir == (0, 0, 0), and the point is exactly on the border,
82 /// the behaviour is in general not specified.
83 /// If dir != (0, 0, 0), and the point is on the border with precision prec,
84 /// the exiting volume is ignored.
85 virtual int check_point_inside(const point& fpt, const vec& dir) const = 0;
86
87 /// Return 1 if point in this volume.
88 /// It starts from embraced manipulators, if any
89 /// If there are embraced volumes, it add some to namvol,
90 /// otherwise it does not add namvol==0.
91 /// The embraced volumes should not cross each other,
92 /// since this function can return only one chain.
93 /// But the borders can coincide with precision given to embraced volumes.
94 /// If the point is on the border, it is considered inside volume only if
95 /// dir is directed inside it.
96 /// Also algorithm of volume is effective if it interrupts
97 /// checking after first volume found.
98 virtual int find_embed_vol(const point& fpt, const vec& dir,
99 manip_absvol_treeid* atid) const;
100
101 /// range considering this volume, all embracing volumes
102 /// sb=0 range restricted by precision reasons.
103 /// sb=1 crossing border of this volume
104 /// sb=2 crossing border of embraced volume
105 /// s_ext=1 inside, and to check all embraced volumes
106 /// s_ext=0 outside
107 /// checks only one level in deep. It is assumed that
108 /// from current volume the particle can pass either outside or
109 /// to one of embracing volumes.
110 /// In the last case *faeid is filled by its id.
111 /// Otherwise *faeid is filled by NULL.
112 virtual int range(trajestep& fts, int s_ext, int& sb,
113 manip_absvol*& faeid) const;
114
115 /// Find cross with current volume ignoring embraced ones.
116 /// s_ext=1 exit, now point is inside, but embraced volumes are ingnored.
117 /// s_ext=0 enter, now point is outside
118 virtual int range_ext(trajestep& fts, int s_ext) const = 0;
119
120 virtual void income(gparticle*) {}
121 virtual void chname(char* nm) const { strcpy(nm, "absvol"); }
122 virtual void print(std::ostream& file, int l) const;
123 virtual absvol* copy() const;
124 virtual std::vector<manip_absvol*> Gamanip_embed() const;
125};
126
127/// Abstract base classs for volume "manipulators".
128class manip_absvol : virtual public absref {
129 public:
130 /// Get the volume.
131 virtual absvol* Gavol() const = 0;
132 /// Get the coordinate system.
133 virtual const abssyscoor* Gasc() const {
134 // Return NULL if it is the same system
135 return NULL;
136 }
137 virtual int m_check_point_inside(const point& fpt, const vec& dir) const;
138 virtual int m_find_embed_vol(const point& fpt, const vec& fdir,
139 manip_absvol_treeid* atid) const;
140 // Do the appropriate manipulations with atid and calls avol->find_embed_vol
141
142 // The two following functions changes syscoor if necessary and
143 // calls similar named functions of absvol
144 virtual int m_range(trajestep& fts, int s_ext, int& sb,
145 manip_absvol*& faeid) const;
146 virtual int m_range_ext(trajestep& fts, int s_ext) const;
147 // s_ext=1 inside, but embraced volumes are ingnored.
148 // s_ext=0 outside
149
150 // The following two functions change reference frame of any object
151 inline void down_absref(absref* f) const {
152 const abssyscoor* asc = Gasc();
153 if (asc) f->down(asc);
154 }
155 inline void up_absref(absref* f) const {
156 const abssyscoor* asc = Gasc();
157 if (asc) f->up(asc);
158 }
159 void m_chname(char* nm) const;
160 virtual void m_print(std::ostream& file, int l) const;
161 manip_absvol* copy() const;
162 virtual ~manip_absvol() {}
163};
164
165// ********* sh_manip_absvol *********
167 protected:
169
170 public:
171 virtual const abssyscoor* Gasc() const override;
172 void Psc(const fixsyscoor& fcsys) { csys = fcsys; }
173
174 protected:
175 virtual absref_transmit get_components() override;
177
178 public:
182 sh_manip_absvol(const abssyscoor& f);
183 sh_manip_absvol(const point& fc, const basis& fbas, const std::string& fname);
184 virtual ~sh_manip_absvol() {}
185
186 virtual void m_chname(char* nm) const;
187 virtual void m_print(std::ostream& file, int l) const override;
188 sh_manip_absvol* copy() const;
189};
190
191}
192
193#endif
virtual void up(const abssyscoor *fasc)
Convert numbering representation of objects to new system.
Definition: vec.cpp:48
virtual void down(const abssyscoor *fasc)
Convert numbering representation of object to basical system of fasc.
Definition: vec.cpp:43
virtual void print(std::ostream &file, int l) const
Definition: volume.cpp:119
virtual int range(trajestep &fts, int s_ext, int &sb, manip_absvol *&faeid) const
Definition: volume.cpp:99
virtual int find_embed_vol(const point &fpt, const vec &dir, manip_absvol_treeid *atid) const
Definition: volume.cpp:80
virtual ~absvol()
Destructor.
Definition: volume.h:76
virtual absvol * copy() const
Definition: volume.cpp:147
virtual void income(gparticle *)
Definition: volume.h:120
virtual int range_ext(trajestep &fts, int s_ext) const =0
bool s_sensitive
Definition: volume.h:73
vfloat prec
Definition: volume.h:72
virtual int check_point_inside(const point &fpt, const vec &dir) const =0
virtual std::vector< manip_absvol * > Gamanip_embed() const
Definition: volume.cpp:76
virtual void chname(char *nm) const
Definition: volume.h:121
Basis.
Definition: vec.h:311
Service class (array of manip_absvol).
Definition: volume.h:32
int check_absvol_registered(absvol *avol)
Definition: volume.cpp:36
void down_absref(absref *f)
Definition: volume.cpp:21
void print(std::ostream &file, int l) const
Definition: volume.cpp:54
void up_absref(absref *f)
Definition: volume.cpp:26
friend int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:61
int check_manip_absvol_registered(manip_absvol *amvol)
Definition: volume.cpp:31
friend int operator==(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.cpp:41
std::vector< manip_absvol * > eid
List of volumes.
Definition: volume.h:37
absvol * G_lavol() const
Get last address of volume.
Definition: volume.cpp:17
manip_absvol_treeid()
Constructor.
Definition: volume.h:35
manip_absvol * G_lamvol() const
Get last address of manipulator.
Definition: volume.h:39
Abstract base classs for volume "manipulators".
Definition: volume.h:128
virtual int m_check_point_inside(const point &fpt, const vec &dir) const
Definition: volume.cpp:154
manip_absvol * copy() const
Definition: volume.cpp:251
void up_absref(absref *f) const
Definition: volume.h:155
virtual ~manip_absvol()
Definition: volume.h:162
virtual absvol * Gavol() const =0
Get the volume.
void m_chname(char *nm) const
Definition: volume.cpp:223
virtual const abssyscoor * Gasc() const
Get the coordinate system.
Definition: volume.h:133
virtual int m_range_ext(trajestep &fts, int s_ext) const
Definition: volume.cpp:211
virtual int m_range(trajestep &fts, int s_ext, int &sb, manip_absvol *&faeid) const
Definition: volume.cpp:197
void down_absref(absref *f) const
Definition: volume.h:151
virtual int m_find_embed_vol(const point &fpt, const vec &fdir, manip_absvol_treeid *atid) const
Definition: volume.cpp:168
virtual void m_print(std::ostream &file, int l) const
Definition: volume.cpp:228
Point.
Definition: vec.h:366
fixsyscoor csys
Definition: volume.h:168
virtual absref_transmit get_components() override
Definition: volume.cpp:258
virtual void m_print(std::ostream &file, int l) const override
Definition: volume.cpp:287
absref * aref_ptr[1]
Definition: volume.h:176
virtual const abssyscoor * Gasc() const override
Get the coordinate system.
Definition: volume.cpp:263
void Psc(const fixsyscoor &fcsys)
Definition: volume.h:172
virtual ~sh_manip_absvol()
Definition: volume.h:184
sh_manip_absvol * copy() const
Definition: volume.cpp:281
virtual void m_chname(char *nm) const
Definition: volume.cpp:276
Definition: vec.h:177
Definition: BGMesh.cpp:6
int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:61
int operator==(const circumf &f1, const circumf &f2)
Definition: circumf.cpp:34
double vfloat
Definition: vfloat.h:16