Skip to content
Snippets Groups Projects
Commit 9f175a23 authored by pospelov's avatar pospelov
Browse files

PythonAPI is restored

parent c6b479fd
No related branches found
No related tags found
No related merge requests found
......@@ -132,6 +132,26 @@ void register_Beam_class(){
Beam_exposer_t Beam_exposer = Beam_exposer_t( "Beam", bp::init< >() );
bp::scope Beam_scope( Beam_exposer );
Beam_exposer.def( bp::init< Beam const & >(( bp::arg("other") )) );
{ //::Beam::SetSpinUpFraction
typedef void ( ::Beam::*SetSpinUpFraction_function_type )( double ) ;
Beam_exposer.def(
"SetSpinUpFraction"
, SetSpinUpFraction_function_type( &::Beam::SetSpinUpFraction )
, ( bp::arg("up_fraction") ) );
}
{ //::Beam::checkPolarization
typedef bool ( ::Beam::*checkPolarization_function_type )( ::Eigen::Matrix2cd const & ) const;
Beam_exposer.def(
"checkPolarization"
, checkPolarization_function_type( &::Beam::checkPolarization )
, ( bp::arg("polarization") ) );
}
{ //::Beam::getCentralK
typedef ::cvector_t ( ::Beam::*getCentralK_function_type )( ) const;
......@@ -149,6 +169,15 @@ void register_Beam_class(){
"getIntensity"
, getIntensity_function_type( &::Beam::getIntensity ) );
}
{ //::Beam::getPolarization
typedef ::Eigen::Matrix2cd ( ::Beam::*getPolarization_function_type )( ) const;
Beam_exposer.def(
"getPolarization"
, getPolarization_function_type( &::Beam::getPolarization ) );
}
{ //::Beam::operator=
......@@ -190,6 +219,16 @@ void register_Beam_class(){
, setIntensity_function_type( &::Beam::setIntensity )
, ( bp::arg("intensity") ) );
}
{ //::Beam::setPolarization
typedef void ( ::Beam::*setPolarization_function_type )( ::Eigen::Matrix2cd const & ) ;
Beam_exposer.def(
"setPolarization"
, setPolarization_function_type( &::Beam::setPolarization )
, ( bp::arg("polarization") ) );
}
{ //::IParameterized::areParametersChanged
......
......@@ -14,14 +14,50 @@ GCC_DIAG_ON(missing-field-initializers);
namespace bp = boost::python;
struct HomogeneousMaterial_wrapper : HomogeneousMaterial, bp::wrapper< HomogeneousMaterial > {
HomogeneousMaterial_wrapper(HomogeneousMaterial const & arg )
: HomogeneousMaterial( arg )
, bp::wrapper< HomogeneousMaterial >(){
// copy constructor
}
HomogeneousMaterial_wrapper(::std::string const & name, ::complex_t const & refractive_index )
: HomogeneousMaterial( name, boost::ref(refractive_index) )
, bp::wrapper< HomogeneousMaterial >(){
// constructor
}
HomogeneousMaterial_wrapper(::std::string const & name, double refractive_index_delta, double refractive_index_beta )
: HomogeneousMaterial( name, refractive_index_delta, refractive_index_beta )
, bp::wrapper< HomogeneousMaterial >(){
// constructor
}
virtual bool isScalarMaterial( ) {
if( bp::override func_isScalarMaterial = this->get_override( "isScalarMaterial" ) )
return func_isScalarMaterial( );
else{
return this->IMaterial::isScalarMaterial( );
}
}
bool default_isScalarMaterial( ) {
return IMaterial::isScalarMaterial( );
}
};
void register_HomogeneousMaterial_class(){
{ //::HomogeneousMaterial
typedef bp::class_< HomogeneousMaterial, bp::bases< IMaterial > > HomogeneousMaterial_exposer_t;
typedef bp::class_< HomogeneousMaterial_wrapper, bp::bases< IMaterial > > HomogeneousMaterial_exposer_t;
HomogeneousMaterial_exposer_t HomogeneousMaterial_exposer = HomogeneousMaterial_exposer_t( "HomogeneousMaterial", bp::init< std::string const &, complex_t const & >(( bp::arg("name"), bp::arg("refractive_index") )) );
bp::scope HomogeneousMaterial_scope( HomogeneousMaterial_exposer );
HomogeneousMaterial_exposer.def( bp::init< std::string const &, double, double >(( bp::arg("name"), bp::arg("refractive_index_real"), bp::arg("refractive_index_imag") )) );
HomogeneousMaterial_exposer.def( bp::init< complex_t const & >(( bp::arg("refractive_index") )) );
HomogeneousMaterial_exposer.def( bp::init< std::string const &, double, double >(( bp::arg("name"), bp::arg("refractive_index_delta"), bp::arg("refractive_index_beta") )) );
{ //::HomogeneousMaterial::getRefractiveIndex
typedef ::complex_t ( ::HomogeneousMaterial::*getRefractiveIndex_function_type )( ) const;
......@@ -41,6 +77,17 @@ void register_HomogeneousMaterial_class(){
, ( bp::arg("refractive_index") ) );
}
{ //::IMaterial::isScalarMaterial
typedef bool ( ::IMaterial::*isScalarMaterial_function_type )( ) ;
typedef bool ( HomogeneousMaterial_wrapper::*default_isScalarMaterial_function_type )( ) ;
HomogeneousMaterial_exposer.def(
"isScalarMaterial"
, isScalarMaterial_function_type(&::IMaterial::isScalarMaterial)
, default_isScalarMaterial_function_type(&HomogeneousMaterial_wrapper::default_isScalarMaterial) );
}
}
}
......@@ -14,13 +14,53 @@ GCC_DIAG_ON(missing-field-initializers);
namespace bp = boost::python;
struct IMaterial_wrapper : IMaterial, bp::wrapper< IMaterial > {
IMaterial_wrapper(IMaterial const & arg )
: IMaterial( arg )
, bp::wrapper< IMaterial >(){
// copy constructor
}
IMaterial_wrapper(::std::string const & name )
: IMaterial( name )
, bp::wrapper< IMaterial >(){
// constructor
}
virtual bool isScalarMaterial( ) {
if( bp::override func_isScalarMaterial = this->get_override( "isScalarMaterial" ) )
return func_isScalarMaterial( );
else{
return this->IMaterial::isScalarMaterial( );
}
}
bool default_isScalarMaterial( ) {
return IMaterial::isScalarMaterial( );
}
};
void register_IMaterial_class(){
{ //::IMaterial
typedef bp::class_< IMaterial > IMaterial_exposer_t;
typedef bp::class_< IMaterial_wrapper > IMaterial_exposer_t;
IMaterial_exposer_t IMaterial_exposer = IMaterial_exposer_t( "IMaterial", bp::init< std::string const & >(( bp::arg("name") )) );
bp::scope IMaterial_scope( IMaterial_exposer );
IMaterial_exposer.def( bp::init< IMaterial const & >(( bp::arg("other") )) );
{ //::IMaterial::isScalarMaterial
typedef bool ( ::IMaterial::*isScalarMaterial_function_type )( ) ;
typedef bool ( IMaterial_wrapper::*default_isScalarMaterial_function_type )( ) ;
IMaterial_exposer.def(
"isScalarMaterial"
, isScalarMaterial_function_type(&::IMaterial::isScalarMaterial)
, default_isScalarMaterial_function_type(&IMaterial_wrapper::default_isScalarMaterial) );
}
}
}
......@@ -48,7 +48,7 @@ void register_MaterialManager_class(){
MaterialManager_exposer.def(
"getHomogeneousMaterial"
, getHomogeneousMaterial_function_type( &::MaterialManager::getHomogeneousMaterial )
, ( bp::arg("name"), bp::arg("refractive_index_real"), bp::arg("refractive_index_imag") )
, ( bp::arg("name"), bp::arg("refractive_index_delta"), bp::arg("refractive_index_beta") )
, bp::return_value_policy< bp::reference_existing_object >() );
}
......
......@@ -30,6 +30,8 @@ void register_global_variables(){
bp::scope().attr("degree") = Units::degree;
bp::scope().attr("gauss") = Units::gauss;
bp::scope().attr("meter") = Units::meter;
bp::scope().attr("micrometer") = Units::micrometer;
......@@ -52,4 +54,6 @@ void register_global_variables(){
bp::scope().attr("steradian") = Units::steradian;
bp::scope().attr("tesla") = Units::tesla;
}
......@@ -18,7 +18,6 @@
#include <string>
#include <iostream>
//#include <typeinfo>
#include "INamed.h"
//! Interface to a named material.
......@@ -29,9 +28,6 @@ class IMaterial : public INamed
//! Constructor that sets _name_.
explicit IMaterial(const std::string& name) : INamed(name) {}
//! Copy constructor. TODO: test whether needed
IMaterial(const IMaterial& other) : INamed(other) {}
//! Destructor.
virtual ~IMaterial() {}
......@@ -46,7 +42,6 @@ class IMaterial : public INamed
protected:
virtual void print(std::ostream& ostr) const
{ ostr << "IMat:" << getName() << "<" << this << ">"; }
// TODO: try ostr << typeid(*this).name() << " " << this;
};
#endif // IMATERIAL_H
......
......@@ -19,7 +19,7 @@ def RunSimulation():
# defining materials
mAmbience = MaterialManager.getHomogeneousMaterial("Air", 0.0, 0.0 )
# collection of particles
n_particle = complex(6e-4, 2e-8)
n_particle = complex(1.0 - 6e-4, 2e-8)
radius1 = 5.0*nanometer
radius2 = 10.0*nanometer
height1 = radius1
......
......@@ -26,7 +26,8 @@ include_dirs = [
'../../Core/Algorithms/inc',
'../../Core/Tools/inc',
'../../Core/PythonAPI/inc',
'../../Core/Geometry/inc'
'../../Core/Geometry/inc',
'../../ThirdParty/eigen3'
]
include_classes = [
......@@ -250,7 +251,7 @@ def MakePythonAPI(OutputTempDir):
print "NOTE: If you update the source library code you need to manually delete the cache_core.xml file, or run 'python codegenerator.py clean'"
xml_cached_fc = parser.create_cached_source_fc( "PythonCoreList.h", "cache_core.xml" )
#xml_cached_fc = parser.create_cached_source_fc( ["PythonCoreList.h","PythonCoreExposer.h"], "cache_core.xml" )
mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64")
mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64 -msse -msse2 -fno-strict-aliasing -msse3")
# -----------------
# general rules
......
......@@ -25,9 +25,9 @@ include_dirs = [
'../../Core/Algorithms/inc',
'../../Core/Tools/inc',
'../../Core/Geometry/inc',
'../../Core/Fitting/inc',
'../../Fit/Factory/inc',
'../../Fit/PythonAPI/inc'
'../../Fit/PythonAPI/inc',
'../../ThirdParty/eigen3',
]
include_classes = [
......@@ -100,7 +100,7 @@ def MakePythonAPI(OutputTempDir):
#If the cache file cache_core.xml doesn't exist it gets created, otherwise it just gets loaded
print "NOTE: If you update the source library code you need to manually delete the cache_fit.xml file, or run 'python codegenerator.py clean'"
xml_cached_fc = parser.create_cached_source_fc( "PythonFitList.h", "cache_fit.xml" )
mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64")
mb = module_builder.module_builder_t( [xml_cached_fc], include_paths=include_dirs, gccxml_path=mygccxml, cflags="-m64 -msse3")
# -----------------
# general rules
......
......@@ -2,8 +2,7 @@
# Common settings for all BornAgain compilations
# -----------------------------------------------------------------------------
#CONFIG += BORNAGAIN_PYTHON # provide python bindings compilation
CONFIG += BORNAGAIN_PYTHON # provide python bindings compilation
win32 {
MAKE_COMMAND = mingw32-make
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment