From eec0022a0de769336d1b1f984498427f71136508 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Tue, 12 Apr 2011 21:07:01 +0000 Subject: Ajout de la methode 'copy()' pour chaque element. --- src/gui/Makefile | 2 +- src/main/Dipole.h | 4 ++++ src/main/Element.h | 2 +- src/main/FODO.cc | 6 ++++++ src/main/FODO.h | 6 ++++++ src/main/Quadrupole.h | 2 ++ src/main/StraightElement.h | 2 ++ 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/Makefile b/src/gui/Makefile index dca1daf..05fc929 100644 --- a/src/gui/Makefile +++ b/src/gui/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: $(BINDIR)/gui/gui -# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Apr 12 19:57:02 2011 +# Generated by qmake (2.01a) (Qt 4.7.0) on: Tue Apr 12 22:34:18 2011 # Project: gui.pro # Template: app # Command: /usr/bin/qmake -o Makefile gui.pro diff --git a/src/main/Dipole.h b/src/main/Dipole.h index 10d8062..c4f7bc0 100644 --- a/src/main/Dipole.h +++ b/src/main/Dipole.h @@ -67,6 +67,10 @@ public: virtual void accept(ElementVisitor& v) {v.visit(this);} + virtual Dipole* copy() const { + return new Dipole(getEntryPosition(), getExitPosition(), getSectionRadius(), getCurvature(), _magneticField); + } + }; diff --git a/src/main/Element.h b/src/main/Element.h index 8e491ad..3a32e3c 100644 --- a/src/main/Element.h +++ b/src/main/Element.h @@ -69,7 +69,7 @@ public: /** Copie l'element sur le heap et renvoye un pointeur sur la copie. * En copiant un element, le pointeur sur l'element suivant est remis a zero. * ATTENTION: La delocation de memoire est sous la responsabilite de l'appelant. */ - //virtual Element* copy() const = 0; + virtual Element* copy() const = 0; /** Determine si la particule donnee a heurte le bord de cet element. */ virtual bool isOutside(const Particle& particle) const = 0; diff --git a/src/main/FODO.cc b/src/main/FODO.cc index c87324c..9ed5308 100644 --- a/src/main/FODO.cc +++ b/src/main/FODO.cc @@ -16,6 +16,8 @@ namespace vhc { FODO::FODO(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double straightLength, double focalisingCoefficient, Element* next): CompositeElement(entry, exit, sectionRadius, next), + straightLength(straightLength), + focalisingCoefficient(focalisingCoefficient), focalisingQuadrupole(NULL), defocalisingQuadrupole(NULL), straightElement1(NULL), @@ -49,4 +51,8 @@ FODO::~FODO() { } } +FODO* FODO::copy() const { + return new FODO(getEntryPosition(), getExitPosition(), getSectionRadius(), straightLength, focalisingCoefficient); +} + } diff --git a/src/main/FODO.h b/src/main/FODO.h index 99241a6..31b5bb9 100644 --- a/src/main/FODO.h +++ b/src/main/FODO.h @@ -15,6 +15,10 @@ namespace vhc { class FODO: public CompositeElement { + +private: + double straightLength; + double focalisingCoefficient; Quadrupole* focalisingQuadrupole; Quadrupole* defocalisingQuadrupole; StraightElement* straightElement1; @@ -24,6 +28,8 @@ public: FODO(const Vector3D& entry, const Vector3D& exit, double sectionRadius, double straightLength, double focalisingCoefficient, Element* next = NULL); virtual ~FODO(); + + virtual FODO* copy() const; }; } diff --git a/src/main/Quadrupole.h b/src/main/Quadrupole.h index c2ee6a5..6179b71 100644 --- a/src/main/Quadrupole.h +++ b/src/main/Quadrupole.h @@ -47,6 +47,8 @@ public: virtual std::string getType() const {return "Quadrupole";} virtual void accept(ElementVisitor& v) {v.visit(this);} + + virtual Quadrupole* copy() const {return new Quadrupole(getEntryPosition(), getExitPosition(), getSectionRadius(), focusingCoefficient);} }; } diff --git a/src/main/StraightElement.h b/src/main/StraightElement.h index eb493d0..1f61635 100644 --- a/src/main/StraightElement.h +++ b/src/main/StraightElement.h @@ -48,6 +48,8 @@ public: virtual void accept(ElementVisitor& v) {v.visit(this);} + virtual StraightElement* copy() const {return new StraightElement(getEntryPosition(), getExitPosition(), getSectionRadius());} + }; } -- cgit v1.2.3