Skip to content
Snippets Groups Projects
Commit 35211757 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Merge branch 'sample_visitor' into develop

parents f117abc1 f4aa5c8c
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 7 deletions
......@@ -267,6 +267,7 @@ HEADERS += \
Samples/inc/IMaterial.h \
Samples/inc/IRoughness.h \
Samples/inc/ISample.h \
Samples/inc/ISampleVisitor.h \
Samples/inc/ISelectionRule.h \
Samples/inc/InterferenceFunction1DParaCrystal.h \
Samples/inc/InterferenceFunction2DLattice.h \
......
......@@ -30,6 +30,9 @@ class IFormFactor : public ISample
virtual IFormFactor *clone() const=0;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Passes the refractive index of the ambient material in which this particle is embedded.
virtual void setAmbientRefractiveIndex(const complex_t& refractive_index)
{
......
......@@ -31,6 +31,9 @@ class Crystal : public IClusteredParticles
virtual Crystal *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
virtual void setAmbientRefractiveIndex(complex_t refractive_index)
{ mp_lattice_basis->setAmbientRefractiveIndex(refractive_index); }
......
......@@ -33,6 +33,9 @@ class DiffuseParticleInfo: public ParticleInfo
virtual ~DiffuseParticleInfo() {}
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! scale abundance
void scaleAbundance(double factor) { m_abundance *= factor; }
......
......@@ -26,8 +26,15 @@ class IInterferenceFunction : public ISample
public:
virtual ~IInterferenceFunction() {}
//! Evaluates the interference function for a given wavevector transfer
virtual double evaluate(const cvector_t& q) const=0;
virtual IInterferenceFunction *clone() const=0;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Retrieves the size-distance coupling constant (default 0.0)
virtual double getKappa() const { return 0.0; }
};
......
......@@ -18,6 +18,7 @@
#include "IParameterized.h"
#include "ICloneable.h"
#include "ISampleVisitor.h"
class ICompositeSample;
class DWBASimulation;
......@@ -35,6 +36,9 @@ class ISample : public IParameterized, public ICloneable
virtual ISample *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor)=0;
//! Returns an ISimulation if DWBA is required.
virtual DWBASimulation *createDWBASimulation() const { return 0; }
......
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file Samples/inc/ISampleVisitor.h
//! @brief Defines interface class ISampleVisitor.
//!
//! @homepage http://apps.jcns.fz-juelich.de/BornAgain
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2013
//! @authors Scientific Computing Group at MLZ Garching
//! @authors C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke
//
// ************************************************************************** //
#ifndef ISAMPLEVISITOR_H
#define ISAMPLEVISITOR_H
class ISample;
//! Interface to visit a sample tree and perform operations on its nodes
class ISampleVisitor
{
public:
//! Destructor
virtual ~ISampleVisitor() {}
//! Performs specific action on the given sample
//! Needs to be overloaded for different ISample types
virtual void visit(ISample *sample);
};
#endif // ISAMPLEVISITOR_H
......@@ -29,6 +29,9 @@ class LatticeBasis : public Particle
virtual ~LatticeBasis();
virtual LatticeBasis *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
void addParticle(const Particle& particle, std::vector<kvector_t > positions);
virtual void setAmbientRefractiveIndex(complex_t refractive_index);
......
......@@ -47,6 +47,9 @@ class Layer : public ICompositeSample
virtual Layer *clone() const { return new Layer(*this); }
//virtual Layer *clone() const { return new Layer(mp_material, m_thickness); }
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Sets layer thickness in Angstrom.
virtual void setThickness(double thickness);
......
......@@ -44,6 +44,9 @@ class LayerDecorator : public Layer
virtual LayerDecorator *clone() const
{ return new LayerDecorator(*this); }
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Sets _thickness_ in Angstrom.
virtual void setThickness(double thickness)
{ mp_decorated_layer->setThickness(thickness); }
......
......@@ -28,6 +28,9 @@ class LayerInterface : public ICompositeSample
public:
virtual ~LayerInterface();
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Creates smooth interface between two layers
static LayerInterface* createSmoothInterface(
const Layer *p_layer_top, const Layer *p_layer_bottom);
......
......@@ -35,6 +35,9 @@ class LayerRoughness : public IRoughness
LayerRoughness *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Returns power spectral density of the surface roughness
double getSpectralFun(const kvector_t& kvec) const;
......
......@@ -31,6 +31,9 @@ class MesoCrystal : public Particle
virtual ~MesoCrystal();
virtual MesoCrystal *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
virtual void setAmbientRefractiveIndex(complex_t refractive_index)
{
mp_particle_structure->setAmbientRefractiveIndex(refractive_index);
......
......@@ -41,6 +41,9 @@ class MultiLayer : public ICompositeSample
MultiLayer();
~MultiLayer();
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Returns number of layers in multilayer
inline size_t getNumberOfLayers() const { return m_layers.size(); }
......@@ -148,11 +151,11 @@ class MultiLayer : public ICompositeSample
}
//! stack of layers [nlayers]
std::vector<Layer *> m_layers;
std::vector<Layer *> m_layers;
//! coordinate of layer's bottoms [nlayers]
std::vector<double > m_layers_z;
std::vector<double > m_layers_z;
//! stack of layer interfaces [nlayers-1]
std::vector<LayerInterface *> m_interfaces;
std::vector<LayerInterface *> m_interfaces;
//! cross correlation length (in z direction) between different layers
double m_crossCorrLength;
};
......
......@@ -33,6 +33,9 @@ class Particle : public ICompositeSample
virtual ~Particle();
virtual Particle *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Sets the refractive index of the ambient material (which influences its scattering power)
virtual void setAmbientRefractiveIndex(complex_t refractive_index)
{
......
......@@ -27,6 +27,9 @@ class ParticleCoreShell : public Particle
virtual ~ParticleCoreShell();
virtual ParticleCoreShell *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Sets the refractive index of the ambient material (which influences its scattering power)
virtual void setAmbientRefractiveIndex(complex_t refractive_index)
{
......
......@@ -47,15 +47,18 @@ class ParticleDecoration : public IDecoration
setName("ParticleDecoration");
addParticle(p_particle.clone(), depth, abundance);
}
~ParticleDecoration()
{
for (size_t i=0; i<m_particles.size(); ++i)
delete m_particles[i];
}
virtual ParticleDecoration *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Adds generic particle, *-version.
void addParticle(
Particle *p_particle, const Geometry::PTransform3D& transform,
......
......@@ -48,6 +48,9 @@ class ParticleInfo : public ICompositeSample
mp_particle->clone(), mP_transform, m_depth, m_abundance);
}
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Returns particle.
const Particle *getParticle() const { return mp_particle; }
......
......@@ -44,6 +44,9 @@ class PositionParticleInfo : public ParticleInfo
virtual PositionParticleInfo *clone() const;
//! Calls the ISampleVisitor's visit method
virtual void accept(ISampleVisitor *p_visitor) { p_visitor->visit(this); }
//! Returns particle.
const Particle *getParticle() const { return mp_particle; }
......
......@@ -66,8 +66,8 @@ class ISingleton
};
template<class T > typename ISingleton<T>::T_Pointer ISingleton<T>::m_instance = 0;
template< class T> bool ISingleton<T>::m_destroyed = false;
template<class T> typename ISingleton<T>::T_Pointer ISingleton<T>::m_instance = 0;
template<class T> bool ISingleton<T>::m_destroyed = false;
#endif // ISINGLETON_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment