OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
OpalPatch.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: OpalPatch.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: OpalPatch
10 // The class of OPAL patch spaces.
11 //
12 // ------------------------------------------------------------------------
13 //
14 // $Date: 2000/03/27 09:33:40 $
15 // $Author: Andreas Adelmann $
16 //
17 // ------------------------------------------------------------------------
18 
19 #include "Elements/OpalPatch.h"
20 #include "Attributes/Attributes.h"
21 #include "BeamlineCore/PatchRep.h"
22 
23 
24 // Class OpalPatch
25 // ------------------------------------------------------------------------
26 
28  OpalElement(SIZE, "PATCH",
29  "The \"PATCH\" element implements a local reference change.") {
30  itsAttr[LENGTH].setReadOnly(true);
31  itsAttr[HORD] = Attributes::makeReal("HORD", "Horizontal orbit shift");
32  itsAttr[VERTD] = Attributes::makeReal("VERTD", "Vertical orbit shift");
33  itsAttr[LONGD] = Attributes::makeReal("LONGD", "Longitudinal orbit shift");
34  itsAttr[VX] = Attributes::makeReal("VX", "Rotation around x-axis.");
35  itsAttr[VY] = Attributes::makeReal("VY", "Rotation around y-axis.");
36  itsAttr[VS] = Attributes::makeReal("VS", "Rotation around s-axis.");
37 
39 
40  setElement(new PatchRep("PATCH"));
41 }
42 
43 
44 OpalPatch::OpalPatch(const std::string &name, OpalPatch *parent):
45  OpalElement(name, parent) {
46  setElement(new PatchRep(name));
47 }
48 
49 
51 {}
52 
53 
54 OpalPatch *OpalPatch::clone(const std::string &name) {
55  return new OpalPatch(name, this);
56 }
57 
58 
59 bool OpalPatch::isPatch() const {
60  return true;
61 }
62 
63 
66 
67  PatchRep *patch = static_cast<PatchRep *>(getElement());
68  double dx = Attributes::getReal(itsAttr[HORD]);
69  double dy = Attributes::getReal(itsAttr[VERTD]);
70  double ds = Attributes::getReal(itsAttr[LONGD]);
71  double vx = Attributes::getReal(itsAttr[VX]);
72  double vy = Attributes::getReal(itsAttr[VY]);
73  double vs = Attributes::getReal(itsAttr[VS]);
74  Euclid3D shift(dx, dy, ds, vx, vy, vs);
75  patch->setPatch(shift);
76 
77  // Transmit "unknown" attributes.
79 }
virtual bool isPatch() const
Test for patch.
Definition: OpalPatch.cpp:59
virtual ~OpalPatch()
Definition: OpalPatch.cpp:50
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
Definition: Object.h:214
Representation for a geometry patch.
Definition: PatchRep.h:33
OpalPatch()
Exemplar constructor.
Definition: OpalPatch.cpp:27
Displacement and rotation in space.
Definition: Euclid3D.h:68
Base class for all beam line elements.
Definition: OpalElement.h:41
void setElement(ElementBase *)
Assign new CLASSIC element.
Definition: Element.h:133
void registerOwnership() const
virtual void update()
Update the embedded CLASSIC element.
virtual void updateUnknown(ElementBase *)
Transmit the ``unknown&#39;&#39; (not known to OPAL) attributes to CLASSIC.
virtual void update()
Update the embedded CLASSIC patch.
Definition: OpalPatch.cpp:64
ElementBase * getElement() const
Return the embedded CLASSIC element.
Definition: Element.h:128
The PATCH element.
Definition: OpalPatch.h:28
void setPatch(const Euclid3D &euclid)
Set patch.
Definition: PatchRep.cpp:134
virtual OpalPatch * clone(const std::string &name)
Make clone.
Definition: OpalPatch.cpp:54
const std::string name
double getReal(const Attribute &attr)
Return real value.
Definition: Attributes.cpp:217
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
Definition: Attributes.cpp:205