OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PatchRep.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: PatchRep.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: PatchRep
10 // Defines a concrete representation for a geometry patch.
11 //
12 // ------------------------------------------------------------------------
13 // Class category: BeamlineCore
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:32:33 $
17 // $Author: fci $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "BeamlineCore/PatchRep.h"
24 
25 
26 // Attribute access table.
27 // ------------------------------------------------------------------------
28 
29 namespace {
30  struct Entry {
31  const char *name;
32  double(PatchRep::*get)() const;
33  void (PatchRep::*set)(double);
34  };
35 
36  const Entry entries[] = {
37  {
38  "X",
41  },
42  {
43  "Y",
46  },
47  {
48  "Z",
51  },
52  {
53  "VX",
56  },
57  {
58  "VY",
61  },
62  {
63  "VZ",
66  },
67  { 0, 0, 0 }
68  };
69 }
70 
71 
72 // Class PatchRep
73 // ------------------------------------------------------------------------
74 
76  Patch(), geometry(), patch()
77 {}
78 
79 
81  Patch(rhs), geometry(), patch(rhs.patch)
82 {}
83 
84 
85 PatchRep::PatchRep(const std::string &name):
86  Patch(name), geometry(), patch()
87 {}
88 
89 
91 {}
92 
93 
95  return new PatchRep(*this);
96 }
97 
98 
99 Channel *PatchRep::getChannel(const std::string &aKey, bool create) {
100  for(const Entry *entry = entries; entry->name != 0; ++entry) {
101  if(aKey == entry->name) {
102  return new IndirectChannel<PatchRep>(*this, entry->get, entry->set);
103  }
104  }
105 
106  return ElementBase::getChannel(aKey, create);
107 }
108 
109 
111  return field;
112 }
113 
115  return field;
116 }
117 
118 
120  return geometry;
121 }
122 
123 
125  return geometry;
126 }
127 
128 
129 const Euclid3D &PatchRep::getPatch() const {
130  return patch;
131 }
132 
133 
134 void PatchRep::setPatch(const Euclid3D &p) {
135  patch = p;
136 }
137 
138 
139 void PatchRep::setPatch(double x, double y, double z,
140  double vx, double vy, double vz) {
141  patch = Euclid3D(x, y, z, vx, vy, vz);
142 }
143 
144 
147 
148  for(const Entry *entry = entries; entry->name != 0; ++entry) {
149  image->setAttribute(entry->name, (this->*(entry->get))());
150  }
151 
152  return image;
153 }
154 
155 
156 double PatchRep::getX() const {
157  return patch.getX();
158 }
159 
160 
161 double PatchRep::getY() const {
162  return patch.getY();
163 }
164 
165 
166 double PatchRep::getZ() const {
167  return patch.getZ();
168 }
169 
170 
171 double PatchRep::getVX() const {
172  double vx, vy, vz;
173  patch.getRotation().getAxis(vx, vy, vz);
174  return vx;
175 }
176 
177 
178 double PatchRep::getVY() const {
179  double vx, vy, vz;
180  patch.getRotation().getAxis(vx, vy, vz);
181  return vy;
182 }
183 
184 
185 double PatchRep::getVZ() const {
186  double vx, vy, vz;
187  patch.getRotation().getAxis(vx, vy, vz);
188  return vz;
189 }
190 
191 
192 void PatchRep::setX(double x) {
193  patch.setX(x);
194 }
195 
196 
197 void PatchRep::setY(double y) {
198  patch.setY(y);
199 }
200 
201 
202 void PatchRep::setZ(double z) {
203  patch.setZ(z);
204 }
205 
206 
207 void PatchRep::setVX(double v) {
208  double vx, vy, vz;
209  patch.getRotation().getAxis(vx, vy, vz);
210  vx = v;
211  patch.setRotation(Rotation3D(vx, vy, vz));
212 }
213 
214 
215 void PatchRep::setVY(double v) {
216  double vx, vy, vz;
217  patch.getRotation().getAxis(vx, vy, vz);
218  vy = v;
219  patch.setRotation(Rotation3D(vx, vy, vz));
220 }
221 
222 
223 void PatchRep::setVZ(double v) {
224  double vx, vy, vz;
225  patch.getRotation().getAxis(vx, vy, vz);
226  vz = v;
227  patch.setRotation(Rotation3D(vx, vy, vz));
228 }
double getVX() const
Get rotation.
Definition: PatchRep.cpp:171
double getX() const
Get displacement.
Definition: PatchRep.cpp:156
virtual Channel * getChannel(const std::string &aKey, bool=false)
Construct a read/write channel.
Definition: PatchRep.cpp:99
void setY(double)
Set displacement.
Definition: PatchRep.cpp:197
double getVZ() const
Get rotation.
Definition: PatchRep.cpp:185
double getVY() const
Get rotation.
Definition: PatchRep.cpp:178
double getX() const
Get displacement.
Definition: Euclid3D.h:216
void setX(double)
Set displacement.
Definition: PatchRep.cpp:192
Interface for basic beam line object.
Definition: ElementBase.h:128
void setY(double y)
Set displacement.
Definition: Euclid3D.cpp:74
virtual ElementBase * clone() const
Return clone.
Definition: PatchRep.cpp:94
virtual NullGeometry & getGeometry()
Get geometry.
Definition: PatchRep.cpp:119
double getZ() const
Get displacement.
Definition: Euclid3D.h:224
void setRotation(const Rotation3D &R)
Set rotation.
Definition: Euclid3D.cpp:90
virtual Channel * getChannel(const std::string &aKey, bool create=false)
Construct a read/write channel.
Representation for a geometry patch.
Definition: PatchRep.h:33
void setVX(double)
Set rotation.
Definition: PatchRep.cpp:207
A zero electromagnetic field.
Definition: NullField.h:30
NullGeometry geometry
The geometry.
Definition: PatchRep.h:146
double getY() const
Get displacement.
Definition: PatchRep.cpp:161
void setVY(double)
Set rotation.
Definition: PatchRep.cpp:215
void setZ(double)
Set displacement.
Definition: PatchRep.cpp:202
An image of an element.
Definition: ElementImage.h:35
virtual ElementImage * getImage() const
Construct an image.
Geometry representing an identity transform.
Definition: NullGeometry.h:32
Displacement and rotation in space.
Definition: Euclid3D.h:68
void setAttribute(const std::string &aKey, double val)
Set value of an attribute.
virtual ~PatchRep()
Definition: PatchRep.cpp:90
PatchRep()
Definition: PatchRep.cpp:75
void setZ(double z)
Set displacement.
Definition: Euclid3D.cpp:79
const Rotation3D & getRotation() const
Get rotation.
Definition: Euclid3D.cpp:64
void setX(double x)
Set displacement.
Definition: Euclid3D.cpp:69
virtual ElementImage * getImage() const
Construct an image.
Definition: PatchRep.cpp:145
Abstract interface for read/write access to variable.
Definition: Channel.h:32
void setPatch(const Euclid3D &euclid)
Set patch.
Definition: PatchRep.cpp:134
NullField field
The zero magnetic field.
Definition: PatchRep.h:143
Euclid3D patch
The geometry patch.
Definition: PatchRep.h:149
virtual NullField & getField()
Get field.
Definition: PatchRep.cpp:110
const std::string name
virtual const Euclid3D & getPatch() const
Get patch.
Definition: PatchRep.cpp:129
Interface for a geometric patch.
Definition: Patch.h:34
Rotation in 3-dimensional space.
Definition: Rotation3D.h:46
double getY() const
Get displacement.
Definition: Euclid3D.h:220
void setVZ(double)
Set rotation.
Definition: PatchRep.cpp:223
Vector3D getAxis() const
Get axis vector.
Definition: Rotation3D.cpp:91
Access to a [b]double[/b] data member.
double getZ() const
Get displacement.
Definition: PatchRep.cpp:166