From 1b409a99a110378dc96c7b606ac105d598ed993c Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Thu, 26 Nov 2015 15:41:22 +0100 Subject: [PATCH] Replace setName("magic constant...") with predefined names in BornAgain namespace --- Core/Algorithms/inc/GISASSimulation.h | 4 +- Core/Algorithms/inc/OffSpecSimulation.h | 2 + Core/Algorithms/src/Beam.cpp | 3 +- Core/Algorithms/src/Distributions.cpp | 47 +++--- Core/Algorithms/src/FTDistributions.cpp | 27 ++-- Core/Algorithms/src/GISASSimulation.cpp | 21 +-- Core/Algorithms/src/IIntensityNormalizer.cpp | 24 +-- Core/Algorithms/src/IsGISAXSDetector.cpp | 5 +- Core/Algorithms/src/OffSpecSimulation.cpp | 21 +-- Core/Algorithms/src/RectangularDetector.cpp | 4 +- Core/Algorithms/src/SphericalDetector.cpp | 4 +- .../inc/FormFactorDecoratorDebyeWaller.h | 1 + .../inc/FormFactorDecoratorFactor.h | 3 +- .../inc/FormFactorDecoratorMaterial.h | 1 - .../FormFactorDecoratorMultiPositionFactor.h | 9 +- .../inc/FormFactorDecoratorPositionFactor.h | 5 +- .../inc/FormFactorDecoratorRotation.h | 26 +-- .../inc/FormFactorEllipsoidalCylinder.h | 4 +- Core/FormFactors/inc/FormFactorFullSphere.h | 32 +--- Core/FormFactors/inc/FormFactorGauss.h | 1 + .../FormFactors/inc/FormFactorHemiEllipsoid.h | 5 - Core/FormFactors/inc/FormFactorLorentz.h | 5 +- Core/FormFactors/inc/FormFactorPrism3.h | 6 +- Core/FormFactors/inc/FormFactorPrism6.h | 4 +- Core/FormFactors/inc/FormFactorPyramid.h | 2 +- Core/FormFactors/inc/FormFactorRipple1.h | 2 +- Core/FormFactors/inc/FormFactorRipple2.h | 2 +- .../inc/FormFactorSphereGaussianRadius.h | 2 +- .../inc/FormFactorSphereLogNormalRadius.h | 2 +- .../inc/FormFactorSphereUniformRadius.h | 2 +- Core/FormFactors/inc/FormFactorTetrahedron.h | 5 +- Core/FormFactors/inc/FormFactorTrivial.h | 4 +- .../FormFactors/inc/FormFactorTruncatedCube.h | 4 +- .../inc/FormFactorTruncatedSphere.h | 2 +- .../inc/FormFactorTruncatedSpheroid.h | 4 +- Core/FormFactors/inc/FormFactorWeighted.h | 4 +- .../src/FormFactorAnisoPyramid.cpp | 3 +- Core/FormFactors/src/FormFactorBox.cpp | 3 +- Core/FormFactors/src/FormFactorCone.cpp | 6 +- Core/FormFactors/src/FormFactorCone6.cpp | 6 +- Core/FormFactors/src/FormFactorCrystal.cpp | 3 +- .../src/FormFactorCuboctahedron.cpp | 3 +- Core/FormFactors/src/FormFactorCylinder.cpp | 4 +- Core/FormFactors/src/FormFactorDWBA.cpp | 3 +- Core/FormFactors/src/FormFactorDWBAPol.cpp | 3 +- .../src/FormFactorDecoratorDebyeWaller.cpp | 16 +- .../src/FormFactorDecoratorMaterial.cpp | 7 +- ...FormFactorDecoratorMultiPositionFactor.cpp | 8 +- .../src/FormFactorDecoratorRotation.cpp | 27 +++- .../src/FormFactorEllipsoidalCylinder.cpp | 13 +- Core/FormFactors/src/FormFactorFullSphere.cpp | 8 +- .../src/FormFactorFullSpheroid.cpp | 3 +- Core/FormFactors/src/FormFactorGauss.cpp | 23 +-- .../src/FormFactorHemiEllipsoid.cpp | 6 +- Core/FormFactors/src/FormFactorLorentz.cpp | 22 ++- Core/FormFactors/src/FormFactorPrism3.cpp | 9 +- Core/FormFactors/src/FormFactorPrism6.cpp | 9 +- Core/FormFactors/src/FormFactorPyramid.cpp | 8 +- Core/FormFactors/src/FormFactorRipple1.cpp | 12 +- Core/FormFactors/src/FormFactorRipple2.cpp | 11 +- .../src/FormFactorSphereGaussianRadius.cpp | 9 +- .../src/FormFactorSphereLogNormalRadius.cpp | 9 +- .../src/FormFactorSphereUniformRadius.cpp | 9 +- .../FormFactors/src/FormFactorTetrahedron.cpp | 17 +- Core/FormFactors/src/FormFactorTrivial.cpp | 9 +- .../src/FormFactorTruncatedCube.cpp | 8 +- .../src/FormFactorTruncatedSphere.cpp | 14 +- .../src/FormFactorTruncatedSpheroid.cpp | 15 +- Core/FormFactors/src/FormFactorWeighted.cpp | 11 +- .../src/FormFactorFullSphere.pypp.cpp | 2 +- .../PythonAPI/src/FormFactorWeighted.pypp.cpp | 3 +- Core/PythonAPI/src/GISASSimulation.pypp.cpp | 2 +- Core/PythonAPI/src/IParameterized.pypp.cpp | 2 +- Core/PythonAPI/src/ISample.pypp.cpp | 11 +- Core/PythonAPI/src/Layer.pypp.cpp | 3 +- Core/Samples/inc/Crystal.h | 3 +- .../inc/InterferenceFunction1DLattice.h | 2 +- .../inc/InterferenceFunction2DLattice.h | 21 +-- .../inc/InterferenceFunction2DParaCrystal.h | 21 ++- Core/Samples/inc/InterferenceFunctionNone.h | 20 +-- .../InterferenceFunctionRadialParaCrystal.h | 18 +-- Core/Samples/inc/Layer.h | 52 ++---- Core/Samples/inc/LayerInterface.h | 24 ++- Core/Samples/inc/LayerRoughness.h | 24 +-- Core/Samples/inc/MesoCrystal.h | 13 +- Core/Samples/inc/Particle.h | 31 ++-- Core/Samples/inc/ParticleComposition.h | 21 +-- Core/Samples/inc/ParticleCoreShell.h | 6 +- Core/Samples/inc/ParticleDistribution.h | 38 ++--- Core/Samples/inc/ParticleInfo.h | 29 +--- Core/Samples/inc/ParticleLayout.h | 20 +-- Core/Samples/inc/Rotations.h | 42 ++--- Core/Samples/src/Crystal.cpp | 11 +- .../src/InterferenceFunction1DLattice.cpp | 70 ++++---- .../src/InterferenceFunction2DLattice.cpp | 153 +++++++++--------- .../src/InterferenceFunction2DParaCrystal.cpp | 17 +- Core/Samples/src/InterferenceFunctionNone.cpp | 38 +++++ .../InterferenceFunctionRadialParaCrystal.cpp | 38 ++++- Core/Samples/src/Layer.cpp | 94 +++++++++-- Core/Samples/src/LayerInterface.cpp | 34 +++- Core/Samples/src/LayerRoughness.cpp | 50 +++++- Core/Samples/src/MesoCrystal.cpp | 57 ++++--- Core/Samples/src/MultiLayer.cpp | 26 +-- Core/Samples/src/Particle.cpp | 62 +++++-- Core/Samples/src/ParticleComposition.cpp | 48 ++++-- Core/Samples/src/ParticleCoreShell.cpp | 34 ++-- Core/Samples/src/ParticleDistribution.cpp | 40 ++++- Core/Samples/src/ParticleInfo.cpp | 28 +++- Core/Samples/src/ParticleLayout.cpp | 27 +++- Core/Samples/src/Rotations.cpp | 69 +++++++- .../ParticleDistributionsBuilder.cpp | 15 +- .../SizeDistributionModelsBuilder.cpp | 10 +- .../TestComponentsRegistry.cpp | 38 ++--- Core/Tools/inc/BornAgainNamespace.h | 128 +++++++++++---- Core/Tools/inc/IParameterized.h | 18 +++ Core/Tools/src/BornAgainNamespace.cpp | 133 +++++++++++++++ Core/Tools/src/IParameterized.cpp | 21 +++ Core/Tools/src/ParameterPool.cpp | 3 +- GUI/coregui/Models/DetectorItems.cpp | 4 +- GUI/coregui/Models/GroupPropertyRegistry.cpp | 2 +- GUI/coregui/Models/ItemFactory.cpp | 2 +- GUI/coregui/Models/TransformToDomain.cpp | 2 +- GUI/coregui/Models/item_constants.h | 2 +- .../UnitTests/TestCore/FTDistributionsTest.h | 45 +++--- Tests/UnitTests/TestCore/FormFactorTest.h | 119 +++++++------- Tests/UnitTests/TestCore/LayerRoughnessTest.h | 27 +--- .../TestCore/ParticleCoreShellTest.h | 56 ++++--- Tests/UnitTests/TestCore/ParticleInfoTest.h | 20 +-- Tests/UnitTests/TestCore/ParticleTest.h | 55 +++---- 129 files changed, 1606 insertions(+), 1014 deletions(-) create mode 100644 Core/Samples/src/InterferenceFunctionNone.cpp create mode 100644 Core/Tools/src/BornAgainNamespace.cpp diff --git a/Core/Algorithms/inc/GISASSimulation.h b/Core/Algorithms/inc/GISASSimulation.h index 303e62f8307..bfcee38fe7a 100644 --- a/Core/Algorithms/inc/GISASSimulation.h +++ b/Core/Algorithms/inc/GISASSimulation.h @@ -117,7 +117,7 @@ public: //! that the channel will be excluded from the simulation. The mask which is added last //! has priority. //! @param shape The shape of mask (Rectangle, Polygon, Line, Ellipse) - //! @mask_value The value of mask + //! @param mask_value The value of mask void addMask(const Geometry::IShape2D &shape, bool mask_value = true); //! Put the mask for all detector channels (i.e. exclude whole detector from the analysis) @@ -145,6 +145,8 @@ protected: // extra components describing a GISAS experiment and its simulation: Instrument m_instrument; OutputData<double> m_intensity_map; +private: + void initialize(); }; #endif /* GISASSIMULATION_H_ */ diff --git a/Core/Algorithms/inc/OffSpecSimulation.h b/Core/Algorithms/inc/OffSpecSimulation.h index 1e32e3cc040..f31e59d4f2f 100644 --- a/Core/Algorithms/inc/OffSpecSimulation.h +++ b/Core/Algorithms/inc/OffSpecSimulation.h @@ -119,6 +119,8 @@ private: //! Check correct number of axes void checkInitialization() const; + + void initialize(); }; #endif /* OFFSPECSIMULATION_H_ */ diff --git a/Core/Algorithms/src/Beam.cpp b/Core/Algorithms/src/Beam.cpp index ea7fbc39a49..e8fdf6eb22f 100644 --- a/Core/Algorithms/src/Beam.cpp +++ b/Core/Algorithms/src/Beam.cpp @@ -14,13 +14,14 @@ // ************************************************************************** // #include "Beam.h" +#include "BornAgainNamespace.h" #include "Exceptions.h" #include "Numeric.h" #include <Eigen/LU> Beam::Beam() : m_wavelength(1.0), m_alpha(0.0), m_phi(0.0), m_intensity(0.0) { - setName("Beam"); + setName(BornAgain::BeamType); init_parameters(); initPolarization(); } diff --git a/Core/Algorithms/src/Distributions.cpp b/Core/Algorithms/src/Distributions.cpp index be649cb3be8..26f98702d6e 100644 --- a/Core/Algorithms/src/Distributions.cpp +++ b/Core/Algorithms/src/Distributions.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "Distributions.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Exceptions.h" @@ -100,20 +101,16 @@ std::vector<double> IDistribution1D::generateValues(size_t nbr_samples, // ---------------------------------------------------------------------------------------------- // -DistributionGate::DistributionGate() - : m_min(0.0) - , m_max(1.0) - { - setName("DistributionGate"); - checkInitialization(); - init_parameters(); - } +DistributionGate::DistributionGate() : m_min(0.0), m_max(1.0) +{ + setName(BornAgain::DistributionGateType); + checkInitialization(); + init_parameters(); +} -DistributionGate::DistributionGate(double min, double max) - : m_min(min) - , m_max(max) +DistributionGate::DistributionGate(double min, double max) : m_min(min), m_max(max) { - setName("DistributionGate"); + setName(BornAgain::DistributionGateType); checkInitialization(); init_parameters(); } @@ -144,7 +141,7 @@ bool DistributionGate::checkInitialization() const { bool result = true; if (m_max < m_min) result = false; - if (!result) SignalBadInitialization("DistributionGate"); + if (!result) SignalBadInitialization(BornAgain::DistributionGateType); return result; } @@ -154,7 +151,7 @@ DistributionLorentz::DistributionLorentz() : m_mean(0.0) , m_hwhm(1.0) { - setName("DistributionLorentz"); + setName(BornAgain::DistributionLorentzType); checkInitialization(); init_parameters(); } @@ -163,7 +160,7 @@ DistributionLorentz::DistributionLorentz(double mean, double hwhm) : m_mean(mean) , m_hwhm(hwhm) { - setName("DistributionLorentz"); + setName(BornAgain::DistributionLorentzType); checkInitialization(); init_parameters(); } @@ -195,7 +192,7 @@ bool DistributionLorentz::checkInitialization() const { bool result = true; if (m_hwhm < 0.0) result = false; - if (!result) SignalBadInitialization("DistributionLorentz"); + if (!result) SignalBadInitialization(BornAgain::DistributionLorentzType); return result; } @@ -205,7 +202,7 @@ DistributionGaussian::DistributionGaussian() : m_mean(0.0) , m_std_dev(1.0) { - setName("DistributionGaussian"); + setName(BornAgain::DistributionGaussianType); checkInitialization(); init_parameters(); } @@ -214,7 +211,7 @@ DistributionGaussian::DistributionGaussian(double mean, double std_dev) : m_mean(mean) , m_std_dev(std_dev) { - setName("DistributionGaussian"); + setName(BornAgain::DistributionGaussianType); checkInitialization(); init_parameters(); } @@ -248,7 +245,7 @@ bool DistributionGaussian::checkInitialization() const { bool result = true; if (m_std_dev < 0.0) result = false; - if (!result) SignalBadInitialization("DistributionGaussian"); + if (!result) SignalBadInitialization(BornAgain::DistributionGaussianType); return result; } @@ -258,7 +255,7 @@ DistributionLogNormal::DistributionLogNormal(double scale_param) : m_median(1.0) , m_scale_param(scale_param) { - setName("DistributionLogNormal"); + setName(BornAgain::DistributionLogNormalType); checkInitialization(); init_parameters(); } @@ -267,7 +264,7 @@ DistributionLogNormal::DistributionLogNormal(double median, double scale_param) : m_median(median) , m_scale_param(scale_param) { - setName("DistributionLogNormal"); + setName(BornAgain::DistributionLogNormalType); checkInitialization(); init_parameters(); } @@ -313,7 +310,7 @@ bool DistributionLogNormal::checkInitialization() const bool result = true; if (m_scale_param < 0.0) result = false; if (m_median <= 0.0) result = false; - if (!result) SignalBadInitialization("DistributionLogNormal"); + if (!result) SignalBadInitialization(BornAgain::DistributionLogNormalType); return result; } @@ -323,7 +320,7 @@ DistributionCosine::DistributionCosine() : m_mean(0.0) , m_sigma(1.0) { - setName("DistributionCosine"); + setName(BornAgain::DistributionCosineType); checkInitialization(); init_parameters(); } @@ -332,7 +329,7 @@ DistributionCosine::DistributionCosine(double mean, double sigma) : m_mean(mean) , m_sigma(sigma) { - setName("DistributionCosine"); + setName(BornAgain::DistributionCosineType); checkInitialization(); init_parameters(); } @@ -365,6 +362,6 @@ bool DistributionCosine::checkInitialization() const { bool result = true; if (m_sigma < 0.0) result = false; - if (!result) SignalBadInitialization("DistributionCosine"); + if (!result) SignalBadInitialization(BornAgain::DistributionCosineType); return result; } diff --git a/Core/Algorithms/src/FTDistributions.cpp b/Core/Algorithms/src/FTDistributions.cpp index 340002fb46e..da7935bb2e9 100644 --- a/Core/Algorithms/src/FTDistributions.cpp +++ b/Core/Algorithms/src/FTDistributions.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FTDistributions.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "MemberFunctionIntegrator.h" @@ -30,7 +31,7 @@ void IFTDistribution1D::init_parameters() FTDistribution1DCauchy::FTDistribution1DCauchy(double omega) : IFTDistribution1D(omega) { - setName("1DDistributionCauchy"); + setName(BornAgain::FTDistribution1DCauchyType); init_parameters(); } @@ -49,7 +50,7 @@ double FTDistribution1DCauchy::evaluate(double q) const FTDistribution1DGauss::FTDistribution1DGauss(double omega) : IFTDistribution1D(omega) { - setName("1DDistributionGauss"); + setName(BornAgain::FTDistribution1DGaussType); init_parameters(); } @@ -68,7 +69,7 @@ double FTDistribution1DGauss::evaluate(double q) const FTDistribution1DGate::FTDistribution1DGate(double omega) : IFTDistribution1D(omega) { - setName("1DDistributionGate"); + setName(BornAgain::FTDistribution1DGateType); init_parameters(); } @@ -86,7 +87,7 @@ double FTDistribution1DGate::evaluate(double q) const FTDistribution1DTriangle::FTDistribution1DTriangle(double omega) : IFTDistribution1D(omega) { - setName("1DDistributionTriangle"); + setName(BornAgain::FTDistribution1DTriangleType); init_parameters(); } @@ -105,7 +106,7 @@ double FTDistribution1DTriangle::evaluate(double q) const FTDistribution1DCosine::FTDistribution1DCosine(double omega) : IFTDistribution1D(omega) { - setName("1DDistributionCosine"); + setName(BornAgain::FTDistribution1DCosineType); init_parameters(); } @@ -130,7 +131,7 @@ FTDistribution1DVoigt::FTDistribution1DVoigt(double omega, double eta) : IFTDistribution1D(omega) , m_eta(eta) { - setName("1DDistributionVoigt"); + setName(BornAgain::FTDistribution1DVoigtType); init_parameters(); } @@ -161,10 +162,8 @@ void IFTDistribution1D::print(std::ostream& ostr) const //==============2D==================== -double IFTDistribution2D::evaluateLattice(double qx, double qy) const +double IFTDistribution2D::evaluateLattice(double, double) const { - (void)qx; - (void)qy; throw NotImplementedException("IFTDistribution2D::evaluateLattice: This " "distribution can not be used for the reciprocal lattice approach"); } @@ -195,7 +194,7 @@ FTDistribution2DCauchy::FTDistribution2DCauchy(double coherence_length_x, double coherence_length_y) : IFTDistribution2D(coherence_length_x, coherence_length_y) { - setName("2DDistributionCauchy"); + setName(BornAgain::FTDistribution2DCauchyType); init_parameters(); } @@ -223,7 +222,7 @@ FTDistribution2DGauss::FTDistribution2DGauss(double coherence_length_x, double coherence_length_y) : IFTDistribution2D(coherence_length_x, coherence_length_y) { - setName("2DDistributionGauss"); + setName(BornAgain::FTDistribution2DGaussType); init_parameters(); } @@ -253,7 +252,7 @@ FTDistribution2DGate::FTDistribution2DGate(double coherence_length_x, double coherence_length_y) : IFTDistribution2D(coherence_length_x, coherence_length_y) { - setName("2DDistributionGate"); + setName(BornAgain::FTDistribution2DGateType); init_parameters(); } @@ -276,7 +275,7 @@ FTDistribution2DCone::FTDistribution2DCone(double coherence_length_x, double coherence_length_y) : IFTDistribution2D(coherence_length_x, coherence_length_y) { - setName("2DDistributionCone"); + setName(BornAgain::FTDistribution2DConeType); init_parameters(); } @@ -315,7 +314,7 @@ FTDistribution2DVoigt::FTDistribution2DVoigt(double coherence_length_x, : IFTDistribution2D(coherence_length_x, coherence_length_y) , m_eta(eta) { - setName("2DDistributionVoigt"); + setName(BornAgain::FTDistribution2DVoigtType); init_parameters(); } diff --git a/Core/Algorithms/src/GISASSimulation.cpp b/Core/Algorithms/src/GISASSimulation.cpp index 5c8b3d186ad..d3b705d4377 100644 --- a/Core/Algorithms/src/GISASSimulation.cpp +++ b/Core/Algorithms/src/GISASSimulation.cpp @@ -33,8 +33,7 @@ GISASSimulation::GISASSimulation() : m_instrument() , m_intensity_map() { - setName("GISASSimulation"); - init_parameters(); + initialize(); } GISASSimulation::GISASSimulation(const ProgramOptions *p_options) @@ -42,8 +41,7 @@ GISASSimulation::GISASSimulation(const ProgramOptions *p_options) , m_instrument() , m_intensity_map() { - setName("GISASSimulation"); - init_parameters(); + initialize(); } GISASSimulation::GISASSimulation( @@ -52,8 +50,7 @@ GISASSimulation::GISASSimulation( , m_instrument() , m_intensity_map() { - setName("GISASSimulation"); - init_parameters(); + initialize(); } GISASSimulation::GISASSimulation( @@ -62,8 +59,7 @@ GISASSimulation::GISASSimulation( , m_instrument() , m_intensity_map() { - setName("GISASSimulation"); - init_parameters(); + initialize(); } GISASSimulation *GISASSimulation::clone() const @@ -232,8 +228,7 @@ GISASSimulation::GISASSimulation(const GISASSimulation& other) { m_intensity_map.copyFrom(other.m_intensity_map); - setName("GISASSimulation"); - init_parameters(); + initialize(); } void GISASSimulation::init_parameters() @@ -275,3 +270,9 @@ void GISASSimulation::updateIntensityMap() } m_intensity_map.setAllTo(0.); } + +void GISASSimulation::initialize() +{ + setName(BornAgain::GISASSimulationType); + init_parameters(); +} diff --git a/Core/Algorithms/src/IIntensityNormalizer.cpp b/Core/Algorithms/src/IIntensityNormalizer.cpp index a53563cf551..af2e9813819 100644 --- a/Core/Algorithms/src/IIntensityNormalizer.cpp +++ b/Core/Algorithms/src/IIntensityNormalizer.cpp @@ -35,24 +35,6 @@ IntensityNormalizer *IntensityNormalizer::clone() const OutputData<double> *IntensityNormalizer::createNormalizedData( const OutputData<double>& data) const { -// double factor = m_max_intensity; -// if(factor == 0) { -// // using self maximum amplitude for normalization -// OutputData<double>::const_iterator it = std::max_element(data.begin(), data.end()); -// factor = *it; -// } -// if(factor == 0) -// throw DivisionByZeroException( -// "IntensityNormalizer::createNormalizedData() -> " -// "Error! Maximum intensity is 0."); -// OutputData<double > *normalized_data = data.clone(); -// for(OutputData<double >::iterator it = -// normalized_data->begin(); it!=normalized_data->end(); ++it) { -// double value = (*it); -// (*it) = m_scale*(value/factor) + m_shift; -// } -// return normalized_data; - OutputData<double > *normalized_data = data.clone(); apply(*normalized_data); return normalized_data; @@ -71,9 +53,7 @@ void IntensityNormalizer::apply(OutputData<double>& data) const "IntensityNormalizer::apply() -> " "Error! Maximum intensity is 0."); - for(OutputData<double >::iterator it = - data.begin(); it!=data.end(); ++it) { - double value = (*it); - (*it) = m_scale*(value/factor) + m_shift; + for(auto& value : data) { + value = m_scale*(value/factor) + m_shift; } } diff --git a/Core/Algorithms/src/IsGISAXSDetector.cpp b/Core/Algorithms/src/IsGISAXSDetector.cpp index 24e31e3381e..53d8fed3154 100644 --- a/Core/Algorithms/src/IsGISAXSDetector.cpp +++ b/Core/Algorithms/src/IsGISAXSDetector.cpp @@ -14,19 +14,20 @@ // ************************************************************************** // #include "IsGISAXSDetector.h" +#include "BornAgainNamespace.h" #include "CustomBinAxis.h" IsGISAXSDetector::IsGISAXSDetector() { - setName("IsGISAXSDetector"); + setName(BornAgain::IsGISAXSDetectorType); init_parameters(); } IsGISAXSDetector::IsGISAXSDetector(const IsGISAXSDetector &other) : SphericalDetector(other) { - setName("IsGISAXSDetector"); + setName(BornAgain::IsGISAXSDetectorType); init_parameters(); } diff --git a/Core/Algorithms/src/OffSpecSimulation.cpp b/Core/Algorithms/src/OffSpecSimulation.cpp index ad1556f4a25..297f0b4ba21 100644 --- a/Core/Algorithms/src/OffSpecSimulation.cpp +++ b/Core/Algorithms/src/OffSpecSimulation.cpp @@ -24,8 +24,7 @@ OffSpecSimulation::OffSpecSimulation() , mp_alpha_i_axis(0) , m_intensity_map() { - setName("OffSpecSimulation"); - init_parameters(); + initialize(); } OffSpecSimulation::OffSpecSimulation(const ProgramOptions* p_options) @@ -34,8 +33,7 @@ OffSpecSimulation::OffSpecSimulation(const ProgramOptions* p_options) , mp_alpha_i_axis(0) , m_intensity_map() { - setName("OffSpecSimulation"); - init_parameters(); + initialize(); } OffSpecSimulation::OffSpecSimulation(const ISample& p_sample, @@ -45,8 +43,7 @@ OffSpecSimulation::OffSpecSimulation(const ISample& p_sample, , mp_alpha_i_axis(0) , m_intensity_map() { - setName("OffSpecSimulation"); - init_parameters(); + initialize(); } OffSpecSimulation::OffSpecSimulation(SampleBuilder_t p_sample_builder, @@ -56,8 +53,7 @@ OffSpecSimulation::OffSpecSimulation(SampleBuilder_t p_sample_builder, , mp_alpha_i_axis(0) , m_intensity_map() { - setName("OffSpecSimulation"); - init_parameters(); + initialize(); } OffSpecSimulation* OffSpecSimulation::clone() const @@ -193,8 +189,7 @@ OffSpecSimulation::OffSpecSimulation(const OffSpecSimulation& other) if(other.mp_alpha_i_axis) mp_alpha_i_axis = other.mp_alpha_i_axis->clone(); m_intensity_map.copyFrom(other.m_intensity_map); - setName("OffSpecSimulation"); - init_parameters(); + initialize(); } void OffSpecSimulation::init_parameters() @@ -295,3 +290,9 @@ void OffSpecSimulation::checkInitialization() const "alpha-axis is not correct"); } } + +void OffSpecSimulation::initialize() +{ + setName(BornAgain::OffSpecSimulationType); + init_parameters(); +} diff --git a/Core/Algorithms/src/RectangularDetector.cpp b/Core/Algorithms/src/RectangularDetector.cpp index 7e1b0d27c7f..bfd809a9a3b 100644 --- a/Core/Algorithms/src/RectangularDetector.cpp +++ b/Core/Algorithms/src/RectangularDetector.cpp @@ -31,7 +31,7 @@ RectangularDetector::RectangularDetector(kvector_t normal_to_detector, kvector_t m_u_unit = normalizeToUnitLength( d2 * u_direction - u_direction.dot(m_normal_to_detector) * m_normal_to_detector); m_v_unit = normalizeToUnitLength(m_u_unit.cross(m_normal_to_detector)); - setName("RectangularDetector"); + setName(BornAgain::RectangularDetectorType); init_parameters(); } @@ -40,7 +40,7 @@ RectangularDetector::RectangularDetector(const RectangularDetector &other) , m_normal_to_detector(other.m_normal_to_detector) , m_u_unit(other.m_u_unit), m_v_unit(other.m_v_unit) { - setName("RectangularDetector"); + setName(BornAgain::RectangularDetectorType); init_parameters(); } diff --git a/Core/Algorithms/src/SphericalDetector.cpp b/Core/Algorithms/src/SphericalDetector.cpp index 121f2c30f09..43d2cc0507d 100644 --- a/Core/Algorithms/src/SphericalDetector.cpp +++ b/Core/Algorithms/src/SphericalDetector.cpp @@ -26,14 +26,14 @@ SphericalDetector::SphericalDetector() { - setName("SphericalDetector"); + setName(BornAgain::SphericalDetectorType); init_parameters(); } SphericalDetector::SphericalDetector(const SphericalDetector &other) : IDetector2D(other) { - setName("SphericalDetector"); + setName(BornAgain::SphericalDetectorType); init_parameters(); } diff --git a/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h b/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h index 1ea4ab11e2a..f2599e01685 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h +++ b/Core/FormFactors/inc/FormFactorDecoratorDebyeWaller.h @@ -52,6 +52,7 @@ protected: private: double m_h_dw_factor; //!< the Debye-Waller factor in the z-direction double m_r_dw_factor; //!< the Debye-Waller factor in the radial direction + void initialize(); }; #endif /* FORMFACTORDECORATORDEBYEWALLER_H_ */ diff --git a/Core/FormFactors/inc/FormFactorDecoratorFactor.h b/Core/FormFactors/inc/FormFactorDecoratorFactor.h index 28ff2f5c169..7d27e6057b4 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorFactor.h @@ -17,6 +17,7 @@ #define FORMFACTORDECORATORFACTOR_H_ #include "IFormFactorDecorator.h" +#include "BornAgainNamespace.h" //! @class FormFactorDecoratorFactor //! @ingroup formfactors_internal @@ -46,7 +47,7 @@ inline FormFactorDecoratorFactor::FormFactorDecoratorFactor(const IFormFactor &f const complex_t &factor) : IFormFactorDecorator(form_factor), m_factor(factor) { - setName("FormFactorDecoratorFactor"); + setName(BornAgain::FormFactorDecoratorFactor); } inline FormFactorDecoratorFactor *FormFactorDecoratorFactor::clone() const diff --git a/Core/FormFactors/inc/FormFactorDecoratorMaterial.h b/Core/FormFactors/inc/FormFactorDecoratorMaterial.h index a626a08f789..f08c163cba2 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorMaterial.h +++ b/Core/FormFactors/inc/FormFactorDecoratorMaterial.h @@ -30,7 +30,6 @@ class BA_CORE_API_ FormFactorDecoratorMaterial : public FormFactorDecoratorFacto public: FormFactorDecoratorMaterial(const IFormFactor &form_factor, complex_t wavevector_scattering_factor = 1.0); - virtual ~FormFactorDecoratorMaterial(); virtual FormFactorDecoratorMaterial *clone() const; diff --git a/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h b/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h index ec9763a14b8..c78b7798032 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorMultiPositionFactor.h @@ -27,15 +27,10 @@ class BA_CORE_API_ FormFactorDecoratorMultiPositionFactor : public IFormFactorDe public: FormFactorDecoratorMultiPositionFactor(const IFormFactor &form_factor, std::vector<kvector_t> positions); - virtual ~FormFactorDecoratorMultiPositionFactor() - { - } + virtual FormFactorDecoratorMultiPositionFactor *clone() const; - virtual void accept(ISampleVisitor *visitor) const - { - visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const; virtual complex_t evaluate(const WavevectorInfo& wavevectors) const; diff --git a/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h b/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h index f7c699e9880..12fc6bab937 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h +++ b/Core/FormFactors/inc/FormFactorDecoratorPositionFactor.h @@ -16,8 +16,9 @@ #ifndef FORMFACTORDECORATORPOSITIONFACTOR_H_ #define FORMFACTORDECORATORPOSITIONFACTOR_H_ -#include "Types.h" #include "IFormFactorDecorator.h" +#include "BornAgainNamespace.h" +#include "Types.h" //! @class FormFactorDecoratorPositionFactor //! @ingroup formfactors_internal @@ -53,7 +54,7 @@ inline FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor( const IFormFactor &form_factor, kvector_t position) : IFormFactorDecorator(form_factor), m_position(position) { - setName("FormFactorDecoratorPositionFactor"); + setName(BornAgain::FormFactorDecoratorPositionFactor); } inline FormFactorDecoratorPositionFactor *FormFactorDecoratorPositionFactor::clone() const diff --git a/Core/FormFactors/inc/FormFactorDecoratorRotation.h b/Core/FormFactors/inc/FormFactorDecoratorRotation.h index 7ecb537cfa9..5aec6a8bc01 100644 --- a/Core/FormFactors/inc/FormFactorDecoratorRotation.h +++ b/Core/FormFactors/inc/FormFactorDecoratorRotation.h @@ -18,7 +18,6 @@ #include "IFormFactorDecorator.h" #include "Rotations.h" -#include <memory> //! @class FormFactorDecoratorRotation //! @ingroup formfactors_internal @@ -28,22 +27,11 @@ class BA_CORE_API_ FormFactorDecoratorRotation : public IFormFactorDecorator { public: //! Constructor, setting form factor and rotation. - FormFactorDecoratorRotation(const IFormFactor &form_factor, const IRotation &transform) - : IFormFactorDecorator(form_factor) - { - setName("FormFactorDecoratorRotation"); - m_transform = transform.getTransform3D(); - } - - virtual ~FormFactorDecoratorRotation() - { - } + FormFactorDecoratorRotation(const IFormFactor &form_factor, const IRotation &transform); virtual FormFactorDecoratorRotation *clone() const; - virtual void accept(ISampleVisitor *visitor) const - { - visitor->visit(this); - } + + virtual void accept(ISampleVisitor *visitor) const; virtual complex_t evaluate(const WavevectorInfo& wavevectors) const; @@ -51,12 +39,4 @@ protected: Geometry::Transform3D m_transform; }; -inline complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo& wavevectors) const -{ - cvector_t rotated_ki = m_transform.transformedInverse(wavevectors.getKi()); - cvector_t rotated_kf = m_transform.transformedInverse(wavevectors.getKf()); - WavevectorInfo rotated_wavevectors(rotated_ki, rotated_kf); - return mp_form_factor->evaluate(rotated_wavevectors); -} - #endif // FORMFACTORDECORATORROTATION_H diff --git a/Core/FormFactors/inc/FormFactorEllipsoidalCylinder.h b/Core/FormFactors/inc/FormFactorEllipsoidalCylinder.h index 60a12b789b7..f7aff04e1a6 100644 --- a/Core/FormFactors/inc/FormFactorEllipsoidalCylinder.h +++ b/Core/FormFactors/inc/FormFactorEllipsoidalCylinder.h @@ -31,10 +31,10 @@ public: //! @param height of Ellipsoidal Cylinder FormFactorEllipsoidalCylinder(double radius_a, double radius_b, double height); - ~FormFactorEllipsoidalCylinder() {} + virtual FormFactorEllipsoidalCylinder *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; double getRadiusA() const { return m_radius_a; } virtual void setRadiusA(double radius_a) { m_radius_a = radius_a; } diff --git a/Core/FormFactors/inc/FormFactorFullSphere.h b/Core/FormFactors/inc/FormFactorFullSphere.h index 82b0a823fac..c5118ccdb3b 100644 --- a/Core/FormFactors/inc/FormFactorFullSphere.h +++ b/Core/FormFactors/inc/FormFactorFullSphere.h @@ -21,44 +21,16 @@ //! @ingroup formfactors //! @class FormFactorFullSphere //! @brief The formfactor of a sphere. - -// // /*! \addtogroup formfactors -// // * Sketch of a Full Sphere -// * @{ -// */ -// //! \f$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\f$ -// //! @image html sphere3d.png "Sphere" -// // - -// /*! -// * @image html sphere3d.png "Sphere" -// */ -// /*! -// * A function -// */ -//void func1() -//{ -//} - -///*! Another function */ -//void func2() -//{ -//} - -// /*! @} */ - - - class BA_CORE_API_ FormFactorFullSphere : public IFormFactorBorn { public: //! @brief Full Sphere constructor //! @param radius of Sphere FormFactorFullSphere(double radius); - ~FormFactorFullSphere() {} + virtual FormFactorFullSphere *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; //! Returns radius of sphere virtual double getRadius() const { return m_radius; } diff --git a/Core/FormFactors/inc/FormFactorGauss.h b/Core/FormFactors/inc/FormFactorGauss.h index a797b22a2b0..62500a556cb 100644 --- a/Core/FormFactors/inc/FormFactorGauss.h +++ b/Core/FormFactors/inc/FormFactorGauss.h @@ -53,6 +53,7 @@ private: double m_width; double m_height; double m_max_ql; + void initialize(); }; #endif /* FORMFACTORGAUSS_H_ */ diff --git a/Core/FormFactors/inc/FormFactorHemiEllipsoid.h b/Core/FormFactors/inc/FormFactorHemiEllipsoid.h index 04147fec6dd..6f82a0ca19e 100644 --- a/Core/FormFactors/inc/FormFactorHemiEllipsoid.h +++ b/Core/FormFactors/inc/FormFactorHemiEllipsoid.h @@ -30,7 +30,6 @@ public: //! @param radius_a half length of one horizontal main axes //! @param radius_b half length of the other horizontal main axes //! @param height of Hemi Ellipsoid - FormFactorHemiEllipsoid(double radius_a, double radius_b, double height); ~FormFactorHemiEllipsoid() {delete m_integrator;} @@ -52,7 +51,6 @@ protected: virtual void init_parameters(); private: - complex_t Integrand(double Z, void* params) const; double m_radius_a; @@ -61,9 +59,6 @@ private: mutable cvector_t m_q; MemberComplexFunctionIntegrator<FormFactorHemiEllipsoid> *m_integrator; - }; #endif // FORMFACTORHEMIELLIPSOID_H - - diff --git a/Core/FormFactors/inc/FormFactorLorentz.h b/Core/FormFactors/inc/FormFactorLorentz.h index 099c06104db..81c41a4e09a 100644 --- a/Core/FormFactors/inc/FormFactorLorentz.h +++ b/Core/FormFactors/inc/FormFactorLorentz.h @@ -27,10 +27,10 @@ class BA_CORE_API_ FormFactorLorentz : public IFormFactorBorn public: FormFactorLorentz(double volume); FormFactorLorentz(double width, double height); - ~FormFactorLorentz() {} + virtual FormFactorLorentz *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual complex_t evaluate_for_q(const cvector_t& q) const; @@ -41,6 +41,7 @@ protected: private: double m_width; double m_height; + void initialize(); }; #endif /* FORMFACTORLORENTZ_H_ */ diff --git a/Core/FormFactors/inc/FormFactorPrism3.h b/Core/FormFactors/inc/FormFactorPrism3.h index 30b7172683f..a94445486ca 100644 --- a/Core/FormFactors/inc/FormFactorPrism3.h +++ b/Core/FormFactors/inc/FormFactorPrism3.h @@ -29,10 +29,10 @@ public: //! @param length of a side of Prism3's base //! @param height of Prism3 FormFactorPrism3(double length, double height); - ~FormFactorPrism3() {} + virtual FormFactorPrism3 *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual void setHeight(double height) { m_height = height; } @@ -53,5 +53,3 @@ private: }; #endif /* FORMFACTORPRISM3_H_ */ - - diff --git a/Core/FormFactors/inc/FormFactorPrism6.h b/Core/FormFactors/inc/FormFactorPrism6.h index 77f28f90611..0b973bbda7e 100644 --- a/Core/FormFactors/inc/FormFactorPrism6.h +++ b/Core/FormFactors/inc/FormFactorPrism6.h @@ -28,10 +28,10 @@ public: //! @param radius of hexagonal base (different from R in IsGisaxs) //! @param height of Prism6 FormFactorPrism6(double radius, double height); - ~FormFactorPrism6() {} + virtual FormFactorPrism6 *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual void setHeight(double height) { m_height = height; } diff --git a/Core/FormFactors/inc/FormFactorPyramid.h b/Core/FormFactors/inc/FormFactorPyramid.h index 0557d10a5df..2f027f149bc 100644 --- a/Core/FormFactors/inc/FormFactorPyramid.h +++ b/Core/FormFactors/inc/FormFactorPyramid.h @@ -34,7 +34,7 @@ public: ~FormFactorPyramid() {} virtual FormFactorPyramid *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual void setHeight(double height) { m_height = height; } diff --git a/Core/FormFactors/inc/FormFactorRipple1.h b/Core/FormFactors/inc/FormFactorRipple1.h index 45f6c46e9c9..ba4cb6b9a10 100644 --- a/Core/FormFactors/inc/FormFactorRipple1.h +++ b/Core/FormFactors/inc/FormFactorRipple1.h @@ -36,7 +36,7 @@ public: virtual FormFactorRipple1 *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual double getWidth() const { return m_width; } diff --git a/Core/FormFactors/inc/FormFactorRipple2.h b/Core/FormFactors/inc/FormFactorRipple2.h index f0e843b8751..fd1ac199b71 100644 --- a/Core/FormFactors/inc/FormFactorRipple2.h +++ b/Core/FormFactors/inc/FormFactorRipple2.h @@ -37,7 +37,7 @@ public: virtual FormFactorRipple2 *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual double getWidth() const { return m_width; } diff --git a/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h b/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h index ca425447938..45625b016e7 100644 --- a/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h +++ b/Core/FormFactors/inc/FormFactorSphereGaussianRadius.h @@ -32,7 +32,7 @@ public: virtual FormFactorSphereGaussianRadius *clone() const; virtual ~FormFactorSphereGaussianRadius(); - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return p_ff_sphere->getHeight(); } diff --git a/Core/FormFactors/inc/FormFactorSphereLogNormalRadius.h b/Core/FormFactors/inc/FormFactorSphereLogNormalRadius.h index 2b69856b3fc..5fd257fc077 100644 --- a/Core/FormFactors/inc/FormFactorSphereLogNormalRadius.h +++ b/Core/FormFactors/inc/FormFactorSphereLogNormalRadius.h @@ -36,7 +36,7 @@ public: virtual FormFactorSphereLogNormalRadius *clone() const; virtual ~FormFactorSphereLogNormalRadius(); - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const; diff --git a/Core/FormFactors/inc/FormFactorSphereUniformRadius.h b/Core/FormFactors/inc/FormFactorSphereUniformRadius.h index 4059446710e..cf8bf9a7cc0 100644 --- a/Core/FormFactors/inc/FormFactorSphereUniformRadius.h +++ b/Core/FormFactors/inc/FormFactorSphereUniformRadius.h @@ -33,7 +33,7 @@ public: virtual FormFactorSphereUniformRadius *clone() const; virtual ~FormFactorSphereUniformRadius(); - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return 2.0*m_mean; } diff --git a/Core/FormFactors/inc/FormFactorTetrahedron.h b/Core/FormFactors/inc/FormFactorTetrahedron.h index 57636e2f2f7..51ec0c7af74 100644 --- a/Core/FormFactors/inc/FormFactorTetrahedron.h +++ b/Core/FormFactors/inc/FormFactorTetrahedron.h @@ -31,11 +31,11 @@ public: //! @param height of Tetrahedron //! @param angle in radians between base and facet FormFactorTetrahedron(double length, double height, double alpha); - ~FormFactorTetrahedron() {delete m_integrator;} + ~FormFactorTetrahedron(); virtual FormFactorTetrahedron *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } virtual void setHeight(double height) { m_height = height; } @@ -53,7 +53,6 @@ protected: virtual void init_parameters(); private: - double m_height; double m_length; double m_alpha; diff --git a/Core/FormFactors/inc/FormFactorTrivial.h b/Core/FormFactors/inc/FormFactorTrivial.h index de1f1a233c9..ec84a1173f4 100644 --- a/Core/FormFactors/inc/FormFactorTrivial.h +++ b/Core/FormFactors/inc/FormFactorTrivial.h @@ -29,10 +29,10 @@ public: //! @param radius of Cylinder's base //! @param height of Cylinder FormFactorTrivial(); - ~FormFactorTrivial() {} + virtual FormFactorTrivial *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual complex_t evaluate_for_q(const cvector_t& q) const; diff --git a/Core/FormFactors/inc/FormFactorTruncatedCube.h b/Core/FormFactors/inc/FormFactorTruncatedCube.h index 9bf45b7c5e6..1dcca01246f 100644 --- a/Core/FormFactors/inc/FormFactorTruncatedCube.h +++ b/Core/FormFactors/inc/FormFactorTruncatedCube.h @@ -29,10 +29,10 @@ public: //! @param side length of the full cube //! @param side length of the trirectangular tetrahedron removed from each vertex of the cube FormFactorTruncatedCube(double length, double removed_length); - ~FormFactorTruncatedCube() {} + virtual FormFactorTruncatedCube *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getLength() const { return m_length; } virtual void setLength(double length) { m_length = length; } diff --git a/Core/FormFactors/inc/FormFactorTruncatedSphere.h b/Core/FormFactors/inc/FormFactorTruncatedSphere.h index 7c2985f4a5d..5a1f135e388 100644 --- a/Core/FormFactors/inc/FormFactorTruncatedSphere.h +++ b/Core/FormFactors/inc/FormFactorTruncatedSphere.h @@ -35,7 +35,7 @@ public: virtual FormFactorTruncatedSphere *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getRadius() const { return m_radius; } virtual double getHeight() const { return m_height; } diff --git a/Core/FormFactors/inc/FormFactorTruncatedSpheroid.h b/Core/FormFactors/inc/FormFactorTruncatedSpheroid.h index 61e295b3650..9578d6ac008 100644 --- a/Core/FormFactors/inc/FormFactorTruncatedSpheroid.h +++ b/Core/FormFactors/inc/FormFactorTruncatedSpheroid.h @@ -33,11 +33,11 @@ public: FormFactorTruncatedSpheroid(double radius, double height, double height_flattening); - ~FormFactorTruncatedSpheroid() {delete m_integrator;} + ~FormFactorTruncatedSpheroid(); virtual FormFactorTruncatedSpheroid *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual double getHeight() const { return m_height; } diff --git a/Core/FormFactors/inc/FormFactorWeighted.h b/Core/FormFactors/inc/FormFactorWeighted.h index 115c34984f6..da71ab3f876 100644 --- a/Core/FormFactors/inc/FormFactorWeighted.h +++ b/Core/FormFactors/inc/FormFactorWeighted.h @@ -28,10 +28,10 @@ class BA_CORE_API_ FormFactorWeighted : public IFormFactor public: FormFactorWeighted(); virtual ~FormFactorWeighted(); + virtual FormFactorWeighted *clone() const; - //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; void addFormFactor(const IFormFactor& form_factor, double weight=1.0); diff --git a/Core/FormFactors/src/FormFactorAnisoPyramid.cpp b/Core/FormFactors/src/FormFactorAnisoPyramid.cpp index c2f05f8cf59..2137c3bc5b0 100644 --- a/Core/FormFactors/src/FormFactorAnisoPyramid.cpp +++ b/Core/FormFactors/src/FormFactorAnisoPyramid.cpp @@ -14,12 +14,13 @@ // ************************************************************************** // #include "FormFactorAnisoPyramid.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorAnisoPyramid::FormFactorAnisoPyramid( double length, double width, double height, double alpha) { - setName("FormFactorAnisoPyramid"); + setName(BornAgain::FFAnisoPyramidType); m_length = length; m_width = width; m_height = height; diff --git a/Core/FormFactors/src/FormFactorBox.cpp b/Core/FormFactors/src/FormFactorBox.cpp index 5d1d18d5a3b..9c7d296196f 100644 --- a/Core/FormFactors/src/FormFactorBox.cpp +++ b/Core/FormFactors/src/FormFactorBox.cpp @@ -14,13 +14,14 @@ // ************************************************************************** // #include "FormFactorBox.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorBox::FormFactorBox(double length, double width, double height) : m_length(length), m_width(width), m_height(height) { - setName("FormFactorBox"); + setName(BornAgain::FFBoxType); check_initialization(); init_parameters(); } diff --git a/Core/FormFactors/src/FormFactorCone.cpp b/Core/FormFactors/src/FormFactorCone.cpp index 54d999e586a..00426ad274b 100644 --- a/Core/FormFactors/src/FormFactorCone.cpp +++ b/Core/FormFactors/src/FormFactorCone.cpp @@ -14,15 +14,17 @@ // ************************************************************************** // #include "FormFactorCone.h" +#include "BornAgainNamespace.h" #include "Numeric.h" #include "MathFunctions.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorCone::FormFactorCone(double radius, double height, double alpha) { - setName("FormFactorCone"); + setName(BornAgain::FFConeType); m_radius = radius; m_height = height; m_alpha = alpha; diff --git a/Core/FormFactors/src/FormFactorCone6.cpp b/Core/FormFactors/src/FormFactorCone6.cpp index 71dfd1b6ef7..2ada20b21ea 100644 --- a/Core/FormFactors/src/FormFactorCone6.cpp +++ b/Core/FormFactors/src/FormFactorCone6.cpp @@ -14,16 +14,18 @@ // ************************************************************************** // #include "FormFactorCone6.h" +#include "BornAgainNamespace.h" #include "Numeric.h" #include "MathFunctions.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorCone6::FormFactorCone6(double radius, double height, double alpha) { - setName("FormFactorCone6"); + setName(BornAgain::FFCone6Type); m_radius = radius; m_height = height; m_alpha = alpha; diff --git a/Core/FormFactors/src/FormFactorCrystal.cpp b/Core/FormFactors/src/FormFactorCrystal.cpp index a4e52ba6682..a520d018775 100644 --- a/Core/FormFactors/src/FormFactorCrystal.cpp +++ b/Core/FormFactors/src/FormFactorCrystal.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorCrystal.h" +#include "BornAgainNamespace.h" #include "FormFactorDecoratorPositionFactor.h" FormFactorCrystal::FormFactorCrystal(const Lattice &lattice, const IFormFactor &basis_form_factor, @@ -22,7 +23,7 @@ FormFactorCrystal::FormFactorCrystal(const Lattice &lattice, const IFormFactor & mp_basis_form_factor(basis_form_factor.clone()), mp_meso_form_factor(meso_form_factor.clone()) { - setName("FormFactorCrystal"); + setName(BornAgain::FormFactorCrystalType); calculateLargestReciprocalDistance(); } diff --git a/Core/FormFactors/src/FormFactorCuboctahedron.cpp b/Core/FormFactors/src/FormFactorCuboctahedron.cpp index 557f33d38c2..f0066a1be52 100644 --- a/Core/FormFactors/src/FormFactorCuboctahedron.cpp +++ b/Core/FormFactors/src/FormFactorCuboctahedron.cpp @@ -14,13 +14,14 @@ // ************************************************************************** // #include "FormFactorCuboctahedron.h" +#include "BornAgainNamespace.h" #include "FormFactorPyramid.h" #include "MathFunctions.h" FormFactorCuboctahedron::FormFactorCuboctahedron( double length, double height, double height_ratio, double alpha) { - setName("FormFactorCuboctahedron"); + setName(BornAgain::FFCuboctahedronType); m_height = height; m_length = length; m_height_ratio = height_ratio; diff --git a/Core/FormFactors/src/FormFactorCylinder.cpp b/Core/FormFactors/src/FormFactorCylinder.cpp index 882ba262e24..c0f1da0b725 100644 --- a/Core/FormFactors/src/FormFactorCylinder.cpp +++ b/Core/FormFactors/src/FormFactorCylinder.cpp @@ -14,13 +14,13 @@ // ************************************************************************** // #include "FormFactorCylinder.h" - +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" FormFactorCylinder::FormFactorCylinder(double radius, double height) { - setName("FormFactorCylinder"); + setName(BornAgain::FFCylinderType); m_radius = radius; m_height = height; check_initialization(); diff --git a/Core/FormFactors/src/FormFactorDWBA.cpp b/Core/FormFactors/src/FormFactorDWBA.cpp index 122c56c6c0a..57c26df678d 100644 --- a/Core/FormFactors/src/FormFactorDWBA.cpp +++ b/Core/FormFactors/src/FormFactorDWBA.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorDWBA.h" +#include "BornAgainNamespace.h" #include <cmath> @@ -22,7 +23,7 @@ FormFactorDWBA::FormFactorDWBA(const IFormFactor& form_factor) , mp_in_coeffs(0) , mp_out_coeffs(0) { - setName("FormFactorDWBA"); + setName(BornAgain::FormFactorDWBAType); } FormFactorDWBA::~FormFactorDWBA() diff --git a/Core/FormFactors/src/FormFactorDWBAPol.cpp b/Core/FormFactors/src/FormFactorDWBAPol.cpp index 095071908d6..13cc64f34bf 100644 --- a/Core/FormFactors/src/FormFactorDWBAPol.cpp +++ b/Core/FormFactors/src/FormFactorDWBAPol.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorDWBAPol.h" +#include "BornAgainNamespace.h" #include "Exceptions.h" FormFactorDWBAPol::FormFactorDWBAPol(const IFormFactor &form_factor) @@ -21,7 +22,7 @@ FormFactorDWBAPol::FormFactorDWBAPol(const IFormFactor &form_factor) , mp_in_coeffs(0) , mp_out_coeffs(0) { - setName("FormFactorDWBAPol"); + setName(BornAgain::FormFactorPolarizedDWBAType); } FormFactorDWBAPol::~FormFactorDWBAPol() diff --git a/Core/FormFactors/src/FormFactorDecoratorDebyeWaller.cpp b/Core/FormFactors/src/FormFactorDecoratorDebyeWaller.cpp index 0f26ad65133..92a4423c7be 100644 --- a/Core/FormFactors/src/FormFactorDecoratorDebyeWaller.cpp +++ b/Core/FormFactors/src/FormFactorDecoratorDebyeWaller.cpp @@ -14,14 +14,13 @@ // ************************************************************************** // #include "FormFactorDecoratorDebyeWaller.h" +#include "BornAgainNamespace.h" FormFactorDecoratorDebyeWaller::FormFactorDecoratorDebyeWaller(const IFormFactor &form_factor, double dw_factor) : IFormFactorDecorator(form_factor), m_h_dw_factor(dw_factor), m_r_dw_factor(dw_factor) { - setName("FormFactorDecoratorDebyeWaller"); - check_initialization(); - init_parameters(); + initialize(); } FormFactorDecoratorDebyeWaller::FormFactorDecoratorDebyeWaller(const IFormFactor &form_factor, @@ -29,9 +28,7 @@ FormFactorDecoratorDebyeWaller::FormFactorDecoratorDebyeWaller(const IFormFactor double dw_r_factor) : IFormFactorDecorator(form_factor), m_h_dw_factor(dw_h_factor), m_r_dw_factor(dw_r_factor) { - setName("FormFactorDecoratorDebyeWaller"); - check_initialization(); - init_parameters(); + initialize(); } FormFactorDecoratorDebyeWaller *FormFactorDecoratorDebyeWaller::clone() const @@ -62,3 +59,10 @@ void FormFactorDecoratorDebyeWaller::init_parameters() registerParameter("hfactor", &m_h_dw_factor, AttLimits::n_positive()); registerParameter("rfactor", &m_r_dw_factor, AttLimits::n_positive()); } + +void FormFactorDecoratorDebyeWaller::initialize() +{ + setName(BornAgain::FormFactorDecoratorDebyeWaller); + check_initialization(); + init_parameters(); +} diff --git a/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp b/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp index ba32c72ba90..4e14a10ed6f 100644 --- a/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp +++ b/Core/FormFactors/src/FormFactorDecoratorMaterial.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorDecoratorMaterial.h" +#include "BornAgainNamespace.h" FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(const IFormFactor &form_factor, complex_t wavevector_scattering_factor) @@ -21,11 +22,7 @@ FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(const IFormFactor &form m_wavevector_scattering_factor(wavevector_scattering_factor), mP_material(0), mP_ambient_material(0) { - setName("FormFactorDecoratorMaterial"); -} - -FormFactorDecoratorMaterial::~FormFactorDecoratorMaterial() -{ + setName(BornAgain::FormFactorDecoratorMaterial); } FormFactorDecoratorMaterial *FormFactorDecoratorMaterial::clone() const diff --git a/Core/FormFactors/src/FormFactorDecoratorMultiPositionFactor.cpp b/Core/FormFactors/src/FormFactorDecoratorMultiPositionFactor.cpp index ab086f79efb..d16f9eb8cc0 100644 --- a/Core/FormFactors/src/FormFactorDecoratorMultiPositionFactor.cpp +++ b/Core/FormFactors/src/FormFactorDecoratorMultiPositionFactor.cpp @@ -14,12 +14,13 @@ // ************************************************************************** // #include "FormFactorDecoratorMultiPositionFactor.h" +#include "BornAgainNamespace.h" FormFactorDecoratorMultiPositionFactor::FormFactorDecoratorMultiPositionFactor( const IFormFactor &form_factor, std::vector<kvector_t> positions) : IFormFactorDecorator(form_factor), m_positions(positions) { - setName("FormFactorDecoratorMultiPositionFactor"); + setName(BornAgain::FormFactorDecoratorMultiPositionFactor); } FormFactorDecoratorMultiPositionFactor *FormFactorDecoratorMultiPositionFactor::clone() const @@ -27,6 +28,11 @@ FormFactorDecoratorMultiPositionFactor *FormFactorDecoratorMultiPositionFactor:: return new FormFactorDecoratorMultiPositionFactor(*mp_form_factor, m_positions); } +void FormFactorDecoratorMultiPositionFactor::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorDecoratorMultiPositionFactor::evaluate(const WavevectorInfo& wavevectors) const { cvector_t q = wavevectors.getQ(); diff --git a/Core/FormFactors/src/FormFactorDecoratorRotation.cpp b/Core/FormFactors/src/FormFactorDecoratorRotation.cpp index 4860a378caa..23365c04854 100644 --- a/Core/FormFactors/src/FormFactorDecoratorRotation.cpp +++ b/Core/FormFactors/src/FormFactorDecoratorRotation.cpp @@ -14,16 +14,35 @@ // ************************************************************************** // #include "FormFactorDecoratorRotation.h" +#include "BornAgainNamespace.h" -#include <boost/scoped_ptr.hpp> +#include <memory> + +FormFactorDecoratorRotation::FormFactorDecoratorRotation(const IFormFactor &form_factor, const IRotation &transform) + : IFormFactorDecorator(form_factor) +{ + setName(BornAgain::FormFactorDecoratorRotation); + m_transform = transform.getTransform3D(); +} FormFactorDecoratorRotation *FormFactorDecoratorRotation::clone() const { - boost::scoped_ptr<IRotation> P_rotation(IRotation::createRotation(m_transform)); + std::unique_ptr<IRotation> P_rotation(IRotation::createRotation(m_transform)); FormFactorDecoratorRotation *result - = new FormFactorDecoratorRotation(*mp_form_factor, *P_rotation); - + = new FormFactorDecoratorRotation(*mp_form_factor, *P_rotation); result->setName(getName()); return result; } +void FormFactorDecoratorRotation::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +complex_t FormFactorDecoratorRotation::evaluate(const WavevectorInfo &wavevectors) const +{ + cvector_t rotated_ki = m_transform.transformedInverse(wavevectors.getKi()); + cvector_t rotated_kf = m_transform.transformedInverse(wavevectors.getKf()); + WavevectorInfo rotated_wavevectors(rotated_ki, rotated_kf); + return mp_form_factor->evaluate(rotated_wavevectors); +} diff --git a/Core/FormFactors/src/FormFactorEllipsoidalCylinder.cpp b/Core/FormFactors/src/FormFactorEllipsoidalCylinder.cpp index 60903930f42..e34b7c22d80 100644 --- a/Core/FormFactors/src/FormFactorEllipsoidalCylinder.cpp +++ b/Core/FormFactors/src/FormFactorEllipsoidalCylinder.cpp @@ -14,16 +14,16 @@ // ************************************************************************** // #include "FormFactorEllipsoidalCylinder.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" -FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(double radius_a, - double radius_b, +FormFactorEllipsoidalCylinder::FormFactorEllipsoidalCylinder(double radius_a, double radius_b, double height) { - setName("FormFactorEllipsoidalCylinder"); + setName(BornAgain::FFEllipsoidalCylinderType); m_height = height; m_radius_a = radius_a; - m_radius_b = radius_b; + m_radius_b = radius_b; check_initialization(); init_parameters(); } @@ -33,6 +33,11 @@ FormFactorEllipsoidalCylinder* FormFactorEllipsoidalCylinder::clone() const return new FormFactorEllipsoidalCylinder(m_radius_a, m_radius_b, m_height); } +void FormFactorEllipsoidalCylinder::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorEllipsoidalCylinder::evaluate_for_q(const cvector_t& q) const { complex_t qxRa = q.x()*m_radius_a; diff --git a/Core/FormFactors/src/FormFactorFullSphere.cpp b/Core/FormFactors/src/FormFactorFullSphere.cpp index 9797c39335a..4582c15aab1 100644 --- a/Core/FormFactors/src/FormFactorFullSphere.cpp +++ b/Core/FormFactors/src/FormFactorFullSphere.cpp @@ -14,12 +14,13 @@ // ************************************************************************** // #include "FormFactorFullSphere.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorFullSphere::FormFactorFullSphere(double radius) : m_radius(radius) { - setName("FormFactorFullSphere"); + setName(BornAgain::FFFullSphereType); check_initialization(); init_parameters(); } @@ -43,6 +44,11 @@ FormFactorFullSphere* FormFactorFullSphere::clone() const return result; } +void FormFactorFullSphere::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorFullSphere::evaluate_for_q(const cvector_t& q) const { complex_t qz = q.z(); diff --git a/Core/FormFactors/src/FormFactorFullSpheroid.cpp b/Core/FormFactors/src/FormFactorFullSpheroid.cpp index 3620fe58f98..ebaab675937 100644 --- a/Core/FormFactors/src/FormFactorFullSpheroid.cpp +++ b/Core/FormFactors/src/FormFactorFullSpheroid.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorFullSpheroid.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" #include "MemberFunctionIntegrator.h" @@ -21,7 +22,7 @@ FormFactorFullSpheroid::FormFactorFullSpheroid(double radius, double height ) { - setName("FormFactorFullSpheroid"); + setName(BornAgain::FFFullSpheroidType); m_radius = radius; m_height = height; check_initialization(); diff --git a/Core/FormFactors/src/FormFactorGauss.cpp b/Core/FormFactors/src/FormFactorGauss.cpp index 960932dfe6f..3ddee7acf03 100644 --- a/Core/FormFactors/src/FormFactorGauss.cpp +++ b/Core/FormFactors/src/FormFactorGauss.cpp @@ -14,30 +14,23 @@ // ************************************************************************** // #include "FormFactorGauss.h" - +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" FormFactorGauss::FormFactorGauss(double volume) { - setName("FormFactorGauss"); m_height = std::pow(volume, 1.0/3.0); m_width = m_height; - check_initialization(); - init_parameters(); - m_max_ql = std::sqrt(-4.0*Units::PI*std::log(Numeric::double_epsilon) - / 3.0); + initialize(); + } FormFactorGauss::FormFactorGauss(double width, double height) { - setName("FormFactorGauss"); m_width = width; m_height = height; - check_initialization(); - init_parameters(); - m_max_ql = std::sqrt(-4.0*Units::PI*std::log(Numeric::double_epsilon) - / 3.0); + initialize(); } bool FormFactorGauss::check_initialization() const @@ -78,3 +71,11 @@ complex_t FormFactorGauss::evaluate_for_q(const cvector_t& q) const return result; } +void FormFactorGauss::initialize() +{ + setName(BornAgain::FFGaussType); + check_initialization(); + init_parameters(); + m_max_ql = std::sqrt(-4.0 * Units::PI * std::log(Numeric::double_epsilon) / 3.0); +} + diff --git a/Core/FormFactors/src/FormFactorHemiEllipsoid.cpp b/Core/FormFactors/src/FormFactorHemiEllipsoid.cpp index cd297044423..1a8b590d5e1 100644 --- a/Core/FormFactors/src/FormFactorHemiEllipsoid.cpp +++ b/Core/FormFactors/src/FormFactorHemiEllipsoid.cpp @@ -14,16 +14,18 @@ // ************************************************************************** // #include "FormFactorHemiEllipsoid.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorHemiEllipsoid::FormFactorHemiEllipsoid( double radius_a, double radius_b, double height) { - setName("FormFactorHemiEllipsoid"); + setName(BornAgain::FFHemiEllipsoidType); m_radius_a = radius_a; m_radius_b = radius_b; m_height = height; diff --git a/Core/FormFactors/src/FormFactorLorentz.cpp b/Core/FormFactors/src/FormFactorLorentz.cpp index 7b9098d8faf..20f13810f65 100644 --- a/Core/FormFactors/src/FormFactorLorentz.cpp +++ b/Core/FormFactors/src/FormFactorLorentz.cpp @@ -14,27 +14,23 @@ // ************************************************************************** // #include "FormFactorLorentz.h" - +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" FormFactorLorentz::FormFactorLorentz(double volume) { - setName("FormFactorLorentz"); double R = std::pow(volume, 1.0/3.0); m_height = R; m_width = R; - check_initialization(); - init_parameters(); + initialize(); } FormFactorLorentz::FormFactorLorentz(double width, double height) { - setName("FormFactorLorentz"); m_width = width; m_height = height; - check_initialization(); - init_parameters(); + initialize(); } bool FormFactorLorentz::check_initialization() const @@ -56,6 +52,11 @@ FormFactorLorentz* FormFactorLorentz::clone() const return result; } +void FormFactorLorentz::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorLorentz::evaluate_for_q(const cvector_t& q) const { static const double sigma2 = 4.0*std::pow(Units::PI, 2.0/3.0); @@ -71,4 +72,9 @@ complex_t FormFactorLorentz::evaluate_for_q(const cvector_t& q) const return result; } - +void FormFactorLorentz::initialize() +{ + setName(BornAgain::FFLorentzType); + check_initialization(); + init_parameters(); +} diff --git a/Core/FormFactors/src/FormFactorPrism3.cpp b/Core/FormFactors/src/FormFactorPrism3.cpp index 5929631886d..db52b3da2b0 100644 --- a/Core/FormFactors/src/FormFactorPrism3.cpp +++ b/Core/FormFactors/src/FormFactorPrism3.cpp @@ -14,12 +14,12 @@ // ************************************************************************** // #include "FormFactorPrism3.h" - +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorPrism3::FormFactorPrism3(double length, double height) { - setName("FormFactorPrism3"); + setName(BornAgain::FFPrism3Type); m_length = length; m_height = height; m_root3 = std::sqrt(3.0); @@ -46,6 +46,11 @@ FormFactorPrism3* FormFactorPrism3::clone() const return result; } +void FormFactorPrism3::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorPrism3::evaluate_for_q(const cvector_t& q) const { complex_t qz = q.z(); diff --git a/Core/FormFactors/src/FormFactorPrism6.cpp b/Core/FormFactors/src/FormFactorPrism6.cpp index f2e851b3496..806886d0270 100644 --- a/Core/FormFactors/src/FormFactorPrism6.cpp +++ b/Core/FormFactors/src/FormFactorPrism6.cpp @@ -14,12 +14,12 @@ // ************************************************************************** // #include "FormFactorPrism6.h" - +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorPrism6::FormFactorPrism6(double radius, double height) { - setName("FormFactorPrism6"); + setName(BornAgain::FFPrism6Type); m_height = height; m_radius = radius; m_root3 = std::sqrt(3.0); @@ -46,6 +46,11 @@ FormFactorPrism6* FormFactorPrism6::clone() const return result; } +void FormFactorPrism6::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorPrism6::evaluate_for_q(const cvector_t& q) const { complex_t qz = q.z(); diff --git a/Core/FormFactors/src/FormFactorPyramid.cpp b/Core/FormFactors/src/FormFactorPyramid.cpp index 99d2e8e261c..72a3e466226 100644 --- a/Core/FormFactors/src/FormFactorPyramid.cpp +++ b/Core/FormFactors/src/FormFactorPyramid.cpp @@ -14,12 +14,13 @@ // ************************************************************************** // #include "FormFactorPyramid.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" FormFactorPyramid::FormFactorPyramid( double length, double height, double alpha) { - setName("FormFactorPyramid"); + setName(BornAgain::FFPyramidType); m_length = length; m_height = height; m_alpha = alpha; @@ -76,6 +77,11 @@ FormFactorPyramid* FormFactorPyramid::clone() const return result; } +void FormFactorPyramid::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorPyramid::evaluate_for_q(const cvector_t& q) const { diff --git a/Core/FormFactors/src/FormFactorRipple1.cpp b/Core/FormFactors/src/FormFactorRipple1.cpp index a1bea2bf9a8..cb40706dc16 100644 --- a/Core/FormFactors/src/FormFactorRipple1.cpp +++ b/Core/FormFactors/src/FormFactorRipple1.cpp @@ -14,18 +14,20 @@ // ************************************************************************** // #include "FormFactorRipple1.h" +#include "BornAgainNamespace.h" #include "Numeric.h" #include "MathFunctions.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorRipple1::FormFactorRipple1(double length, double width, double height) : m_width(width) , m_height(height) , m_length(length) { - setName("FormFactorRipple1"); + setName(BornAgain::FFRipple1Type); check_initialization(); init_parameters(); @@ -65,9 +67,12 @@ FormFactorRipple1 *FormFactorRipple1::clone() const return result; } +void FormFactorRipple1::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} //! Integrand for complex formfactor. - complex_t FormFactorRipple1::Integrand(double Z, void* params) const { (void)params; // to avoid unused-variable warning @@ -77,7 +82,6 @@ complex_t FormFactorRipple1::Integrand(double Z, void* params) const } //! Complex formfactor. - complex_t FormFactorRipple1::evaluate_for_q(const cvector_t& q) const { m_q = q; diff --git a/Core/FormFactors/src/FormFactorRipple2.cpp b/Core/FormFactors/src/FormFactorRipple2.cpp index 0f144f15f79..21b8a265a2d 100644 --- a/Core/FormFactors/src/FormFactorRipple2.cpp +++ b/Core/FormFactors/src/FormFactorRipple2.cpp @@ -14,19 +14,21 @@ // ************************************************************************** // #include "FormFactorRipple2.h" +#include "BornAgainNamespace.h" #include "Numeric.h" #include "MathFunctions.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorRipple2::FormFactorRipple2(double length, double width, double height, double asymetry) : m_width(width) , m_height(height) , m_length(length) , m_d(asymetry) { - setName("FormFactorRipple2"); + setName(BornAgain::FFRipple2Type); check_initialization(); init_parameters(); } @@ -77,9 +79,12 @@ FormFactorRipple2 *FormFactorRipple2::clone() const return result; } +void FormFactorRipple2::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} //! Complex formfactor. - complex_t FormFactorRipple2::evaluate_for_q(const cvector_t& q) const { m_q = q; diff --git a/Core/FormFactors/src/FormFactorSphereGaussianRadius.cpp b/Core/FormFactors/src/FormFactorSphereGaussianRadius.cpp index c607a6606d9..13f930f86ec 100644 --- a/Core/FormFactors/src/FormFactorSphereGaussianRadius.cpp +++ b/Core/FormFactors/src/FormFactorSphereGaussianRadius.cpp @@ -14,6 +14,8 @@ // ************************************************************************** // #include "FormFactorSphereGaussianRadius.h" +#include "BornAgainNamespace.h" + FormFactorSphereGaussianRadius::FormFactorSphereGaussianRadius(double mean, double sigma) @@ -22,7 +24,7 @@ FormFactorSphereGaussianRadius::FormFactorSphereGaussianRadius(double mean, , m_mean_r3(0.0) , p_ff_sphere(0) { - setName("FormFactorSphereGaussianRadius"); + setName(BornAgain::FormFactorSphereGaussianRadiusType); m_mean_r3 = calculateMeanR3(); p_ff_sphere = new FormFactorFullSphere(m_mean_r3); check_initialization(); @@ -42,6 +44,11 @@ FormFactorSphereGaussianRadius::~FormFactorSphereGaussianRadius() delete p_ff_sphere; } +void FormFactorSphereGaussianRadius::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorSphereGaussianRadius::evaluate_for_q( const cvector_t& q) const { diff --git a/Core/FormFactors/src/FormFactorSphereLogNormalRadius.cpp b/Core/FormFactors/src/FormFactorSphereLogNormalRadius.cpp index 999e37ffc54..64dd9dc1bc5 100644 --- a/Core/FormFactors/src/FormFactorSphereLogNormalRadius.cpp +++ b/Core/FormFactors/src/FormFactorSphereLogNormalRadius.cpp @@ -14,7 +14,7 @@ // ************************************************************************** // #include "FormFactorSphereLogNormalRadius.h" - +#include "BornAgainNamespace.h" #include "Distributions.h" FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius( @@ -24,7 +24,7 @@ FormFactorSphereLogNormalRadius::FormFactorSphereLogNormalRadius( , m_n_samples(n_samples) , mp_distribution(0) { - setName("FormFactorSphereLogNormalRadius"); + setName(BornAgain::FormFactorSphereLogNormalRadiusType); mp_distribution = new DistributionLogNormal(mean, scale_param); check_initialization(); init_parameters(); @@ -44,6 +44,11 @@ FormFactorSphereLogNormalRadius::~FormFactorSphereLogNormalRadius() delete mp_distribution; } +void FormFactorSphereLogNormalRadius::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorSphereLogNormalRadius::evaluate_for_q( const cvector_t& q) const { diff --git a/Core/FormFactors/src/FormFactorSphereUniformRadius.cpp b/Core/FormFactors/src/FormFactorSphereUniformRadius.cpp index 53842c2f128..c044de0ba25 100644 --- a/Core/FormFactors/src/FormFactorSphereUniformRadius.cpp +++ b/Core/FormFactors/src/FormFactorSphereUniformRadius.cpp @@ -14,6 +14,8 @@ // ************************************************************************** // #include "FormFactorSphereUniformRadius.h" +#include "BornAgainNamespace.h" + FormFactorSphereUniformRadius::FormFactorSphereUniformRadius(double mean, double full_width) @@ -25,7 +27,7 @@ FormFactorSphereUniformRadius::FormFactorSphereUniformRadius(double mean, "FormFactorSphereUniformRadius::FormFactorSphereUniformRadius:" " mean radius must be bigger than the half width"); } - setName("FormFactorSphereUniformRadius"); + setName(BornAgain::FormFactorSphereUniformRadiusType); check_initialization(); init_parameters(); } @@ -42,6 +44,11 @@ FormFactorSphereUniformRadius::~FormFactorSphereUniformRadius() { } +void FormFactorSphereUniformRadius::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorSphereUniformRadius::evaluate_for_q( const cvector_t& q) const { diff --git a/Core/FormFactors/src/FormFactorTetrahedron.cpp b/Core/FormFactors/src/FormFactorTetrahedron.cpp index 6ebbb286a42..441b4567c18 100644 --- a/Core/FormFactors/src/FormFactorTetrahedron.cpp +++ b/Core/FormFactors/src/FormFactorTetrahedron.cpp @@ -15,15 +15,14 @@ #include "FormFactorTetrahedron.h" #include "MathFunctions.h" - -// Integration +#include "BornAgainNamespace.h" #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" FormFactorTetrahedron::FormFactorTetrahedron( double length, double height, double alpha) { - setName("FormFactorTetrahedron"); + setName(BornAgain::FFTetrahedronType); m_height = height; m_length = length; m_alpha = alpha; @@ -31,13 +30,15 @@ FormFactorTetrahedron::FormFactorTetrahedron( check_initialization(); init_parameters(); - // addition integration - MemberComplexFunctionIntegrator<FormFactorTetrahedron>::mem_function p_mf = & FormFactorTetrahedron::Integrand; m_integrator = new MemberComplexFunctionIntegrator<FormFactorTetrahedron>(p_mf, this); +} +FormFactorTetrahedron::~FormFactorTetrahedron() +{ + delete m_integrator; } bool FormFactorTetrahedron::check_initialization() const @@ -71,7 +72,11 @@ FormFactorTetrahedron* FormFactorTetrahedron::clone() const return result; } -// addition integration +void FormFactorTetrahedron::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorTetrahedron::Integrand(double Z, void* params) const { (void)params; diff --git a/Core/FormFactors/src/FormFactorTrivial.cpp b/Core/FormFactors/src/FormFactorTrivial.cpp index df7ec190b2d..b3bff7dcfb4 100644 --- a/Core/FormFactors/src/FormFactorTrivial.cpp +++ b/Core/FormFactors/src/FormFactorTrivial.cpp @@ -14,10 +14,12 @@ // ************************************************************************** // #include "FormFactorTrivial.h" +#include "BornAgainNamespace.h" + FormFactorTrivial::FormFactorTrivial() { - setName("FormFactorTrivial"); + setName(BornAgain::FormFactorTrivialType); check_initialization(); init_parameters(); } @@ -29,6 +31,11 @@ FormFactorTrivial* FormFactorTrivial::clone() const return result; } +void FormFactorTrivial::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + complex_t FormFactorTrivial::evaluate_for_q(const cvector_t& q) const { (void)q; diff --git a/Core/FormFactors/src/FormFactorTruncatedCube.cpp b/Core/FormFactors/src/FormFactorTruncatedCube.cpp index 0cec89c8565..ff14ca2167b 100644 --- a/Core/FormFactors/src/FormFactorTruncatedCube.cpp +++ b/Core/FormFactors/src/FormFactorTruncatedCube.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorTruncatedCube.h" +#include "BornAgainNamespace.h" #include "FormFactorBox.h" #include "MathFunctions.h" @@ -22,7 +23,7 @@ FormFactorTruncatedCube::FormFactorTruncatedCube( : m_length(length) , m_removed_length(removed_length) { - setName("FormFactorTruncatedCube"); + setName(BornAgain::FFTruncatedCubeType); check_initialization(); init_parameters(); } @@ -42,6 +43,11 @@ FormFactorTruncatedCube* FormFactorTruncatedCube::clone() const return result; } +void FormFactorTruncatedCube::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + bool FormFactorTruncatedCube::check_initialization() const { bool result(true); diff --git a/Core/FormFactors/src/FormFactorTruncatedSphere.cpp b/Core/FormFactors/src/FormFactorTruncatedSphere.cpp index 66495c3338b..faf5d5f1fd0 100644 --- a/Core/FormFactors/src/FormFactorTruncatedSphere.cpp +++ b/Core/FormFactors/src/FormFactorTruncatedSphere.cpp @@ -14,17 +14,19 @@ // ************************************************************************** // #include "FormFactorTruncatedSphere.h" +#include "BornAgainNamespace.h" #include "Numeric.h" #include "MathFunctions.h" -#include <cmath> #include "MemberFunctionIntegrator.h" #include "MemberComplexFunctionIntegrator.h" +#include <cmath> + FormFactorTruncatedSphere::FormFactorTruncatedSphere(double radius, double height) : m_radius(radius) , m_height(height) { - setName("FormFactorTruncatedSphere"); + setName(BornAgain::FFTruncatedSphereType); check_initialization(); init_parameters(); @@ -61,8 +63,12 @@ FormFactorTruncatedSphere *FormFactorTruncatedSphere::clone() const return result; } -//! Integrand for complex formfactor. +void FormFactorTruncatedSphere::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} +//! Integrand for complex formfactor. complex_t FormFactorTruncatedSphere::Integrand(double Z, void* params) const { (void)params; // to avoid unused-variable warning @@ -90,5 +96,3 @@ complex_t FormFactorTruncatedSphere::evaluate_for_q(const cvector_t& q) const return Units::PI2*integral*std::exp(iqzR); } } - - diff --git a/Core/FormFactors/src/FormFactorTruncatedSpheroid.cpp b/Core/FormFactors/src/FormFactorTruncatedSpheroid.cpp index 222ea76b45d..d130e1671cb 100644 --- a/Core/FormFactors/src/FormFactorTruncatedSpheroid.cpp +++ b/Core/FormFactors/src/FormFactorTruncatedSpheroid.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "FormFactorTruncatedSpheroid.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "Numeric.h" #include "MemberFunctionIntegrator.h" @@ -21,7 +22,7 @@ FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(double radius, double height, double height_flattening) { - setName("FormFactorTruncatedSpheroid"); + setName(BornAgain::FFTruncatedSpheroidType); m_radius = radius; m_height = height; m_height_flattening = height_flattening; @@ -32,7 +33,12 @@ FormFactorTruncatedSpheroid::FormFactorTruncatedSpheroid(double radius, double h & FormFactorTruncatedSpheroid::Integrand; m_integrator = new MemberComplexFunctionIntegrator<FormFactorTruncatedSpheroid>(p_mf, this); - } +} + +FormFactorTruncatedSpheroid::~FormFactorTruncatedSpheroid() +{ + delete m_integrator; +} bool FormFactorTruncatedSpheroid::check_initialization() const { @@ -65,6 +71,11 @@ FormFactorTruncatedSpheroid* FormFactorTruncatedSpheroid::clone() const return result; } +void FormFactorTruncatedSpheroid::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + //! Integrand for complex formfactor. complex_t FormFactorTruncatedSpheroid::Integrand(double Z, void* params) const { diff --git a/Core/FormFactors/src/FormFactorWeighted.cpp b/Core/FormFactors/src/FormFactorWeighted.cpp index 685b352bfef..e5c5c624fc7 100644 --- a/Core/FormFactors/src/FormFactorWeighted.cpp +++ b/Core/FormFactors/src/FormFactorWeighted.cpp @@ -14,10 +14,12 @@ // ************************************************************************** // #include "FormFactorWeighted.h" +#include "BornAgainNamespace.h" + FormFactorWeighted::FormFactorWeighted() { - setName("FormFactorWeighted"); + setName(BornAgain::FormFactorWeighted); } FormFactorWeighted::~FormFactorWeighted() @@ -37,8 +39,13 @@ FormFactorWeighted* FormFactorWeighted::clone() const return result; } +void FormFactorWeighted::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + void FormFactorWeighted::addFormFactor(const IFormFactor& form_factor, - double weight) + double weight) { m_form_factors.push_back(form_factor.clone()); m_weights.push_back(weight); diff --git a/Core/PythonAPI/src/FormFactorFullSphere.pypp.cpp b/Core/PythonAPI/src/FormFactorFullSphere.pypp.cpp index 6b7c811729b..854314c8fd4 100644 --- a/Core/PythonAPI/src/FormFactorFullSphere.pypp.cpp +++ b/Core/PythonAPI/src/FormFactorFullSphere.pypp.cpp @@ -316,7 +316,7 @@ void register_FormFactorFullSphere_class(){ { //::FormFactorFullSphere typedef bp::class_< FormFactorFullSphere_wrapper, bp::bases< IFormFactorBorn >, std::auto_ptr< FormFactorFullSphere_wrapper >, boost::noncopyable > FormFactorFullSphere_exposer_t; - FormFactorFullSphere_exposer_t FormFactorFullSphere_exposer = FormFactorFullSphere_exposer_t( "FormFactorFullSphere", bp::init< double >(( bp::arg("radius") ), "Full Sphere constructor.\n\n:Parameters:\n - 'radius' - of Sphere\n") ); + FormFactorFullSphere_exposer_t FormFactorFullSphere_exposer = FormFactorFullSphere_exposer_t( "FormFactorFullSphere", "The formfactor of a sphere.", bp::init< double >(( bp::arg("radius") ), "Full Sphere constructor.\n\n:Parameters:\n - 'radius' - of Sphere\n") ); bp::scope FormFactorFullSphere_scope( FormFactorFullSphere_exposer ); { //::FormFactorFullSphere::clone diff --git a/Core/PythonAPI/src/FormFactorWeighted.pypp.cpp b/Core/PythonAPI/src/FormFactorWeighted.pypp.cpp index 33cf0b3091d..450643f612d 100644 --- a/Core/PythonAPI/src/FormFactorWeighted.pypp.cpp +++ b/Core/PythonAPI/src/FormFactorWeighted.pypp.cpp @@ -301,8 +301,7 @@ void register_FormFactorWeighted_class(){ FormFactorWeighted_exposer.def( "addFormFactor" , addFormFactor_function_type( &::FormFactorWeighted::addFormFactor ) - , ( bp::arg("form_factor"), bp::arg("weight")=1.0e+0 ) - , "calls the ISampleVisitor's visit method." ); + , ( bp::arg("form_factor"), bp::arg("weight")=1.0e+0 ) ); } { //::FormFactorWeighted::clone diff --git a/Core/PythonAPI/src/GISASSimulation.pypp.cpp b/Core/PythonAPI/src/GISASSimulation.pypp.cpp index 989730c3c9c..cfbdcf0c50f 100644 --- a/Core/PythonAPI/src/GISASSimulation.pypp.cpp +++ b/Core/PythonAPI/src/GISASSimulation.pypp.cpp @@ -230,7 +230,7 @@ void register_GISASSimulation_class(){ "addMask" , addMask_function_type( &::GISASSimulation::addMask ) , ( bp::arg("shape"), bp::arg("mask_value")=(bool)(true) ) - , "Adds mask of given shape to the stack of detector masks. The mask value 'true' means that the channel will be excluded from the simulation. The mask which is added last has priority. @param shape The shape of mask (Rectangle, Polygon, Line, Ellipse) @mask_value The value of mask \n\n:Parameters:\n - 'shape' - The shape of mask (Rectangle, Polygon, Line, Ellipse)\n" ); + , "Adds mask of given shape to the stack of detector masks. The mask value 'true' means that the channel will be excluded from the simulation. The mask which is added last has priority. @param shape The shape of mask (Rectangle, Polygon, Line, Ellipse) @param mask_value The value of mask \n\n:Parameters:\n - 'shape' - The shape of mask (Rectangle, Polygon, Line, Ellipse)\n - 'mask_value' - The value of mask\n" ); } { //::GISASSimulation::clone diff --git a/Core/PythonAPI/src/IParameterized.pypp.cpp b/Core/PythonAPI/src/IParameterized.pypp.cpp index 66f020ceebb..dc65d72017f 100644 --- a/Core/PythonAPI/src/IParameterized.pypp.cpp +++ b/Core/PythonAPI/src/IParameterized.pypp.cpp @@ -148,7 +148,7 @@ void register_IParameterized_class(){ { //::IParameterized typedef bp::class_< IParameterized_wrapper > IParameterized_exposer_t; - IParameterized_exposer_t IParameterized_exposer = IParameterized_exposer_t( "IParameterized", "Manage a local parameter pool, and a tree of children's pools.", bp::init< >() ); + IParameterized_exposer_t IParameterized_exposer = IParameterized_exposer_t( "IParameterized", "Manage a local parameter pool, and a tree of child pools.", bp::init< >() ); bp::scope IParameterized_scope( IParameterized_exposer ); IParameterized_exposer.def( bp::init< std::string const & >(( bp::arg("name") )) ); IParameterized_exposer.def( bp::init< IParameterized const & >(( bp::arg("other") )) ); diff --git a/Core/PythonAPI/src/ISample.pypp.cpp b/Core/PythonAPI/src/ISample.pypp.cpp index 5f9b9cbe565..f38f7ea880b 100644 --- a/Core/PythonAPI/src/ISample.pypp.cpp +++ b/Core/PythonAPI/src/ISample.pypp.cpp @@ -30,11 +30,11 @@ namespace bp = boost::python; struct ISample_wrapper : ISample, bp::wrapper< ISample > { - ISample_wrapper( ) - : ISample( ) + ISample_wrapper() + : ISample() , bp::wrapper< ISample >(){ // null constructor - m_pyobj = 0; + m_pyobj = 0; } virtual void accept( ::ISampleVisitor * p_visitor ) const { @@ -230,7 +230,7 @@ void register_ISample_class(){ { //::ISample typedef bp::class_< ISample_wrapper, bp::bases< ICloneable, IParameterized >, std::auto_ptr< ISample_wrapper >, boost::noncopyable > ISample_exposer_t; - ISample_exposer_t ISample_exposer = ISample_exposer_t( "ISample", "Interface for objects related to scattering.", bp::init< >() ); + ISample_exposer_t ISample_exposer = ISample_exposer_t( "ISample", "Interface for objects related to scattering." ); bp::scope ISample_scope( ISample_exposer ); { //::ISample::accept @@ -250,7 +250,8 @@ void register_ISample_class(){ ISample_exposer.def( "clone" , bp::pure_virtual( clone_function_type(&::ISample::clone) ) - , bp::return_value_policy< bp::manage_new_object >() ); + , bp::return_value_policy< bp::manage_new_object >() + , "Returns a clone of this ISample object." ); } { //::ISample::cloneInvertB diff --git a/Core/PythonAPI/src/Layer.pypp.cpp b/Core/PythonAPI/src/Layer.pypp.cpp index 409187834dc..4f3df23db4e 100644 --- a/Core/PythonAPI/src/Layer.pypp.cpp +++ b/Core/PythonAPI/src/Layer.pypp.cpp @@ -498,7 +498,8 @@ void register_Layer_class(){ Layer_exposer.def( "getTotalParticleSurfaceDensity" , getTotalParticleSurfaceDensity_function_type( &::Layer::getTotalParticleSurfaceDensity ) - , ( bp::arg("layout_index") ) ); + , ( bp::arg("layout_index") ) + , "creates and returns a LayerDWBASimulation for the given layout." ); } { //::Layer::setMaterial diff --git a/Core/Samples/inc/Crystal.h b/Core/Samples/inc/Crystal.h index 01c2320dc13..dcda1bddd19 100644 --- a/Core/Samples/inc/Crystal.h +++ b/Core/Samples/inc/Crystal.h @@ -37,8 +37,7 @@ public: //! Returns a clone with inverted magnetic fields Crystal *cloneInvertB() const; - //! Calls the ISampleVisitor's visit method - void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + void accept(ISampleVisitor *visitor) const; void setAmbientMaterial(const IMaterial& material) { mp_lattice_basis->setAmbientMaterial(material); diff --git a/Core/Samples/inc/InterferenceFunction1DLattice.h b/Core/Samples/inc/InterferenceFunction1DLattice.h index 3ae81012600..14de87db04b 100644 --- a/Core/Samples/inc/InterferenceFunction1DLattice.h +++ b/Core/Samples/inc/InterferenceFunction1DLattice.h @@ -37,7 +37,7 @@ public: virtual InterferenceFunction1DLattice *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; void setProbabilityDistribution(const IFTDistribution1D& pdf); diff --git a/Core/Samples/inc/InterferenceFunction2DLattice.h b/Core/Samples/inc/InterferenceFunction2DLattice.h index 2e9c2f8435f..c9640d2f3ec 100644 --- a/Core/Samples/inc/InterferenceFunction2DLattice.h +++ b/Core/Samples/inc/InterferenceFunction2DLattice.h @@ -27,7 +27,6 @@ class BA_CORE_API_ InterferenceFunction2DLattice : public IInterferenceFunction { public: - //! @brief contructor //! @param length_1 Lattice length 1 //! @param length_2 Lattice length 2 @@ -39,24 +38,19 @@ public: virtual InterferenceFunction2DLattice *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; - static InterferenceFunction2DLattice *createSquare(double lattice_length, - double xi = 0.0); - static InterferenceFunction2DLattice *createHexagonal(double lattice_length, - double xi = 0.0); + static InterferenceFunction2DLattice *createSquare(double lattice_length, double xi = 0.0); + static InterferenceFunction2DLattice *createHexagonal(double lattice_length, double xi = 0.0); void setProbabilityDistribution(const IFTDistribution2D& pdf); - const IFTDistribution2D *getProbabilityDistribution() const { - return mp_pdf; - } + const IFTDistribution2D *getProbabilityDistribution() const; virtual double evaluate(const kvector_t& q) const; - Lattice2DIFParameters getLatticeParameters() const { - return m_lattice_params; - } + Lattice2DIFParameters getLatticeParameters() const; + protected: //! Returns interference from a single reciprocal lattice vector double interferenceAtOneRecLatticePoint(double qx, double qy) const; @@ -73,6 +67,7 @@ protected: Lattice2DIFParameters m_lattice_params; IFTDistribution2D *mp_pdf; static const int nmax = 20; //!< maximum value for qx*Lambdax and qy*lambday + private: InterferenceFunction2DLattice(const Lattice2DIFParameters& lattice_params); @@ -93,5 +88,3 @@ private: }; #endif /* INTERFERENCEFUNCTION2DLATTICE_H_ */ - - diff --git a/Core/Samples/inc/InterferenceFunction2DParaCrystal.h b/Core/Samples/inc/InterferenceFunction2DParaCrystal.h index 0080e7b9d95..9eb268b07c4 100644 --- a/Core/Samples/inc/InterferenceFunction2DParaCrystal.h +++ b/Core/Samples/inc/InterferenceFunction2DParaCrystal.h @@ -40,22 +40,21 @@ public: virtual InterferenceFunction2DParaCrystal *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; - static InterferenceFunction2DParaCrystal *createSquare( - double peak_distance, double damping_length=0.0, - double domain_size_1=0.0, double domain_size_2=0.0); - static InterferenceFunction2DParaCrystal *createHexagonal( - double peak_distance, double damping_length=0.0, - double domain_size_1=0.0, double domain_size_2=0.0); + static InterferenceFunction2DParaCrystal *createSquare(double peak_distance, + double damping_length = 0.0, + double domain_size_1 = 0.0, + double domain_size_2 = 0.0); + static InterferenceFunction2DParaCrystal *createHexagonal(double peak_distance, + double damping_length = 0.0, + double domain_size_1 = 0.0, + double domain_size_2 = 0.0); //! @brief Sets sizes of coherence domain //! @param size_1: size in first lattice direction //! @param size_2: size in second lattice direction - void setDomainSizes(double size_1, double size_2) { - m_domain_sizes[0] = size_1; - m_domain_sizes[1] = size_2; - } + void setDomainSizes(double size_1, double size_2); void setProbabilityDistributions(const IFTDistribution2D& pdf_1, const IFTDistribution2D& pdf_2); diff --git a/Core/Samples/inc/InterferenceFunctionNone.h b/Core/Samples/inc/InterferenceFunctionNone.h index b474650730a..ea1e0cffa4b 100644 --- a/Core/Samples/inc/InterferenceFunctionNone.h +++ b/Core/Samples/inc/InterferenceFunctionNone.h @@ -25,19 +25,13 @@ class BA_CORE_API_ InterferenceFunctionNone : public IInterferenceFunction { public: - InterferenceFunctionNone() { setName("InterferenceFunctionNone"); } - virtual ~InterferenceFunctionNone() {} - virtual InterferenceFunctionNone *clone() const - { - InterferenceFunctionNone *result = new InterferenceFunctionNone(); - result->setName(getName()); - return result; - } - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } - - virtual double evaluate(const kvector_t& q) const { (void)q; return 1.0; } -}; + InterferenceFunctionNone(); -#endif /* INTERFERENCEFUNCTIONNONE_H_ */ + virtual InterferenceFunctionNone *clone() const; + virtual void accept(ISampleVisitor *visitor) const; + virtual double evaluate(const kvector_t& q) const; +}; + +#endif /* INTERFERENCEFUNCTIONNONE_H_ */ diff --git a/Core/Samples/inc/InterferenceFunctionRadialParaCrystal.h b/Core/Samples/inc/InterferenceFunctionRadialParaCrystal.h index 77841e4b084..4360fa813bc 100644 --- a/Core/Samples/inc/InterferenceFunctionRadialParaCrystal.h +++ b/Core/Samples/inc/InterferenceFunctionRadialParaCrystal.h @@ -40,27 +40,23 @@ public: virtual ~InterferenceFunctionRadialParaCrystal() {} virtual InterferenceFunctionRadialParaCrystal *clone() const; - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; //! @brief Sets size of coherence domain //! @param size: size in lattice direction - void setDomainSize(double size) { - m_domain_size = size; - } + void setDomainSize(double size); //! @brief Gets size of coherence domain //! @param size: size in lattice direction - double getDomainSize() const { - return m_domain_size; - } + double getDomainSize() const; //! @brief Sets size-spacing coupling parameter //! @param kappa: size-spacing coupling parameter - void setKappa(double kappa) { m_kappa = kappa; } + void setKappa(double kappa); //! @brief Gets size-spacing coupling parameter //! @param kappa: size-spacing coupling parameter - virtual double getKappa() const { return m_kappa; } + virtual double getKappa() const; virtual double evaluate(const kvector_t& q) const; //TODO: replace these with strategy pattern for different algorithms @@ -74,9 +70,9 @@ public: //! nearest particle const IFTDistribution1D *getPropabilityDistribution() const; - double getPeakDistance() const { return m_peak_distance; } + double getPeakDistance() const; - double getDampingLength() const { return m_damping_length; } + double getDampingLength() const; protected: double m_peak_distance; //!< the distance to the first neighbor peak diff --git a/Core/Samples/inc/Layer.h b/Core/Samples/inc/Layer.h index 107789ebf2d..36eb0eb6fbd 100644 --- a/Core/Samples/inc/Layer.h +++ b/Core/Samples/inc/Layer.h @@ -44,31 +44,28 @@ public: virtual Layer *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor* visitor) const; //! Sets layer thickness in nanometers. virtual void setThickness(double thickness); //! Returns layer thickness in nanometers. - virtual double getThickness() const { return m_thickness; } + virtual double getThickness() const; //! Sets _material_ of the layer. virtual void setMaterial(const IMaterial& material); //! Sets _material_ and _thickness_. - virtual void setMaterialAndThickness(const IMaterial& material, - double thickness); + virtual void setMaterialAndThickness(const IMaterial& material, double thickness); //! Returns layer's material. - virtual const IMaterial* getMaterial() const { return mp_material; } + virtual const IMaterial* getMaterial() const; //! Returns refractive index of the layer's material. virtual complex_t getRefractiveIndex() const; //! Returns squared refractive index of the layer's material. - complex_t getRefractiveIndex2() const { - return getRefractiveIndex()*getRefractiveIndex(); - } + complex_t getRefractiveIndex2() const; //! sets particle layout virtual void addLayout(const ILayout& decoration); @@ -79,17 +76,10 @@ public: } //! returns particle decoration - virtual const ILayout* getLayout(size_t i) const { - if (i>=m_layouts.size()) { - return 0; - } - return m_layouts[i]; - } + virtual const ILayout* getLayout(size_t i) const; //! Returns true if decoration is present - virtual bool hasDWBASimulation() const { - return (m_layouts.size()>0); - } + virtual bool hasDWBASimulation() const; //! creates and returns a LayerDWBASimulation for the given layout LayerDWBASimulation *createLayoutSimulation(size_t layout_index) const; @@ -98,13 +88,9 @@ public: double getTotalAbundance() const; - void setNumberOfLayers(size_t n_layers) { - mn_layers = n_layers; - } + void setNumberOfLayers(size_t n_layers); - size_t getNumberOfLayers() const { - return mn_layers; - } + size_t getNumberOfLayers() const; protected: Layer(const Layer& other); @@ -120,24 +106,8 @@ protected: IMaterial* mp_material; //!< pointer to the material SafePointerVector<ILayout> m_layouts; //!< independent layouts in this layer size_t mn_layers; +private: + void initialize(); }; - -inline complex_t Layer::getRefractiveIndex() const -{ - return (mp_material ? mp_material->getRefractiveIndex() - : complex_t(1.0,0.0)); -} - -inline double Layer::getTotalParticleSurfaceDensity(size_t layout_index) const -{ - if (getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts()) { - return 0.0; - } - return getLayout(layout_index)->getTotalParticleSurfaceDensity(); -} - - #endif // LAYER_H - - diff --git a/Core/Samples/inc/LayerInterface.h b/Core/Samples/inc/LayerInterface.h index e69853ad20e..356e9a88178 100644 --- a/Core/Samples/inc/LayerInterface.h +++ b/Core/Samples/inc/LayerInterface.h @@ -33,24 +33,22 @@ public: LayerInterface *clone() const; //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; //! Creates smooth interface between two layers - static LayerInterface* createSmoothInterface( - const Layer *p_layer_top, const Layer *p_layer_bottom); + static LayerInterface* createSmoothInterface(const Layer *p_layer_top, + const Layer *p_layer_bottom); //! Creates rough interface between two layers - static LayerInterface* createRoughInterface( - const Layer *p_layer_top, const Layer *p_layer_bottom, - const LayerRoughness& roughness); + static LayerInterface* createRoughInterface(const Layer *p_layer_top, + const Layer *p_layer_bottom, + const LayerRoughness& roughness); //! Sets link to the layer above the interface. - void setLayerTop(const Layer* p_layer_top) - { m_LayerTop = p_layer_top; } + void setLayerTop(const Layer* p_layer_top); //! Sets link to the layer below the interface. - void setLayerBottom(const Layer* p_layer_bottom) - { m_LayerBottom = p_layer_bottom; } + void setLayerBottom(const Layer* p_layer_bottom); //! Sets links to the layers above and below the interface. void setLayersTopBottom( @@ -61,13 +59,13 @@ public: void setRoughness(const LayerRoughness& roughness); //! Returns roughness of the interface. - const LayerRoughness *getRoughness() const { return m_roughness; } + const LayerRoughness *getRoughness() const; //! Returns top layer. - const Layer *getLayerTop() const { return m_LayerTop; } + const Layer *getLayerTop() const; //! Returns bottom layer. - const Layer *getLayerBottom() const { return m_LayerBottom; } + const Layer *getLayerBottom() const; protected: void print(std::ostream& ostr) const; diff --git a/Core/Samples/inc/LayerRoughness.h b/Core/Samples/inc/LayerRoughness.h index dc4f0fa993e..b4af11e5af5 100644 --- a/Core/Samples/inc/LayerRoughness.h +++ b/Core/Samples/inc/LayerRoughness.h @@ -36,7 +36,10 @@ public: LayerRoughness *clone() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const + { + visitor->visit(this); + } //! Returns power spectral density of the surface roughness double getSpectralFun(const kvector_t& kvec) const; @@ -44,23 +47,22 @@ public: double getCorrFun(const kvector_t& k) const; //! Sets rms of roughness - inline void setSigma(double sigma) { m_sigma = sigma; } + void setSigma(double sigma); //! Returns rms of roughness - inline double getSigma() const { return m_sigma; } + double getSigma() const; //! Sets hurst parameter. It describes how jagged the surface is. - inline void setHurstParameter(double hurstParameter) { m_hurstParameter = hurstParameter; } + void setHurstParameter(double hurstParameter); //! Returns hurst parameter - inline double getHurstParameter() const { return m_hurstParameter; } + double getHurstParameter() const; //! Sets lateral correlation length - inline void setLatteralCorrLength(double latteralCorrLength) { m_latteralCorrLength = latteralCorrLength; } + void setLatteralCorrLength(double latteralCorrLength); //! Returns latteral correlation length - inline double getLatteralCorrLength() const { return m_latteralCorrLength; } + double getLatteralCorrLength() const; //! Prints class - friend std::ostream& operator<<(std::ostream& ostr, /*const*/ LayerRoughness& m) - { m.print(ostr); return ostr; } + friend std::ostream& operator<<(std::ostream& ostr, /*const*/ LayerRoughness& m); protected: //! Registers some class members for later access via parameter pool @@ -72,8 +74,8 @@ protected: double m_sigma; //!< rms of roughness double m_hurstParameter; //!< Hurst parameter which describes how jagged the interface, 0<H<=1 double m_latteralCorrLength; //!< latteral correlation length of the roughness +private: + void initialize(); }; #endif // LAYERROUGHNESS_H - - diff --git a/Core/Samples/inc/MesoCrystal.h b/Core/Samples/inc/MesoCrystal.h index 0a2dd5e9ae7..fca9e2cb010 100644 --- a/Core/Samples/inc/MesoCrystal.h +++ b/Core/Samples/inc/MesoCrystal.h @@ -27,10 +27,8 @@ class BA_CORE_API_ MesoCrystal : public IParticle { public: - MesoCrystal(IClusteredParticles *p_particle_structure, - IFormFactor *p_form_factor); - MesoCrystal(const IClusteredParticles& particle_structure, - IFormFactor& form_factor); + MesoCrystal(IClusteredParticles *p_particle_structure, IFormFactor *p_form_factor); + MesoCrystal(const IClusteredParticles &particle_structure, IFormFactor &form_factor); virtual ~MesoCrystal(); virtual MesoCrystal *clone() const; @@ -39,7 +37,7 @@ public: virtual MesoCrystal *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; virtual void setAmbientMaterial(const IMaterial& material); virtual const IMaterial* getAmbientMaterial() const; @@ -51,9 +49,7 @@ public: //! @brief get the internal structure, which is in principle unbounded in //! space (eg. an infinite crystal) - const IClusteredParticles *getClusteredParticles() const { - return mp_particle_structure; - } + const IClusteredParticles *getClusteredParticles() const; private: //! Creates a form factor decorated with the IParticle's position/rotation @@ -63,6 +59,7 @@ private: IClusteredParticles *mp_particle_structure; IFormFactor *mp_meso_form_factor; + void initialize(); }; #endif /* MESOCRYSTAL_H_ */ diff --git a/Core/Samples/inc/Particle.h b/Core/Samples/inc/Particle.h index f20322c79f7..e9e99771ad5 100644 --- a/Core/Samples/inc/Particle.h +++ b/Core/Samples/inc/Particle.h @@ -42,19 +42,14 @@ public: virtual Particle *cloneInvertB() const; //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; //! Sets the refractive index of the ambient material (which influences its //! scattering power) - virtual void setAmbientMaterial(const IMaterial& material) - { - if(mP_ambient_material.get() != &material) { - mP_ambient_material.reset(material.clone()); - } - } + virtual void setAmbientMaterial(const IMaterial& material); //! Returns particle's material. - virtual const IMaterial* getAmbientMaterial() const { return mP_ambient_material.get(); } + virtual const IMaterial* getAmbientMaterial() const; //! Create a form factor for this particle with an extra scattering factor virtual IFormFactor *createTransformedFormFactor(complex_t wavevector_scattering_factor, @@ -62,34 +57,26 @@ public: kvector_t translation) const; //! Sets _material_. - virtual void setMaterial(const IMaterial& material) { - if(mP_material.get() != &material) { - mP_material.reset(material.clone()); - } - } + virtual void setMaterial(const IMaterial& material); //! Returns particle's material. - virtual const IMaterial* getMaterial() const { return mP_material.get(); } + virtual const IMaterial* getMaterial() const; //! Returns refractive index of the particle - virtual complex_t getRefractiveIndex() const - { - return (mP_material.get() ? mP_material->getRefractiveIndex() - : complex_t(0,0)); - } + virtual complex_t getRefractiveIndex() const; //! Sets the form factor void setFormFactor(const IFormFactor& form_factor); //! Returns the form factor - const IFormFactor* getFormFactor() const { - return mP_form_factor.get(); - } + const IFormFactor* getFormFactor() const; protected: boost::scoped_ptr<IMaterial> mP_material; boost::scoped_ptr<IMaterial> mP_ambient_material; boost::scoped_ptr<IFormFactor> mP_form_factor; +private: + void initialize(); }; #endif // PARTICLE_H diff --git a/Core/Samples/inc/ParticleComposition.h b/Core/Samples/inc/ParticleComposition.h index 650f6593ffb..eede0458514 100644 --- a/Core/Samples/inc/ParticleComposition.h +++ b/Core/Samples/inc/ParticleComposition.h @@ -31,6 +31,7 @@ public: explicit ParticleComposition(const IParticle& particle); ParticleComposition(const IParticle& particle, kvector_t position); ParticleComposition(const IParticle& particle, std::vector<kvector_t > positions); + virtual ~ParticleComposition(); virtual ParticleComposition *clone() const; @@ -38,7 +39,7 @@ public: virtual ParticleComposition *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; void addParticle(const IParticle& particle); void addParticle(const IParticle& particle, kvector_t position); @@ -53,23 +54,16 @@ public: kvector_t translation) const; //! Returns number of different particles - size_t getNbrParticles() const {return m_particles.size(); } + size_t getNbrParticles() const; //! Returns particle with given index - const IParticle *getParticle(size_t index) const { - return m_particles[check_index(index)]; - } + const IParticle *getParticle(size_t index) const; - kvector_t getParticlePosition(size_t index) const - { return m_particles[check_index(index)]->getPosition(); } + kvector_t getParticlePosition(size_t index) const; private: //! Checks index - inline size_t check_index(size_t index) const { - return index < m_particles.size() - ? index - : throw OutOfBoundsException("ParticleComposition::check_index()" - "-> Index is out of bounds"); } + size_t check_index(size_t index) const; //! Checks if particle's type is suitable for adding void checkParticleType(const IParticle& p_particle); @@ -78,8 +72,7 @@ private: void addParticlePointer(IParticle *p_particle); std::vector<IParticle *> m_particles; + void initialize(); }; #endif /* PARTICLECOMPOSITION_H_ */ - - diff --git a/Core/Samples/inc/ParticleCoreShell.h b/Core/Samples/inc/ParticleCoreShell.h index 9c2a2689813..d4b189fb07f 100644 --- a/Core/Samples/inc/ParticleCoreShell.h +++ b/Core/Samples/inc/ParticleCoreShell.h @@ -34,7 +34,7 @@ public: virtual ParticleCoreShell *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const; //! Sets the refractive index of the ambient material (which influences //! its scattering power) @@ -47,10 +47,10 @@ public: kvector_t translation) const; //! Returns the core particle - const Particle *getCoreParticle() const { return mp_core; } + const Particle *getCoreParticle() const; //! Returns the shell particle - const Particle *getShellParticle() const { return mp_shell; } + const Particle *getShellParticle() const; protected: void addAndRegisterCore(const Particle &core, kvector_t relative_core_position); diff --git a/Core/Samples/inc/ParticleDistribution.h b/Core/Samples/inc/ParticleDistribution.h index ae41541cde7..169182c642b 100644 --- a/Core/Samples/inc/ParticleDistribution.h +++ b/Core/Samples/inc/ParticleDistribution.h @@ -32,54 +32,34 @@ class BA_CORE_API_ ParticleDistribution : public IAbstractParticle public: ParticleDistribution(const IParticle &prototype, const ParameterDistribution &par_distr); - virtual ~ParticleDistribution() - { - } virtual ParticleDistribution *clone() const; //! Returns a clone with inverted magnetic fields virtual ParticleDistribution *cloneInvertB() const; //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const - { - visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const; //! Sets the refractive index of the ambient material (which influences its //! scattering power) - virtual void setAmbientMaterial(const IMaterial &material) - { - mP_particle->setAmbientMaterial(material); - } + virtual void setAmbientMaterial(const IMaterial &material); //! Returns particle's material. - virtual const IMaterial *getAmbientMaterial() const - { - return mP_particle->getAmbientMaterial(); - } + virtual const IMaterial *getAmbientMaterial() const; //! Initializes list of new particles generated according to a distribution - virtual void generateParticleInfos(std::vector<const IParticle*>& particle_vector, - std::vector<double>& abundance_vector, - double abundance) const; + virtual void generateParticleInfos(std::vector<const IParticle *> &particle_vector, + std::vector<double> &abundance_vector, + double abundance) const; //! Returns the distributed parameter data - ParameterDistribution getParameterDistribution() const - { - return m_par_distribution; - } + ParameterDistribution getParameterDistribution() const; //! Returns the parameter pool that can be used for parameter distributions - ParameterPool *createDistributedParameterPool() const { - return mP_particle->createParameterTree(); - } + ParameterPool *createDistributedParameterPool() const; //! Returns particle. - const IParticle *getParticle() const - { - return mP_particle.get(); - } + const IParticle *getParticle() const; private: boost::scoped_ptr<IParticle> mP_particle; diff --git a/Core/Samples/inc/ParticleInfo.h b/Core/Samples/inc/ParticleInfo.h index 5031f92e434..55a6cbc168f 100644 --- a/Core/Samples/inc/ParticleInfo.h +++ b/Core/Samples/inc/ParticleInfo.h @@ -32,44 +32,25 @@ class BA_CORE_API_ ParticleInfo : public ICompositeSample public: ParticleInfo(const IAbstractParticle &p_particle, double abundance = 1.0); - virtual ~ParticleInfo() - { - } - virtual ParticleInfo *clone() const; //! Returns a clone with inverted magnetic fields virtual ParticleInfo *cloneInvertB() const; //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const - { - visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const; //! Returns particle. - const IAbstractParticle *getParticle() const - { - return mP_particle.get(); - } + const IAbstractParticle *getParticle() const; //! Returns abundance. - double getAbundance() const - { - return m_abundance; - } + double getAbundance() const; //! Sets abundance. - void setAbundance(double abundance) - { - m_abundance = abundance; - } + void setAbundance(double abundance); //! Sets the ambient material - void setAmbientMaterial(const IMaterial &material) - { - mP_particle->setAmbientMaterial(material); - } + void setAmbientMaterial(const IMaterial &material); protected: virtual void init_parameters(); diff --git a/Core/Samples/inc/ParticleLayout.h b/Core/Samples/inc/ParticleLayout.h index d8b8d1ea57f..d185f0dbdf7 100644 --- a/Core/Samples/inc/ParticleLayout.h +++ b/Core/Samples/inc/ParticleLayout.h @@ -42,10 +42,7 @@ public: virtual ParticleLayout *cloneInvertB() const; //! calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *visitor) const - { - visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const; //! @brief Adds generic particle to the layout with only abundance defined //! @param abundance Particle abundance @@ -65,10 +62,7 @@ public: const kvector_t &position, const IRotation& rotation); //! Returns number of particles - virtual size_t getNumberOfParticles() const - { - return m_particles.size(); - } + virtual size_t getNumberOfParticles() const; //! get information about particle with index virtual const IAbstractParticle *getParticle(size_t index) const; @@ -82,16 +76,10 @@ public: double getAbundanceOfParticle(size_t index) const; //! Returns number of interference functions - virtual size_t getNumberOfInterferenceFunctions() const - { - return m_interference_functions.size(); - } + virtual size_t getNumberOfInterferenceFunctions() const; //! Returns interference functions - virtual SafePointerVector<IInterferenceFunction> getInterferenceFunctions() const - { - return m_interference_functions; - } + virtual SafePointerVector<IInterferenceFunction> getInterferenceFunctions() const; //! Adds interference function void addInterferenceFunction(IInterferenceFunction *p_interference_function); diff --git a/Core/Samples/inc/Rotations.h b/Core/Samples/inc/Rotations.h index 3702358b59c..455f6d79aa5 100644 --- a/Core/Samples/inc/Rotations.h +++ b/Core/Samples/inc/Rotations.h @@ -19,8 +19,6 @@ #include "ISample.h" #include "Transform3D.h" -#include <memory> - //! @class IRotation //! @ingroup samples //! @brief An interface for classes representing a rotation @@ -42,13 +40,13 @@ public: virtual IRotation *createInverse() const=0; //! Calls the ISampleVisitor's visit method - void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + void accept(ISampleVisitor* visitor) const; //! Returns transformation. virtual Geometry::Transform3D getTransform3D() const=0; //! Returns true if roation matrix is identity matrix (no rotations) - virtual bool isIdentity() const { return getTransform3D().isIdentity(); } + virtual bool isIdentity() const; }; BA_CORE_API_ IRotation *CreateProduct(const IRotation& left, const IRotation &right); @@ -59,20 +57,17 @@ public: RotationX(double angle); RotationX *clone() const; - RotationX *cloneInvertB() const; - RotationX *createInverse() const; - double getAngle() const { return m_angle; } + double getAngle() const; - void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + void accept(ISampleVisitor* visitor) const; Geometry::Transform3D getTransform3D() const; protected: void init_parameters(); - double m_angle; }; @@ -82,20 +77,17 @@ public: RotationY(double angle); RotationY *clone() const; - RotationY *cloneInvertB() const; - RotationY *createInverse() const; - double getAngle() const { return m_angle; } + double getAngle() const; - void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + void accept(ISampleVisitor* visitor) const; Geometry::Transform3D getTransform3D() const; protected: void init_parameters(); - double m_angle; }; @@ -105,20 +97,17 @@ public: RotationZ(double angle = 0.0); RotationZ *clone() const; - RotationZ *cloneInvertB() const; - RotationZ *createInverse() const; - double getAngle() const { return m_angle; } + double getAngle() const; - void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + void accept(ISampleVisitor* visitor) const; Geometry::Transform3D getTransform3D() const; protected: void init_parameters(); - double m_angle; }; @@ -128,28 +117,21 @@ public: RotationEuler(double alpha, double beta, double gamma); RotationEuler *clone() const; - RotationEuler *cloneInvertB() const; - IRotation *createInverse() const; - double getAlpha() const { return m_alpha; } - - double getBeta() const { return m_beta; } + double getAlpha() const; + double getBeta() const; + double getGamma() const; - double getGamma() const { return m_gamma; } - - void accept(ISampleVisitor* visitor) const { visitor->visit(this); } + void accept(ISampleVisitor* visitor) const; Geometry::Transform3D getTransform3D() const; protected: void init_parameters(); - double m_alpha, m_beta, m_gamma; }; #endif // ROTATIONS_H - - diff --git a/Core/Samples/src/Crystal.cpp b/Core/Samples/src/Crystal.cpp index f109d49db46..eb805b65bc3 100644 --- a/Core/Samples/src/Crystal.cpp +++ b/Core/Samples/src/Crystal.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "Crystal.h" +#include "BornAgainNamespace.h" #include "FormFactors.h" #include "Units.h" #include "MathFunctions.h" @@ -21,7 +22,7 @@ Crystal::Crystal(const ParticleComposition &lattice_basis, const Lattice &lattice) : m_lattice(lattice), m_dw_factor(0.0) { - setName("Crystal"); + setName(BornAgain::CrystalType); mp_lattice_basis = lattice_basis.clone(); registerChild(mp_lattice_basis); } @@ -42,10 +43,14 @@ Crystal *Crystal::cloneInvertB() const { Crystal *p_new = new Crystal(mp_lattice_basis->cloneInvertB(), m_lattice); p_new->setDWFactor(m_dw_factor); - p_new->setName(getName() + "_inv"); return p_new; } +void Crystal::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + IFormFactor *Crystal::createTotalFormFactor(const IFormFactor &meso_crystal_form_factor, complex_t wavevector_scattering_factor, const IRotation *p_rotation, @@ -74,7 +79,7 @@ Lattice Crystal::getTransformedLattice(const IRotation *p_rotation) const Crystal::Crystal(ParticleComposition *p_lattice_basis, const Lattice &lattice) : m_lattice(lattice), m_dw_factor(0.0) { - setName("Crystal"); + setName(BornAgain::CrystalType); mp_lattice_basis = p_lattice_basis; registerChild(mp_lattice_basis); } diff --git a/Core/Samples/src/InterferenceFunction1DLattice.cpp b/Core/Samples/src/InterferenceFunction1DLattice.cpp index 88f2b10299d..3888e4328df 100644 --- a/Core/Samples/src/InterferenceFunction1DLattice.cpp +++ b/Core/Samples/src/InterferenceFunction1DLattice.cpp @@ -14,17 +14,14 @@ // ************************************************************************** // #include "InterferenceFunction1DLattice.h" -#include <cassert> +#include "BornAgainNamespace.h" -InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length, - double xi) -: mp_pdf(0) -, m_prefactor(1.0) -, m_na(0) +InterferenceFunction1DLattice::InterferenceFunction1DLattice(double length, double xi) + : mp_pdf(0), m_prefactor(1.0), m_na(0) { m_lattice_params.m_length = length; m_lattice_params.m_xi = xi; - setName("InterferenceFunction1DLattice"); + setName(BornAgain::InterferenceFunction1DLatticeType); init_parameters(); } @@ -33,32 +30,37 @@ InterferenceFunction1DLattice::~InterferenceFunction1DLattice() delete mp_pdf; } -InterferenceFunction1DLattice *InterferenceFunction1DLattice::clone() const { - InterferenceFunction1DLattice *result = - new InterferenceFunction1DLattice(m_lattice_params); - if(mp_pdf) result->setProbabilityDistribution(*mp_pdf); +InterferenceFunction1DLattice *InterferenceFunction1DLattice::clone() const +{ + InterferenceFunction1DLattice *result = new InterferenceFunction1DLattice(m_lattice_params); + if (mp_pdf) + result->setProbabilityDistribution(*mp_pdf); result->setName(getName()); return result; } +void InterferenceFunction1DLattice::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} -void InterferenceFunction1DLattice::setProbabilityDistribution( - const IFTDistribution1D& pdf) +void InterferenceFunction1DLattice::setProbabilityDistribution(const IFTDistribution1D &pdf) { - if (mp_pdf != &pdf) delete mp_pdf; + if (mp_pdf != &pdf) + delete mp_pdf; mp_pdf = pdf.clone(); double omega = mp_pdf->getOmega(); -// initialize_calc_factors(omega): - m_prefactor = Units::PI*omega; - double qa_max = (m_lattice_params.m_length/Units::PI2)*nmax/omega; - m_na = (int) (std::abs(qa_max) + 0.5); + // initialize_calc_factors(omega): + m_prefactor = Units::PI * omega; + double qa_max = (m_lattice_params.m_length / Units::PI2) * nmax / omega; + m_na = (int)(std::abs(qa_max) + 0.5); } -double InterferenceFunction1DLattice::evaluate(const kvector_t& q) const +double InterferenceFunction1DLattice::evaluate(const kvector_t &q) const { - if(!mp_pdf) { + if (!mp_pdf) { throw NullPointerException("InterferenceFunction1DLattice::evaluate" - " -> Error! No probability distribution function defined."); + " -> Error! No probability distribution function defined."); } double result = 0.0; double qxr = q.x(); @@ -66,32 +68,28 @@ double InterferenceFunction1DLattice::evaluate(const kvector_t& q) const double qx_frac; double xi = m_lattice_params.m_xi; double a = m_lattice_params.m_length; - double a_rec = Units::PI2/a; + double a_rec = Units::PI2 / a; // rotate the q vector to xi angle // so that qx_prime is along the a axis of lattice - double qx_prime = qxr*std::cos(xi) + qyr*std::sin(xi); + double qx_prime = qxr * std::cos(xi) + qyr * std::sin(xi); // calculate reciprocal vector fraction - int qa_int = (int) (qx_prime/a_rec); - qx_frac = qx_prime - qa_int*a_rec; + int qa_int = (int)(qx_prime / a_rec); + qx_frac = qx_prime - qa_int * a_rec; - for (int i=-m_na-1; i<m_na+2; ++i) - { - double qx = qx_frac + i*a_rec; + for (int i = -m_na - 1; i < m_na + 2; ++i) { + double qx = qx_frac + i * a_rec; result += mp_pdf->evaluate(qx); } - return m_prefactor*result; + return m_prefactor * result; } InterferenceFunction1DLattice::InterferenceFunction1DLattice( - const Lattice1DIFParameters& lattice_params) -: m_lattice_params(lattice_params) -, mp_pdf(0) -, m_prefactor(1.0) -, m_na(0) + const Lattice1DIFParameters &lattice_params) + : m_lattice_params(lattice_params), mp_pdf(0), m_prefactor(1.0), m_na(0) { - setName("InterferenceFunction1DLattice"); + setName(BornAgain::InterferenceFunction1DLatticeType); init_parameters(); } @@ -101,5 +99,3 @@ void InterferenceFunction1DLattice::init_parameters() registerParameter("length", &m_lattice_params.m_length); registerParameter("xi", &m_lattice_params.m_xi); } - - diff --git a/Core/Samples/src/InterferenceFunction2DLattice.cpp b/Core/Samples/src/InterferenceFunction2DLattice.cpp index e39507e4728..d525153fa8f 100644 --- a/Core/Samples/src/InterferenceFunction2DLattice.cpp +++ b/Core/Samples/src/InterferenceFunction2DLattice.cpp @@ -14,25 +14,22 @@ // ************************************************************************** // #include "InterferenceFunction2DLattice.h" +#include "BornAgainNamespace.h" -#include <cassert> #include "Macros.h" GCC_DIAG_OFF(unused-parameter) #include <boost/math/special_functions/round.hpp> GCC_DIAG_ON(unused-parameter) -InterferenceFunction2DLattice::InterferenceFunction2DLattice( - double length_1, double length_2, double angle, double xi) -: mp_pdf(0) -, m_prefactor(1.0) -, m_na(0) -, m_nb(0) +InterferenceFunction2DLattice::InterferenceFunction2DLattice(double length_1, double length_2, + double angle, double xi) + : mp_pdf(0), m_prefactor(1.0), m_na(0), m_nb(0) { m_lattice_params.m_length_1 = length_1; m_lattice_params.m_length_2 = length_2; m_lattice_params.m_angle = angle; m_lattice_params.m_xi = xi; - setName("InterferenceFunction2DLattice"); + setName(BornAgain::InterferenceFunction2DLatticeType); init_parameters(); initialize_rec_vectors(); } @@ -42,51 +39,62 @@ InterferenceFunction2DLattice::~InterferenceFunction2DLattice() delete mp_pdf; } -InterferenceFunction2DLattice *InterferenceFunction2DLattice::clone() const { +InterferenceFunction2DLattice *InterferenceFunction2DLattice::clone() const +{ InterferenceFunction2DLattice *result = new InterferenceFunction2DLattice(m_lattice_params); - if(mp_pdf) result->setProbabilityDistribution(*mp_pdf); + if (mp_pdf) + result->setProbabilityDistribution(*mp_pdf); result->setName(getName()); return result; } -InterferenceFunction2DLattice *InterferenceFunction2DLattice::createSquare( - double lattice_length, double xi) +void InterferenceFunction2DLattice::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +InterferenceFunction2DLattice *InterferenceFunction2DLattice::createSquare(double lattice_length, + double xi) { Lattice2DIFParameters lattice_params; lattice_params.m_length_1 = lattice_length; lattice_params.m_length_2 = lattice_length; - lattice_params.m_angle = Units::PI/2.0; + lattice_params.m_angle = Units::PI / 2.0; lattice_params.m_xi = xi; return new InterferenceFunction2DLattice(lattice_params); } -InterferenceFunction2DLattice *InterferenceFunction2DLattice::createHexagonal( - double lattice_length, double xi) +InterferenceFunction2DLattice *InterferenceFunction2DLattice::createHexagonal(double lattice_length, + double xi) { Lattice2DIFParameters lattice_params; lattice_params.m_length_1 = lattice_length; lattice_params.m_length_2 = lattice_length; - lattice_params.m_angle = 2.0*Units::PI/3.0; + lattice_params.m_angle = 2.0 * Units::PI / 3.0; lattice_params.m_xi = xi; return new InterferenceFunction2DLattice(lattice_params); } - -void InterferenceFunction2DLattice::setProbabilityDistribution( - const IFTDistribution2D& pdf) +void InterferenceFunction2DLattice::setProbabilityDistribution(const IFTDistribution2D &pdf) { - if (mp_pdf != &pdf) delete mp_pdf; + if (mp_pdf != &pdf) + delete mp_pdf; mp_pdf = pdf.clone(); double coherence_length_x = mp_pdf->getCoherenceLengthX(); double coherence_length_y = mp_pdf->getCoherenceLengthY(); initialize_calc_factors(coherence_length_x, coherence_length_y); } -double InterferenceFunction2DLattice::evaluate(const kvector_t& q) const +const IFTDistribution2D *InterferenceFunction2DLattice::getProbabilityDistribution() const +{ + return mp_pdf; +} + +double InterferenceFunction2DLattice::evaluate(const kvector_t &q) const { - if(!mp_pdf) { + if (!mp_pdf) { throw NullPointerException("InterferenceFunction2DLattice::evaluate" - " -> Error! No probability distribution function defined."); + " -> Error! No probability distribution function defined."); } double result = 0.0; double qxr = q.x(); @@ -94,24 +102,26 @@ double InterferenceFunction2DLattice::evaluate(const kvector_t& q) const double qx_frac, qy_frac; calculateReciprocalVectorFraction(qxr, qyr, qx_frac, qy_frac); - for (int i=-m_na-1; i<m_na+2; ++i) - { - for (int j=-m_nb-1; j<m_nb+2; ++j) - { - double qx = qx_frac + i*m_asx + j*m_bsx; - double qy = qy_frac + i*m_asy + j*m_bsy; + for (int i = -m_na - 1; i < m_na + 2; ++i) { + for (int j = -m_nb - 1; j < m_nb + 2; ++j) { + double qx = qx_frac + i * m_asx + j * m_bsx; + double qy = qy_frac + i * m_asy + j * m_bsy; result += interferenceAtOneRecLatticePoint(qx, qy); } } - return m_prefactor*result; + return m_prefactor * result; +} + +Lattice2DIFParameters InterferenceFunction2DLattice::getLatticeParameters() const +{ + return m_lattice_params; } -double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint( - double qx, double qy) const +double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint(double qx, double qy) const { - if(!mp_pdf) { + if (!mp_pdf) { throw NullPointerException("InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint" - " -> Error! No probability distribution function defined."); + " -> Error! No probability distribution function defined."); } double qp1, qp2; double gamma = m_lattice_params.m_xi + mp_pdf->getGamma(); @@ -120,35 +130,34 @@ double InterferenceFunction2DLattice::interferenceAtOneRecLatticePoint( return mp_pdf->evaluateLattice(qp1, qp2); } -void InterferenceFunction2DLattice::transformToPrincipalAxes(double qx, - double qy, double gamma, double delta, double& q_pa_1, double& q_pa_2) const +void InterferenceFunction2DLattice::transformToPrincipalAxes(double qx, double qy, double gamma, + double delta, double &q_pa_1, + double &q_pa_2) const { - q_pa_1 = qx*std::cos(gamma) + qy*std::sin(gamma); - q_pa_2 = qx*std::cos(gamma+delta) + qy*std::sin(gamma+delta); + q_pa_1 = qx * std::cos(gamma) + qy * std::sin(gamma); + q_pa_2 = qx * std::cos(gamma + delta) + qy * std::sin(gamma + delta); } -void InterferenceFunction2DLattice::calculateReciprocalVectorFraction(double qx, - double qy, double& qx_frac, double& qy_frac) const +void InterferenceFunction2DLattice::calculateReciprocalVectorFraction(double qx, double qy, + double &qx_frac, + double &qy_frac) const { double a = m_lattice_params.m_length_1; double b = m_lattice_params.m_length_2; double xi = m_lattice_params.m_xi; double xialpha = xi + m_lattice_params.m_angle; - int qa_int = boost::math::iround( a*(qx*std::cos(xi)+qy*std::sin(xi))/Units::PI2 ); - int qb_int = boost::math::iround( b*(qx*std::cos(xialpha)+qy*std::sin(xialpha))/Units::PI2 ); - qx_frac = qx - qa_int*m_asx - qb_int*m_bsx; - qy_frac = qy - qa_int*m_asy - qb_int*m_bsy; + int qa_int = boost::math::iround(a * (qx * std::cos(xi) + qy * std::sin(xi)) / Units::PI2); + int qb_int + = boost::math::iround(b * (qx * std::cos(xialpha) + qy * std::sin(xialpha)) / Units::PI2); + qx_frac = qx - qa_int * m_asx - qb_int * m_bsx; + qy_frac = qy - qa_int * m_asy - qb_int * m_bsy; } InterferenceFunction2DLattice::InterferenceFunction2DLattice( - const Lattice2DIFParameters& lattice_params) -: m_lattice_params(lattice_params) -, mp_pdf(0) -, m_prefactor(1.0) -, m_na(0) -, m_nb(0) -{ - setName("InterferenceFunction2DLattice"); + const Lattice2DIFParameters &lattice_params) + : m_lattice_params(lattice_params), mp_pdf(0), m_prefactor(1.0), m_na(0), m_nb(0) +{ + setName(BornAgain::InterferenceFunction2DLatticeType); init_parameters(); initialize_rec_vectors(); } @@ -162,45 +171,41 @@ void InterferenceFunction2DLattice::init_parameters() registerParameter("xi", &m_lattice_params.m_xi); } - void InterferenceFunction2DLattice::initialize_rec_vectors() { - if(m_lattice_params.m_length_1==0 || m_lattice_params.m_length_2 == 0) { + if (m_lattice_params.m_length_1 == 0 || m_lattice_params.m_length_2 == 0) { throw DivisionByZeroException("InterferenceFunction2DLattice::" - "initialize_rec_vectors() -> Error! Zero parameters" - " m_lattice_params.m_length1 or m_lattice_params.m_length_2"); + "initialize_rec_vectors() -> Error! Zero parameters" + " m_lattice_params.m_length1 or m_lattice_params.m_length_2"); } double sinalpha = std::sin(m_lattice_params.m_angle); - double ainv = Units::PI2/m_lattice_params.m_length_1/sinalpha; - double binv = Units::PI2/m_lattice_params.m_length_2/sinalpha; + double ainv = Units::PI2 / m_lattice_params.m_length_1 / sinalpha; + double binv = Units::PI2 / m_lattice_params.m_length_2 / sinalpha; double xi = m_lattice_params.m_xi; double xialpha = xi + m_lattice_params.m_angle; - m_asx = ainv*std::sin(xialpha); - m_asy = -ainv*std::cos(xialpha); - m_bsx = -binv*std::sin(xi); - m_bsy = binv*std::cos(xi); + m_asx = ainv * std::sin(xialpha); + m_asy = -ainv * std::cos(xialpha); + m_bsx = -binv * std::sin(xi); + m_bsy = binv * std::cos(xi); } -void InterferenceFunction2DLattice::initialize_calc_factors( - double coherence_length_x, double coherence_length_y) +void InterferenceFunction2DLattice::initialize_calc_factors(double coherence_length_x, + double coherence_length_y) { - if(!mp_pdf) { + if (!mp_pdf) { throw NullPointerException("InterferenceFunction2DLattice::initialize_calc_factors" - " -> Error! No probability distribution function defined."); + " -> Error! No probability distribution function defined."); } // constant prefactor - //TODO: for non 2D distributions: check if this still applies - m_prefactor = Units::PI2*coherence_length_x*coherence_length_y; + // TODO: for non 2D distributions: check if this still applies + m_prefactor = Units::PI2 * coherence_length_x * coherence_length_y; // number of reciprocal lattice points to use double qa_max, qb_max; - mp_pdf->transformToStarBasis(nmax/coherence_length_x, - nmax/coherence_length_y, m_lattice_params.m_angle, - m_lattice_params.m_length_1, m_lattice_params.m_length_2, - qa_max, qb_max); + mp_pdf->transformToStarBasis(nmax / coherence_length_x, nmax / coherence_length_y, + m_lattice_params.m_angle, m_lattice_params.m_length_1, + m_lattice_params.m_length_2, qa_max, qb_max); m_na = boost::math::iround(std::abs(qa_max)); m_nb = boost::math::iround(std::abs(qb_max)); } - - diff --git a/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp b/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp index f07edc815b3..10f8721ba58 100644 --- a/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp +++ b/Core/Samples/src/InterferenceFunction2DParaCrystal.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "InterferenceFunction2DParaCrystal.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" #include "MemberFunctionIntegrator.h" #include "Exceptions.h" @@ -35,7 +36,7 @@ InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal( m_pdfs[1] = 0; m_domain_sizes[0] = 0.0; m_domain_sizes[1] = 0.0; - setName("InterferenceFunction2DParaCrystal"); + setName(BornAgain::InterferenceFunction2DParaCrystalType); if (m_damping_length==0.0) { m_use_damping_length = false; } @@ -60,6 +61,10 @@ InterferenceFunction2DParaCrystal return result; } +void InterferenceFunction2DParaCrystal::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} void InterferenceFunction2DParaCrystal::setProbabilityDistributions( const IFTDistribution2D& pdf_1, const IFTDistribution2D& pdf_2) @@ -130,9 +135,15 @@ InterferenceFunction2DParaCrystal* InterferenceFunction2DParaCrystal:: return p_new; } +void InterferenceFunction2DParaCrystal::setDomainSizes(double size_1, double size_2) +{ + m_domain_sizes[0] = size_1; + m_domain_sizes[1] = size_2; +} + void InterferenceFunction2DParaCrystal::transformToPrincipalAxes(double qx, - double qy, double gamma, double delta, double& q_pa_1, - double& q_pa_2) const + double qy, double gamma, double delta, double& q_pa_1, + double& q_pa_2) const { q_pa_1 = qx*std::cos(gamma) + qy*std::sin(gamma); q_pa_2 = qx*std::cos(gamma+delta) + qy*std::sin(gamma+delta); diff --git a/Core/Samples/src/InterferenceFunctionNone.cpp b/Core/Samples/src/InterferenceFunctionNone.cpp new file mode 100644 index 00000000000..eef19bc22b7 --- /dev/null +++ b/Core/Samples/src/InterferenceFunctionNone.cpp @@ -0,0 +1,38 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file Samples/inc/InterferenceFunctionNone.cpp +//! @brief Implements class InterferenceFunctionNone. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2015 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#include "InterferenceFunctionNone.h" +#include "BornAgainNamespace.h" + + +InterferenceFunctionNone::InterferenceFunctionNone() +{ + setName(BornAgain::InterferenceFunctionNoneType); +} + +InterferenceFunctionNone *InterferenceFunctionNone::clone() const +{ + return new InterferenceFunctionNone(); +} + +void InterferenceFunctionNone::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +double InterferenceFunctionNone::evaluate(const kvector_t &) const +{ + return 1.0; +} diff --git a/Core/Samples/src/InterferenceFunctionRadialParaCrystal.cpp b/Core/Samples/src/InterferenceFunctionRadialParaCrystal.cpp index c422d73bfc6..54a41e6b1f5 100644 --- a/Core/Samples/src/InterferenceFunctionRadialParaCrystal.cpp +++ b/Core/Samples/src/InterferenceFunctionRadialParaCrystal.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "InterferenceFunctionRadialParaCrystal.h" +#include "BornAgainNamespace.h" #include "MathFunctions.h" InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal( @@ -24,7 +25,7 @@ InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal( , m_kappa(0.0) , m_domain_size(0.0) { - setName("InterferenceFunctionRadialParaCrystal"); + setName(BornAgain::InterferenceFunctionRadialParaCrystalType); if (m_damping_length==0.0) { m_use_damping_length = false; } @@ -54,6 +55,31 @@ InterferenceFunctionRadialParaCrystal *InterferenceFunctionRadialParaCrystal::cl return result; } +void InterferenceFunctionRadialParaCrystal::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +void InterferenceFunctionRadialParaCrystal::setDomainSize(double size) +{ + m_domain_size = size; +} + +double InterferenceFunctionRadialParaCrystal::getDomainSize() const +{ + return m_domain_size; +} + +void InterferenceFunctionRadialParaCrystal::setKappa(double kappa) +{ + m_kappa = kappa; +} + +double InterferenceFunctionRadialParaCrystal::getKappa() const +{ + return m_kappa; +} + double InterferenceFunctionRadialParaCrystal::evaluate(const kvector_t& q) const { @@ -121,4 +147,14 @@ const IFTDistribution1D return mP_pdf.get(); } +double InterferenceFunctionRadialParaCrystal::getPeakDistance() const +{ + return m_peak_distance; +} + +double InterferenceFunctionRadialParaCrystal::getDampingLength() const +{ + return m_damping_length; +} + diff --git a/Core/Samples/src/Layer.cpp b/Core/Samples/src/Layer.cpp index 96ef394267e..512e8188d3a 100644 --- a/Core/Samples/src/Layer.cpp +++ b/Core/Samples/src/Layer.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "Layer.h" +#include "BornAgainNamespace.h" #include "Exceptions.h" #include "DecoratedLayerDWBASimulation.h" #include "MultiLayer.h" @@ -25,17 +26,15 @@ Layer::Layer() : m_thickness(0) , mp_material(0) { - setName("Layer"); - init_parameters(); + initialize(); } Layer::Layer(const IMaterial &material, double thickness) : m_thickness(thickness) , mp_material(0) { - setName("Layer"); setMaterial(material); - init_parameters(); + initialize(); } Layer::Layer(const Layer& other) : ICompositeSample() @@ -46,9 +45,8 @@ Layer::Layer(const Layer& other) : ICompositeSample() for (size_t i=0; i<other.getNumberOfLayouts();++i) { addLayoutPtr(other.getLayout(i)->clone()); } - setName(other.getName()); setNumberOfLayers(other.getNumberOfLayers()); - init_parameters(); + initialize(); } Layer::~Layer() @@ -71,10 +69,9 @@ Layer* Layer::cloneInvertB() const return p_clone; } -void Layer::init_parameters() +void Layer::accept(ISampleVisitor *visitor) const { - clearParameterPool(); - registerParameter("thickness", &m_thickness); + visitor->visit(this); } //! Sets layer thickness in nanometers. @@ -85,6 +82,11 @@ void Layer::setThickness(double thickness) m_thickness = thickness; } +double Layer::getThickness() const +{ + return m_thickness; +} + //! Sets _material_ of the layer. void Layer::setMaterial(const IMaterial &material) { @@ -98,12 +100,20 @@ void Layer::setMaterialAndThickness(const IMaterial &material, double thickness) setThickness(thickness); } -void Layer::addLayoutPtr(ILayout *layout) +const IMaterial *Layer::getMaterial() const { - if( !layout ) return; + return mp_material; +} - m_layouts.push_back(layout); - registerChild(layout); +complex_t Layer::getRefractiveIndex() const +{ + return (mp_material ? mp_material->getRefractiveIndex() + : complex_t(1.0,0.0)); +} + +complex_t Layer::getRefractiveIndex2() const +{ + return getRefractiveIndex()*getRefractiveIndex(); } void Layer::addLayout(const ILayout &decoration) @@ -111,11 +121,17 @@ void Layer::addLayout(const ILayout &decoration) addLayoutPtr(decoration.clone()); } -//! Prints description. -void Layer::print(std::ostream& ostr) const +const ILayout *Layer::getLayout(size_t i) const { - ICompositeSample::print(ostr); - ostr << "-->Layer{" << *getMaterial() << "}"; + if (i>=m_layouts.size()) { + return 0; + } + return m_layouts[i]; +} + +bool Layer::hasDWBASimulation() const +{ + return (m_layouts.size()>0); } LayerDWBASimulation *Layer::createLayoutSimulation(size_t layout_index) const @@ -126,6 +142,14 @@ LayerDWBASimulation *Layer::createLayoutSimulation(size_t layout_index) const return new DecoratedLayerDWBASimulation(this, layout_index); } +double Layer::getTotalParticleSurfaceDensity(size_t layout_index) const +{ + if (getNumberOfLayouts()==0 || layout_index>=getNumberOfLayouts()) { + return 0.0; + } + return getLayout(layout_index)->getTotalParticleSurfaceDensity(); +} + double Layer::getTotalAbundance() const { double total_abundance = 0.0; @@ -135,3 +159,39 @@ double Layer::getTotalAbundance() const return total_abundance; } +void Layer::setNumberOfLayers(size_t n_layers) +{ + mn_layers = n_layers; +} + +size_t Layer::getNumberOfLayers() const +{ + return mn_layers; +} + +void Layer::init_parameters() +{ + clearParameterPool(); + registerParameter("thickness", &m_thickness); +} + +//! Prints description. +void Layer::print(std::ostream& ostr) const +{ + ICompositeSample::print(ostr); + ostr << "-->Layer{" << *getMaterial() << "}"; +} + +void Layer::addLayoutPtr(ILayout *layout) +{ + if( !layout ) return; + + m_layouts.push_back(layout); + registerChild(layout); +} + +void Layer::initialize() +{ + setName(BornAgain::LayerType); + init_parameters(); +} diff --git a/Core/Samples/src/LayerInterface.cpp b/Core/Samples/src/LayerInterface.cpp index 668d4f77715..a6cfd2ea759 100644 --- a/Core/Samples/src/LayerInterface.cpp +++ b/Core/Samples/src/LayerInterface.cpp @@ -14,7 +14,9 @@ // ************************************************************************** // #include "LayerInterface.h" +#include "BornAgainNamespace.h" #include "MessageService.h" + #include <iostream> #include <iomanip> @@ -23,7 +25,7 @@ LayerInterface::LayerInterface() , m_LayerTop(0) , m_LayerBottom(0) { - setName("LayerInterface"); + setName(BornAgain::LayerInterfaceType); } LayerInterface::~LayerInterface() @@ -36,6 +38,11 @@ LayerInterface *LayerInterface::clone() const throw NotImplementedException("LayerInterface::clone() -> Not allowed to clone."); } +void LayerInterface::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + LayerInterface *LayerInterface::createSmoothInterface(const Layer *p_layer_top, const Layer *p_layer_bottom) { LayerInterface *lr = new LayerInterface(); @@ -53,6 +60,16 @@ LayerInterface *LayerInterface::createRoughInterface(const Layer *p_layer_top, c return lr; } +void LayerInterface::setLayerTop(const Layer *p_layer_top) +{ + m_LayerTop = p_layer_top; +} + +void LayerInterface::setLayerBottom(const Layer *p_layer_bottom) +{ + m_LayerBottom = p_layer_bottom; +} + void LayerInterface::setRoughness(const LayerRoughness& roughness) { if(m_roughness) { @@ -66,6 +83,21 @@ void LayerInterface::setRoughness(const LayerRoughness& roughness) registerChild(m_roughness); } +const LayerRoughness *LayerInterface::getRoughness() const +{ + return m_roughness; +} + +const Layer *LayerInterface::getLayerTop() const +{ + return m_LayerTop; +} + +const Layer *LayerInterface::getLayerBottom() const +{ + return m_LayerBottom; +} + void LayerInterface::print(std::ostream& ostr) const { ICompositeSample::print(ostr); diff --git a/Core/Samples/src/LayerRoughness.cpp b/Core/Samples/src/LayerRoughness.cpp index 74bb9bbcfe0..dabe6ba091d 100644 --- a/Core/Samples/src/LayerRoughness.cpp +++ b/Core/Samples/src/LayerRoughness.cpp @@ -14,6 +14,8 @@ // ************************************************************************** // #include "LayerRoughness.h" +#include "BornAgainNamespace.h" + #include <cmath> #include <iostream> #include <iomanip> @@ -23,8 +25,7 @@ LayerRoughness::LayerRoughness() , m_hurstParameter(0) , m_latteralCorrLength(0) { - setName("LayerRoughness"); - init_parameters(); + initialize(); } LayerRoughness::LayerRoughness(double sigma, double hurstParameter, double latteralCorrLength) @@ -32,8 +33,7 @@ LayerRoughness::LayerRoughness(double sigma, double hurstParameter, double latte , m_hurstParameter(hurstParameter) , m_latteralCorrLength(latteralCorrLength) { - setName("LayerRoughness"); - init_parameters(); + initialize(); } LayerRoughness *LayerRoughness::clone() const @@ -76,10 +76,50 @@ double LayerRoughness::getCorrFun(const kvector_t& k) const return m_sigma*m_sigma*std::exp( -1.0*std::pow(R/clength, 2.*H) ); } +void LayerRoughness::setSigma(double sigma) +{ + m_sigma = sigma; +} + +double LayerRoughness::getSigma() const +{ + return m_sigma; +} + +void LayerRoughness::setHurstParameter(double hurstParameter) +{ + m_hurstParameter = hurstParameter; +} + +double LayerRoughness::getHurstParameter() const +{ + return m_hurstParameter; +} + +void LayerRoughness::setLatteralCorrLength(double latteralCorrLength) +{ + m_latteralCorrLength = latteralCorrLength; +} + +double LayerRoughness::getLatteralCorrLength() const +{ + return m_latteralCorrLength; +} + +std::ostream &operator<<(std::ostream &ostr, LayerRoughness &m) +{ + m.print(ostr); + return ostr; +} + void LayerRoughness::print(std::ostream& ostr) const { ISample::print(ostr); ostr << "-->LayerRoughness{ sigma=" << m_sigma << "}"; } - +void LayerRoughness::initialize() +{ + setName(BornAgain::LayerBasicRoughnessType); + init_parameters(); +} diff --git a/Core/Samples/src/MesoCrystal.cpp b/Core/Samples/src/MesoCrystal.cpp index ee1384754cb..90a500d4333 100644 --- a/Core/Samples/src/MesoCrystal.cpp +++ b/Core/Samples/src/MesoCrystal.cpp @@ -14,29 +14,20 @@ // ************************************************************************** // #include "MesoCrystal.h" +#include "BornAgainNamespace.h" #include "FormFactorDecoratorPositionFactor.h" #include "FormFactorDecoratorRotation.h" -MesoCrystal::MesoCrystal(IClusteredParticles* p_particle_structure, - IFormFactor* p_form_factor) - : mp_particle_structure(p_particle_structure) - , mp_meso_form_factor(p_form_factor) +MesoCrystal::MesoCrystal(IClusteredParticles *p_particle_structure, IFormFactor *p_form_factor) + : mp_particle_structure(p_particle_structure), mp_meso_form_factor(p_form_factor) { - setName("MesoCrystal"); - registerPosition(); - registerChild(mp_particle_structure); - registerChild(mp_meso_form_factor); + initialize(); } -MesoCrystal::MesoCrystal(const IClusteredParticles& particle_structure, - IFormFactor& form_factor) - : mp_particle_structure(particle_structure.clone()) - , mp_meso_form_factor(form_factor.clone()) +MesoCrystal::MesoCrystal(const IClusteredParticles &particle_structure, IFormFactor &form_factor) + : mp_particle_structure(particle_structure.clone()), mp_meso_form_factor(form_factor.clone()) { - setName("MesoCrystal"); - registerPosition(); - registerChild(mp_particle_structure); - registerChild(mp_meso_form_factor); + initialize(); } MesoCrystal::~MesoCrystal() @@ -45,10 +36,10 @@ MesoCrystal::~MesoCrystal() delete mp_particle_structure; } -MesoCrystal* MesoCrystal::clone() const +MesoCrystal *MesoCrystal::clone() const { - MesoCrystal *p_result = new MesoCrystal(mp_particle_structure->clone(), - mp_meso_form_factor->clone()); + MesoCrystal *p_result + = new MesoCrystal(mp_particle_structure->clone(), mp_meso_form_factor->clone()); if (mP_rotation.get()) { p_result->setRotation(*mP_rotation); } @@ -56,10 +47,10 @@ MesoCrystal* MesoCrystal::clone() const return p_result; } -MesoCrystal* MesoCrystal::cloneInvertB() const +MesoCrystal *MesoCrystal::cloneInvertB() const { - MesoCrystal *p_result = new MesoCrystal(mp_particle_structure->cloneInvertB(), - mp_meso_form_factor->clone()); + MesoCrystal *p_result + = new MesoCrystal(mp_particle_structure->cloneInvertB(), mp_meso_form_factor->clone()); if (mP_rotation.get()) { p_result->setRotation(*mP_rotation); } @@ -67,6 +58,11 @@ MesoCrystal* MesoCrystal::cloneInvertB() const return p_result; } +void MesoCrystal::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + void MesoCrystal::setAmbientMaterial(const IMaterial& material) { mp_particle_structure->setAmbientMaterial(material); @@ -84,15 +80,20 @@ IFormFactor *MesoCrystal::createTransformedFormFactor(complex_t wavevector_scatt { if (!mp_particle_structure || !mp_meso_form_factor) return 0; - boost::scoped_ptr<IRotation> P_total_rotation(createComposedRotation(p_rotation)); + std::unique_ptr<IRotation> P_total_rotation(createComposedRotation(p_rotation)); kvector_t total_position = getComposedTranslation(p_rotation, translation); - boost::scoped_ptr<IFormFactor> P_transformed_meso(createTransformationDecoratedFormFactor( + std::unique_ptr<IFormFactor> P_transformed_meso(createTransformationDecoratedFormFactor( *mp_meso_form_factor, P_total_rotation.get(), total_position)); IFormFactor *p_result = mp_particle_structure->createTotalFormFactor( *P_transformed_meso, wavevector_scattering_factor, P_total_rotation.get(), total_position); return p_result; } +const IClusteredParticles *MesoCrystal::getClusteredParticles() const +{ + return mp_particle_structure; +} + IFormFactor *MesoCrystal::createTransformationDecoratedFormFactor(const IFormFactor &bare_ff, const IRotation *p_rotation, kvector_t translation) const @@ -112,3 +113,11 @@ IFormFactor *MesoCrystal::createTransformationDecoratedFormFactor(const IFormFac } return p_result; } + +void MesoCrystal::initialize() +{ + setName(BornAgain::MesoCrystalType); + registerPosition(); + registerChild(mp_particle_structure); + registerChild(mp_meso_form_factor); +} diff --git a/Core/Samples/src/MultiLayer.cpp b/Core/Samples/src/MultiLayer.cpp index 213fe319a07..d3280ad230f 100644 --- a/Core/Samples/src/MultiLayer.cpp +++ b/Core/Samples/src/MultiLayer.cpp @@ -14,14 +14,16 @@ // ************************************************************************** // #include "MultiLayer.h" +#include "BornAgainNamespace.h" #include "MessageService.h" + #include <algorithm> #include <stdexcept> #include <iomanip> MultiLayer::MultiLayer() : m_crossCorrLength(0) { - setName("MultiLayer"); + setName(BornAgain::MultiLayerType); init_parameters(); } @@ -30,20 +32,12 @@ MultiLayer::~MultiLayer() clear(); } - -/* ************************************************************************* */ -// initialize pool parameters, i.e. register some of class members for later -// access via parameter pool -/* ************************************************************************* */ void MultiLayer::init_parameters() { clearParameterPool(); registerParameter("crossCorrLength", &m_crossCorrLength); } -/* ************************************************************************* */ -// clear MultiLayer contents including interfaces -/* ************************************************************************* */ void MultiLayer::clear() { for(size_t i=0; i<m_layers.size(); i++) delete m_layers[i]; @@ -57,8 +51,6 @@ void MultiLayer::clear() clearParameterPool(); } -//! clone MultiLayer contents including interfaces - MultiLayer *MultiLayer::clone() const { MultiLayer *newMultiLayer = new MultiLayer(); @@ -72,8 +64,6 @@ MultiLayer *MultiLayer::clone() const } for(size_t i=0; i<m_interfaces.size(); i++) { -// const Layer *topLayer = newMultiLayer->m_layers[i]; -// const Layer *bottomLayer = newMultiLayer->m_layers[i+1]; const Layer *topLayer = layer_buffer[i]; const Layer *bottomLayer = layer_buffer[i+1]; @@ -85,7 +75,6 @@ MultiLayer *MultiLayer::clone() const newInterface = LayerInterface::createSmoothInterface(topLayer, bottomLayer ); } - newMultiLayer->addAndRegisterLayer( layer_buffer[i] ); newMultiLayer->addAndRegisterInterface( newInterface ); } @@ -105,17 +94,12 @@ MultiLayer* MultiLayer::cloneInvertB() const newMultiLayer->m_layers_z = m_layers_z; -// for(size_t i=0; i<m_layers.size(); i++) { -// newMultiLayer->addAndRegisterLayer( m_layers[i]->cloneInvertB() ); -// } std::vector<Layer *> layer_buffer; for(size_t i=0; i<m_layers.size(); i++) { layer_buffer.push_back(m_layers[i]->cloneInvertB() ); } for(size_t i=0; i<m_interfaces.size(); i++) { -// const Layer *topLayer = newMultiLayer->m_layers[i]; -// const Layer *bottomLayer = newMultiLayer->m_layers[i+1]; const Layer *topLayer = layer_buffer[i]; const Layer *bottomLayer = layer_buffer[i+1]; @@ -196,7 +180,6 @@ void MultiLayer::addLayer(const Layer& layer) //! Fourier transform of the correlation function of roughnesses between the interfaces //! j,k - indexes of layers in multilayer whose bottom interfaces we are considering - double MultiLayer::getCrossCorrSpectralFun(const kvector_t& kvec, size_t j, size_t k) const { if(m_crossCorrLength == 0) return 0.0; @@ -214,8 +197,6 @@ double MultiLayer::getCrossCorrSpectralFun(const kvector_t& kvec, size_t j, size return corr; } -//! Changes layer thickness. - void MultiLayer::setLayerThickness(size_t i_layer, double thickness) { if (thickness < 0.) @@ -232,7 +213,6 @@ void MultiLayer::setLayerThickness(size_t i_layer, double thickness) } } - MultiLayerDWBASimulation* MultiLayer::createDWBASimulation() const { return new MultiLayerDWBASimulation(this); diff --git a/Core/Samples/src/Particle.cpp b/Core/Samples/src/Particle.cpp index 705dbc329d1..eb2524bdd25 100644 --- a/Core/Samples/src/Particle.cpp +++ b/Core/Samples/src/Particle.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "Particle.h" +#include "BornAgainNamespace.h" #include "Materials.h" #include "FormFactorDecoratorPositionFactor.h" @@ -21,23 +22,20 @@ Particle::Particle() { - setName("Particle"); - registerPosition(); + initialize(); } Particle::Particle(const IMaterial &p_material) : mP_material(p_material.clone()) { - setName("Particle"); - registerPosition(); + initialize(); } Particle::Particle(const IMaterial &p_material, const IFormFactor &form_factor) : mP_material(p_material.clone()) , mP_form_factor(form_factor.clone()) { - setName("Particle"); - registerPosition(); + initialize(); registerChild(mP_form_factor.get()); } @@ -46,8 +44,7 @@ Particle::Particle(const IMaterial &p_material, const IFormFactor &form_factor, : mP_material(p_material.clone()) , mP_form_factor(form_factor.clone()) { - setName("Particle"); - registerPosition(); + initialize(); setRotation(rotation); registerChild(mP_form_factor.get()); } @@ -65,7 +62,6 @@ Particle *Particle::clone() const if (mP_rotation.get()) p_result->setRotation(*mP_rotation); p_result->setPosition(m_position); - p_result->setName(getName()); return p_result; } @@ -86,12 +82,28 @@ Particle *Particle::cloneInvertB() const p_result->setRotation(*mP_rotation); p_result->setPosition(m_position); - p_result->setName(getName() + "_inv"); return p_result; } +void Particle::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +void Particle::setAmbientMaterial(const IMaterial &material) +{ + if(mP_ambient_material.get() != &material) { + mP_ambient_material.reset(material.clone()); + } +} + +const IMaterial *Particle::getAmbientMaterial() const +{ + return mP_ambient_material.get(); +} + IFormFactor *Particle::createTransformedFormFactor(complex_t wavevector_scattering_factor, - const IRotation *p_rotation, kvector_t translation) const + const IRotation *p_rotation, kvector_t translation) const { if (!mP_form_factor.get()) return 0; boost::scoped_ptr<IRotation> P_total_rotation(createComposedRotation(p_rotation)); @@ -123,6 +135,24 @@ IFormFactor *Particle::createTransformedFormFactor(complex_t wavevector_scatteri return p_ff; } +void Particle::setMaterial(const IMaterial &material) +{ + if(mP_material.get() != &material) { + mP_material.reset(material.clone()); + } +} + +const IMaterial *Particle::getMaterial() const +{ + return mP_material.get(); +} + +complex_t Particle::getRefractiveIndex() const +{ + return (mP_material.get() ? mP_material->getRefractiveIndex() + : complex_t(0,0)); +} + void Particle::setFormFactor(const IFormFactor &form_factor) { if (&form_factor != mP_form_factor.get()) { @@ -132,3 +162,13 @@ void Particle::setFormFactor(const IFormFactor &form_factor) } } +const IFormFactor *Particle::getFormFactor() const +{ + return mP_form_factor.get(); +} + +void Particle::initialize() +{ + setName(BornAgain::ParticleType); + registerPosition(); +} diff --git a/Core/Samples/src/ParticleComposition.cpp b/Core/Samples/src/ParticleComposition.cpp index 306137d9729..2033fa5fb14 100644 --- a/Core/Samples/src/ParticleComposition.cpp +++ b/Core/Samples/src/ParticleComposition.cpp @@ -14,36 +14,32 @@ // ************************************************************************** // #include "ParticleComposition.h" +#include "BornAgainNamespace.h" #include "FormFactors.h" #include "Materials.h" #include "ParticleDistribution.h" -#include <boost/scoped_ptr.hpp> ParticleComposition::ParticleComposition() { - setName("ParticleComposition"); - registerPosition(); + initialize(); } ParticleComposition::ParticleComposition(const IParticle& particle) { - setName("ParticleComposition"); - registerPosition(); + initialize(); addParticle( particle, kvector_t(0.0, 0.0, 0.0) ); } ParticleComposition::ParticleComposition(const IParticle &particle, kvector_t position) { - setName("ParticleComposition"); - registerPosition(); + initialize(); addParticle(particle, position); } ParticleComposition::ParticleComposition(const IParticle& particle, std::vector<kvector_t> positions) { - setName("ParticleComposition"); - registerPosition(); + initialize(); addParticles(particle, positions); } @@ -75,7 +71,6 @@ ParticleComposition* ParticleComposition::cloneInvertB() const for (size_t index=0; index<m_particles.size(); ++index) { p_new->addParticlePointer(m_particles[index]->cloneInvertB()); } - p_new->setName(getName() + "_inv"); if(getAmbientMaterial()) { p_new->setAmbientMaterial(*Materials::createInvertedMaterial(getAmbientMaterial())); @@ -88,6 +83,11 @@ ParticleComposition* ParticleComposition::cloneInvertB() const return p_new; } +void ParticleComposition::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + void ParticleComposition::addParticle(const IParticle &particle) { checkParticleType(particle); @@ -147,6 +147,28 @@ ParticleComposition::createTransformedFormFactor(complex_t wavevector_scattering return p_result; } +size_t ParticleComposition::getNbrParticles() const +{ + return m_particles.size(); +} + +const IParticle *ParticleComposition::getParticle(size_t index) const +{ + return m_particles[check_index(index)]; +} + +kvector_t ParticleComposition::getParticlePosition(size_t index) const +{ + return m_particles[check_index(index)]->getPosition(); +} + +size_t ParticleComposition::check_index(size_t index) const +{ + return index < m_particles.size() ? index : throw OutOfBoundsException( + "ParticleComposition::check_index()" + "-> Index is out of bounds"); +} + void ParticleComposition::checkParticleType(const IParticle &p_particle) { const ParticleDistribution *p_distr = dynamic_cast<const ParticleDistribution*>(&p_particle); @@ -161,3 +183,9 @@ void ParticleComposition::addParticlePointer(IParticle* p_particle) registerChild(p_particle); m_particles.push_back(p_particle); } + +void ParticleComposition::initialize() +{ + setName(BornAgain::ParticleCompositionType); + registerPosition(); +} diff --git a/Core/Samples/src/ParticleCoreShell.cpp b/Core/Samples/src/ParticleCoreShell.cpp index 21d122e132a..3dc70ac8f0f 100644 --- a/Core/Samples/src/ParticleCoreShell.cpp +++ b/Core/Samples/src/ParticleCoreShell.cpp @@ -14,17 +14,16 @@ // ************************************************************************** // #include "ParticleCoreShell.h" +#include "BornAgainNamespace.h" #include "FormFactors.h" #include "Materials.h" -#include <boost/scoped_ptr.hpp> ParticleCoreShell::ParticleCoreShell(const Particle& shell, const Particle& core, kvector_t relative_core_position) - : mp_shell(0) - , mp_core(0) + : mp_shell { nullptr }, mp_core { nullptr } { - setName("ParticleCoreShell"); + setName(BornAgain::ParticleCoreShellType); registerPosition(); addAndRegisterCore(core, relative_core_position); addAndRegisterShell(shell); @@ -44,7 +43,6 @@ ParticleCoreShell *ParticleCoreShell::clone() const p_new->setRotation(*mP_rotation); } p_new->setPosition(m_position); - p_new->setName(getName()); return p_new; } @@ -58,10 +56,14 @@ ParticleCoreShell* ParticleCoreShell::cloneInvertB() const p_new->setRotation(*mP_rotation); } p_new->setPosition(m_position); - p_new->setName(getName() + "_inv"); return p_new; } +void ParticleCoreShell::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + void ParticleCoreShell::setAmbientMaterial(const IMaterial& material) { mp_shell->setAmbientMaterial(material); @@ -78,7 +80,7 @@ IFormFactor *ParticleCoreShell::createTransformedFormFactor(complex_t wavevector { if (mp_core==0 || mp_shell==0) return 0; FormFactorWeighted *p_result = new FormFactorWeighted(); - boost::scoped_ptr<IRotation> P_total_rotation(createComposedRotation(p_rotation)); + std::unique_ptr<IRotation> P_total_rotation(createComposedRotation(p_rotation)); kvector_t total_position = getComposedTranslation(p_rotation, translation); // shell form factor boost::scoped_ptr<IFormFactor> P_ff_shell( @@ -87,9 +89,9 @@ IFormFactor *ParticleCoreShell::createTransformedFormFactor(complex_t wavevector if (P_ff_shell.get()==0) return 0; p_result->addFormFactor(*P_ff_shell, 1.0); // core form factor - boost::scoped_ptr<Particle> P_core_clone(mp_core->clone()); + std::unique_ptr<Particle> P_core_clone(mp_core->clone()); P_core_clone->setAmbientMaterial(*mp_shell->getMaterial()); - boost::scoped_ptr<IFormFactor> P_ff_core( + std::unique_ptr<IFormFactor> P_ff_core( P_core_clone->createTransformedFormFactor(wavevector_scattering_factor, P_total_rotation.get(), total_position) ); if (P_ff_core.get()==0) return 0; @@ -97,6 +99,16 @@ IFormFactor *ParticleCoreShell::createTransformedFormFactor(complex_t wavevector return p_result; } +const Particle *ParticleCoreShell::getCoreParticle() const +{ + return mp_core; +} + +const Particle *ParticleCoreShell::getShellParticle() const +{ + return mp_shell; +} + void ParticleCoreShell::addAndRegisterCore(const Particle &core, kvector_t relative_core_position) { if(mp_core) { @@ -120,7 +132,7 @@ void ParticleCoreShell::addAndRegisterShell(const Particle &shell) } ParticleCoreShell::ParticleCoreShell() -: mp_shell(0) -, mp_core(0) + : mp_shell { nullptr }, mp_core { nullptr } { + setName(BornAgain::ParticleCoreShellType); } diff --git a/Core/Samples/src/ParticleDistribution.cpp b/Core/Samples/src/ParticleDistribution.cpp index 70b9e38a5ae..2a21285bcaf 100644 --- a/Core/Samples/src/ParticleDistribution.cpp +++ b/Core/Samples/src/ParticleDistribution.cpp @@ -14,15 +14,15 @@ // ************************************************************************** // #include "ParticleDistribution.h" +#include "BornAgainNamespace.h" #include "ParticleInfo.h" -#include <boost/scoped_ptr.hpp> ParticleDistribution::ParticleDistribution(const IParticle &prototype, const ParameterDistribution &par_distr) : m_par_distribution(par_distr) { - setName("ParticleDistribution"); + setName(BornAgain::ParticleDistributionType); mP_particle.reset(prototype.clone()); registerChild(mP_particle.get()); } @@ -40,10 +40,25 @@ ParticleDistribution *ParticleDistribution::cloneInvertB() const "cloneInvertB: should never be called"); } +void ParticleDistribution::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +void ParticleDistribution::setAmbientMaterial(const IMaterial &material) +{ + mP_particle->setAmbientMaterial(material); +} + +const IMaterial *ParticleDistribution::getAmbientMaterial() const +{ + return mP_particle->getAmbientMaterial(); +} + void ParticleDistribution::generateParticleInfos(std::vector<const IParticle*> &particle_vector, - std::vector<double> &abundance_vector, double abundance) const + std::vector<double> &abundance_vector, double abundance) const { - boost::scoped_ptr<ParameterPool> P_pool(createDistributedParameterPool()); + std::unique_ptr<ParameterPool> P_pool(createDistributedParameterPool()); std::string main_par_name = m_par_distribution.getMainParameterName(); std::vector<ParameterPool::parameter_t> main_par_matches = P_pool->getMatchedParameters(main_par_name); @@ -75,7 +90,7 @@ void ParticleDistribution::generateParticleInfos(std::vector<const IParticle*> & ParameterSample main_sample = main_par_samples[i]; double particle_abundance = abundance * main_sample.weight; IParticle *p_particle_clone = mP_particle->clone(); - boost::scoped_ptr<ParameterPool> P_new_pool(p_particle_clone->createParameterTree()); + std::unique_ptr<ParameterPool> P_new_pool(p_particle_clone->createParameterTree()); int changed = P_new_pool->setMatchedParametersValue(main_par_name, main_sample.value); if (changed != 1) { throw Exceptions::RuntimeErrorException( @@ -98,3 +113,18 @@ void ParticleDistribution::generateParticleInfos(std::vector<const IParticle*> & abundance_vector.push_back(particle_abundance); } } + +ParameterDistribution ParticleDistribution::getParameterDistribution() const +{ + return m_par_distribution; +} + +ParameterPool *ParticleDistribution::createDistributedParameterPool() const +{ + return mP_particle->createParameterTree(); +} + +const IParticle *ParticleDistribution::getParticle() const +{ + return mP_particle.get(); +} diff --git a/Core/Samples/src/ParticleInfo.cpp b/Core/Samples/src/ParticleInfo.cpp index 4ea35f58a89..4732606f926 100644 --- a/Core/Samples/src/ParticleInfo.cpp +++ b/Core/Samples/src/ParticleInfo.cpp @@ -14,13 +14,14 @@ // ************************************************************************** // #include "ParticleInfo.h" +#include "BornAgainNamespace.h" ParticleInfo::ParticleInfo(const IAbstractParticle& p_particle, double abundance) : mP_particle(p_particle.clone()) , m_abundance(abundance) { - setName("ParticleInfo"); + setName(BornAgain::ParticleInfoType); registerChild(mP_particle.get()); init_parameters(); } @@ -37,6 +38,31 @@ ParticleInfo *ParticleInfo::cloneInvertB() const return new ParticleInfo(*P_inverted_particle, m_abundance); } +void ParticleInfo::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +const IAbstractParticle *ParticleInfo::getParticle() const +{ + return mP_particle.get(); +} + +double ParticleInfo::getAbundance() const +{ + return m_abundance; +} + +void ParticleInfo::setAbundance(double abundance) +{ + m_abundance = abundance; +} + +void ParticleInfo::setAmbientMaterial(const IMaterial &material) +{ + mP_particle->setAmbientMaterial(material); +} + void ParticleInfo::init_parameters() { clearParameterPool(); diff --git a/Core/Samples/src/ParticleLayout.cpp b/Core/Samples/src/ParticleLayout.cpp index 8904a9a1bd1..0f97ea6f7f3 100644 --- a/Core/Samples/src/ParticleLayout.cpp +++ b/Core/Samples/src/ParticleLayout.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "ParticleLayout.h" +#include "BornAgainNamespace.h" #include "InterferenceFunctionNone.h" #include "DecouplingApproximationStrategy.h" #include "InterferenceFunctionRadialParaCrystal.h" @@ -26,12 +27,12 @@ ParticleLayout::ParticleLayout() { - setName("ParticleLayout"); + setName(BornAgain::ParticleLayoutType); } ParticleLayout::ParticleLayout(const IAbstractParticle& particle, double abundance) { - setName("ParticleLayout"); + setName(BornAgain::ParticleLayoutType); addParticle(particle, abundance); } @@ -75,6 +76,11 @@ ParticleLayout* ParticleLayout::cloneInvertB() const return p_new; } +void ParticleLayout::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + void ParticleLayout::addParticle(const IAbstractParticle& particle, double abundance) { addAndRegisterParticleInfo(new ParticleInfo(particle, abundance)); @@ -103,6 +109,11 @@ void ParticleLayout::addParticle(const IParticle &particle, double abundance, addAndRegisterParticleInfo(new ParticleInfo(*P_particle_clone, abundance)); } +size_t ParticleLayout::getNumberOfParticles() const +{ + return m_particles.size(); +} + //! Returns particle info const IAbstractParticle* ParticleLayout::getParticle(size_t index) const { @@ -145,9 +156,19 @@ double ParticleLayout::getAbundanceOfParticle(size_t index) const return m_particles[index]->getAbundance(); } +size_t ParticleLayout::getNumberOfInterferenceFunctions() const +{ + return m_interference_functions.size(); +} + +SafePointerVector<IInterferenceFunction> ParticleLayout::getInterferenceFunctions() const +{ + return m_interference_functions; +} + //! Adds interference functions void ParticleLayout::addInterferenceFunction( - IInterferenceFunction* p_interference_function) + IInterferenceFunction* p_interference_function) { addAndRegisterInterferenceFunction(p_interference_function); } diff --git a/Core/Samples/src/Rotations.cpp b/Core/Samples/src/Rotations.cpp index 2463b19d7a3..f4e8e3459e7 100644 --- a/Core/Samples/src/Rotations.cpp +++ b/Core/Samples/src/Rotations.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "Rotations.h" +#include "BornAgainNamespace.h" IRotation *IRotation::createRotation(const Geometry::Transform3D &transform) @@ -35,6 +36,16 @@ IRotation *IRotation::createRotation(const Geometry::Transform3D &transform) } } +void IRotation::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + +bool IRotation::isIdentity() const +{ + return getTransform3D().isIdentity(); +} + IRotation *CreateProduct(const IRotation &left, const IRotation &right) { Geometry::Transform3D tr_left = left.getTransform3D(); @@ -48,7 +59,7 @@ IRotation *CreateProduct(const IRotation &left, const IRotation &right) RotationX::RotationX(double angle) : m_angle(angle) { - setName("RotationX"); + setName(BornAgain::XRotationType); init_parameters(); } @@ -67,6 +78,16 @@ RotationX *RotationX::createInverse() const return new RotationX(-m_angle); } +double RotationX::getAngle() const +{ + return m_angle; +} + +void RotationX::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + Geometry::Transform3D RotationX::getTransform3D() const { return Geometry::Transform3D::createRotateX(m_angle); @@ -83,7 +104,7 @@ void RotationX::init_parameters() RotationY::RotationY(double angle) : m_angle(angle) { - setName("RotationY"); + setName(BornAgain::YRotationType); init_parameters(); } @@ -102,6 +123,16 @@ RotationY *RotationY::createInverse() const return new RotationY(-m_angle); } +double RotationY::getAngle() const +{ + return m_angle; +} + +void RotationY::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + Geometry::Transform3D RotationY::getTransform3D() const { return Geometry::Transform3D::createRotateY(m_angle); @@ -118,7 +149,7 @@ void RotationY::init_parameters() RotationZ::RotationZ(double angle) : m_angle(angle) { - setName("RotationZ"); + setName(BornAgain::ZRotationType); init_parameters(); } @@ -137,6 +168,16 @@ RotationZ *RotationZ::createInverse() const return new RotationZ(-m_angle); } +double RotationZ::getAngle() const +{ + return m_angle; +} + +void RotationZ::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + Geometry::Transform3D RotationZ::getTransform3D() const { return Geometry::Transform3D::createRotateZ(m_angle); @@ -155,7 +196,7 @@ RotationEuler::RotationEuler(double alpha, double beta, double gamma) , m_beta(beta) , m_gamma(gamma) { - setName("RotationEuler"); + setName(BornAgain::EulerRotationType); init_parameters(); } @@ -175,6 +216,26 @@ IRotation *RotationEuler::createInverse() const return createRotation(inverse_transform); } +double RotationEuler::getAlpha() const +{ + return m_alpha; +} + +double RotationEuler::getBeta() const +{ + return m_beta; +} + +double RotationEuler::getGamma() const +{ + return m_gamma; +} + +void RotationEuler::accept(ISampleVisitor *visitor) const +{ + visitor->visit(this); +} + Geometry::Transform3D RotationEuler::getTransform3D() const { return Geometry::Transform3D::createRotateEuler(m_alpha, m_beta, m_gamma); diff --git a/Core/StandardSamples/ParticleDistributionsBuilder.cpp b/Core/StandardSamples/ParticleDistributionsBuilder.cpp index c28371dee93..290220cc346 100644 --- a/Core/StandardSamples/ParticleDistributionsBuilder.cpp +++ b/Core/StandardSamples/ParticleDistributionsBuilder.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "ParticleDistributionsBuilder.h" +#include "BornAgainNamespace.h" #include "MultiLayer.h" #include "ParticleLayout.h" #include "Materials.h" @@ -23,6 +24,8 @@ #include "Distributions.h" #include "ParticleDistribution.h" +using namespace BornAgain; + CylindersWithSizeDistributionBuilder::CylindersWithSizeDistributionBuilder() : m_height(5*Units::nanometer) , m_radius(5*Units::nanometer) @@ -58,7 +61,9 @@ ISample *CylindersWithSizeDistributionBuilder::buildSample() const // to get radius_min = average - 2.0*FWHM: double n_sigma = 2.0*2.0*std::sqrt(2.0*std::log(2.0)); DistributionGaussian gauss(m_radius, sigma); - ParameterDistribution par_distr("/Particle/FormFactorCylinder/radius", gauss, n_samples, n_sigma); + ParameterPattern pattern; + pattern.add(ParticleType).add(FFCylinderType).add("radius"); + ParameterDistribution par_distr(pattern.toStdString(), gauss, n_samples, n_sigma); ParticleDistribution particle_collection(nano_particle, par_distr); particle_layout.addParticle(particle_collection); particle_layout.addInterferenceFunction(new InterferenceFunctionNone()); @@ -126,10 +131,14 @@ ISample *TwoTypesCylindersDistributionBuilder::buildSample() const DistributionGaussian gauss2(m_radius2, sigma2); // building distribution of nano particles - ParameterDistribution par_distr1("/Particle/FormFactorCylinder/radius", gauss1, nbins, n_sigma); + ParameterPattern pattern1; + pattern1.add(ParticleType).add(FFCylinderType).add("radius"); + ParameterDistribution par_distr1(pattern1.toStdString(), gauss1, nbins, n_sigma); ParticleDistribution particle_collection1(cylinder1, par_distr1); particle_layout.addParticle(particle_collection1, 0.95); - ParameterDistribution par_distr2("/Particle/FormFactorCylinder/radius", gauss2, nbins, n_sigma); + ParameterPattern pattern2; + pattern2.add(ParticleType).add(FFCylinderType).add("radius"); + ParameterDistribution par_distr2(pattern2.toStdString(), gauss2, nbins, n_sigma); ParticleDistribution particle_collection2(cylinder2, par_distr2); particle_layout.addParticle(particle_collection2, 0.05); diff --git a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp index b47d5507632..99343ff2c0c 100644 --- a/Core/StandardSamples/SizeDistributionModelsBuilder.cpp +++ b/Core/StandardSamples/SizeDistributionModelsBuilder.cpp @@ -14,6 +14,7 @@ // ************************************************************************** // #include "SizeDistributionModelsBuilder.h" +#include "BornAgainNamespace.h" #include "MultiLayer.h" #include "ParticleLayout.h" #include "Materials.h" @@ -23,6 +24,7 @@ #include "Distributions.h" #include "ParticleDistribution.h" +using namespace BornAgain; ISample *SizeDistributionDAModelBuilder::buildSample() const { @@ -183,8 +185,12 @@ ISample *CylindersInSSCABuilder::buildSample() const Particle particle_prototype(particle_material, ff_cylinder); DistributionGaussian gauss(5.0*Units::nanometer, 1.25*Units::nanometer); - ParameterDistribution par_distr("/Particle/FormFactorCylinder/radius", gauss, 30, 3.0); - par_distr.linkParameter("/Particle/FormFactorCylinder/height"); + ParameterPattern pattern_radius; + pattern_radius.add(ParticleType).add(FFCylinderType).add("radius"); + ParameterDistribution par_distr(pattern_radius.toStdString(), gauss, 30, 3.0); + ParameterPattern pattern_height; + pattern_height.add(ParticleType).add(FFCylinderType).add("height"); + par_distr.linkParameter(pattern_height.toStdString()); ParticleDistribution particle_collection(particle_prototype, par_distr); particle_layout.addParticle(particle_collection); diff --git a/Core/StandardSamples/TestComponentsRegistry.cpp b/Core/StandardSamples/TestComponentsRegistry.cpp index ce1f083276d..c3e8222e228 100644 --- a/Core/StandardSamples/TestComponentsRegistry.cpp +++ b/Core/StandardSamples/TestComponentsRegistry.cpp @@ -32,60 +32,60 @@ TestFTDistribution2DRegistry::TestFTDistribution2DRegistry() TestFormFactorsRegistry::TestFormFactorsRegistry() { - add(BornAgain::AnisoPyramidType, + add(BornAgain::FFAnisoPyramidType, new FormFactorAnisoPyramid(10.0, 20.0, 5.0, Units::deg2rad(54.73 ))); - add(BornAgain::BoxType, + add(BornAgain::FFBoxType, new FormFactorBox(10.0, 20.0, 5.0)); - add(BornAgain::ConeType, + add(BornAgain::FFConeType, new FormFactorCone(5.0, 6.0, Units::deg2rad(54.73 ))); - add(BornAgain::Cone6Type, + add(BornAgain::FFCone6Type, new FormFactorCone6(2./sqrt(3.)*5.0, 5.0, Units::deg2rad(54.73))); - add(BornAgain::CuboctahedronType, + add(BornAgain::FFCuboctahedronType, new FormFactorCuboctahedron(10.0, 5.0, 1.0, Units::deg2rad(54.73 ))); - add(BornAgain::CylinderType, + add(BornAgain::FFCylinderType, new FormFactorCylinder(5.0, 10.0)); - add(BornAgain::EllipsoidalCylinderType, + add(BornAgain::FFEllipsoidalCylinderType, new FormFactorEllipsoidalCylinder(5.0, 10.0, 15.0)); - add(BornAgain::FullSphereType, + add(BornAgain::FFFullSphereType, new FormFactorFullSphere(5.0)); - add(BornAgain::FullSpheroidType, + add(BornAgain::FFFullSpheroidType, new FormFactorFullSpheroid(5.0, 10.0)); - add(BornAgain::HemiEllipsoidType, + add(BornAgain::FFHemiEllipsoidType, new FormFactorHemiEllipsoid(5.0, 10.0, 15.0)); - add(BornAgain::Prism3Type, + add(BornAgain::FFPrism3Type, new FormFactorPrism3(10.0, 5.0)); - add(BornAgain::Prism6Type, + add(BornAgain::FFPrism6Type, new FormFactorPrism6(2./sqrt(3.)*5.0, 5.0)); - add(BornAgain::PyramidType, + add(BornAgain::FFPyramidType, new FormFactorPyramid(10.0, 5.0, Units::deg2rad(54.73 ))); - add(BornAgain::Ripple1Type, + add(BornAgain::FFRipple1Type, new FormFactorRipple1(100.0, 20.0, 4.0)); - add(BornAgain::Ripple2Type, + add(BornAgain::FFRipple2Type, new FormFactorRipple2(100.0, 20.0, 4.0, 0.0)); - add(BornAgain::TetrahedronType, + add(BornAgain::FFTetrahedronType, new FormFactorTetrahedron(10.0, 4.0, Units::deg2rad(54.73 ))); - add(BornAgain::TruncatedCubeType, + add(BornAgain::FFTruncatedCubeType, new FormFactorTruncatedCube(15.0, 6.0)); - add(BornAgain::TruncatedSphereType, + add(BornAgain::FFTruncatedSphereType, new FormFactorTruncatedSphere(5.0, 7.0)); - add(BornAgain::TruncatedSpheroidType, + add(BornAgain::FFTruncatedSpheroidType, new FormFactorTruncatedSpheroid(5.0, 7.0, 1.0)); } diff --git a/Core/Tools/inc/BornAgainNamespace.h b/Core/Tools/inc/BornAgainNamespace.h index ed7f1bf4e4b..50724dd6b82 100644 --- a/Core/Tools/inc/BornAgainNamespace.h +++ b/Core/Tools/inc/BornAgainNamespace.h @@ -20,40 +20,112 @@ namespace BornAgain { - static const std::string PHI_AXIS_NAME = "phi_f"; - static const std::string ALPHA_AXIS_NAME = "alpha_f"; - static const std::string U_AXIS_NAME = "u"; - static const std::string V_AXIS_NAME = "v"; - static const size_t PHI_AXIS_INDEX = 0; - static const size_t ALPHA_AXIS_INDEX = 1; - static const size_t X_AXIS_INDEX = 0; - static const size_t Y_AXIS_INDEX = 1; + const std::string PHI_AXIS_NAME = "phi_f"; + const std::string ALPHA_AXIS_NAME = "alpha_f"; + const std::string U_AXIS_NAME = "u"; + const std::string V_AXIS_NAME = "v"; + const size_t PHI_AXIS_INDEX = 0; + const size_t ALPHA_AXIS_INDEX = 1; + const size_t X_AXIS_INDEX = 0; + const size_t Y_AXIS_INDEX = 1; + + const std::string GISASSimulationType = "GISASSimulation"; + const std::string OffSpecSimulationType = "OffSpecSimulation"; + + const std::string InstrumentType = "Instrument"; + const std::string DetectorType = "Detector"; + const std::string SphericalDetectorType = "SphericalDetector"; + const std::string RectangularDetectorType = "RectangularDetector"; + const std::string IsGISAXSDetectorType = "IsGISAXSDetector"; + const std::string BeamType = "Beam"; + + const std::string MultiLayerType = "MultiLayer"; + const std::string LayerType = "Layer"; + const std::string LayerInterfaceType = "LayerInterface"; + const std::string ParticleLayoutType = "ParticleLayout"; + const std::string ParticleType = "Particle"; + const std::string ParticleInfoType = "ParticleInfo"; + const std::string ParticleCoreShellType = "ParticleCoreShell"; + const std::string ParticleDistributionType = "ParticleDistribution"; + const std::string ParticleCompositionType = "ParticleComposition"; + const std::string TransformationType = "Rotation"; + + const std::string LayerBasicRoughnessType = "LayerBasicRoughness"; + const std::string LayerZeroRoughnessType = "LayerZeroRoughness"; + + const std::string InterferenceFunctionNoneType = "InterferenceFunctionNone"; + const std::string InterferenceFunction1DLatticeType = "InterferenceFunction1DLattice"; + const std::string InterferenceFunctionRadialParaCrystalType = + "InterferenceFunctionRadialParaCrystal"; + const std::string InterferenceFunction2DParaCrystalType = "InterferenceFunction2DParaCrystal"; + const std::string InterferenceFunction2DLatticeType = "InterferenceFunction2DLattice"; + + const std::string CrystalType = "Crystal"; + const std::string MesoCrystalType = "MesoCrystal"; + + const std::string FFAnisoPyramidType = "AnisoPyramid"; + const std::string FFBoxType = "Box"; + const std::string FFConeType = "Cone"; + const std::string FFCone6Type = "Cone6"; + const std::string FFCuboctahedronType = "Cuboctahedron"; + const std::string FFCylinderType = "Cylinder"; + const std::string FFEllipsoidalCylinderType = "EllipsoidalCylinder"; + const std::string FFFullSphereType = "FullSphere"; + const std::string FFFullSpheroidType = "FullSpheroid"; + const std::string FFGaussType = "FormFactorGauss"; + const std::string FFHemiEllipsoidType = "HemiEllipsoid"; + const std::string FFLorentzType = "FormFactorLorentz"; + const std::string FFPrism3Type = "Prism3"; + const std::string FFPrism6Type = "Prism6"; + const std::string FFPyramidType = "Pyramid"; + const std::string FFRipple1Type = "Ripple1"; + const std::string FFRipple2Type = "Ripple2"; + const std::string FFTetrahedronType = "Tetrahedron"; + const std::string FFTruncatedCubeType = "TruncatedCube"; + const std::string FFTruncatedSphereType = "TruncatedSphere"; + const std::string FFTruncatedSpheroidType = "TruncatedSpheroid"; + + const std::string FormFactorCrystalType = "FormFactorCrystal"; + const std::string FormFactorSphereGaussianRadiusType = "FormFactorSphereGaussianRadius"; + const std::string FormFactorSphereLogNormalRadiusType = "FormFactorSphereLogNormalRadius"; + const std::string FormFactorSphereUniformRadiusType = "FormFactorSphereUniformRadius"; + const std::string FormFactorTrivialType = "FormFactorTrivial"; + const std::string FormFactorDWBAType = "FormFactorDWBA"; + const std::string FormFactorPolarizedDWBAType = "FormFactorDWBAPol"; + + const std::string FormFactorDecoratorFactor = "FormFactorDecoratorFactor"; + const std::string FormFactorDecoratorPositionFactor = "FormFactorDecoratorPositionFactor"; + const std::string FormFactorDecoratorMultiPositionFactor = + "FormFactorDecoratorMultiPositionFactor"; + const std::string FormFactorDecoratorRotation = "FormFactorDecoratorRotation"; + const std::string FormFactorDecoratorDebyeWaller = "FormFactorDecoratorDebyeWaller"; + const std::string FormFactorDecoratorMaterial = "FormFactorDecoratorMaterial"; + const std::string FormFactorWeighted = "FormFactorWeighted"; + + const std::string XRotationType = "XRotation"; + const std::string YRotationType = "YRotation"; + const std::string ZRotationType = "ZRotation"; + const std::string EulerRotationType = "EulerRotation"; + + const std::string DistributionNoneType = "DistributionNone"; + const std::string DistributionGateType = "DistributionGate"; + const std::string DistributionLorentzType = "DistributionLorentz"; + const std::string DistributionGaussianType = "DistributionGaussian"; + const std::string DistributionLogNormalType = "DistributionLogNormal"; + const std::string DistributionCosineType = "DistributionCosine"; + + const std::string FTDistribution1DCauchyType = "FTDistribution1DCauchy"; + const std::string FTDistribution1DGaussType = "FTDistribution1DGauss"; + const std::string FTDistribution1DGateType = "FTDistribution1DGate"; + const std::string FTDistribution1DTriangleType = "FTDistribution1DTriangle"; + const std::string FTDistribution1DCosineType = "FTDistribution1DCosine"; + const std::string FTDistribution1DVoigtType = "FTDistribution1DVoigt"; const std::string FTDistribution2DCauchyType = "FTDistribution2DCauchy"; const std::string FTDistribution2DGaussType = "FTDistribution2DGauss"; const std::string FTDistribution2DGateType = "FTDistribution2DGate"; const std::string FTDistribution2DConeType = "FTDistribution2DCone"; const std::string FTDistribution2DVoigtType = "FTDistribution2DVoigt"; - - const std::string AnisoPyramidType = "AnisoPyramid"; - const std::string BoxType = "Box"; - const std::string ConeType = "Cone"; - const std::string Cone6Type = "Cone6"; - const std::string CuboctahedronType = "Cuboctahedron"; - const std::string CylinderType = "Cylinder"; - const std::string EllipsoidalCylinderType = "EllipsoidalCylinder"; - const std::string FullSphereType = "FullSphere"; - const std::string FullSpheroidType = "FullSpheroid"; - const std::string HemiEllipsoidType = "HemiEllipsoid"; - const std::string Prism3Type = "Prism3"; - const std::string Prism6Type = "Prism6"; - const std::string PyramidType = "Pyramid"; - const std::string Ripple1Type = "Ripple1"; - const std::string Ripple2Type = "Ripple2"; - const std::string TetrahedronType = "Tetrahedron"; - const std::string TruncatedCubeType = "TruncatedCube"; - const std::string TruncatedSphereType = "TruncatedSphere"; - const std::string TruncatedSpheroidType = "TruncatedSpheroid"; } #endif // BORNAGAINNAMESPACE_H diff --git a/Core/Tools/inc/IParameterized.h b/Core/Tools/inc/IParameterized.h index 5afdaef3a77..b2977f785df 100644 --- a/Core/Tools/inc/IParameterized.h +++ b/Core/Tools/inc/IParameterized.h @@ -80,6 +80,24 @@ protected: IChangeable m_status; }; +//! @class ParameterPattern +//! @ingroup tools_internal +//! @brief Helper class for constructing parameter patterns. + +class BA_CORE_API_ ParameterPattern +{ +public: + ParameterPattern(); + ParameterPattern(std::string root_object); + + ParameterPattern& add(std::string object_type); + + std::string toStdString() const; +private: + std::string m_pattern; +}; + + #endif /* IPARAMETERIZED_H_ */ diff --git a/Core/Tools/src/BornAgainNamespace.cpp b/Core/Tools/src/BornAgainNamespace.cpp new file mode 100644 index 00000000000..f1700f93164 --- /dev/null +++ b/Core/Tools/src/BornAgainNamespace.cpp @@ -0,0 +1,133 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file Tools/inc/BornAgainNamespace.h +//! @brief Defines BornAgain namespace +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2015 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#ifndef BORNAGAINNAMESPACE_H +#define BORNAGAINNAMESPACE_H + +#include<string> + +namespace BornAgain +{ + const std::string PHI_AXIS_NAME = "phi_f"; + const std::string ALPHA_AXIS_NAME = "alpha_f"; + const std::string U_AXIS_NAME = "u"; + const std::string V_AXIS_NAME = "v"; + const size_t PHI_AXIS_INDEX = 0; + const size_t ALPHA_AXIS_INDEX = 1; + const size_t X_AXIS_INDEX = 0; + const size_t Y_AXIS_INDEX = 1; + + const std::string GISASSimulationType = "GISASSimulation"; + const std::string OffSpecSimulationType = "OffSpecSimulation"; + + const std::string InstrumentType = "Instrument"; + const std::string DetectorType = "Detector"; + const std::string SphericalDetectorType = "SphericalDetector"; + const std::string RectangularDetectorType = "RectangularDetector"; + const std::string IsGISAXSDetectorType = "IsGISAXSDetector"; + const std::string BeamType = "Beam"; + + const std::string MultiLayerType = "MultiLayer"; + const std::string LayerType = "Layer"; + const std::string LayerInterfaceType = "LayerInterface"; + const std::string ParticleLayoutType = "ParticleLayout"; + const std::string ParticleType = "Particle"; + const std::string ParticleInfoType = "ParticleInfo"; + const std::string ParticleCoreShellType = "ParticleCoreShell"; + const std::string ParticleDistributionType = "ParticleDistribution"; + const std::string ParticleCompositionType = "ParticleComposition"; + const std::string TransformationType = "Rotation"; + + const std::string LayerBasicRoughnessType = "LayerBasicRoughness"; + const std::string LayerZeroRoughnessType = "LayerZeroRoughness"; + + const std::string InterferenceFunctionNoneType = "InterferenceFunctionNone"; + const std::string InterferenceFunction1DLatticeType = "InterferenceFunction1DLattice"; + const std::string InterferenceFunctionRadialParaCrystalType = + "InterferenceFunctionRadialParaCrystal"; + const std::string InterferenceFunction2DParaCrystalType = "InterferenceFunction2DParaCrystal"; + const std::string InterferenceFunction2DLatticeType = "InterferenceFunction2DLattice"; + + const std::string CrystalType = "Crystal"; + const std::string MesoCrystalType = "MesoCrystal"; + + const std::string AnisoPyramidType = "AnisoPyramid"; + const std::string BoxType = "Box"; + const std::string ConeType = "Cone"; + const std::string Cone6Type = "Cone6"; + const std::string CuboctahedronType = "Cuboctahedron"; + const std::string CylinderType = "Cylinder"; + const std::string EllipsoidalCylinderType = "EllipsoidalCylinder"; + const std::string FullSphereType = "FullSphere"; + const std::string FullSpheroidType = "FullSpheroid"; + const std::string FFGaussType = "FormFactorGauss"; + const std::string HemiEllipsoidType = "HemiEllipsoid"; + const std::string FFLorentzType = "FormFactorLorentz"; + const std::string Prism3Type = "Prism3"; + const std::string Prism6Type = "Prism6"; + const std::string PyramidType = "Pyramid"; + const std::string Ripple1Type = "Ripple1"; + const std::string Ripple2Type = "Ripple2"; + const std::string TetrahedronType = "Tetrahedron"; + const std::string TruncatedCubeType = "TruncatedCube"; + const std::string TruncatedSphereType = "TruncatedSphere"; + const std::string TruncatedSpheroidType = "TruncatedSpheroid"; + + const std::string FormFactorCrystalType = "FormFactorCrystal"; + const std::string FormFactorSphereGaussianRadiusType = "FormFactorSphereGaussianRadius"; + const std::string FormFactorSphereLogNormalRadiusType = "FormFactorSphereLogNormalRadius"; + const std::string FormFactorSphereUniformRadiusType = "FormFactorSphereUniformRadius"; + const std::string FormFactorTrivialType = "FormFactorTrivial"; + const std::string FormFactorDWBAType = "FormFactorDWBA"; + const std::string FormFactorPolarizedDWBAType = "FormFactorDWBAPol"; + + const std::string FormFactorDecoratorFactor = "FormFactorDecoratorFactor"; + const std::string FormFactorDecoratorPositionFactor = "FormFactorDecoratorPositionFactor"; + const std::string FormFactorDecoratorMultiPositionFactor = + "FormFactorDecoratorMultiPositionFactor"; + const std::string FormFactorDecoratorRotation = "FormFactorDecoratorRotation"; + const std::string FormFactorDecoratorDebyeWaller = "FormFactorDecoratorDebyeWaller"; + const std::string FormFactorDecoratorMaterial = "FormFactorDecoratorMaterial"; + const std::string FormFactorWeighted = "FormFactorWeighted"; + + const std::string XRotationType = "XRotation"; + const std::string YRotationType = "YRotation"; + const std::string ZRotationType = "ZRotation"; + const std::string EulerRotationType = "EulerRotation"; + + const std::string DistributionNoneType = "DistributionNone"; + const std::string DistributionGateType = "DistributionGate"; + const std::string DistributionLorentzType = "DistributionLorentz"; + const std::string DistributionGaussianType = "DistributionGaussian"; + const std::string DistributionLogNormalType = "DistributionLogNormal"; + const std::string DistributionCosineType = "DistributionCosine"; + + const std::string FTDistribution1DCauchyType = "FTDistribution1DCauchy"; + const std::string FTDistribution1DGaussType = "FTDistribution1DGauss"; + const std::string FTDistribution1DGateType = "FTDistribution1DGate"; + const std::string FTDistribution1DTriangleType = "FTDistribution1DTriangle"; + const std::string FTDistribution1DCosineType = "FTDistribution1DCosine"; + const std::string FTDistribution1DVoigtType = "FTDistribution1DVoigt"; + + const std::string FTDistribution2DCauchyType = "FTDistribution2DCauchy"; + const std::string FTDistribution2DGaussType = "FTDistribution2DGauss"; + const std::string FTDistribution2DGateType = "FTDistribution2DGate"; + const std::string FTDistribution2DConeType = "FTDistribution2DCone"; + const std::string FTDistribution2DVoigtType = "FTDistribution2DVoigt"; +} + +#endif // BORNAGAINNAMESPACE_H + + diff --git a/Core/Tools/src/IParameterized.cpp b/Core/Tools/src/IParameterized.cpp index 580d283eec4..9f1fc049773 100644 --- a/Core/Tools/src/IParameterized.cpp +++ b/Core/Tools/src/IParameterized.cpp @@ -84,3 +84,24 @@ void IParameterized::print(std::ostream& ostr) const { ostr << "IParameterized:" << getName() << " " << m_parameters; } + +ParameterPattern::ParameterPattern() + : m_pattern { } +{ +} + +ParameterPattern::ParameterPattern(std::string root_object) + : m_pattern { "/" + root_object } +{ +} + +ParameterPattern &ParameterPattern::add(std::string object_type) +{ + m_pattern = m_pattern + "/" + object_type; + return *this; +} + +std::string ParameterPattern::toStdString() const +{ + return m_pattern; +} diff --git a/Core/Tools/src/ParameterPool.cpp b/Core/Tools/src/ParameterPool.cpp index 34d5fe49002..d675fe12b9b 100644 --- a/Core/Tools/src/ParameterPool.cpp +++ b/Core/Tools/src/ParameterPool.cpp @@ -94,8 +94,7 @@ std::vector<ParameterPool::parameter_t> ParameterPool::getMatchedParameters( // loop over all parameters in the pool for(parametermap_t::const_iterator it=m_map.begin(); it!= m_map.end(); ++it) { // (*it).first - parameter key, (*it).second - parameter itself - // parameters whose key match pattern is added to the FitMultiParameter - // container + // parameters whose key match pattern are added to selected_parameters if( Utils::String::MatchPattern( (*it).first, wildcards ) ) { selected_parameters.push_back((*it).second); } diff --git a/GUI/coregui/Models/DetectorItems.cpp b/GUI/coregui/Models/DetectorItems.cpp index bf3236a81be..f995b672265 100644 --- a/GUI/coregui/Models/DetectorItems.cpp +++ b/GUI/coregui/Models/DetectorItems.cpp @@ -35,9 +35,9 @@ const QString PhiAlphaDetectorItem::P_ALPHA_AXIS = "Alpha axis"; const QString PhiAlphaDetectorItem::P_RESOLUTION_FUNCTION = "Type"; PhiAlphaDetectorItem::PhiAlphaDetectorItem(ParameterizedItem *parent) - : ParameterizedItem(Constants::PhiAlphaDetectorType, parent) + : ParameterizedItem(Constants::SphericalDetectorType, parent) { - setItemName(Constants::PhiAlphaDetectorType); + setItemName(Constants::SphericalDetectorType); registerGroupProperty(P_PHI_AXIS, Constants::BasicAxisType); getSubItems()[P_PHI_AXIS]->setPropertyAppearance(BasicAxisItem::P_TITLE, PropertyAttribute::HIDDEN); diff --git a/GUI/coregui/Models/GroupPropertyRegistry.cpp b/GUI/coregui/Models/GroupPropertyRegistry.cpp index 8f421a496dd..0cc0abce484 100644 --- a/GUI/coregui/Models/GroupPropertyRegistry.cpp +++ b/GUI/coregui/Models/GroupPropertyRegistry.cpp @@ -62,7 +62,7 @@ GroupPropertyRegistry::SelectableGroupMap_t initializeSelectableGroupMap() result[Constants::LayerRoughnessGroup] = roughnesses; std::map<QString, QString> detectors; - detectors[Constants::PhiAlphaDetectorType] = "[Phi, Alpha] plane"; + detectors[Constants::SphericalDetectorType] = "[Phi, Alpha] plane"; result[Constants::DetectorGroup] = detectors; std::map<QString, QString> distributions; diff --git a/GUI/coregui/Models/ItemFactory.cpp b/GUI/coregui/Models/ItemFactory.cpp index 3ec97d55134..b96f4e6aeb1 100644 --- a/GUI/coregui/Models/ItemFactory.cpp +++ b/GUI/coregui/Models/ItemFactory.cpp @@ -102,7 +102,7 @@ ItemFactory::ItemMap_t initializeItemMap() { result[Constants::LayerZeroRoughnessType] = &createInstance<LayerZeroRoughnessItem>; result[Constants::DetectorType] = &createInstance<DetectorItem>; - result[Constants::PhiAlphaDetectorType] = &createInstance<PhiAlphaDetectorItem>; + result[Constants::SphericalDetectorType] = &createInstance<PhiAlphaDetectorItem>; result[Constants::DistributionNoneType] = &createInstance<DistributionNoneItem>; result[Constants::DistributionGateType] = &createInstance<DistributionGateItem>; diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp index cf7f76162ea..c368b380c33 100644 --- a/GUI/coregui/Models/TransformToDomain.cpp +++ b/GUI/coregui/Models/TransformToDomain.cpp @@ -315,7 +315,7 @@ void TransformToDomain::initInstrumentFromDetectorItem(const ParameterizedItem & auto subDetector = item.getSubItems()[DetectorItem::P_DETECTOR]; Q_ASSERT(subDetector); - if (subDetector->modelType() == Constants::PhiAlphaDetectorType) { + if (subDetector->modelType() == Constants::SphericalDetectorType) { auto x_axis = dynamic_cast<BasicAxisItem *>( subDetector->getSubItems()[PhiAlphaDetectorItem::P_PHI_AXIS]); Q_ASSERT(x_axis); diff --git a/GUI/coregui/Models/item_constants.h b/GUI/coregui/Models/item_constants.h index b63bbff113c..ee0b0c986b9 100644 --- a/GUI/coregui/Models/item_constants.h +++ b/GUI/coregui/Models/item_constants.h @@ -70,7 +70,7 @@ const ModelType VectorType = "Vector"; const ModelType LayerBasicRoughnessType = "LayerBasicRoughness"; const ModelType LayerZeroRoughnessType = "LayerZeroRoughness"; -const ModelType PhiAlphaDetectorType = "PhiAlphaDetector"; +const ModelType SphericalDetectorType = "SphericalDetector"; const ModelType DistributionNoneType = "DistributionNone"; const ModelType DistributionGateType = "DistributionGate"; diff --git a/Tests/UnitTests/TestCore/FTDistributionsTest.h b/Tests/UnitTests/TestCore/FTDistributionsTest.h index 16ec4f58601..feec56c0676 100644 --- a/Tests/UnitTests/TestCore/FTDistributionsTest.h +++ b/Tests/UnitTests/TestCore/FTDistributionsTest.h @@ -2,6 +2,7 @@ #define FTDISTRIBUTIONSTEST_H #include "FTDistributions.h" +#include "BornAgainNamespace.h" class FTDistributionsTest : public ::testing::Test { @@ -16,7 +17,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DCauchyConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DCauchy(1.0); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionCauchy", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DCauchyType, iftd1D->getName()); EXPECT_NEAR(0.961538, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -34,7 +35,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DCauchyClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionCauchy", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DCauchyType, iftd1DClone->getName()); EXPECT_NEAR(0.5, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -45,7 +46,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DGaussConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DGauss(1.0); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionGauss", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DGaussType, iftd1D->getName()); EXPECT_NEAR(0.9801987, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -60,7 +61,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DGaussClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionGauss", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DGaussType, iftd1DClone->getName()); EXPECT_NEAR(0.6065307, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -71,7 +72,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DGateConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DGate(1.0); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionGate", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DGateType, iftd1D->getName()); EXPECT_NEAR(0.993347, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -86,7 +87,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DGateClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionGate", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DGateType, iftd1DClone->getName()); EXPECT_NEAR(0.841471, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -97,7 +98,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DTriangleConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DTriangle(1.0); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionTriangle", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DTriangleType, iftd1D->getName()); EXPECT_NEAR(0.996671, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -112,7 +113,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DTriangleClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionTriangle", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DTriangleType, iftd1DClone->getName()); EXPECT_NEAR(0.919395, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -123,7 +124,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DCosineConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DCosine(1.0); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionCosine", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DCosineType, iftd1D->getName()); EXPECT_NEAR(0.997389, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -138,7 +139,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DCosineClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionCosine", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DCosineType, iftd1DClone->getName()); EXPECT_NEAR(0.936342, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -149,7 +150,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DVoigtConstructor) { IFTDistribution1D * iftd1D = new FTDistribution1DVoigt(1.0,1.7); EXPECT_EQ(1.0, iftd1D->getOmega()); - EXPECT_EQ("1DDistributionVoigt", iftd1D->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DVoigtType, iftd1D->getName()); EXPECT_NEAR(0.993261, iftd1D->evaluate(0.2),0.000001); iftd1D->setOmega(3.0); @@ -164,7 +165,7 @@ TEST_F(FTDistributionsTest, FTDistribution1DVoigtClone) IFTDistribution1D * iftd1DClone = iftd1D->clone(); EXPECT_EQ(-5.0, iftd1DClone->getOmega()); - EXPECT_EQ("1DDistributionVoigt", iftd1DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution1DVoigtType, iftd1DClone->getName()); EXPECT_NEAR(-0.096572, iftd1DClone->evaluate(0.2),0.000001); delete iftd1D; @@ -181,7 +182,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DCauchyConstructor) EXPECT_EQ(-2.0, iftd2D->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2D->getDelta()); EXPECT_EQ(0.0, iftd2D->getGamma()); - EXPECT_EQ("2DDistributionCauchy", iftd2D->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DCauchyType, iftd2D->getName()); EXPECT_NEAR(0.343206, iftd2D->evaluate(0.2, 0.5),0.000001); iftd2D->setGamma(3.0); @@ -204,7 +205,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DCauchyClone) EXPECT_EQ(2.3, iftd2DClone->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2DClone->getDelta()); EXPECT_EQ(0.0, iftd2DClone->getGamma()); - EXPECT_EQ("2DDistributionCauchy", iftd2DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DCauchyType, iftd2DClone->getName()); EXPECT_NEAR(0.165121078, iftd2DClone->evaluate(0.2, 0.5),0.000001); delete iftd2D; @@ -220,7 +221,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGaussConstructor) EXPECT_EQ(-2.0, iftd2D->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2D->getDelta()); EXPECT_EQ(0.0, iftd2D->getGamma()); - EXPECT_EQ("2DDistributionGauss", iftd2D->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DGaussType, iftd2D->getName()); EXPECT_NEAR(0.5945205, iftd2D->evaluate(0.2, 0.5),0.000001); iftd2D->setGamma(3.0); @@ -238,7 +239,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGaussClone) EXPECT_EQ(2.3, iftd2DClone->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2DClone->getDelta()); EXPECT_EQ(0.0, iftd2DClone->getGamma()); - EXPECT_EQ("2DDistributionGauss", iftd2DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DGaussType, iftd2DClone->getName()); EXPECT_NEAR(0.3130945, iftd2DClone->evaluate(0.2, 0.5),0.000001); delete iftd2D; @@ -252,7 +253,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGateConstructor) EXPECT_EQ(-2.0, iftd2D->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2D->getDelta()); EXPECT_EQ(0.0, iftd2D->getGamma()); - EXPECT_EQ("2DDistributionGate", iftd2D->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DGateType, iftd2D->getName()); EXPECT_NEAR(0.875513, iftd2D->evaluate(0.2, 0.5),0.000001); iftd2D->setGamma(3.0); @@ -270,7 +271,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DGateClone) EXPECT_EQ(2.3, iftd2DClone->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2DClone->getDelta()); EXPECT_EQ(0.0, iftd2DClone->getGamma()); - EXPECT_EQ("2DDistributionGate", iftd2DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DGateType, iftd2DClone->getName()); EXPECT_NEAR(0.736461, iftd2DClone->evaluate(0.2, 0.5),0.000001); delete iftd2D; @@ -284,7 +285,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DConeConstructor) EXPECT_EQ(-2.0, iftd2D->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2D->getDelta()); EXPECT_EQ(0.0, iftd2D->getGamma()); - EXPECT_EQ("2DDistributionCone", iftd2D->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DConeType, iftd2D->getName()); EXPECT_NEAR(0.924374, iftd2D->evaluate(0.2, 0.5),0.000001); iftd2D->setGamma(3.0); @@ -302,7 +303,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DConeClone) EXPECT_EQ(2.3, iftd2DClone->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2DClone->getDelta()); EXPECT_EQ(0.0, iftd2DClone->getGamma()); - EXPECT_EQ("2DDistributionCone", iftd2DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DConeType, iftd2DClone->getName()); EXPECT_NEAR(0.837410, iftd2DClone->evaluate(0.2, 0.5),0.000001); delete iftd2D; @@ -316,7 +317,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DVoigtConstructor) EXPECT_EQ(-2.0, iftd2D->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2D->getDelta()); EXPECT_EQ(0.0, iftd2D->getGamma()); - EXPECT_EQ("2DDistributionVoigt", iftd2D->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DVoigtType, iftd2D->getName()); EXPECT_NEAR(1.2228072, iftd2D->evaluate(0.2, 0.5),0.000001); iftd2D->setGamma(3.0); @@ -334,7 +335,7 @@ TEST_F(FTDistributionsTest, FTDistribution2DVoigtClone) EXPECT_EQ(2.3, iftd2DClone->getCoherenceLengthY()); EXPECT_EQ(Units::PI/2.0, iftd2DClone->getDelta()); EXPECT_EQ(0.0, iftd2DClone->getGamma()); - EXPECT_EQ("2DDistributionVoigt", iftd2DClone->getName()); + EXPECT_EQ(BornAgain::FTDistribution2DVoigtType, iftd2DClone->getName()); EXPECT_NEAR(-0.6635305, iftd2DClone->evaluate(0.2, 0.5),0.000001); delete iftd2D; diff --git a/Tests/UnitTests/TestCore/FormFactorTest.h b/Tests/UnitTests/TestCore/FormFactorTest.h index d8d69b91787..0bd25b4282a 100644 --- a/Tests/UnitTests/TestCore/FormFactorTest.h +++ b/Tests/UnitTests/TestCore/FormFactorTest.h @@ -17,14 +17,14 @@ #define FORMFACTORTEST_H #include "Units.h" +#include "BornAgainNamespace.h" #include "FormFactors.h" #include "gtest/gtest.h" class FormFactorTest : public ::testing::Test { - protected: +protected: FormFactorTest(){} - virtual ~FormFactorTest(){} }; @@ -42,7 +42,7 @@ TEST_F(FormFactorTest, AnisoPyramid) FormFactorAnisoPyramid anisopyramid(length, width, height, alpha); - EXPECT_EQ("FormFactorAnisoPyramid",anisopyramid.getName()); + EXPECT_EQ(BornAgain::FFAnisoPyramidType, anisopyramid.getName()); EXPECT_DOUBLE_EQ(volume, anisopyramid.getVolume()); EXPECT_EQ(12., anisopyramid.getLength()); EXPECT_EQ(14., anisopyramid.getWidth()); @@ -50,7 +50,7 @@ TEST_F(FormFactorTest, AnisoPyramid) EXPECT_EQ(0.8, anisopyramid.getAlpha()); FormFactorAnisoPyramid *anisopyramidclone = anisopyramid.clone(); - EXPECT_EQ("FormFactorAnisoPyramid",anisopyramidclone->getName()); + EXPECT_EQ(BornAgain::FFAnisoPyramidType, anisopyramidclone->getName()); EXPECT_DOUBLE_EQ(volume, anisopyramidclone->getVolume()); EXPECT_EQ(12., anisopyramidclone->getLength()); EXPECT_EQ(14., anisopyramidclone->getWidth()); @@ -69,14 +69,14 @@ TEST_F(FormFactorTest, HemiEllipsoid) FormFactorHemiEllipsoid hemiellipsoid(radius_a, radius_b, height); - EXPECT_EQ("FormFactorHemiEllipsoid",hemiellipsoid.getName()); + EXPECT_EQ(BornAgain::FFHemiEllipsoidType, hemiellipsoid.getName()); EXPECT_EQ(6., hemiellipsoid.getRadiusA()); EXPECT_EQ(7., hemiellipsoid.getRadiusB()); EXPECT_EQ(5., hemiellipsoid.getHeight()); EXPECT_DOUBLE_EQ(volume, hemiellipsoid.getVolume()); FormFactorHemiEllipsoid *hemiellipsoidclone = hemiellipsoid.clone(); - EXPECT_EQ("FormFactorHemiEllipsoid",hemiellipsoidclone->getName()); + EXPECT_EQ(BornAgain::FFHemiEllipsoidType, hemiellipsoidclone->getName()); EXPECT_EQ(6., hemiellipsoidclone->getRadiusA()); EXPECT_EQ(7., hemiellipsoidclone->getRadiusB()); EXPECT_EQ(5., hemiellipsoidclone->getHeight()); @@ -93,14 +93,14 @@ TEST_F(FormFactorTest, Box) FormFactorBox box(length, width, height); - EXPECT_EQ("FormFactorBox",box.getName()); + EXPECT_EQ(BornAgain::FFBoxType, box.getName()); EXPECT_EQ(7., box.getWidth()); EXPECT_EQ(5., box.getHeight()); EXPECT_EQ(3., box.getRadius()); EXPECT_DOUBLE_EQ(volume, box.getVolume()); FormFactorBox *boxclone = box.clone(); - EXPECT_EQ("FormFactorBox",boxclone->getName()); + EXPECT_EQ(BornAgain::FFBoxType, boxclone->getName()); EXPECT_EQ(7., boxclone->getWidth()); EXPECT_EQ(5., boxclone->getHeight()); EXPECT_EQ(3., boxclone->getRadius()); @@ -120,14 +120,14 @@ TEST_F(FormFactorTest, Cone) FormFactorCone cone(radius, height, alpha); - EXPECT_EQ("FormFactorCone",cone.getName()); + EXPECT_EQ(BornAgain::FFConeType, cone.getName()); EXPECT_EQ(6., cone.getRadius()); EXPECT_EQ(5., cone.getHeight()); EXPECT_EQ(0.8, cone.getAlpha()); EXPECT_DOUBLE_EQ(volume, cone.getVolume()); FormFactorCone *coneclone = cone.clone(); - EXPECT_EQ("FormFactorCone",coneclone->getName()); + EXPECT_EQ(BornAgain::FFConeType, coneclone->getName()); EXPECT_EQ(6., coneclone->getRadius()); EXPECT_EQ(5., coneclone->getHeight()); EXPECT_EQ(0.8, coneclone->getAlpha()); @@ -147,14 +147,14 @@ TEST_F(FormFactorTest, Cone6) FormFactorCone6 cone6(radius, height, alpha); - EXPECT_EQ("FormFactorCone6",cone6.getName()); + EXPECT_EQ(BornAgain::FFCone6Type, cone6.getName()); EXPECT_EQ(6., cone6.getRadius()); EXPECT_EQ(5., cone6.getHeight()); EXPECT_EQ(0.8, cone6.getAlpha()); EXPECT_DOUBLE_EQ(volume, cone6.getVolume()); FormFactorCone6 *cone6clone = cone6.clone(); - EXPECT_EQ("FormFactorCone6",cone6clone->getName()); + EXPECT_EQ(BornAgain::FFCone6Type, cone6clone->getName()); EXPECT_EQ(6., cone6clone->getRadius()); EXPECT_EQ(5., cone6clone->getHeight()); EXPECT_EQ(0.8, cone6clone->getAlpha()); @@ -179,7 +179,7 @@ TEST_F(FormFactorTest, Cuboctahedron) FormFactorCuboctahedron cuboctahedron(length, height, height_ratio, alpha); - EXPECT_EQ("FormFactorCuboctahedron",cuboctahedron.getName()); + EXPECT_EQ(BornAgain::FFCuboctahedronType, cuboctahedron.getName()); EXPECT_EQ(4., cuboctahedron.getHeight()); EXPECT_EQ(10., cuboctahedron.getLength()); EXPECT_EQ(1., cuboctahedron.getHeightRatio()); @@ -187,7 +187,7 @@ TEST_F(FormFactorTest, Cuboctahedron) EXPECT_DOUBLE_EQ(volume, cuboctahedron.getVolume()); FormFactorCuboctahedron *cuboctahedronclone = cuboctahedron.clone(); - EXPECT_EQ("FormFactorCuboctahedron",cuboctahedronclone->getName()); + EXPECT_EQ(BornAgain::FFCuboctahedronType, cuboctahedronclone->getName()); EXPECT_EQ(4., cuboctahedronclone->getHeight()); EXPECT_EQ(10., cuboctahedronclone->getLength()); EXPECT_EQ(1., cuboctahedronclone->getHeightRatio()); @@ -203,13 +203,13 @@ TEST_F(FormFactorTest, Cylinder) double volume = Units::PI*radius*radius*height; FormFactorCylinder cylinder(radius,height); - EXPECT_EQ("FormFactorCylinder",cylinder.getName()); + EXPECT_EQ(BornAgain::FFCylinderType, cylinder.getName()); EXPECT_EQ(5., cylinder.getHeight()); EXPECT_EQ(3., cylinder.getRadius()); EXPECT_DOUBLE_EQ(volume, cylinder.getVolume()); FormFactorCylinder *cylinderclone = cylinder.clone(); - EXPECT_EQ("FormFactorCylinder",cylinderclone->getName()); + EXPECT_EQ(BornAgain::FFCylinderType, cylinderclone->getName()); EXPECT_EQ(5., cylinderclone->getHeight()); EXPECT_EQ(3., cylinderclone-> getRadius()); EXPECT_DOUBLE_EQ(volume, cylinderclone-> getVolume()); @@ -225,14 +225,14 @@ TEST_F(FormFactorTest, EllipsoidalCylinder) FormFactorEllipsoidalCylinder ellipscyl(radius_a, radius_b, height); - EXPECT_EQ("FormFactorEllipsoidalCylinder",ellipscyl.getName()); + EXPECT_EQ(BornAgain::FFEllipsoidalCylinderType, ellipscyl.getName()); EXPECT_EQ(4., ellipscyl.getHeight()); EXPECT_EQ(3., ellipscyl.getRadiusA()); EXPECT_EQ(5., ellipscyl.getRadiusB()); EXPECT_DOUBLE_EQ(volume, ellipscyl.getVolume()); FormFactorEllipsoidalCylinder *ellipscylclone = ellipscyl.clone(); - EXPECT_EQ("FormFactorEllipsoidalCylinder",ellipscylclone->getName()); + EXPECT_EQ(BornAgain::FFEllipsoidalCylinderType, ellipscylclone->getName()); EXPECT_EQ(4., ellipscylclone->getHeight()); EXPECT_EQ(3., ellipscylclone->getRadiusA()); EXPECT_EQ(5., ellipscylclone->getRadiusB()); @@ -248,13 +248,13 @@ TEST_F(FormFactorTest, FullSphere) FormFactorFullSphere fullsphere(radius); - EXPECT_EQ("FormFactorFullSphere",fullsphere.getName()); + EXPECT_EQ(BornAgain::FFFullSphereType, fullsphere.getName()); EXPECT_EQ(5., fullsphere.getRadius()); EXPECT_EQ(2.*5., fullsphere.getHeight()); EXPECT_DOUBLE_EQ(volume, fullsphere.getVolume()); FormFactorFullSphere *fullsphereclone = fullsphere.clone(); - EXPECT_EQ("FormFactorFullSphere",fullsphereclone->getName()); + EXPECT_EQ(BornAgain::FFFullSphereType, fullsphereclone->getName()); EXPECT_EQ(5., fullsphereclone->getRadius()); EXPECT_EQ(2.*5., fullsphereclone->getHeight()); EXPECT_DOUBLE_EQ(volume, fullsphereclone->getVolume()); @@ -269,13 +269,13 @@ TEST_F(FormFactorTest, FullSpheroid) FormFactorFullSpheroid fullspheroid(radius,height); - EXPECT_EQ("FormFactorFullSpheroid",fullspheroid.getName()); + EXPECT_EQ(BornAgain::FFFullSpheroidType, fullspheroid.getName()); EXPECT_EQ(3., fullspheroid.getRadius()); EXPECT_EQ(5., fullspheroid.getHeight()); EXPECT_DOUBLE_EQ(volume, fullspheroid.getVolume()); FormFactorFullSpheroid *fullspheroidclone = fullspheroid.clone(); - EXPECT_EQ("FormFactorFullSpheroid",fullspheroidclone->getName()); + EXPECT_EQ(BornAgain::FFFullSpheroidType, fullspheroidclone->getName()); EXPECT_EQ(3., fullspheroidclone->getRadius()); EXPECT_EQ(5, fullspheroidclone->getHeight()); EXPECT_DOUBLE_EQ(volume, fullspheroidclone->getVolume()); @@ -290,14 +290,14 @@ TEST_F(FormFactorTest, Prism3) FormFactorPrism3 prism3(length, height); - EXPECT_EQ("FormFactorPrism3",prism3.getName()); + EXPECT_EQ(BornAgain::FFPrism3Type, prism3.getName()); EXPECT_EQ(4., prism3.getHeight()); EXPECT_EQ(6., prism3.getLength()); EXPECT_DOUBLE_EQ(volume, prism3.getVolume()); FormFactorPrism3 *prism3clone = prism3.clone(); - EXPECT_EQ("FormFactorPrism3",prism3clone->getName()); + EXPECT_EQ(BornAgain::FFPrism3Type, prism3clone->getName()); EXPECT_EQ(4., prism3clone->getHeight()); EXPECT_EQ(6., prism3clone->getLength()); EXPECT_DOUBLE_EQ(volume, prism3clone->getVolume()); @@ -312,14 +312,14 @@ TEST_F(FormFactorTest, Prism6) FormFactorPrism6 prism6(radius, height); - EXPECT_EQ("FormFactorPrism6",prism6.getName()); + EXPECT_EQ(BornAgain::FFPrism6Type, prism6.getName()); EXPECT_EQ(4., prism6.getHeight()); EXPECT_EQ(3., prism6.getRadius()); EXPECT_DOUBLE_EQ(volume, prism6.getVolume()); FormFactorPrism6 *prism6clone = prism6.clone(); - EXPECT_EQ("FormFactorPrism6",prism6clone->getName()); + EXPECT_EQ(BornAgain::FFPrism6Type, prism6clone->getName()); EXPECT_EQ(4., prism6clone->getHeight()); EXPECT_EQ(3., prism6clone->getRadius()); EXPECT_DOUBLE_EQ(volume, prism6clone->getVolume()); @@ -338,14 +338,14 @@ TEST_F(FormFactorTest, Pyramid) FormFactorPyramid pyramid(length, height, alpha); - EXPECT_EQ("FormFactorPyramid", pyramid.getName()); + EXPECT_EQ(BornAgain::FFPyramidType, pyramid.getName()); EXPECT_EQ(4., pyramid.getHeight()); EXPECT_EQ(10., pyramid.getLength()); EXPECT_EQ(0.8, pyramid.getAlpha()); EXPECT_DOUBLE_EQ(volume, pyramid.getVolume()); FormFactorPyramid *pyramidclone = pyramid.clone(); - EXPECT_EQ("FormFactorPyramid", pyramidclone->getName()); + EXPECT_EQ(BornAgain::FFPyramidType, pyramidclone->getName()); EXPECT_EQ(4., pyramidclone->getHeight()); EXPECT_EQ(10., pyramidclone->getLength()); EXPECT_EQ(0.8, pyramidclone->getAlpha()); @@ -363,12 +363,12 @@ TEST_F(FormFactorTest, TruncatedSphere) FormFactorTruncatedSphere trsphere(radius, height); - EXPECT_EQ("FormFactorTruncatedSphere", trsphere.getName()); + EXPECT_EQ(BornAgain::FFTruncatedSphereType, trsphere.getName()); EXPECT_EQ(3., trsphere.getHeight()); EXPECT_DOUBLE_EQ(volume, trsphere.getVolume()); FormFactorTruncatedSphere *trsphereclone = trsphere.clone(); - EXPECT_EQ("FormFactorTruncatedSphere", trsphereclone->getName()); + EXPECT_EQ(BornAgain::FFTruncatedSphereType, trsphereclone->getName()); EXPECT_DOUBLE_EQ(3., trsphereclone->getHeight()); } @@ -384,14 +384,14 @@ TEST_F(FormFactorTest, TruncatedSpheroid) FormFactorTruncatedSpheroid trspheroid(radius, height,flattening); - EXPECT_EQ("FormFactorTruncatedSpheroid", trspheroid.getName()); + EXPECT_EQ(BornAgain::FFTruncatedSpheroidType, trspheroid.getName()); EXPECT_EQ(5., trspheroid.getHeight()); EXPECT_EQ(3., trspheroid.getRadius()); EXPECT_DOUBLE_EQ(total_height, trspheroid.getHeightFullSpheroid()); EXPECT_DOUBLE_EQ(volume, trspheroid.getVolume()); FormFactorTruncatedSpheroid *trspheroidclone = trspheroid.clone(); - EXPECT_EQ("FormFactorTruncatedSpheroid", trspheroidclone->getName()); + EXPECT_EQ(BornAgain::FFTruncatedSpheroidType, trspheroidclone->getName()); EXPECT_EQ(5., trspheroidclone->getHeight()); EXPECT_EQ(3., trspheroidclone->getRadius()); EXPECT_DOUBLE_EQ(total_height, trspheroidclone->getHeightFullSpheroid()); @@ -411,40 +411,20 @@ TEST_F(FormFactorTest, Tetrahedron) FormFactorTetrahedron tetrahedron(length, height, alpha); - EXPECT_EQ("FormFactorTetrahedron", tetrahedron.getName()); + EXPECT_EQ(BornAgain::FFTetrahedronType, tetrahedron.getName()); EXPECT_EQ(4., tetrahedron.getHeight()); EXPECT_EQ(16., tetrahedron.getLength()); EXPECT_EQ(0.8, tetrahedron.getAlpha()); EXPECT_DOUBLE_EQ(volume, tetrahedron.getVolume()); FormFactorTetrahedron *tetrahedronclone = tetrahedron.clone(); - EXPECT_EQ("FormFactorTetrahedron", tetrahedronclone->getName()); + EXPECT_EQ(BornAgain::FFTetrahedronType, tetrahedronclone->getName()); EXPECT_EQ(4., tetrahedronclone->getHeight()); EXPECT_EQ(16., tetrahedronclone->getLength()); EXPECT_EQ(0.8, tetrahedronclone->getAlpha()); EXPECT_DOUBLE_EQ(volume, tetrahedronclone->getVolume()); } -// Test form factor of a ripple2 (triangular) -TEST_F(FormFactorTest, Ripple2) -{ - double width = 20.; - double height = 4.; - double length = 100.0; - double d = 0.3; // asymetry - double volume = 0.5*height*width*length; - - FormFactorRipple2 ripple2(length, width, height, d); - - EXPECT_EQ("FormFactorRipple2", ripple2.getName()); - EXPECT_EQ(4., ripple2.getHeight()); - EXPECT_DOUBLE_EQ(volume, ripple2.getVolume()); - - FormFactorRipple2 *ripple2clone = ripple2.clone(); - EXPECT_EQ("FormFactorRipple2", ripple2clone->getName()); - EXPECT_DOUBLE_EQ(4., ripple2clone->getHeight()); -} - // Test form factor of a ripple1 (cosine) TEST_F(FormFactorTest, Ripple1) { @@ -455,20 +435,40 @@ TEST_F(FormFactorTest, Ripple1) FormFactorRipple1 ripple1(length, width, height); - EXPECT_EQ("FormFactorRipple1", ripple1.getName()); + EXPECT_EQ(BornAgain::FFRipple1Type, ripple1.getName()); EXPECT_EQ(4., ripple1.getHeight()); EXPECT_EQ(20., ripple1.getWidth()); EXPECT_EQ(100., ripple1.getLength()); EXPECT_DOUBLE_EQ(volume, ripple1.getVolume()); FormFactorRipple1 *ripple1clone = ripple1.clone(); - EXPECT_EQ("FormFactorRipple1", ripple1clone->getName()); + EXPECT_EQ(BornAgain::FFRipple1Type, ripple1clone->getName()); EXPECT_DOUBLE_EQ(4., ripple1clone->getHeight()); EXPECT_EQ(20., ripple1clone->getWidth()); EXPECT_EQ(100., ripple1clone->getLength()); EXPECT_DOUBLE_EQ(volume, ripple1clone->getVolume()); } +// Test form factor of a ripple2 (triangular) +TEST_F(FormFactorTest, Ripple2) +{ + double width = 20.; + double height = 4.; + double length = 100.0; + double d = 0.3; // asymetry + double volume = 0.5*height*width*length; + + FormFactorRipple2 ripple2(length, width, height, d); + + EXPECT_EQ(BornAgain::FFRipple2Type, ripple2.getName()); + EXPECT_EQ(4., ripple2.getHeight()); + EXPECT_DOUBLE_EQ(volume, ripple2.getVolume()); + + FormFactorRipple2 *ripple2clone = ripple2.clone(); + EXPECT_EQ(BornAgain::FFRipple2Type, ripple2clone->getName()); + EXPECT_DOUBLE_EQ(4., ripple2clone->getHeight()); +} + // Test form factor of a truncated cube TEST_F(FormFactorTest, TruncatedCube) { @@ -478,20 +478,17 @@ TEST_F(FormFactorTest, TruncatedCube) FormFactorTruncatedCube trcube(length, t); - EXPECT_EQ("FormFactorTruncatedCube",trcube.getName()); + EXPECT_EQ(BornAgain::FFTruncatedCubeType,trcube.getName()); EXPECT_EQ(length, trcube.getLength()); EXPECT_DOUBLE_EQ(t, trcube.getRemovedLength()); // length or length -2t EXPECT_DOUBLE_EQ(trcube.getVolume(), volume); FormFactorTruncatedCube *trcubeclone = trcube.clone(); - EXPECT_EQ("FormFactorTruncatedCube", trcubeclone->getName()); + EXPECT_EQ(BornAgain::FFTruncatedCubeType, trcubeclone->getName()); EXPECT_EQ(length, trcubeclone->getLength()); EXPECT_EQ(t, trcubeclone->getRemovedLength()); EXPECT_EQ(trcubeclone->getVolume(), volume); } - - #endif // FORMFACTORTEST_H - diff --git a/Tests/UnitTests/TestCore/LayerRoughnessTest.h b/Tests/UnitTests/TestCore/LayerRoughnessTest.h index 1dc596ac319..a01354867ff 100644 --- a/Tests/UnitTests/TestCore/LayerRoughnessTest.h +++ b/Tests/UnitTests/TestCore/LayerRoughnessTest.h @@ -2,16 +2,14 @@ #define LAYERROUGHNESSTEST_H #include "LayerRoughness.h" +#include "BornAgainNamespace.h" class LayerRoughnessTest : public ::testing::Test { protected: LayerRoughnessTest(){} - virtual ~LayerRoughnessTest(){} - }; - TEST_F(LayerRoughnessTest , LayerRoughnessInitial) { //test with default parameter @@ -19,8 +17,7 @@ TEST_F(LayerRoughnessTest , LayerRoughnessInitial) EXPECT_EQ(0.0, roughness.getSigma()); EXPECT_EQ(0.0, roughness.getHurstParameter()); EXPECT_EQ(0.0, roughness.getLatteralCorrLength()); - EXPECT_EQ("LayerRoughness", roughness.getName()); - + EXPECT_EQ(BornAgain::LayerBasicRoughnessType, roughness.getName()); //set new parameter roughness.setSigma(1.1); @@ -32,22 +29,17 @@ TEST_F(LayerRoughnessTest , LayerRoughnessInitial) roughness.setLatteralCorrLength(1.3); EXPECT_EQ(1.3, roughness.getLatteralCorrLength()); - - //test with given parameter LayerRoughness roughness2(2.1, 2.2, 2.3); EXPECT_EQ(2.1, roughness2.getSigma()); EXPECT_EQ(2.2, roughness2.getHurstParameter()); EXPECT_EQ(2.3, roughness2.getLatteralCorrLength()); - EXPECT_EQ("LayerRoughness", roughness.getName()); - - + EXPECT_EQ(BornAgain::LayerBasicRoughnessType, roughness.getName()); } //test clone LayerRoughness TEST_F(LayerRoughnessTest , LayerRoughnessClone) { - LayerRoughness original(3.1,3.2,3.3); LayerRoughness *clone = original.clone(); @@ -66,19 +58,14 @@ TEST_F(LayerRoughnessTest , LayerRoughnessPool) EXPECT_EQ(0.0, roughnessPool.getHurstParameter()); EXPECT_EQ(0.0, roughnessPool.getLatteralCorrLength()); - roughnessPool.setParameterValue("/LayerRoughness/sigma",4.1); - roughnessPool.setParameterValue("/LayerRoughness/hurst",4.2); - roughnessPool.setParameterValue("/LayerRoughness/corrlength",4.3); + roughnessPool.setParameterValue("/" + BornAgain::LayerBasicRoughnessType + "/sigma",4.1); + roughnessPool.setParameterValue("/" + BornAgain::LayerBasicRoughnessType + "/hurst",4.2); + roughnessPool.setParameterValue("/" + BornAgain::LayerBasicRoughnessType + "/corrlength",4.3); EXPECT_EQ(4.1, roughnessPool.getSigma()); EXPECT_EQ(4.2, roughnessPool.getHurstParameter()); EXPECT_EQ(4.3, roughnessPool.getLatteralCorrLength()); - EXPECT_EQ("LayerRoughness", roughnessPool.getName()); + EXPECT_EQ(BornAgain::LayerBasicRoughnessType, roughnessPool.getName()); } - - - - #endif // LAYERROUGHNESSTEST_H - diff --git a/Tests/UnitTests/TestCore/ParticleCoreShellTest.h b/Tests/UnitTests/TestCore/ParticleCoreShellTest.h index c98f9937067..10ab690aa24 100644 --- a/Tests/UnitTests/TestCore/ParticleCoreShellTest.h +++ b/Tests/UnitTests/TestCore/ParticleCoreShellTest.h @@ -2,11 +2,13 @@ #define PARTICLECORESHELLTEST_H #include "ParticleCoreShell.h" +#include "BornAgainNamespace.h" #include "Units.h" #include "HomogeneousMaterial.h" #include "FormFactorFullSphere.h" #include "Particle.h" #include "Rotations.h" + #include <iostream> class ParticleCoreShellTest : public ::testing::Test @@ -19,7 +21,7 @@ protected: }; ParticleCoreShellTest::ParticleCoreShellTest() - : mp_coreshell(0) + : mp_coreshell(nullptr) { Particle core; Particle shell; @@ -32,58 +34,57 @@ ParticleCoreShellTest::~ParticleCoreShellTest() delete mp_coreshell; } - TEST_F(ParticleCoreShellTest, InitialState) { - EXPECT_EQ(NULL, mp_coreshell->getAmbientMaterial()); - EXPECT_EQ(NULL, mp_coreshell->createFormFactor(1.0)); - EXPECT_EQ(NULL, mp_coreshell->getRotation()); - EXPECT_EQ("ParticleCoreShell", mp_coreshell->getName()); - EXPECT_EQ("Particle", mp_coreshell->getCoreParticle()->getName()); - EXPECT_EQ("Particle", mp_coreshell->getShellParticle()->getName()); + EXPECT_EQ(nullptr, mp_coreshell->getAmbientMaterial()); + EXPECT_EQ(nullptr, mp_coreshell->createFormFactor(1.0)); + EXPECT_EQ(nullptr, mp_coreshell->getRotation()); + EXPECT_EQ(BornAgain::ParticleCoreShellType, mp_coreshell->getName()); + EXPECT_EQ(BornAgain::ParticleType, mp_coreshell->getCoreParticle()->getName()); + EXPECT_EQ(BornAgain::ParticleType, mp_coreshell->getShellParticle()->getName()); } TEST_F(ParticleCoreShellTest, Clone) { ParticleCoreShell *p_clone = mp_coreshell->clone(); - EXPECT_EQ(NULL, p_clone->getAmbientMaterial()); - EXPECT_EQ(NULL, p_clone->createFormFactor(1.0)); - EXPECT_EQ(NULL, p_clone->getRotation()); - EXPECT_EQ("ParticleCoreShell", p_clone->getName()); - EXPECT_EQ("Particle", p_clone->getCoreParticle()->getName()); - EXPECT_EQ("Particle", p_clone->getShellParticle()->getName()); + EXPECT_EQ(nullptr, p_clone->getAmbientMaterial()); + EXPECT_EQ(nullptr, p_clone->createFormFactor(1.0)); + EXPECT_EQ(nullptr, p_clone->getRotation()); + EXPECT_EQ(BornAgain::ParticleCoreShellType, p_clone->getName()); + EXPECT_EQ(BornAgain::ParticleType, p_clone->getCoreParticle()->getName()); + EXPECT_EQ(BornAgain::ParticleType, p_clone->getShellParticle()->getName()); delete p_clone; } TEST_F(ParticleCoreShellTest, CloneInvertB) { ParticleCoreShell *p_clone = mp_coreshell->cloneInvertB(); - EXPECT_EQ(NULL, p_clone->getAmbientMaterial()); - EXPECT_EQ(NULL, p_clone->createFormFactor(1.0)); - EXPECT_EQ(NULL, p_clone->getRotation()); - EXPECT_EQ("ParticleCoreShell_inv", p_clone->getName()); - EXPECT_EQ("Particle_inv", p_clone->getCoreParticle()->getName()); - EXPECT_EQ("Particle_inv", p_clone->getShellParticle()->getName()); + EXPECT_EQ(nullptr, p_clone->getAmbientMaterial()); + EXPECT_EQ(nullptr, p_clone->createFormFactor(1.0)); + EXPECT_EQ(nullptr, p_clone->getRotation()); + EXPECT_EQ(BornAgain::ParticleCoreShellType, p_clone->getName()); + EXPECT_EQ(BornAgain::ParticleType, p_clone->getCoreParticle()->getName()); + EXPECT_EQ(BornAgain::ParticleType, p_clone->getShellParticle()->getName()); delete p_clone; } TEST_F(ParticleCoreShellTest, AmbientMaterial) { HomogeneousMaterial mat("Air", 0.0, 0.0); - EXPECT_EQ(NULL, mp_coreshell->getAmbientMaterial()); + EXPECT_EQ(nullptr, mp_coreshell->getAmbientMaterial()); mp_coreshell->setAmbientMaterial(mat); const IMaterial *p_material = mp_coreshell->getAmbientMaterial(); EXPECT_EQ("Air", p_material->getName()); EXPECT_EQ(complex_t(1.0, 0.0), p_material->getRefractiveIndex()); p_material = mp_coreshell->getCoreParticle()->getAmbientMaterial(); - EXPECT_EQ(NULL, p_material); + EXPECT_EQ(nullptr, p_material); p_material = mp_coreshell->getShellParticle()->getAmbientMaterial(); EXPECT_EQ("Air", p_material->getName()); EXPECT_EQ(complex_t(1.0, 0.0), p_material->getRefractiveIndex()); - EXPECT_EQ(NULL, mp_coreshell->createFormFactor(1.0)); - EXPECT_EQ("ParticleCoreShell", mp_coreshell->getName()); - EXPECT_EQ("Particle", mp_coreshell->getCoreParticle()->getName()); - EXPECT_EQ("Particle", mp_coreshell->getShellParticle()->getName()); + EXPECT_EQ(nullptr, mp_coreshell->createFormFactor(1.0)); + EXPECT_EQ(BornAgain::ParticleCoreShellType, mp_coreshell->getName()); + EXPECT_EQ(BornAgain::ParticleType, mp_coreshell->getCoreParticle()->getName()); + EXPECT_EQ(BornAgain::ParticleType, mp_coreshell->getShellParticle()->getName()); } TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) @@ -108,9 +109,6 @@ TEST_F(ParticleCoreShellTest, ComplexCoreShellClone) ParticleCoreShell *clone = coreshell.clone(); EXPECT_EQ(coreshell.getCoreParticle()->getPosition(), relative_pos); EXPECT_EQ(clone->getCoreParticle()->getPosition(), relative_pos); - - } - #endif // PARTICLECORESHELLTEST_H diff --git a/Tests/UnitTests/TestCore/ParticleInfoTest.h b/Tests/UnitTests/TestCore/ParticleInfoTest.h index 1f02f1de5c7..734462e36e0 100644 --- a/Tests/UnitTests/TestCore/ParticleInfoTest.h +++ b/Tests/UnitTests/TestCore/ParticleInfoTest.h @@ -2,33 +2,29 @@ #define PARTICLEINFOTEST_H #include "ParticleInfo.h" +#include "BornAgainNamespace.h" class ParticleInfoTest : public ::testing::Test { - protected: +protected: ParticleInfoTest(){} - virtual ~ParticleInfoTest(){} }; - TEST_F(ParticleInfoTest , ParticleInfoInitialState) { - //test with default parameter Particle particle; ParticleInfo particleInfo(particle); EXPECT_EQ(1.0, particleInfo.getAbundance()); - EXPECT_EQ("ParticleInfo", particleInfo.getName()); + EXPECT_EQ(BornAgain::ParticleInfoType, particleInfo.getName()); //set new parameter particleInfo.setAbundance(2.0); EXPECT_EQ(2.0, particleInfo.getAbundance()); } - -//test parameter pool TEST_F(ParticleInfoTest , ParticleInfoTestPool) { Particle particle; @@ -38,10 +34,9 @@ TEST_F(ParticleInfoTest , ParticleInfoTestPool) particleInfo.setParameterValue("/ParticleInfo/abundance",4.2); EXPECT_EQ(4.2, particleInfo.getAbundance()); - EXPECT_EQ("ParticleInfo", particleInfo.getName()); + EXPECT_EQ(BornAgain::ParticleInfoType, particleInfo.getName()); } - TEST_F(ParticleInfoTest , ParticleInfoInitialStateClonedParticle) { @@ -53,10 +48,9 @@ TEST_F(ParticleInfoTest , ParticleInfoInitialStateClonedParticle) delete pClone; EXPECT_EQ(3.0, particleInfo.getAbundance()); - EXPECT_EQ("ParticleInfo", particleInfo.getName()); + EXPECT_EQ(BornAgain::ParticleInfoType, particleInfo.getName()); } - TEST_F(ParticleInfoTest , ParticleInfoClone) { //test with default parameter @@ -72,7 +66,6 @@ TEST_F(ParticleInfoTest , ParticleInfoClone) delete clone; } - TEST_F(ParticleInfoTest , ParticleInfoCloneInvertB) { HomogeneousMaterial mat("Air",0,0); @@ -81,10 +74,9 @@ TEST_F(ParticleInfoTest , ParticleInfoCloneInvertB) ParticleInfo *clone = particle_info2.cloneInvertB(); EXPECT_EQ(clone->getAbundance(), particle_info2.getAbundance()); EXPECT_EQ(clone->getName(), particle_info2.getName()); - EXPECT_EQ(clone->getParticle()->getName(), particle2.getName()+"_inv"); + EXPECT_EQ(clone->getParticle()->getName(), particle2.getName()); delete clone; } - #endif // PARTICLEINFOTEST_H diff --git a/Tests/UnitTests/TestCore/ParticleTest.h b/Tests/UnitTests/TestCore/ParticleTest.h index 7f173e8c669..24b188c28a0 100644 --- a/Tests/UnitTests/TestCore/ParticleTest.h +++ b/Tests/UnitTests/TestCore/ParticleTest.h @@ -2,39 +2,40 @@ #define PARTICLETEST_H #include "Particle.h" +#include "BornAgainNamespace.h" #include "Units.h" #include "HomogeneousMaterial.h" #include "ParticleInfo.h" #include "FormFactorFullSphere.h" + #include <iostream> class ParticleTest : public ::testing::Test { protected: ParticleTest(){} - virtual ~ParticleTest(){} }; TEST_F(ParticleTest, InitialState) { Particle particle; - EXPECT_EQ(NULL, particle.getMaterial()); + EXPECT_EQ(nullptr, particle.getMaterial()); EXPECT_EQ(complex_t(0,0), particle.getRefractiveIndex()); - EXPECT_EQ(NULL, particle.getFormFactor()); - EXPECT_EQ(NULL, particle.createFormFactor(1.0)); - EXPECT_EQ("Particle", particle.getName()); + EXPECT_EQ(nullptr, particle.getFormFactor()); + EXPECT_EQ(nullptr, particle.createFormFactor(1.0)); + EXPECT_EQ(BornAgain::ParticleType, particle.getName()); } TEST_F(ParticleTest, Clone) { Particle particle; Particle *particle2 = particle.clone(); - EXPECT_EQ(NULL, particle2->getMaterial()); + EXPECT_EQ(nullptr, particle2->getMaterial()); EXPECT_EQ(complex_t(0,0), particle2->getRefractiveIndex()); - EXPECT_EQ(NULL, particle2->getFormFactor()); - EXPECT_EQ(NULL, particle2->createFormFactor(1.0)); - EXPECT_EQ("Particle", particle2->getName()); + EXPECT_EQ(nullptr, particle2->getFormFactor()); + EXPECT_EQ(nullptr, particle2->createFormFactor(1.0)); + EXPECT_EQ(BornAgain::ParticleType, particle2->getName()); delete particle2; } @@ -42,11 +43,11 @@ TEST_F(ParticleTest, CloneInvertB) { Particle particle; Particle *particle2 = particle.cloneInvertB(); - EXPECT_EQ(NULL, particle2->getMaterial()); + EXPECT_EQ(nullptr, particle2->getMaterial()); EXPECT_EQ(complex_t(0,0), particle2->getRefractiveIndex()); - EXPECT_EQ(NULL, particle2->getFormFactor()); - EXPECT_EQ(NULL, particle2->createFormFactor(1.0)); - EXPECT_EQ("Particle_inv", particle2->getName()); + EXPECT_EQ(nullptr, particle2->getFormFactor()); + EXPECT_EQ(nullptr, particle2->createFormFactor(1.0)); + EXPECT_EQ(BornAgain::ParticleType, particle2->getName()); delete particle2; } @@ -57,15 +58,15 @@ TEST_F(ParticleTest, Constructors) Particle *p1 = new Particle(mat); EXPECT_EQ("Air", p1->getMaterial()->getName()); EXPECT_EQ(complex_t(1,0), p1->getRefractiveIndex()); - EXPECT_EQ(NULL, p1->getFormFactor()); - EXPECT_EQ(NULL, p1->createFormFactor(1.0)); - EXPECT_EQ( NULL, p1->getRotation()); + EXPECT_EQ(nullptr, p1->getFormFactor()); + EXPECT_EQ(nullptr, p1->createFormFactor(1.0)); + EXPECT_EQ( nullptr, p1->getRotation()); delete p1; FormFactorFullSphere sphere(1.0); Particle *p2 = new Particle(mat, sphere); - EXPECT_EQ("FormFactorFullSphere", p2->getFormFactor()->getName()); + EXPECT_EQ(BornAgain::FFFullSphereType, p2->getFormFactor()->getName()); EXPECT_EQ(1, p2->getFormFactor()->getRadius()); EXPECT_TRUE(dynamic_cast<FormFactorDecoratorMaterial *>( p2->createFormFactor(1.0))); @@ -80,7 +81,7 @@ TEST_F(ParticleTest, Constructors) EXPECT_EQ(sphere3.getRadius(), p3->getFormFactor()->getRadius()); Particle *p4 = p3->clone(); - EXPECT_EQ("FormFactorFullSphere", p4->getFormFactor()->getName()); + EXPECT_EQ(BornAgain::FFFullSphereType, p4->getFormFactor()->getName()); delete p3; delete p4; @@ -95,7 +96,7 @@ TEST_F(ParticleTest, Transform) EXPECT_EQ("Air", particle->getMaterial()->getName()); - EXPECT_TRUE(NULL != particle->getRotation()); + EXPECT_TRUE(nullptr != particle->getRotation()); delete particle; } @@ -107,27 +108,27 @@ TEST_F(ParticleTest, SetParam) RotationY transform(45.*Units::degree); Particle particle; - EXPECT_EQ(NULL, particle.getMaterial()); - EXPECT_EQ(NULL, particle.getFormFactor()); - EXPECT_EQ(NULL, particle.getRotation()); + EXPECT_EQ(nullptr, particle.getMaterial()); + EXPECT_EQ(nullptr, particle.getFormFactor()); + EXPECT_EQ(nullptr, particle.getRotation()); particle.setMaterial(mat); EXPECT_EQ("Air", particle.getMaterial()->getName()); EXPECT_EQ(complex_t(1.0), particle.getRefractiveIndex()); particle.setFormFactor(sphere); - EXPECT_EQ("FormFactorFullSphere", particle.getFormFactor()->getName()); + EXPECT_EQ(BornAgain::FFFullSphereType, particle.getFormFactor()->getName()); EXPECT_EQ(2.1, particle.getFormFactor()->getRadius()); particle.setRotation(transform); - EXPECT_TRUE(NULL != particle.getRotation()); + EXPECT_TRUE(nullptr != particle.getRotation()); Particle *particle2 = particle.clone(); - EXPECT_EQ("Particle", particle2->getName()); + EXPECT_EQ(BornAgain::ParticleType, particle2->getName()); EXPECT_EQ("Air", particle2->getMaterial()->getName()); EXPECT_EQ(complex_t(1.0), particle2->getRefractiveIndex()); - EXPECT_TRUE(NULL != particle2->getFormFactor()); + EXPECT_TRUE(nullptr != particle2->getFormFactor()); EXPECT_EQ(2.1, particle2->getFormFactor()->getRadius()); - EXPECT_TRUE(NULL != particle2->getRotation()); + EXPECT_TRUE(nullptr != particle2->getRotation()); delete particle2; } -- GitLab