diff --git a/Core/Algorithms/inc/Mask.h b/Core/Algorithms/inc/Mask.h index a95bb724095ed7fbae3f0bdd0a94513041f60768..dce9ddf98b464ecc0bf5105d1a2d4b8866d64d1c 100644 --- a/Core/Algorithms/inc/Mask.h +++ b/Core/Algorithms/inc/Mask.h @@ -25,7 +25,8 @@ class Mask : public ICloneable public: template <class TValue, class TContainer> friend class OutputDataIterator; template <class TValue> friend class OutputData; - explicit Mask(Mask *p_submask=0); + explicit Mask(Mask *p_submask=0) + : m_own_index(0), m_max_index(0), mp_submask(p_submask) {} virtual ~Mask() { delete mp_submask; } virtual Mask *clone() const; diff --git a/Core/Algorithms/src/FTDistributions.cpp b/Core/Algorithms/src/FTDistributions.cpp index 9d83296b7f258c1d4833e3bfb7d7d373560bfffc..68e11d33b3434b5ac42eb2b506f72beb56940d29 100644 --- a/Core/Algorithms/src/FTDistributions.cpp +++ b/Core/Algorithms/src/FTDistributions.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Algorithms/src/FTDistributions.cpp -//! @brief Implements class FTDistributions. +//! @brief Implements class FTDistribution2DCauchy. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/Core/Algorithms/src/Mask.cpp b/Core/Algorithms/src/Mask.cpp index 6e89af97a8b3a71609d9fc763fa565386b61b2ba..cb3f892ed1383f2bd5ee80f095d93739aa84da85 100644 --- a/Core/Algorithms/src/Mask.cpp +++ b/Core/Algorithms/src/Mask.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Algorithms/src/Mask.cpp -//! @brief Implements classes Mask and MaskCoordinate. +//! @brief Implements classes Mask, MaskIndexModulus, MaskCoordinates. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -18,10 +18,9 @@ #include <iostream> #include <algorithm> -Mask::Mask(Mask* p_submask) -: m_own_index(0), m_max_index(0), mp_submask(p_submask) -{ -} +// ************************************************************************** // +// implement class Mask +// ************************************************************************** // Mask* Mask::clone() const { @@ -91,6 +90,10 @@ size_t Mask::nextSubIndex(size_t total_index) return result; } +// ************************************************************************** // +// implement class MaskIndexModulus +// ************************************************************************** // + MaskIndexModulus* MaskIndexModulus::clone() const { @@ -98,7 +101,8 @@ MaskIndexModulus* MaskIndexModulus::clone() const if (mp_submask) { p_new_submask = mp_submask->clone(); } - MaskIndexModulus *p_new = new MaskIndexModulus(m_modulus, m_remainder, p_new_submask); + MaskIndexModulus *p_new = + new MaskIndexModulus(m_modulus, m_remainder, p_new_submask); p_new->m_own_index = m_own_index; p_new->setMaxIndex(m_max_index); return p_new; @@ -110,6 +114,10 @@ bool MaskIndexModulus::isMasked(size_t total_index) const return m_own_index % m_modulus != m_remainder; } +// ************************************************************************** // +// implement class MaskCoordinates +// ************************************************************************** // + MaskCoordinates::MaskCoordinates(size_t rank, const int* dims, Mask* p_submask) : Mask(p_submask) , m_rank(rank) @@ -149,7 +157,8 @@ MaskCoordinates* MaskCoordinates::clone() const return p_new; } -void MaskCoordinates::setMaskCoordinateFunction(MaskCoordinateFunction* p_mask_function) +void MaskCoordinates::setMaskCoordinateFunction( + MaskCoordinateFunction* p_mask_function) { if(mp_mask_function && mp_mask_function != p_mask_function) { delete mp_mask_function; diff --git a/Core/Core.pro b/Core/Core.pro index 136d134c3490931e4aac0242f1200fc4bb3a8408..86bf44193d9d5518d9693f78e0b8efffb18126c8 100644 --- a/Core/Core.pro +++ b/Core/Core.pro @@ -6,7 +6,7 @@ TEMPLATE = lib CONFIG += plugin # to remove versions from file name QT -= core gui QMAKE_EXTENSION_SHLIB = so # making standard *.so extension -CONFIG += BORNAGAIN_PYTHON +# CONFIG += BORNAGAIN_PYTHON # ----------------------------------------------------------------------------- # source and headers diff --git a/Core/Geometry/inc/BasicVector3D.h b/Core/Geometry/inc/BasicVector3D.h index 914c69f9fa22ebabf8a5149d5a2b2bdd7c0b30db..ad52e9cc4bb5677d8518a9ca0a42bdcc08790985 100644 --- a/Core/Geometry/inc/BasicVector3D.h +++ b/Core/Geometry/inc/BasicVector3D.h @@ -204,19 +204,6 @@ template<class T> class BasicVector3D { } } - // --------- - // Rotations - // --------- - - //! Rotates around x-axis. - BasicVector3D<T>& rotateX(T a); - //! Rotates around y-axis. - BasicVector3D<T>& rotateY(T a); - //! Rotates around z-axis. - BasicVector3D<T>& rotateZ(T a); - //! Rotates around the axis specified by another vector. - BasicVector3D<T>& rotate(T a, const BasicVector3D<T>& v); - // --------------------------------------------- // Specifically for grazing-incidence scattering // --------------------------------------------- diff --git a/Core/Geometry/inc/Transform3D.h b/Core/Geometry/inc/Transform3D.h index f9f0c2c5786d6cd9bb983c4dc243fd1b15bded1d..afcd75f5daf5aaf36e18288db0ccacb2f041501e 100644 --- a/Core/Geometry/inc/Transform3D.h +++ b/Core/Geometry/inc/Transform3D.h @@ -37,10 +37,6 @@ namespace Geometry { -class Translate3D; -class Rotate3D; -class Scale3D; - // ************************************************************************** // // Main class Transform3D // ************************************************************************** // @@ -277,124 +273,7 @@ class Transform3D { //! resulting transformation will be used several times. //! Transform3D operator*(const Transform3D& b) const; - - //! Test for equality. - bool operator == (const Transform3D& transform) const; - - //! Test for inequality. - bool operator != (const Transform3D& transform) const { - return ! operator==(transform); - } - - //! Difference between corresponding matrix elements less than tolerance? - bool isNear(const Transform3D& t, double tolerance = 2.2E-14 ) const; -}; - -// ************************************************************************** // -// Rotations -// ************************************************************************** // - -//! A rotation of 3D geometrical objects (points, vectors, normals). - -//! This class provides additional constructors for Transform3D -//! and should not be used as a separate class. -//! -//! Example of use: -//! @code -//! Transform3D m; -//! m = Rotate3D(30.*deg, HepVector3D(1.,1.,1.)); -//! @endcode -//! -//! @author <Evgueni.Tcherniaev@cern.ch> 1996-2003 -//! -class Rotate3D : public Transform3D { -public: - //! Default constructor: sets the Identity transformation. - Rotate3D() : Transform3D() {} - - //! Construct rotation by angle a around axis p1->p2. - Rotate3D(double a, - const Point3D<double>& p1, - const Point3D<double>& p2); - - //! Constructor from original and rotated position of two points. - - //! It is assumed that there is no reflection. - //! @param fr1 original position of 1st point - //! @param fr2 original position of 2nd point - //! @param to1 rotated position of 1st point - //! @param to2 rotated position of 2nd point - inline Rotate3D(const Point3D<double>& fr1, - const Point3D<double>& fr2, - const Point3D<double>& to1, - const Point3D<double>& to2) - : Transform3D(Point3D<double>(0.0, 0.0, 0.0),fr1,fr2, - Point3D<double>(0.0, 0.0, 0.0),to1,to2) {} - - - //! Constructor from angle and axis. - - //! @param a angle of rotation - //! @param v axis of rotation - inline Rotate3D(double a, const Vector3D<double>& v) - // TODO(C++11): simplify using delegating constructor - { *this = Rotate3D(a, Point3D<double>(0.0, 0.0, 0.0), - Point3D<double>(v.x(),v.y(),v.z()) ); } -}; - -//! A rotation of 3D geometrical objects around the x-axis. - -//! Should not be instantiated: see Rotate3D for example of use. -//! -//! @author <Evgueni.Tcherniaev@cern.ch> -//! -class RotateX3D : public Rotate3D { -public: - //! Default constructor: sets the Identity transformation. - RotateX3D() : Rotate3D() {} - - //! Constructs a rotation around x-axis by angle a. - RotateX3D(double a) { - double cosa = std::cos(a), sina = std::sin(a); - setTransform(1.0,0.0,0.0,0.0, 0.0,cosa,-sina,0.0, 0.0,sina,cosa,0.0); - } -}; - -//! A rotation of 3D geometrical objects around the y-axis. - -//! Should not be instantiated: see Rotate3D for example of use. -//! -//! @author <Evgueni.Tcherniaev@cern.ch> -//! -class RotateY3D : public Rotate3D { -public: - //! Default constructor: sets the Identity transformation. - RotateY3D() : Rotate3D() {} - - //! Constructs a rotation around y-axis by angle a. - RotateY3D(double a) { - double cosa = std::cos(a), sina = std::sin(a); - setTransform(cosa,0.0,sina,0.0, 0.0,1.0,0.0,0.0, -sina,0.0,cosa,0.0); - } -}; - -//! A rotation of 3D geometrical objects around the z-axis. - -//! Should not be instantiated: see Rotate3D for example of use. -//! -//! @author <Evgueni.Tcherniaev@cern.ch> -//! -class RotateZ3D : public Rotate3D { -public: - //! Default constructor: sets the Identity transformation. - RotateZ3D() : Rotate3D() {} - - //! Constructs a rotation around z-axis by angle a. - RotateZ3D(double a) { - double cosa = std::cos(a), sina = std::sin(a); - setTransform(cosa,-sina,0.0,0.0, sina,cosa,0.0,0.0, 0.0,0.0,1.0,0.0); - } -}; + }; // ************************************************************************** // // Inlines that involve both Transform3D and Transform3D_row diff --git a/Core/Geometry/src/BasicVector3D.cpp b/Core/Geometry/src/BasicVector3D.cpp index 39e6aaf2a0ec70e010f0807b6010fe3fd1df289b..dfae364b052a0e85e108ea56cfc2f338a3f9a194 100644 --- a/Core/Geometry/src/BasicVector3D.cpp +++ b/Core/Geometry/src/BasicVector3D.cpp @@ -175,68 +175,6 @@ double BasicVector3D<double>::angle(const BasicVector3D<double>& v) const return std::acos(cosa); } -// ----------------------------------------------------------------------------- -// Rotations -// ----------------------------------------------------------------------------- - -template<> -BasicVector3D<double>& BasicVector3D<double>::rotateX (double a) -{ - double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z(); - setY(dy*cosa-dz*sina); - setZ(dz*cosa+dy*sina); - return *this; -} - -template<> -BasicVector3D<double>& BasicVector3D<double>::rotateY (double a) -{ - double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x(); - setZ(dz*cosa-dx*sina); - setX(dx*cosa+dz*sina); - return *this; -} - -template<> -BasicVector3D<double>& BasicVector3D<double>::rotateZ (double a) -{ - double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y(); - setX(dx*cosa-dy*sina); - setY(dy*cosa+dx*sina); - return *this; -} - -template<> -BasicVector3D<double>& BasicVector3D<double>::rotate ( - double a, const BasicVector3D<double>& v) -{ - if (a == 0) return *this; - double cx = v.x(), cy = v.y(), cz = v.z(); - double ll = std::sqrt(cx*cx + cy*cy + cz*cz); - if (ll == 0) { - std::cerr << "BasicVector<double>::rotate() : zero axis" << std::endl; - return *this; - } - double cosa = std::cos(a), sina = std::sin(a); - cx /= ll; cy /= ll; cz /= ll; - - double xx = cosa + (1-cosa)*cx*cx; - double xy = (1-cosa)*cx*cy - sina*cz; - double xz = (1-cosa)*cx*cz + sina*cy; - - double yx = (1-cosa)*cy*cx + sina*cz; - double yy = cosa + (1-cosa)*cy*cy; - double yz = (1-cosa)*cy*cz - sina*cx; - - double zx = (1-cosa)*cz*cx - sina*cy; - double zy = (1-cosa)*cz*cy + sina*cx; - double zz = cosa + (1-cosa)*cz*cz; - - cx = x(); cy = y(); cz = z(); - setXYZ(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz); - return *this; -} - // ========================================================================= // Non-member functions for BasicVector3D<double> // ========================================================================= diff --git a/Core/Geometry/src/Transform3D.cpp b/Core/Geometry/src/Transform3D.cpp index e161cc1c16f7fd7123ab42ba6cf815ec02e75c12..cd1d825faccef70c116c3e23550bfb043e42f14d 100644 --- a/Core/Geometry/src/Transform3D.cpp +++ b/Core/Geometry/src/Transform3D.cpp @@ -177,72 +177,4 @@ Transform3D Transform3D::inverse() const detxz, -detyz, detzz, -detxz*dx_+detyz*dy_-detzz*dz_); } -//! Difference between corresponding matrix elements less than tolerance? - -bool Transform3D::isNear(const Transform3D & t, double tolerance) const -{ - return ( (std::abs(xx_ - t.xx_) <= tolerance) && - (std::abs(xy_ - t.xy_) <= tolerance) && - (std::abs(xz_ - t.xz_) <= tolerance) && - (std::abs(dx_ - t.dx_) <= tolerance) && - (std::abs(yx_ - t.yx_) <= tolerance) && - (std::abs(yy_ - t.yy_) <= tolerance) && - (std::abs(yz_ - t.yz_) <= tolerance) && - (std::abs(dy_ - t.dy_) <= tolerance) && - (std::abs(zx_ - t.zx_) <= tolerance) && - (std::abs(zy_ - t.zy_) <= tolerance) && - (std::abs(zz_ - t.zz_) <= tolerance) && - (std::abs(dz_ - t.dz_) <= tolerance) ); -} - -//! Test for equality. - -bool Transform3D::operator==(const Transform3D & t) const -{ - return (this == &t) ? true : - (xx_==t.xx_ && xy_==t.xy_ && xz_==t.xz_ && dx_==t.dx_ && - yx_==t.yx_ && yy_==t.yy_ && yz_==t.yz_ && dy_==t.dy_ && - zx_==t.zx_ && zy_==t.zy_ && zz_==t.zz_ && dz_==t.dz_ ); -} - - -//! Construct rotation by angle a around axis p1->p2. -//! -//! @author E. Chernyaev 1996 - -Rotate3D::Rotate3D(double a, - const Point3D<double> & p1, - const Point3D<double> & p2) - : Transform3D() -{ - if (a == 0) return; - - double cx = p2.x()-p1.x(), cy = p2.y()-p1.y(), cz = p2.z()-p1.z(); - double ll = std::sqrt(cx*cx + cy*cy + cz*cz); - if (ll == 0) { - std::cerr << "Rotate3D: zero axis" << std::endl; - } else { - double cosa = std::cos(a), sina = std::sin(a); - cx /= ll; cy /= ll; cz /= ll; - - double txx = cosa + (1-cosa)*cx*cx; - double txy = (1-cosa)*cx*cy - sina*cz; - double txz = (1-cosa)*cx*cz + sina*cy; - - double tyx = (1-cosa)*cy*cx + sina*cz; - double tyy = cosa + (1-cosa)*cy*cy; - double tyz = (1-cosa)*cy*cz - sina*cx; - - double tzx = (1-cosa)*cz*cx - sina*cy; - double tzy = (1-cosa)*cz*cy + sina*cx; - double tzz = cosa + (1-cosa)*cz*cz; - - double tdx = p1.x(), tdy = p1.y(), tdz = p1.z(); - - setTransform(txx, txy, txz, tdx-txx*tdx-txy*tdy-txz*tdz, - tyx, tyy, tyz, tdy-tyx*tdx-tyy*tdy-tyz*tdz, - tzx, tzy, tzz, tdz-tzx*tdx-tzy*tdy-tzz*tdz); - } -} - } // namespace Geometry diff --git a/Core/PythonAPI/src/Transform3D.pypp.cpp b/Core/PythonAPI/src/Transform3D.pypp.cpp deleted file mode 100644 index aa14c0a6fa8a9aa93ef4ef6b22d12b2b38e88801..0000000000000000000000000000000000000000 --- a/Core/PythonAPI/src/Transform3D.pypp.cpp +++ /dev/null @@ -1,266 +0,0 @@ -// This file has been generated by Py++. - -#include "Macros.h" -GCC_DIAG_OFF(unused-parameter); -GCC_DIAG_OFF(missing-field-initializers); -#include "boost/python.hpp" -#include "boost/python/suite/indexing/vector_indexing_suite.hpp" -GCC_DIAG_ON(unused-parameter); -GCC_DIAG_ON(missing-field-initializers); -#include "BasicVector3D.h" -#include "Bin.h" -#include "Crystal.h" -#include "DiffuseParticleInfo.h" -#include "FTDistributions.h" -#include "FormFactorBox.h" -#include "FormFactorCrystal.h" -#include "FormFactorCylinder.h" -#include "FormFactorDecoratorDebyeWaller.h" -#include "FormFactorFullSphere.h" -#include "FormFactorGauss.h" -#include "FormFactorLorentz.h" -#include "FormFactorParallelepiped.h" -#include "FormFactorPrism3.h" -#include "FormFactorPyramid.h" -#include "FormFactorSphereGaussianRadius.h" -#include "HomogeneousMaterial.h" -#include "ICloneable.h" -#include "IClusteredParticles.h" -#include "ICompositeSample.h" -#include "IDecoration.h" -#include "IFormFactor.h" -#include "IFormFactorBorn.h" -#include "IFormFactorDecorator.h" -#include "IInterferenceFunction.h" -#include "IMaterial.h" -#include "IParameterized.h" -#include "ISample.h" -#include "ISampleBuilder.h" -#include "ISelectionRule.h" -#include "ISingleton.h" -#include "Instrument.h" -#include "InterferenceFunction1DParaCrystal.h" -#include "InterferenceFunction2DLattice.h" -#include "InterferenceFunction2DParaCrystal.h" -#include "InterferenceFunctionNone.h" -#include "Lattice.h" -#include "Lattice2DIFParameters.h" -#include "LatticeBasis.h" -#include "Layer.h" -#include "LayerDecorator.h" -#include "LayerRoughness.h" -#include "Lattice2DIFParameters.h" -#include "MaterialManager.h" -#include "MesoCrystal.h" -#include "MultiLayer.h" -#include "OpticalFresnel.h" -#include "ParameterPool.h" -#include "Particle.h" -#include "ParticleBuilder.h" -#include "ParticleCoreShell.h" -#include "ParticleDecoration.h" -#include "ParticleInfo.h" -#include "PositionParticleInfo.h" -#include "PythonOutputData.h" -#include "PythonPlusplusHelper.h" -#include "RealParameterWrapper.h" -#include "Simulation.h" -#include "SimulationParameters.h" -#include "IStochasticParameter.h" -#include "StochasticGaussian.h" -#include "StochasticSampledParameter.h" -#include "StochasticDoubleGate.h" -#include "Transform3D.h" -#include "Types.h" -#include "Units.h" -#include "Transform3D.pypp.h" - -namespace bp = boost::python; - -void register_Transform3D_class(){ - - { //::Geometry::Transform3D - typedef bp::class_< Geometry::Transform3D > Transform3D_exposer_t; - Transform3D_exposer_t Transform3D_exposer = Transform3D_exposer_t( "Transform3D", bp::init< >() ); - bp::scope Transform3D_scope( Transform3D_exposer ); - bp::class_< Geometry::Transform3D::Transform3D_row, boost::noncopyable >( "Transform3D_row", bp::init< Geometry::Transform3D const &, int >(( bp::arg("r"), bp::arg("i") )) ) - .def( - "__getitem__" - , (double ( ::Geometry::Transform3D::Transform3D_row::* )( int ) const)( &::Geometry::Transform3D::Transform3D_row::operator[] ) - , ( bp::arg("jj") ) ); - Transform3D_exposer.def( bp::init< Geometry::BasicVector3D< double > const &, Geometry::BasicVector3D< double > const &, Geometry::BasicVector3D< double > const &, Geometry::BasicVector3D< double > const &, Geometry::BasicVector3D< double > const &, Geometry::BasicVector3D< double > const & >(( bp::arg("fr0"), bp::arg("fr1"), bp::arg("fr2"), bp::arg("to0"), bp::arg("to1"), bp::arg("to2") )) ); - Transform3D_exposer.def( bp::init< Geometry::Transform3D const & >(( bp::arg("m") )) ); - { //::Geometry::Transform3D::dx - - typedef double ( ::Geometry::Transform3D::*dx_function_type )( ) const; - - Transform3D_exposer.def( - "dx" - , dx_function_type( &::Geometry::Transform3D::dx ) ); - - } - { //::Geometry::Transform3D::dy - - typedef double ( ::Geometry::Transform3D::*dy_function_type )( ) const; - - Transform3D_exposer.def( - "dy" - , dy_function_type( &::Geometry::Transform3D::dy ) ); - - } - { //::Geometry::Transform3D::dz - - typedef double ( ::Geometry::Transform3D::*dz_function_type )( ) const; - - Transform3D_exposer.def( - "dz" - , dz_function_type( &::Geometry::Transform3D::dz ) ); - - } - { //::Geometry::Transform3D::inverse - - typedef ::Geometry::Transform3D ( ::Geometry::Transform3D::*inverse_function_type )( ) const; - - Transform3D_exposer.def( - "inverse" - , inverse_function_type( &::Geometry::Transform3D::inverse ) ); - - } - { //::Geometry::Transform3D::isNear - - typedef bool ( ::Geometry::Transform3D::*isNear_function_type )( ::Geometry::Transform3D const &,double ) const; - - Transform3D_exposer.def( - "isNear" - , isNear_function_type( &::Geometry::Transform3D::isNear ) - , ( bp::arg("t"), bp::arg("tolerance")=2.20000000000000009206578920655319378310295179435041035276e-14 ) ); - - } - Transform3D_exposer.def( bp::self != bp::self ); - { //::Geometry::Transform3D::operator() - - typedef double ( ::Geometry::Transform3D::*__call___function_type )( int,int ) const; - - Transform3D_exposer.def( - "__call__" - , __call___function_type( &::Geometry::Transform3D::operator() ) - , ( bp::arg("arg0"), bp::arg("arg1") ) ); - - } - Transform3D_exposer.def( bp::self * bp::self ); - { //::Geometry::Transform3D::operator= - - typedef ::Geometry::Transform3D & ( ::Geometry::Transform3D::*assign_function_type )( ::Geometry::Transform3D const & ) ; - - Transform3D_exposer.def( - "assign" - , assign_function_type( &::Geometry::Transform3D::operator= ) - , ( bp::arg("m") ) - , bp::return_self< >() ); - - } - Transform3D_exposer.def( bp::self == bp::self ); - { //::Geometry::Transform3D::operator[] - - typedef ::Geometry::Transform3D::Transform3D_row const ( ::Geometry::Transform3D::*__getitem___function_type )( int ) const; - - Transform3D_exposer.def( - "__getitem__" - , __getitem___function_type( &::Geometry::Transform3D::operator[] ) - , ( bp::arg("i") ) ); - - } - { //::Geometry::Transform3D::setIdentity - - typedef void ( ::Geometry::Transform3D::*setIdentity_function_type )( ) ; - - Transform3D_exposer.def( - "setIdentity" - , setIdentity_function_type( &::Geometry::Transform3D::setIdentity ) ); - - } - { //::Geometry::Transform3D::xx - - typedef double ( ::Geometry::Transform3D::*xx_function_type )( ) const; - - Transform3D_exposer.def( - "xx" - , xx_function_type( &::Geometry::Transform3D::xx ) ); - - } - { //::Geometry::Transform3D::xy - - typedef double ( ::Geometry::Transform3D::*xy_function_type )( ) const; - - Transform3D_exposer.def( - "xy" - , xy_function_type( &::Geometry::Transform3D::xy ) ); - - } - { //::Geometry::Transform3D::xz - - typedef double ( ::Geometry::Transform3D::*xz_function_type )( ) const; - - Transform3D_exposer.def( - "xz" - , xz_function_type( &::Geometry::Transform3D::xz ) ); - - } - { //::Geometry::Transform3D::yx - - typedef double ( ::Geometry::Transform3D::*yx_function_type )( ) const; - - Transform3D_exposer.def( - "yx" - , yx_function_type( &::Geometry::Transform3D::yx ) ); - - } - { //::Geometry::Transform3D::yy - - typedef double ( ::Geometry::Transform3D::*yy_function_type )( ) const; - - Transform3D_exposer.def( - "yy" - , yy_function_type( &::Geometry::Transform3D::yy ) ); - - } - { //::Geometry::Transform3D::yz - - typedef double ( ::Geometry::Transform3D::*yz_function_type )( ) const; - - Transform3D_exposer.def( - "yz" - , yz_function_type( &::Geometry::Transform3D::yz ) ); - - } - { //::Geometry::Transform3D::zx - - typedef double ( ::Geometry::Transform3D::*zx_function_type )( ) const; - - Transform3D_exposer.def( - "zx" - , zx_function_type( &::Geometry::Transform3D::zx ) ); - - } - { //::Geometry::Transform3D::zy - - typedef double ( ::Geometry::Transform3D::*zy_function_type )( ) const; - - Transform3D_exposer.def( - "zy" - , zy_function_type( &::Geometry::Transform3D::zy ) ); - - } - { //::Geometry::Transform3D::zz - - typedef double ( ::Geometry::Transform3D::*zz_function_type )( ) const; - - Transform3D_exposer.def( - "zz" - , zz_function_type( &::Geometry::Transform3D::zz ) ); - - } - Transform3D_exposer.def_readonly( "Identity", Geometry::Transform3D::Identity ); - } - -} diff --git a/Core/Tools/inc/IParameterized.h b/Core/Tools/inc/IParameterized.h index 21dea8058ee0f8e7fac99499ce8be7b561e03418..0ca770bdc0fa20bab22d6921d7ce7daf802ed378 100644 --- a/Core/Tools/inc/IParameterized.h +++ b/Core/Tools/inc/IParameterized.h @@ -22,21 +22,27 @@ class IParameterized : public INamed { -public: - IParameterized(); - IParameterized(const std::string &name); - IParameterized(const IParameterized &other); + public: + IParameterized() + : m_parameters(), m_status() {} + IParameterized(const std::string &name) + : INamed(name), m_parameters(), m_status() {} + IParameterized(const IParameterized &other) + : INamed(other), m_parameters(), m_status() {} IParameterized &operator=(const IParameterized &other); virtual ~IParameterized() {} - //! return pointer to the parameter pool + //! Return pointer to the parameter pool. ParameterPool *getParameterPool() { return &m_parameters; } - //! create new parameter pool which contains all local parameter and parameters of children + //! Create new parameter pool, with all local parameter and parameters of children virtual ParameterPool *createParameterTree() const; - //! add parameters from local pool to external pool and call recursion over direct children - virtual std::string addParametersToExternalPool(std::string path, ParameterPool *external_pool, int copy_number=-1) const; + //! Add parameters from local pool to external pool and call recursion over direct children. + virtual std::string addParametersToExternalPool( + std::string path, + ParameterPool *external_pool, + int copy_number=-1) const; virtual void printParameters() const; @@ -45,10 +51,10 @@ public: virtual void setParametersAreChanged() { m_status.setIsChanged(true); } protected: - //! initialize pool parameters, i.e. register some of class members for later access via parameter pool (to overload) + //! Throw non-implemented exception (needed for Python). virtual void init_parameters(); - ParameterPool m_parameters; //! parameter pool + ParameterPool m_parameters; //!< parameter pool IChangeable m_status; }; diff --git a/Core/Tools/inc/OutputDataWriteStrategy.h b/Core/Tools/inc/OutputDataWriteStrategy.h index d0750e0cb1767a60395ace2276ee902d382101be..b2d4dea96f0b867930d592247f93ca952dd48f0f 100644 --- a/Core/Tools/inc/OutputDataWriteStrategy.h +++ b/Core/Tools/inc/OutputDataWriteStrategy.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/inc/OutputDataWriteStrategy.h -//! @brief Defines classes OutputDataWriteStrategy and OutputDataWriteStreamIMA. +//! @brief Defines classes IOutputDataWriteStrategy and OutputDataWriteStreamIMA. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) diff --git a/Core/Tools/inc/Utils.h b/Core/Tools/inc/Utils.h index 710ec5ef90fa6926bdedfb661d8c7a0fa6f810a5..3700bcfc9464aab75aa57734ac6154483cf380f8 100644 --- a/Core/Tools/inc/Utils.h +++ b/Core/Tools/inc/Utils.h @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/inc/Utils.h -//! @brief Various stuff in namespace Utils. +//! @brief Defines various stuff in namespace Utils. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -22,34 +22,31 @@ namespace Utils { -//- ------------------------------------------------------------------- -//! @class String -//! @brief Collection of utilities for std::string -//- ------------------------------------------------------------------- +//! Collection of utilities for std::string. + class String { -public: - //! parse double values from string to vector of double + public: + //! Parse double values from string to vector of double. static vdouble1d_t parse_doubles(const std::string &str); //! assuming that string consist of doubles return new string where doubles are rounded according to the precision static std::string round_doubles(const std::string &str, int precision); - //! return true if text matches pattern with wildcards '*' and '?' - static bool MatchPattern(const std::string &text, std::string wildcardPattern); + //! Return true if text matches pattern with wildcards '*' and '?'. + static bool MatchPattern(const std::string &text, + std::string wildcardPattern); - //! split string into vector of string using delimeter - static std::vector<std::string> Split(const std::string &text, const std::string &delimeter); + //! Split string into vector of string using delimeter. + static std::vector<std::string> Split(const std::string &text, + const std::string &delimeter); }; +//! Control how often a string is used. -//- ------------------------------------------------------------------- -//! @class StringUsageMap -//! @brief Definition of StringUsageMap to control how often string is used -//- ------------------------------------------------------------------- class StringUsageMap { -public: + public: typedef std::map<std::string, int> nstringmap_t; typedef nstringmap_t::iterator iterator_t; @@ -78,19 +75,16 @@ public: //! get current string std::string get_current() const { return m_current_string; } -private: + private: std::string m_current_string; nstringmap_t m_nstringmap; }; +//! Utilities to deal with file system. -//- ------------------------------------------------------------------- -//! @class FileSystem -//! @brief different utilities to deal with file system -//- ------------------------------------------------------------------- class FileSystem { -public: + public: //! return path to the current (working) directory static std::string GetWorkingPath(); @@ -108,14 +102,12 @@ public: //! return file extension after stripping '.gz' if any static std::string GetFileMainExtension(const std::string &name); -private: + private: static std::string m_relative_path; //!< it's value of argv[0], i.e. the path from working directory to executable module }; +//! Adjust length of the string, padding with blanks. -//- ------------------------------------------------------------------- -//! @brief adjust length of the string -//- ------------------------------------------------------------------- inline std::string AdjustStringLength(std::string name, int length) { std::string newstring = name; @@ -123,14 +115,12 @@ inline std::string AdjustStringLength(std::string name, int length) return newstring; } +// Unordered map (wrap boost::unordered_map). -/* ************************************************************************* */ -// unordered map of values -/* ************************************************************************* */ template<class Key, class Object > class UnorderedMap { -public: + public: typedef boost::unordered_map<Key, Object > container_t; typedef typename container_t::iterator iterator; typedef typename container_t::const_iterator const_iterator; @@ -148,14 +138,15 @@ public: if(pos != m_value_map.end() ) { return (*pos).second; } else { - throw RuntimeErrorException("UnorderedMap::find() -> Error! Can't find the object"); + throw RuntimeErrorException( + "UnorderedMap::find() -> Error! Can't find the object"); } } size_t size() { return m_value_map.size(); } Object & operator[] (const Key &key) { return m_value_map[key]; } -private: + private: UnorderedMap &operator=(const UnorderedMap &); container_t m_value_map; diff --git a/Core/Tools/src/IParameterized.cpp b/Core/Tools/src/IParameterized.cpp index b2d5976587dd17b038174c957f1098aafeff8f14..b2bdf2a68bc2381cf2df603992fe284623d15d36 100644 --- a/Core/Tools/src/IParameterized.cpp +++ b/Core/Tools/src/IParameterized.cpp @@ -3,7 +3,8 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/src/IParameterized.cpp -//! @brief Implements class IParameterized, mainly by including IParametrized.h. +//! @brief Implements class IParameterized, +//! mainly by including IParameterized.h. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -16,21 +17,6 @@ #include "IParameterized.h" #include "Utils.h" -/* ************************************************************************* */ -// constructors -/* ************************************************************************* */ -IParameterized::IParameterized() : m_parameters(), m_status() -{ -} - -IParameterized::IParameterized(const std::string &name) : INamed(name), m_parameters(), m_status() -{ -} - -IParameterized::IParameterized(const IParameterized &other) : INamed(other), m_parameters(), m_status() -{ -} - IParameterized &IParameterized::operator=(const IParameterized &other) { if( this != &other) @@ -41,10 +27,10 @@ IParameterized &IParameterized::operator=(const IParameterized &other) return *this; } -/* ************************************************************************* */ -// create new parameter pool which contains all local parameter and parameters of children -// user have to delete it -/* ************************************************************************* */ +//! Create new parameter pool, with all local parameter and parameters of children + +//! User has to delete it. +//! ParameterPool *IParameterized::createParameterTree() const { ParameterPool *newpool = new ParameterPool; @@ -53,11 +39,10 @@ ParameterPool *IParameterized::createParameterTree() const return newpool; } +//! Add parameters from local pool to external pool and call recursion over direct children. -/* ************************************************************************* */ -// add parameters from local pool to external pool -/* ************************************************************************* */ -std::string IParameterized::addParametersToExternalPool(std::string path, ParameterPool *external_pool, int copy_number) const +std::string IParameterized::addParametersToExternalPool( + std::string path, ParameterPool *external_pool, int copy_number) const { // adding trailing slash, if it is not already there if( path[path.length()-1] != '/' ) path += "/"; @@ -80,10 +65,13 @@ void IParameterized::printParameters() const delete p_pool; } -/* ************************************************************************* */ -// No pure virtual function here, due to problems in exporting abstract classes to python -/* ************************************************************************* */ +//! Throw non-implemented exception (needed for Python). + +//! No pure virtual function here, +//! due to problems in exporting abstract classes to python +//! void IParameterized::init_parameters() { - throw NotImplementedException("IParameterized::init_parameters() -> Error! Method is not implemented"); + throw NotImplementedException("IParameterized::init_parameters() -> " + "Error! Method is not implemented"); } diff --git a/Core/Tools/src/OutputDataReadStrategy.cpp b/Core/Tools/src/OutputDataReadStrategy.cpp index a134df05d6ddc9448117eb3015063c668032b7f6..6619478863b03c4810151e39839747c8655e1723 100644 --- a/Core/Tools/src/OutputDataReadStrategy.cpp +++ b/Core/Tools/src/OutputDataReadStrategy.cpp @@ -3,7 +3,8 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/src/OutputDataReadStrategy.cpp -//! @brief Implements class OutputDataReadStrategy. +//! @brief Implements read functions for classes OutputDataReadStreamGZip, +//! OutputDataReadStreamIMA, OutputDataReadStreamV1. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -38,33 +39,33 @@ GCC_DIAG_OFF(unused-parameter); #include <string> GCC_DIAG_ON(unused-parameter); +//! Decorator to unzip stream. -/* ************************************************************************* */ -// decorator to unzip stream -/* ************************************************************************* */ -OutputData<double > *OutputDataReadStreamGZip::readOutputData(std::istream &input_stream) +OutputData<double> *OutputDataReadStreamGZip::readOutputData( + std::istream &input_stream) { - boost::iostreams::filtering_streambuf<boost::iostreams::input> input_filtered; + boost::iostreams::filtering_streambuf<boost::iostreams::input> + input_filtered; input_filtered.push(boost::iostreams::gzip_decompressor()); input_filtered.push(input_stream); std::istream incoming(&input_filtered); return m_read_strategy->readOutputData(incoming); } -/* ************************************************************************* */ -// read data from ASCII file (2D assumed) and fill newly created OutputData with it -/* ************************************************************************* */ -OutputData<double > *OutputDataReadStreamIMA::readOutputData(std::istream &input_stream) +//! Read data from ASCII file (2D assumed) into newly created OutputData. + +OutputData<double > *OutputDataReadStreamIMA::readOutputData( + std::istream &input_stream) { std::string sline; vdouble2d_t buff_2d; - // reading file line by line, every line is parsed into vector of double, so at the end we have buffer_2d of doubles + // reading file line by line, every line is parsed into vector of double, + // so at the end we have buffer_2d of doubles while( std::getline(input_stream, sline)) { std::string str = Utils::String::round_doubles(sline, 10); vdouble1d_t buff = Utils::String::parse_doubles(str); - buff_2d.push_back(buff); } @@ -88,17 +89,18 @@ OutputData<double > *OutputDataReadStreamIMA::readOutputData(std::istream &input return p_result; } -/* ************************************************************************* */ -// parsing stream of double's into OutputData object -// '#' - comments (not treated) -// ' ' - delimeter between double's -// Each line is 1D array (or 1D slice of 2D array -// Expected: -// line representing x bins [nX] -// line representing y bins [nY] -// [nX] lines of [nY] size representing data itself -/* ************************************************************************* */ -OutputData<double > *OutputDataReadStreamV1::readOutputData(std::istream &input_stream) +//! Parse stream of double's into OutputData object. + +//! '#' - comments (not treated) +//! ' ' - delimeter between double's +//! Each line is 1D array (or 1D slice of 2D array +//! Expected: +//! line representing x bins [nX] +//! line representing y bins [nY] +//! [nX] lines of [nY] size representing data itself +//! +OutputData<double> *OutputDataReadStreamV1::readOutputData( + std::istream &input_stream) { std::string sline; vdouble1d_t buff_xaxis, buff_yaxis; @@ -121,12 +123,15 @@ OutputData<double > *OutputDataReadStreamV1::readOutputData(std::istream &input_ // check consistency of y dimension and data buffer if( buff_data.size() != buff_yaxis.size()) { - throw LogicErrorException("OutputDataReadASCII::readOutputData() -> Error. Unconsistent y-size."); + throw LogicErrorException("OutputDataReadASCII::readOutputData() -> " + "Error. Unconsistent y-size."); } // check consistency of x dimension and data buffer for(size_t i = 0; i<buff_yaxis.size(); ++i) { if( buff_data[i].size() != buff_xaxis.size()) { - throw LogicErrorException("OutputDataReadASCII::readOutputData() -> Error. Unconsistent x-size."); + throw LogicErrorException( + "OutputDataReadASCII::readOutputData() -> " + "Error. Unconsistent x-size."); } } diff --git a/Core/Tools/src/OutputDataWriteStrategy.cpp b/Core/Tools/src/OutputDataWriteStrategy.cpp index 88b4cf1602b6b8932b35883bc7847eef0d7a04da..4376da6cfefd9621009982adf2345a97aa34faa9 100644 --- a/Core/Tools/src/OutputDataWriteStrategy.cpp +++ b/Core/Tools/src/OutputDataWriteStrategy.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/src/OutputDataWriteStrategy.cpp -//! @brief Implements class OutputDataWriteStrategy. +//! @brief Implements OutputDataWriteStreamIMA::writeOutputData. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -19,7 +19,7 @@ #include <sstream> #include <iomanip> -//! read data from ASCII file (2D assumed) and fill newly created OutputData with it +//! Read data from ASCII file (2D assumed) into newly created OutputData. void OutputDataWriteStreamIMA::writeOutputData(const OutputData<double> &data, std::ostream &output_stream) { diff --git a/Core/Tools/src/Utils.cpp b/Core/Tools/src/Utils.cpp index 8f65ca5f3197546b4da74c834166f824d62f0d8e..6b5007c507aa3989f3193e051653c2a414bc0b34 100644 --- a/Core/Tools/src/Utils.cpp +++ b/Core/Tools/src/Utils.cpp @@ -3,7 +3,7 @@ // BornAgain: simulate and fit scattering at grazing incidence // //! @file Tools/src/Utils.cpp -//! @brief Implements class Utils. +//! @brief Implements various stuff in namespace Utils. //! //! @homepage http://apps.jcns.fz-juelich.de/BornAgain //! @license GNU General Public License v3 or higher (see COPYING) @@ -23,15 +23,17 @@ std::string Utils::FileSystem::m_relative_path = "relative path is undefined"; -//! parse double values from string to vector of double +//! Parse double values from string to vector of double vdouble1d_t Utils::String::parse_doubles(const std::string &str) { vdouble1d_t buff_1d; std::istringstream iss(str); - std::copy(std::istream_iterator<double>(iss), std::istream_iterator<double>(), back_inserter(buff_1d)); + std::copy(std::istream_iterator<double>(iss), + std::istream_iterator<double>(), back_inserter(buff_1d)); if( buff_1d.empty() ) { - std::cout << "OutputDataReadFileASCII::parse_doubles() -> Warning! No parsed values in 1d vector of doubles." << std::endl; + std::cout << "OutputDataReadFileASCII::parse_doubles() -> " + "Warning! No parsed values in 1d vector of doubles." << std::endl; } return buff_1d; } @@ -85,23 +87,25 @@ bool Utils::String::MatchPattern(const std::string &text, std::string wildcardPa return boost::regex_match(text, pattern); } -//! split string into vector of string using delimeter +//! Split string into vector of string using delimeter. -std::vector<std::string> Utils::String::Split(const std::string &text, const std::string &delimeter) +std::vector<std::string> Utils::String::Split( + const std::string &text, const std::string &delimeter) { std::vector<std::string> tokens; boost::split(tokens, text, boost::is_any_of(delimeter)); return tokens; } -//! return path to the current (working) directory +//! Return path to the current (working) directory. std::string Utils::FileSystem::GetWorkingPath() { return boost::filesystem::current_path().string(); } -//! return path to BornAgain home directory +//! Return path to BornAgain home directory. + std::string Utils::FileSystem::GetHomePath() { // the path to executable module is: boost::filesystem::current_path() + argv[0] @@ -126,29 +130,34 @@ std::string Utils::FileSystem::GetHomePath() std::string project_name("BornAgain"); std::string::size_type pos = path.rfind(project_name); if(pos == std::string::npos) { - throw LogicErrorException("Utils::FileSystem::GetHomePath() -> Error. Cant parse path to application from line '"+path+"'"); + throw LogicErrorException( + "Utils::FileSystem::GetHomePath() -> " + "Error. Cant parse path to application from line '"+path+"'"); } path.erase(pos+project_name.size()); path += "/"; return path; } -//! return file extension +//! Return file extension. std::string Utils::FileSystem::GetFileExtension(const std::string &name) { return boost::filesystem::extension(name.c_str()); } -//! return true if name contains *.gz extension +//! Does name contain *.gz extension? + bool Utils::FileSystem::isGZipped(const std::string &name) { static const std::string gzip_extension(".gz"); - if ( Utils::FileSystem::GetFileExtension(name) == gzip_extension) return true; + if ( Utils::FileSystem::GetFileExtension(name) == gzip_extension) + return true; return false; } -//! return file main extension (without .gz) +//! Return file main extension (without .gz). + std::string Utils::FileSystem::GetFileMainExtension(const std::string &name) { if( !isGZipped(name) ) { diff --git a/Core/python_module.pri b/Core/python_module.pri index 6d070cc4d410966672a05a2190d70b881a649842..33b66fb39ea2492f4a5401b48a5d21c4f048313c 100644 --- a/Core/python_module.pri +++ b/Core/python_module.pri @@ -70,10 +70,6 @@ HEADERS += \ PythonAPI/inc/PythonInterface_free_functions.pypp.h \ PythonAPI/inc/PythonInterface_global_variables.pypp.h \ PythonAPI/inc/RealParameterWrapper.pypp.h \ - PythonAPI/inc/Rotate3D.pypp.h \ - PythonAPI/inc/RotateX3D.pypp.h \ - PythonAPI/inc/RotateY3D.pypp.h \ - PythonAPI/inc/RotateZ3D.pypp.h \ PythonAPI/inc/SimpleSelectionRule.pypp.h \ PythonAPI/inc/Simulation.pypp.h \ PythonAPI/inc/SimulationParameters.pypp.h \ @@ -160,10 +156,6 @@ SOURCES += \ PythonAPI/src/PythonInterface_free_functions.pypp.cpp \ PythonAPI/src/PythonInterface_global_variables.pypp.cpp \ PythonAPI/src/RealParameterWrapper.pypp.cpp \ - PythonAPI/src/Rotate3D.pypp.cpp \ - PythonAPI/src/RotateX3D.pypp.cpp \ - PythonAPI/src/RotateY3D.pypp.cpp \ - PythonAPI/src/RotateZ3D.pypp.cpp \ PythonAPI/src/SimpleSelectionRule.pypp.cpp \ PythonAPI/src/Simulation.pypp.cpp \ PythonAPI/src/SimulationParameters.pypp.cpp \ diff --git a/Fit/Fit.pro b/Fit/Fit.pro index ddb6211be830282d0ed799b4d4811bc3dd0c49b7..7f5537db9b0ae50c79415408aeece436ca5dc5f0 100644 --- a/Fit/Fit.pro +++ b/Fit/Fit.pro @@ -6,7 +6,7 @@ TEMPLATE = lib CONFIG += plugin # to remove versions from file name QT -= core gui QMAKE_EXTENSION_SHLIB = so # making standard *.so extension -CONFIG += BORNAGAIN_PYTHON +# CONFIG += BORNAGAIN_PYTHON CONFIG += BORNAGAIN_ROOT # -----------------------------------------------------------------------------