Revision: 7717
http://cctbx.svn.sourceforge.net/cctbx/?rev=7717&view=rev
Author: luc_j_bourhis
Date: 2008-07-21 15:11:30 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
- the "using base_t::stretching" confused Visual Studio: remove them and domino effect
- simpler wrappers
Modified Paths:
--------------
trunk/smtbx/refinement/constraints/geometric_hydrogen.cpp
trunk/smtbx/refinement/constraints/geometric_hydrogen.h
Modified: trunk/smtbx/refinement/constraints/geometric_hydrogen.cpp
===================================================================
--- trunk/smtbx/refinement/constraints/geometric_hydrogen.cpp 2008-07-20 22:09:12 UTC (rev 7716)
+++ trunk/smtbx/refinement/constraints/geometric_hydrogen.cpp 2008-07-21 15:11:30 UTC (rev 7717)
@@ -14,157 +14,69 @@
namespace smtbx { namespace refinement { namespace constraints {
namespace boost_python {
-
-
-template<template<typename FloatType_bis,
- class XrayScattererType_bis,
- template<typename FloatType_ter> class SharedArray1D_>
- class ConstraintTemplate,
- typename FloatType=double,
- class XrayScattererType=xray::scatterer<> >
-struct few_scatterer_constraint_wrapper
+struct common_wrapper
{
- typedef ConstraintTemplate<FloatType,
- XrayScattererType,
- af::boost_python::flex_1d> wt;
-
- boost::python::class_<wt> wrapped;
-
- few_scatterer_constraint_wrapper(char const *name)
- : wrapped(name, boost::python::no_init)
- {
- using namespace boost::python;
+ template<class wt>
+ static void wrap(boost::python::class_<wt> &wrapped, char const *name) {
std::string array_name = std::string(name) + std::string("_array");
constraint_array_wrapper<wt>::wrap(array_name.c_str());
wrapped
- .def("compute_gradients", &wt::compute_gradients)
- .def("apply_shifts", &wt::apply_shifts)
- .def("place_constrained_scatterers", &wt::place_constrained_scatterers)
- ;
- }
-};
-
-template<template<typename FloatType_bis,
- class XrayScattererType_bis,
- template<typename FloatType_ter> class SharedArray1D>
- class ConstraintTemplate,
- typename FloatType=double,
- class XrayScattererType=xray::scatterer<> >
-struct hydrogen_constraint_wrapper
- : few_scatterer_constraint_wrapper<ConstraintTemplate,
- FloatType,
- XrayScattererType>
-{
- typedef few_scatterer_constraint_wrapper<ConstraintTemplate,
- FloatType,
- XrayScattererType> base_t;
- typedef typename base_t::wt wt;
- using base_t::wrapped;
-
- hydrogen_constraint_wrapper(char const *name)
- : base_t(name)
- {
- using namespace boost::python;
- wrapped
.add_property("pivot", &wt::pivot)
.add_property("hydrogens", &wt::hydrogens)
- .add_property("bond_length", &wt::bond_length, &wt::set_bond_length)
.add_property("stretching", &wt::stretching, &wt::set_stretching)
+ .add_property("bond_length", &wt::bond_length, &wt::set_bond_length)
+ .add_property("initialise_in_context", &wt::initialise_in_context)
+ .add_property("place_constrained_scatterers",
+ &wt::place_constrained_scatterers)
+ .add_property("compute_gradients", &wt::compute_gradients)
+ .add_property("apply_shifts", &wt::apply_shifts)
;
}
};
-template<template<typename FloatType_bis,
- class XrayScattererType_bis,
- template<typename FloatType_ter> class SharedArray1D>
- class ConstraintTemplate,
- int n_neighbours, int n_hydrogens,
- typename FloatType=double,
- class XrayScattererType=xray::scatterer<> >
-struct common_hydrogen_constraint_wrapper
- : hydrogen_constraint_wrapper<ConstraintTemplate,
- FloatType,
- XrayScattererType>
-{
- typedef hydrogen_constraint_wrapper<ConstraintTemplate,
- FloatType,
- XrayScattererType> base_t;
- typedef typename base_t::wt wt;
- typedef typename wt::float_type float_type;
- using base_t::wrapped;
-
- common_hydrogen_constraint_wrapper(char const *name)
- : base_t(name)
- {
- using namespace boost::python;
- wrapped
- .def(init<int,
- af::tiny<int, n_neighbours>,
- af::tiny<int, n_hydrogens>,
- float_type,
- bool>((
- arg("pivot"), arg("pivot_neighbours"),
- arg("hydrogens"),
- arg("bond_length"),
- arg("stretching")=false)))
- ;
- }
-};
-
template<typename FloatType=double,
class XrayScattererType=xray::scatterer<> >
struct terminal_X_Hn_wrapper
- : hydrogen_constraint_wrapper<terminal_X_Hn,
- FloatType,
- XrayScattererType>
{
- typedef hydrogen_constraint_wrapper<terminal_X_Hn,
- FloatType,
- XrayScattererType> base_t;
- typedef typename base_t::wt wt;
+ typedef terminal_X_Hn<FloatType, XrayScattererType, af::boost_python::flex_1d>
+ wt;
typedef typename wt::float_type float_type;
- using base_t::wrapped;
- terminal_X_Hn_wrapper(char const *name)
- : base_t(name)
- {
+ static void wrap(char const *name) {
using namespace boost::python;
+ class_<wt> wrapped(name, no_init);
+ common_wrapper::wrap(wrapped, name);
wrapped
- .def(init<int, int, af::small<int, 3>, float_type, float_type, bool, bool>
- ((arg("pivot"), arg("pivot_neighbour"),
- arg("hydrogens"),
- arg("azimuth"), arg("bond_length"),
- arg("rotating")=true, arg("stretching")=false)))
+ .def(init<int, int, af::small<int,3>, float_type, float_type, bool, bool>
+ ((arg("pivot"), arg("pivot_neighbour"), arg("hydrogens"),
+ arg("azimuth"), arg("bond_length"), arg("rotating")=true,
+ arg("stretching")=false)))
.add_property("rotating", &wt::rotating, &wt::set_rotating)
.add_property("azimuth", &wt::azimuth, &wt::set_azimuth)
.add_property("local_cartesian_frame", &wt::local_cartesian_frame)
;
- }
+ }
};
template<typename FloatType=double,
class XrayScattererType=xray::scatterer<> >
struct secondary_CH2_wrapper
- : common_hydrogen_constraint_wrapper<secondary_CH2, 2, 2,
- FloatType,
- XrayScattererType>
{
- typedef common_hydrogen_constraint_wrapper<secondary_CH2, 2, 2,
- FloatType,
- XrayScattererType>
- base_t;
- typedef typename base_t::wt wt;
+ typedef secondary_CH2<FloatType, XrayScattererType, af::boost_python::flex_1d>
+ wt;
typedef typename wt::float_type float_type;
- using base_t::wrapped;
- secondary_CH2_wrapper(char const *name)
- : base_t(name)
- {
+ static void wrap(char const *name) {
using namespace boost::python;
+ class_<wt> wrapped(name, no_init);
+ common_wrapper::wrap(wrapped, name);
wrapped
- .def_readwrite("theta0", wt::theta0)
- .def_readwrite("dtheta_over_dXY_sq", wt::dtheta_over_dXY_sq)
+ .def(init<int, af::tiny<int,2>, af::tiny<int,2>, float_type, bool>
+ ((arg("pivot"), arg("pivot_neighbours"), arg("hydrogens"),
+ arg("bond_length"), arg("stretching")=false)))
+ .def_readonly("theta0", wt::theta0)
+ .def_readonly("dtheta_over_dXY_sq", &wt::dtheta_over_dXY_sq)
;
}
};
@@ -172,35 +84,28 @@
template<typename FloatType=double,
class XrayScattererType=xray::scatterer<> >
struct tertiary_CH_wrapper
- : hydrogen_constraint_wrapper<tertiary_CH,
- FloatType,
- XrayScattererType>
{
- typedef hydrogen_constraint_wrapper<tertiary_CH,
- FloatType,
- XrayScattererType> base_t;
- typedef typename base_t::wt wt;
+ typedef tertiary_CH<FloatType, XrayScattererType, af::boost_python::flex_1d>
+ wt;
typedef typename wt::float_type float_type;
- using base_t::wrapped;
- tertiary_CH_wrapper(char const *name)
- : base_t(name)
- {
+ static void wrap(char const *name) {
using namespace boost::python;
+ class_<wt> wrapped(name, no_init);
+ common_wrapper::wrap(wrapped, name);
wrapped
- .def(init<int, af::tiny<int, 3>, int, float_type, bool>
- ((arg("pivot"), arg("pivot_neighbours"),
- arg("hydrogen"),
- arg("bond_length"),
- arg("stretching")=false)))
+ .def(init<int, af::tiny<int,3>, int, float_type, bool>
+ ((arg("pivot"), arg("pivot_neighbours"), arg("hydrogen"),
+ arg("bond_length"), arg("stretching")=false)))
;
}
};
+
void wrap_geometric_hydrogen() {
- terminal_X_Hn_wrapper<>("terminal_X_Hn");
- secondary_CH2_wrapper<>("secondary_CH2");
- tertiary_CH_wrapper<>("tertiary_CH");
+ terminal_X_Hn_wrapper<>::wrap("terminal_X_Hn");
+ secondary_CH2_wrapper<>::wrap("secondary_CH2");
+ tertiary_CH_wrapper<>::wrap("tertiary_CH");
}
}}}} // smtbx::refinement::constraints::boost_python
Modified: trunk/smtbx/refinement/constraints/geometric_hydrogen.h
===================================================================
--- trunk/smtbx/refinement/constraints/geometric_hydrogen.h 2008-07-20 22:09:12 UTC (rev 7716)
+++ trunk/smtbx/refinement/constraints/geometric_hydrogen.h 2008-07-21 15:11:30 UTC (rev 7717)
@@ -131,7 +131,6 @@
using base_t::i_hydrogens;
using base_t::l;
using base_t::on_;
- using base_t::stretching;
using base_t::i_reparametrization_begin;
typedef XrayScattererType xray_scatterer_type;
@@ -236,7 +235,7 @@
dx_over_dphi[i]
= l*sin_tetrahedral_angle*(-sin_phi[i]*e0 + cos_phi[i]*e1);
}
- if (stretching()) {
+ if (base_t::stretching()) {
dx_over_dl[i]
= sin_tetrahedral_angle*(cos_phi[i]*e0 + sin_phi[i]*e1) + e2/3;
}
@@ -259,7 +258,7 @@
crystallographic_parameter_map,
crystallographic_gradients);
- if (!rotating() && !stretching()) return;
+ if (!rotating() && !base_t::stretching()) return;
using namespace constants;
i_reparametrization_begin = reparametrization_gradients.size();
@@ -282,7 +281,7 @@
}
// stretching
- if (stretching()) {
+ if (base_t::stretching()) {
float_type dF_over_dl = 0;
for (int i=0; i < i_hydrogens.size(); ++i) {
dF_over_dl += dF_over_dx[i] * dx_over_dl[i];
@@ -306,7 +305,7 @@
float_type delta_phi = reparametrization_shifts[i_dF_over_dphi()];
phi += delta_phi;
}
- if (stretching()) {
+ if (base_t::stretching()) {
float_type delta_l = reparametrization_shifts[i_dF_over_dl()];
l += delta_l;
}
@@ -350,7 +349,6 @@
using base_t::i_hydrogens;
using base_t::l;
using base_t::on_;
- using base_t::stretching;
using base_t::i_reparametrization_begin;
typedef XrayScattererType xray_scatterer_type;
@@ -419,7 +417,7 @@
crystallographic_parameter_map,
crystallographic_gradients);
- if (!stretching()) return;
+ if (!base_t::stretching()) return;
i_reparametrization_begin = reparametrization_gradients.size();
float_type dF_over_dl = 0;
@@ -485,7 +483,6 @@
using base_t::i_hydrogens;
using base_t::l;
using base_t::on_;
- using base_t::stretching;
using base_t::i_reparametrization_begin;
typedef XrayScattererType xray_scatterer_type;
@@ -543,7 +540,7 @@
crystallographic_parameter_map,
crystallographic_gradients);
- if (stretching()) {
+ if (base_t::stretching()) {
i_reparametrization_begin = reparametrization_gradients.size();
int i_grad_site_h = crystallographic_parameter_map[i_hydrogens[0]].site;
frac_t dF_over_dx_frac(&crystallographic_gradients[i_grad_site_h]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|