diff --git a/CMakeLists.txt b/CMakeLists.txt index ba1c57dd6ab0405cb9c956f9a613be85caf1ce8e..1556db88df8bdf325814e429c9b86e07f914fa09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -318,6 +318,9 @@ message(STATUS " Compound Lib (-DCOMPOUND_LIB) : ${_COMP_LIB}\n" " TMAlign and TMScore (-DCOMPILE_TMTOOLS) : ${_TM_TOOLS}\n" " Static Libraries (-DENABLE_STATIC) : ${ENABLE_STATIC}\n" - " Debian-style 'libexec' (-DDEBIAN_STYLE_LIBEXEC) : ${_DEBIAN_STYLE_LIBEXEC}\n" - " Hidden object visibility (-DHIDDEN_VISIBILITY) : ${_HIDDEN_VIS}") + " Debian-style 'libexec' (-DDEBIAN_STYLE_LIBEXEC) : ${_DEBIAN_STYLE_LIBEXEC}") +if (CMAKE_COMPILER_IS_GNUCXX) + message(STATUS + " Hidden object visibility (-DHIDDEN_VISIBILITY) : ${_HIDDEN_VIS}") +endif() diff --git a/examples/code_fragments/dokk/ligand.py b/examples/code_fragments/dokk/ligand.py index 4fc297ebc0f961e1e7e13db2bd43f18b8fd8cdcf..2683aaddb139c60ea561964057774079c4c72cb7 100644 --- a/examples/code_fragments/dokk/ligand.py +++ b/examples/code_fragments/dokk/ligand.py @@ -100,7 +100,7 @@ class Ligand: shift_vec = geom.Vec3(float(self.config.start["POSX"]), float(self.config.start["POSY"]), float(self.config.start["POSZ"])) - transf = mol.Transform() + transf = geom.Transform() transf.SetTrans(shift_vec) edi.SetTransform(transf.GetMatrix()) self.RotateAxis(geom.Vec3(1,0,0), float(self.config.start["ROTX"])) @@ -123,4 +123,4 @@ class Ligand: if dot>0: vec-=dot*p.GetNormal() return vec - return vec \ No newline at end of file + return vec diff --git a/examples/code_fragments/dokk/spnav_input.py b/examples/code_fragments/dokk/spnav_input.py index e51798578ed9842c8d4a75ec8b22481d997fa426..6f1a9de953ef00196588011c823b3cfe5744096a 100644 --- a/examples/code_fragments/dokk/spnav_input.py +++ b/examples/code_fragments/dokk/spnav_input.py @@ -39,7 +39,7 @@ class SpnavInputDevice(QtCore.QObject): def InputChanged(self, tx,ty,tz,rx,ry,rz): if (not self._lock_input) and (self.level is not None): ligand = self.level.ligand - transf = mol.Transform() + transf = geom.Transform() if(self.trans): delta = geom.Vec3 ((tx/480.0)*self._trans_factor, (ty/480.0)*self._trans_factor, (-tz/480.0)*self._trans_factor) transf.SetTrans(delta) diff --git a/modules/geom/pymod/CMakeLists.txt b/modules/geom/pymod/CMakeLists.txt index f79aeac4c2f9c8c127e28b0071c0ef502ba0ac38..5988cc95b1235d1b578e74b738469d002d3b2f0b 100644 --- a/modules/geom/pymod/CMakeLists.txt +++ b/modules/geom/pymod/CMakeLists.txt @@ -14,6 +14,7 @@ set(OST_GEOM_PYMOD_SOURCES export_composite2_op.cc export_composite3_op.cc export_quat.cc + export_transform.cc ) if (NOT ENABLE_STATIC) diff --git a/modules/mol/base/pymod/export_transform.cc b/modules/geom/pymod/export_transform.cc similarity index 91% rename from modules/mol/base/pymod/export_transform.cc rename to modules/geom/pymod/export_transform.cc index 1dc8bdc16bb6df0ba9f55693ebd0866da449400e..b2f921246bd2b6bedc90fa786aaa58f58b045ac5 100644 --- a/modules/mol/base/pymod/export_transform.cc +++ b/modules/geom/pymod/export_transform.cc @@ -18,14 +18,10 @@ //------------------------------------------------------------------------------ #include <boost/python.hpp> -#include <ost/mol/transform.hh> -#if(OST_INFO_ENABLED) -#include <ost/info/info.hh> -#endif +#include <ost/geom/transform.hh> using namespace boost::python; -using namespace ost; -using namespace ost::mol; +using namespace geom; void export_Transform() { @@ -56,8 +52,4 @@ void export_Transform() .def("ApplyZAxisTranslation",&Transform::ApplyZAxisTranslation) .def("ApplyAxisRotation",&Transform::ApplyAxisRotation) ; -#if(OST_INFO_ENABLED) - def("TransformToInfo", &TransformToInfo); - def("TransformFromInfo", &TransformFromInfo); -#endif } diff --git a/modules/geom/pymod/wrap_geom.cc b/modules/geom/pymod/wrap_geom.cc index 76bb7930057165463a426f60e133f15314b00618..14df2fa8b1fc2dbcff97f1f9913ca2861bc584e7 100644 --- a/modules/geom/pymod/wrap_geom.cc +++ b/modules/geom/pymod/wrap_geom.cc @@ -35,6 +35,7 @@ extern void export_Composite3(); extern void export_Composite2_op(); extern void export_Composite3_op(); extern void export_Quat(); +extern void export_Transform(); namespace details { #if (defined(OST_STATIC_PROPERTY_WORKAROUND)) @@ -64,6 +65,7 @@ BOOST_PYTHON_MODULE(_ost_geom) export_Composite2_op(); export_Composite3_op(); export_Quat(); + export_Transform(); #if (defined(OST_STATIC_PROPERTY_WORKAROUND)) // workaround for a problem with boost python and python 2.6.3/4 diff --git a/modules/geom/src/CMakeLists.txt b/modules/geom/src/CMakeLists.txt index b20b7d2439b5f58f2d5e2f936513fb4cda16dd8d..40f33282a196138eda009046a886606702360a9f 100644 --- a/modules/geom/src/CMakeLists.txt +++ b/modules/geom/src/CMakeLists.txt @@ -25,7 +25,7 @@ composite3_op.hh aligned_cuboid.hh vec_mat_predicates.hh quat.hh - +transform.hh point_cloud.hh module_config.hh ) @@ -43,6 +43,7 @@ composite3.cc composite2_op.cc composite3_op.cc quat.cc +transform.cc aligned_cuboid.cc point_cloud.cc ) diff --git a/modules/geom/src/geom.hh b/modules/geom/src/geom.hh index 138e8da92f7e78a45051f0123a4e6301c5ad9a6f..2bf028ab5b825a8a9eb100ba1c4d35e27626a640 100644 --- a/modules/geom/src/geom.hh +++ b/modules/geom/src/geom.hh @@ -29,5 +29,6 @@ #include "composite_op.hh" #include "quat.hh" #include "aligned_cuboid.hh" +#include "transform.hh" #endif diff --git a/modules/mol/base/src/transform.cc b/modules/geom/src/transform.cc similarity index 78% rename from modules/mol/base/src/transform.cc rename to modules/geom/src/transform.cc index ba1e59258299ca1f6011ddc1ebe1582aafba222b..d2a07f6ab0a701d0194bdcd1a4d300f039017f1f 100644 --- a/modules/mol/base/src/transform.cc +++ b/modules/geom/src/transform.cc @@ -18,18 +18,13 @@ //------------------------------------------------------------------------------ #include <ost/config.hh> -#if(OST_INFO_ENABLED) -#include <ost/info/info.hh> -#include <ost/info/geom_info_conversion.hh> -#endif #include <ost/log.hh> -#include "transform.hh" - -namespace ost { -using namespace geom; +#include "transform.hh" +#include "vecmat3_op.hh" +#include "vecmat4_op.hh" -namespace mol { +namespace geom { Transform::Transform(): rot_(Mat3(1,0,0, 0,1,0, 0,0,1)), @@ -207,7 +202,7 @@ void Transform::update_tm() try { itm_ = Invert(tm_); } catch (GeomException& e) { - LOG_WARNING("caught GeomException in Transform::update_tm: " << e.what()); + std::cerr << "caught GeomException in Transform::update_tm: " << e.what() << std::endl; itm_=geom::Mat4(); } } @@ -221,36 +216,4 @@ void Transform::update_components() trans_[2] = tm_(3,2); } -#if(OST_INFO_ENABLED) -Transform TransformFromInfo(const info::InfoGroup& group) -{ - if (!group.HasItem("center")) { - throw info::InfoError("Error while loading transform from info: " - "Group does not contain a center element"); - } - if (!group.HasGroup("rotation")) { - throw info::InfoError("Error while loading transform from info: " - "Group does not contain a rotation element"); - } - if (!group.HasItem("translation")) { - throw info::InfoError("Error while loading transform from info: " - "Group does not contain a translation element"); - } - Transform tf; - tf.SetCenter(group.GetItem("center").AsVector()); - tf.SetTrans(group.GetItem("translation").AsVector()); - tf.SetRot(info::Mat3FromInfo(group.GetGroup("rotation"))); - return tf; -} - -void TransformToInfo(const Transform& transform, info::InfoGroup& group) -{ - Transform tf; - group.CreateItem("center", transform.GetCenter()); - group.CreateItem("translation", transform.GetTrans()); - info::InfoGroup rot=group.CreateGroup("rotation"); - info::Mat3ToInfo(transform.GetRot(), rot); -} -#endif - -}} // ns +} // ns diff --git a/modules/mol/base/src/transform.hh b/modules/geom/src/transform.hh similarity index 53% rename from modules/mol/base/src/transform.hh rename to modules/geom/src/transform.hh index f9c59f6f5095256795b90e105d8067f20f1e6772..997f763950d7f94a7f7c6df35ea11f210b40847d 100644 --- a/modules/mol/base/src/transform.hh +++ b/modules/geom/src/transform.hh @@ -16,37 +16,44 @@ // along with this library; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA //------------------------------------------------------------------------------ -#ifndef OST_MOL_BASE_TRANSFORM_HH -#define OST_MOL_BASE_TRANSFORM_HH +#ifndef OST_GEOM_TRANSFORM_HH +#define OST_GEOM_TRANSFORM_HH /* Author: Ansgar Philippsen */ #include <ost/config.hh> -#include <ost/geom/geom.hh> -#if(OST_INFO_ENABLED) -#include <ost/info/info_fw.hh> -#endif -#include <ost/mol/module_config.hh> -namespace ost { namespace mol { +#include "module_config.hh" +#include "vec3.hh" +#include "vec4.hh" +#include "mat3.hh" +#include "mat.hh" +#include "aligned_cuboid.hh" + +namespace geom { /// \brief basic and essential transformation class, including translation, /// rotation and center of rotation -class DLLEXPORT_OST_MOL Transform { +class DLLEXPORT_OST_GEOM Transform { public: Transform(); - geom::Mat4 GetMatrix() const {return tm_;} - geom::Mat4 GetTransposedMatrix() const {return ttm_;} - geom::Mat4 GetInvertedMatrix() const {return itm_;} + /// \brief retrieve transformation matrix + Mat4 GetMatrix() const {return tm_;} + /// \brief retrieve transposed transformation matrix + Mat4 GetTransposedMatrix() const {return ttm_;} + /// \brief retrieve inverted transformation matrix + Mat4 GetInvertedMatrix() const {return itm_;} - void SetCenter(const geom::Vec3& c); - geom::Vec3 GetCenter() const; + /// \brief set center of rotation + void SetCenter(const Vec3& c); + /// \brief retrieve center of rotation + Vec3 GetCenter() const; // directly set tm, messing up rot/trans/cen ! - void SetMatrix(const geom::Mat4& m); + void SetMatrix(const Mat4& m); /// \name rotation //@{ @@ -54,51 +61,40 @@ public: void ApplyXAxisRotation(float delta); void ApplyYAxisRotation(float delta); void ApplyZAxisRotation(float delta); - void ApplyAxisRotation(float delta, const geom::Vec3& axis); + void ApplyAxisRotation(float delta, const Vec3& axis); - geom::Mat3 GetXAxisRotation(float delta); - geom::Mat3 GetYAxisRotation(float delta); - geom::Mat3 GetZAxisRotation(float delta); + Mat3 GetXAxisRotation(float delta); + Mat3 GetYAxisRotation(float delta); + Mat3 GetZAxisRotation(float delta); - geom::Mat3 GetRot() const; - void SetRot(const geom::Mat3& r); + Mat3 GetRot() const; + void SetRot(const Mat3& r); //@} /// \brief translation //@{ void ApplyXAxisTranslation(float delta); void ApplyYAxisTranslation(float delta); void ApplyZAxisTranslation(float delta); - void SetTrans(const geom::Vec3& t); - geom::Vec3 GetTrans() const; + void SetTrans(const Vec3& t); + Vec3 GetTrans() const; //@} - geom::Vec3 Apply(const geom::Vec3& v) const; - geom::Vec4 Apply(const geom::Vec4& v) const; - geom::AlignedCuboid Apply(const geom::AlignedCuboid& c) const; + Vec3 Apply(const Vec3& v) const; + Vec4 Apply(const Vec4& v) const; + AlignedCuboid Apply(const AlignedCuboid& c) const; private: - geom::Mat3 rot_; - geom::Vec3 trans_; - geom::Vec3 cen_; - geom::Mat4 tm_; - geom::Mat4 ttm_; - geom::Mat4 itm_; + Mat3 rot_; + Vec3 trans_; + Vec3 cen_; + Mat4 tm_; + Mat4 ttm_; + Mat4 itm_; void update_tm(); void update_components(); }; - - -#if(OST_INFO_ENABLED) -/// \brief read transformation from info group -/// \relates Transform -Transform DLLEXPORT_OST_MOL TransformFromInfo(const info::InfoGroup& group); -/// \brief store transformation in info group -/// \relates Transform -void DLLEXPORT_OST_MOL TransformToInfo(const Transform& transform, - info::InfoGroup& group); -#endif -}} // ns +} // ns #endif diff --git a/modules/geom/tests/CMakeLists.txt b/modules/geom/tests/CMakeLists.txt index 027a167490b6256249a53a4cf1e569a237f3c8af..e4056c27878386828af14e91f2c56ee40e1566a6 100644 --- a/modules/geom/tests/CMakeLists.txt +++ b/modules/geom/tests/CMakeLists.txt @@ -11,6 +11,7 @@ set(GEOM_UNITTESTS test_vec2.cc test_vec3.cc test_vec4.cc + test_transform.cc tests.cc test_geom.py ) diff --git a/modules/mol/base/tests/test_transform.cc b/modules/geom/tests/test_transform.cc similarity index 92% rename from modules/mol/base/tests/test_transform.cc rename to modules/geom/tests/test_transform.cc index 5c950acc5a170448290be09dde71d76fad5e8e66..5f4a543fd8ecfa21c3a3ac78a0a4b88d24ee36f9 100644 --- a/modules/mol/base/tests/test_transform.cc +++ b/modules/geom/tests/test_transform.cc @@ -22,14 +22,11 @@ #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> #include <boost/test/auto_unit_test.hpp> -#include <ost/mol/mol.hh> -#include <ost/mol/transform.hh> #include <ost/geom/geom.hh> -using namespace ost; -using namespace ost::mol; +using namespace geom; -BOOST_AUTO_TEST_SUITE( mol_base ); +BOOST_AUTO_TEST_SUITE( geom_base ); BOOST_AUTO_TEST_CASE(test_transform) { diff --git a/modules/img/alg/pymod/wrap_alg.cc b/modules/img/alg/pymod/wrap_alg.cc index c141fe11310076374194677f601e98a1929eb446..7185f34021a1b70e7f6a8f380896ec7feeafcdc6 100644 --- a/modules/img/alg/pymod/wrap_alg.cc +++ b/modules/img/alg/pymod/wrap_alg.cc @@ -54,7 +54,7 @@ using namespace ost; using namespace ost::img; -using namespace ost::img::alg; +//using namespace ost::img::alg; using namespace boost::python; // fw decl @@ -63,11 +63,8 @@ void export_Normalizer(); void export_Transcendentals(); void export_Polar(); -using namespace ost::img; -using namespace ost::img::alg; - namespace { -list get_histo_bins(const Histogram& hist) { +list get_histo_bins(const alg::Histogram& hist) { list result; const std::vector<int>& bins = hist.GetBins(); for(std::vector<int>::const_iterator it=bins.begin();it!=bins.end();++it) { @@ -76,32 +73,32 @@ list get_histo_bins(const Histogram& hist) { return result; } -void frac_shift0(FractionalShift* s) +void frac_shift0(alg::FractionalShift* s) { s->SetShift(); } -void frac_shift1(FractionalShift* s, Real sx) +void frac_shift1(alg::FractionalShift* s, Real sx) { s->SetShift(sx); } -void frac_shift2(FractionalShift* s, Real sx, Real sy) +void frac_shift2(alg::FractionalShift* s, Real sx, Real sy) { s->SetShift(sx,sy); } -void frac_shift3(FractionalShift* s, Real sx, Real sy, Real sz) +void frac_shift3(alg::FractionalShift* s, Real sx, Real sy, Real sz) { s->SetShift(sx,sy,sz); } -void frac_shift4(FractionalShift* s, const Vec2& v) +void frac_shift4(alg::FractionalShift* s, const Vec2& v) { s->SetShift(v); } -void frac_shift5(FractionalShift* s, const Vec3& v) +void frac_shift5(alg::FractionalShift* s, const Vec3& v) { s->SetShift(v); } @@ -109,7 +106,7 @@ void frac_shift5(FractionalShift* s, const Vec3& v) Real real_spatial_cross_correlation_1(const ConstImageHandle& image1, const ConstImageHandle& image2) { - return RealSpatialCrossCorrelation(image1,image2); + return alg::RealSpatialCrossCorrelation(image1,image2); } @@ -117,94 +114,94 @@ Real real_spatial_cross_correlation_2(const ConstImageHandle& image1, const ConstImageHandle& image2, const Extent& extent) { - return RealSpatialCrossCorrelation(image1,image2,extent); + return alg::RealSpatialCrossCorrelation(image1,image2,extent); } } //anon ns BOOST_PYTHON_MODULE(_ost_img_alg) { - class_<AutoCorrelate, bases<ConstModOPAlgorithm> >("AutoCorrelate",init<>()); + class_<alg::AutoCorrelate, bases<ConstModOPAlgorithm> >("AutoCorrelate",init<>()); - class_<Clear,bases<ConstModIPAlgorithm> >("Clear", init<>()); + class_<alg::Clear,bases<ConstModIPAlgorithm> >("Clear", init<>()); - class_<Conj,bases<ConstModIPAlgorithm> >("Conj", init<>()); + class_<alg::Conj,bases<ConstModIPAlgorithm> >("Conj", init<>()); - class_<ExplicitConvolute,bases<ConstModOPAlgorithm> >("ExplicitConvolute", init<const ConstImageHandle&,optional<bool> >()); + class_<alg::ExplicitConvolute,bases<ConstModOPAlgorithm> >("ExplicitConvolute", init<const ConstImageHandle&,optional<bool> >()); - class_<ExplicitCorrelate,bases<ConstModOPAlgorithm> >("ExplicitCorrelate", init<const ConstImageHandle&>()); + class_<alg::ExplicitCorrelate,bases<ConstModOPAlgorithm> >("ExplicitCorrelate", init<const ConstImageHandle&>()); - class_<CrossCorrelate,bases<ConstModIPAlgorithm> >("CrossCorrelate", init<const ConstImageHandle&>()); + class_<alg::CrossCorrelate,bases<ConstModIPAlgorithm> >("CrossCorrelate", init<const ConstImageHandle&>()); - class_<DFT,bases<ConstModOPAlgorithm> >("DFT", init<>()); + class_<alg::DFT,bases<ConstModOPAlgorithm> >("DFT", init<>()); - class_<FFT,bases<ConstModOPAlgorithm> >("FFT", init<>()); + class_<alg::FFT,bases<ConstModOPAlgorithm> >("FFT", init<>()); - class_<PowerSpectrum,bases<ConstModOPAlgorithm> >("PowerSpectrum",init<>()); + class_<alg::PowerSpectrum,bases<ConstModOPAlgorithm> >("PowerSpectrum",init<>()); - class_<Fill,bases<ConstModIPAlgorithm> >("Fill", init<const Complex&>()) + class_<alg::Fill,bases<ConstModIPAlgorithm> >("Fill", init<const Complex&>()) .def(init<Real>()) ; - class_<Threshold,bases<ConstModIPAlgorithm> >("Threshold", init<const Complex&>()) + class_<alg::Threshold,bases<ConstModIPAlgorithm> >("Threshold", init<const Complex&>()) .def(init<Real>()) ; - class_<DensitySlice,bases<ConstModIPAlgorithm> >("DensitySlice", + class_<alg::DensitySlice,bases<ConstModIPAlgorithm> >("DensitySlice", init<const Complex&,const Complex&>()) .def(init<Real,Real>()) ; - class_<ClipMinMax,bases<ConstModIPAlgorithm> >("ClipMinMax", + class_<alg::ClipMinMax,bases<ConstModIPAlgorithm> >("ClipMinMax", init<const Complex&,const Complex&>()) .def(init<Real,Real>()) ; - class_<Histogram, bases<NonModAlgorithm> >("Histogram", init<int,Real,Real>() ) + class_<alg::Histogram, bases<NonModAlgorithm> >("Histogram", init<int,Real,Real>() ) .def("GetBins",get_histo_bins) ; - class_<Negate,bases<ConstModIPAlgorithm> >("Negate", init<>()); - - class_<Stat, bases<NonModAlgorithm> >("Stat", init<>() ) - .def("GetMean",&Stat::GetMean) - .def("SetMean",&Stat::SetMean) - .def("GetMinimum",&Stat::GetMinimum) - .def("GetMinimumPosition",&Stat::GetMinimumPosition) - .def("SetMinimum",&Stat::SetMinimum) - .def("GetMaximum",&Stat::GetMaximum) - .def("GetMaximumPosition",&Stat::GetMaximumPosition) - .def("SetMaximum",&Stat::SetMaximum) - .def("GetSum",&Stat::GetSum) - .def("GetRootMeanSquare",&Stat::GetRootMeanSquare) - .def("GetSkewness",&Stat::GetSkewness) - .def("GetKurtosis",&Stat::GetKurtosis) - .def("GetVariance",&Stat::GetVariance) - .def("SetVariance",&Stat::SetVariance) - .def("GetStandardDeviation",&Stat::GetStandardDeviation) - .def("SetStandardDeviation",&Stat::SetStandardDeviation) - .def("GetCenterOfMass",&Stat::GetCenterOfMass) + class_<alg::Negate,bases<ConstModIPAlgorithm> >("Negate", init<>()); + + class_<alg::Stat, bases<NonModAlgorithm> >("Stat", init<>() ) + .def("GetMean",&alg::Stat::GetMean) + .def("SetMean",&alg::Stat::SetMean) + .def("GetMinimum",&alg::Stat::GetMinimum) + .def("GetMinimumPosition",&alg::Stat::GetMinimumPosition) + .def("SetMinimum",&alg::Stat::SetMinimum) + .def("GetMaximum",&alg::Stat::GetMaximum) + .def("GetMaximumPosition",&alg::Stat::GetMaximumPosition) + .def("SetMaximum",&alg::Stat::SetMaximum) + .def("GetSum",&alg::Stat::GetSum) + .def("GetRootMeanSquare",&alg::Stat::GetRootMeanSquare) + .def("GetSkewness",&alg::Stat::GetSkewness) + .def("GetKurtosis",&alg::Stat::GetKurtosis) + .def("GetVariance",&alg::Stat::GetVariance) + .def("SetVariance",&alg::Stat::SetVariance) + .def("GetStandardDeviation",&alg::Stat::GetStandardDeviation) + .def("SetStandardDeviation",&alg::Stat::SetStandardDeviation) + .def("GetCenterOfMass",&alg::Stat::GetCenterOfMass) .def(self_ns::str(self)) ; - class_<StatMinMax, bases<NonModAlgorithm> >("StatMinMax", init<>() ) - .def("GetMinimum",&StatMinMax::GetMinimum) - .def("GetMinimumPosition",&StatMinMax::GetMinimumPosition) - .def("SetMinimum",&StatMinMax::SetMinimum) - .def("GetMaximum",&StatMinMax::GetMaximum) - .def("GetMaximumPosition",&StatMinMax::GetMaximumPosition) - .def("SetMaximum",&StatMinMax::SetMaximum) + class_<alg::StatMinMax, bases<NonModAlgorithm> >("StatMinMax", init<>() ) + .def("GetMinimum",&alg::StatMinMax::GetMinimum) + .def("GetMinimumPosition",&alg::StatMinMax::GetMinimumPosition) + .def("SetMinimum",&alg::StatMinMax::SetMinimum) + .def("GetMaximum",&alg::StatMinMax::GetMaximum) + .def("GetMaximumPosition",&alg::StatMinMax::GetMaximumPosition) + .def("SetMaximum",&alg::StatMinMax::SetMaximum) .def(self_ns::str(self)) ; - class_<Randomize,bases<ConstModIPAlgorithm> >("Randomize", init<>()); + class_<alg::Randomize,bases<ConstModIPAlgorithm> >("Randomize", init<>()); - class_<MaskImage, bases<ConstModIPAlgorithm> >("MaskImage",init<const MaskPtr&,optional<bool> >()) + class_<alg::MaskImage, bases<ConstModIPAlgorithm> >("MaskImage",init<const MaskPtr&,optional<bool> >()) ; - class_<SmoothMaskImage, bases<ModIPAlgorithm> >("SmoothMaskImage",init<const MaskPtr&, Real, optional<bool> >()) + class_<alg::SmoothMaskImage, bases<ModIPAlgorithm> >("SmoothMaskImage",init<const MaskPtr&, Real, optional<bool> >()) ; - class_<LocalSigmaThreshold, bases<ConstModOPAlgorithm> >("LocalSigmaThreshold", init<int,Real>() ); + class_<alg::LocalSigmaThreshold, bases<ConstModOPAlgorithm> >("LocalSigmaThreshold", init<int,Real>() ); export_Filter(); export_Normalizer(); @@ -212,34 +209,34 @@ BOOST_PYTHON_MODULE(_ost_img_alg) export_Transcendentals(); - class_<Transformation>("Transformation", init<>()) + class_<alg::Transformation>("Transformation", init<>()) .def(init<const Mat4&>()) .def(init<const Mat4&, const Mat4&>()) ; - class_<Rotate2D, bases<Transformation> >("Rotate2D", init<Real>() ); - class_<Rotate2D90, bases<Transformation> >("Rotate2D90", init<int>() ); - class_<Scale, bases<Transformation> >("Scale", init<Real>() ); - class_<Translate, bases<Transformation> >("Translate", init<const Vec3&>() ); + class_<alg::Rotate2D, bases<alg::Transformation> >("Rotate2D", init<Real>() ); + class_<alg::Rotate2D90, bases<alg::Transformation> >("Rotate2D90", init<int>() ); + class_<alg::Scale, bases<alg::Transformation> >("Scale", init<Real>() ); + class_<alg::Translate, bases<alg::Transformation> >("Translate", init<const Vec3&>() ); - class_<Transform,bases<ConstModOPAlgorithm> >("Transform",init<>()) - .def(init<const Transformation&, optional<const Vec3&> >()) + class_<alg::Transform,bases<ConstModOPAlgorithm> >("Transform",init<>()) + .def(init<const alg::Transformation&, optional<const Vec3&> >()) ; - class_<Shift,bases<ConstModOPAlgorithm> >("Shift",init<>()) + class_<alg::Shift,bases<ConstModOPAlgorithm> >("Shift",init<>()) .def(init<const Point&>()) ; - class_<Mirror,bases<ConstModOPAlgorithm> >("Mirror",init<>()) + class_<alg::Mirror,bases<ConstModOPAlgorithm> >("Mirror",init<>()) .def(init<int>()) ; - class_<DiscreteShrink, bases<ConstModOPAlgorithm> >("DiscreteShrink",init<optional<const Size&> >()) - .def("SetBlocksize",&DiscreteShrink::SetBlocksize) - .def("GetBlocksize",&DiscreteShrink::GetBlocksize) + class_<alg::DiscreteShrink, bases<ConstModOPAlgorithm> >("DiscreteShrink",init<optional<const Size&> >()) + .def("SetBlocksize",&alg::DiscreteShrink::SetBlocksize) + .def("GetBlocksize",&alg::DiscreteShrink::GetBlocksize) ; - class_<FractionalShift, bases<ModIPAlgorithm> >("FractionalShift", init<optional <Real,Real,Real> >() ) + class_<alg::FractionalShift, bases<ModIPAlgorithm> >("FractionalShift", init<optional <Real,Real,Real> >() ) .def(init<const Vec3&>()) .def("SetShift",frac_shift0) .def("SetShift",frac_shift1) @@ -247,22 +244,22 @@ BOOST_PYTHON_MODULE(_ost_img_alg) .def("SetShift",frac_shift3) .def("SetShift",frac_shift4) .def("SetShift",frac_shift5) - .def("GetShift",&FractionalShift::GetShift) + .def("GetShift",&alg::FractionalShift::GetShift) ; - class_<LineAverage, bases<ConstModOPAlgorithm> >("LineAverage", init<>() ) + class_<alg::LineAverage, bases<ConstModOPAlgorithm> >("LineAverage", init<>() ) .def(init<unsigned int>()) - .def("GetGeometry",&LineAverage::GetGeometry) - .def("SetGeometry",&LineAverage::SetGeometry) + .def("GetGeometry",&alg::LineAverage::GetGeometry) + .def("SetGeometry",&alg::LineAverage::SetGeometry) ; def("RealSpatialCrossCorrelation",real_spatial_cross_correlation_1); def("RealSpatialCrossCorrelation",real_spatial_cross_correlation_2); - class_<HighestPeakSearch3D, bases<NonModAlgorithm> >("HighestPeakSearch3D" ,init<int,int,Real>()) + class_<alg::HighestPeakSearch3D, bases<NonModAlgorithm> >("HighestPeakSearch3D" ,init<int,int,Real>()) .def(init<int,int>()) .def(init<int>()) .def(init<>()) - .def("GetPeakList",&HighestPeakSearch3D::GetPeakList) - .def("ClearPeakList",&HighestPeakSearch3D::ClearPeakList) + .def("GetPeakList",&alg::HighestPeakSearch3D::GetPeakList) + .def("ClearPeakList",&alg::HighestPeakSearch3D::ClearPeakList) ; } diff --git a/modules/img/alg/tests/test_transform.cc b/modules/img/alg/tests/test_transform.cc index 2721c3369d73805d7ec99675f08d085e74210d01..62a12549d8e66ea390c61ca8535f474d348d8af0 100644 --- a/modules/img/alg/tests/test_transform.cc +++ b/modules/img/alg/tests/test_transform.cc @@ -33,21 +33,20 @@ namespace { using namespace ost::img; -using namespace ost::img::alg; void test() { alg::Randomize rnd; - Transform transform; + alg::Transform transform; } void test_point() { Point p0(3,-2,1); Point p1a(9,-6,3); - Point p1b(Scale(3.0).Apply(p0)); + Point p1b(alg::Scale(3.0).Apply(p0)); Point p2a(Point(2,3,1)); - Point p2b=Rotate2D(M_PI_2).Apply(p0); + Point p2b=alg::Rotate2D(M_PI_2).Apply(p0); std::ostringstream msg; msg << p1a << " != " << p1b; @@ -61,9 +60,9 @@ void test_extent() { Extent e0(Point(0,0),Point(2,3)); Extent e1a(Point(-1,-1),Point(7,10)); - Extent e1b=Scale(3.0).Apply(e0); + Extent e1b=alg::Scale(3.0).Apply(e0); Extent e2a(Point(-3,0),Point(0,2)); - Extent e2b=Rotate2D(M_PI_2).Apply(e0); + Extent e2b=alg::Rotate2D(M_PI_2).Apply(e0); std::ostringstream msg; msg << e1a << " != " << e1b; @@ -74,10 +73,10 @@ void test_extent() e0=Extent(Point(-3,-2),Size(8,10)); e1a=Extent(Point(-10,-7),Size(24,30)); - e1b=Scale(3.0).Apply(e0); + e1b=alg::Scale(3.0).Apply(e0); e2a=Extent(Point(-7,-3),Size(10,8)); - e2b=Rotate2D(M_PI_2).Apply(e0); + e2b=alg::Rotate2D(M_PI_2).Apply(e0); msg.str(""); msg << e1a << " != " << e1b; diff --git a/modules/info/pymod/wrap_info.cc b/modules/info/pymod/wrap_info.cc index 4af9741d63430f0964b415d83410641ab9d54762..cf15c736d937cccbd6f910e3646aba3c8448d97a 100644 --- a/modules/info/pymod/wrap_info.cc +++ b/modules/info/pymod/wrap_info.cc @@ -314,4 +314,8 @@ BOOST_PYTHON_MODULE(_ost_info) class_<VerboseInfoVisitor, bases<InfoVisitor> >("VerboseInfoVisitor",init<>()) ; + + def("TransformToInfo", &TransformToInfo); + def("TransformFromInfo", &TransformFromInfo); + } diff --git a/modules/info/src/geom_info_conversion.cc b/modules/info/src/geom_info_conversion.cc index 8c7681be583ed4464f1e6460dcf32a3e541aa4c9..8e5711904bb103d9ce0237b051e7c799bb0071e9 100644 --- a/modules/info/src/geom_info_conversion.cc +++ b/modules/info/src/geom_info_conversion.cc @@ -80,4 +80,35 @@ geom::Mat4 Mat4FromInfo(const InfoGroup& group) return mat; } -}} +geom::Transform TransformFromInfo(const InfoGroup& group) +{ + if (!group.HasItem("center")) { + throw InfoError("Error while loading transform from info: " + "Group does not contain a center element"); + } + if (!group.HasGroup("rotation")) { + throw InfoError("Error while loading transform from info: " + "Group does not contain a rotation element"); + } + if (!group.HasItem("translation")) { + throw InfoError("Error while loading transform from info: " + "Group does not contain a translation element"); + } + geom::Transform tf; + tf.SetCenter(group.GetItem("center").AsVector()); + tf.SetTrans(group.GetItem("translation").AsVector()); + tf.SetRot(Mat3FromInfo(group.GetGroup("rotation"))); + return tf; +} + +void TransformToInfo(const geom::Transform& transform, InfoGroup& group) +{ + geom::Transform tf; + group.CreateItem("center", transform.GetCenter()); + group.CreateItem("translation", transform.GetTrans()); + InfoGroup rot=group.CreateGroup("rotation"); + Mat3ToInfo(transform.GetRot(), rot); +} + +}} // ns + diff --git a/modules/info/src/geom_info_conversion.hh b/modules/info/src/geom_info_conversion.hh index cb06e05ebeefa521ae05daab60c28c8f551663f4..bab90abec02b82cfbf701a75dcd258db88b9bbaa 100644 --- a/modules/info/src/geom_info_conversion.hh +++ b/modules/info/src/geom_info_conversion.hh @@ -53,6 +53,15 @@ void DLLEXPORT_OST_INFO Mat4ToInfo(const geom::Mat4& mat, InfoGroup& group); ///\brief load Mat4 from info geom::Mat4 DLLEXPORT_OST_INFO Mat4FromInfo(const InfoGroup& group); + +/// \brief read transformation from info group +/// \relates Transform +geom::Transform DLLEXPORT_OST_INFO TransformFromInfo(const info::InfoGroup& group); +/// \brief store transformation in info group +/// \relates Transform +void DLLEXPORT_OST_INFO TransformToInfo(const geom::Transform& transform, + info::InfoGroup& group); + //@} }} diff --git a/modules/mol/base/pymod/CMakeLists.txt b/modules/mol/base/pymod/CMakeLists.txt index 6e158771aa0c9e3b2608203469f9b3afc65e5708..3f514b2b8afba9e8f95473898b9649da2b3afcb7 100644 --- a/modules/mol/base/pymod/CMakeLists.txt +++ b/modules/mol/base/pymod/CMakeLists.txt @@ -18,7 +18,6 @@ export_bounding_box.cc export_query_view_wrapper.cc export_torsion.cc export_visitor.cc -export_transform.cc wrap_mol.cc export_entity_property_mapper.cc ) diff --git a/modules/mol/base/pymod/__init__.py b/modules/mol/base/pymod/__init__.py index 8eb77fa6d3055f6259d7d1aa4c31ccffb9da7098..c51905578ce1f422598c5769f2717f69c4039e0f 100644 --- a/modules/mol/base/pymod/__init__.py +++ b/modules/mol/base/pymod/__init__.py @@ -20,6 +20,17 @@ from _ost_mol import * import ost.geom as _geom from ost.mol import alg +__transform_warning_flag=True + +def Transform(tf=None): + from ost import LogWarning + if __transform_warning_flag: + LogWarning("mol.Transform is deprecated, please use geom.Transform instead") + __transform_warning_flag=False + if tf: + return _geom.Transform(tf) + else: + return _geom.Transform() def MergeCoordGroups(*coord_groups): """ diff --git a/modules/mol/base/pymod/wrap_mol.cc b/modules/mol/base/pymod/wrap_mol.cc index 31cf8165b463460f346fc6d1ec820ceb317edb65..0c1281ad8f9b490790e32902e0f8822e559be33b 100644 --- a/modules/mol/base/pymod/wrap_mol.cc +++ b/modules/mol/base/pymod/wrap_mol.cc @@ -42,7 +42,6 @@ void export_PropertyID(); void export_BoundingBox(); void export_QueryViewWrapper(); void export_EntityPropertyMapper(); -void export_Transform(); BOOST_PYTHON_MODULE(_ost_mol) { @@ -71,5 +70,4 @@ BOOST_PYTHON_MODULE(_ost_mol) export_BoundingBox(); export_QueryViewWrapper(); export_EntityPropertyMapper(); - export_Transform(); } diff --git a/modules/mol/base/src/CMakeLists.txt b/modules/mol/base/src/CMakeLists.txt index 7c92f9f45ca67bef9452a829ef6e6de6e933c5ff..8bb7187ebe9d229fe4aad338a71e53674e22ae3f 100644 --- a/modules/mol/base/src/CMakeLists.txt +++ b/modules/mol/base/src/CMakeLists.txt @@ -31,7 +31,6 @@ residue_view.cc surface_builder.cc surface_handle.cc torsion_handle.cc -transform.cc query_view_wrapper.cc view_op.cc coord_source.cc @@ -87,13 +86,13 @@ surface_builder.hh surface_handle.hh surface_prop.hh torsion_handle.hh -transform.hh query_view_wrapper.hh view_op.hh view_type_fw.hh view_op.hh xcs_editor.hh bounding_box.hh +transform.hh module_config.hh) foreach(_impl_src ${OST_MOL_IMPL_SOURCES}) diff --git a/modules/mol/base/src/coord_group.hh b/modules/mol/base/src/coord_group.hh index 74fffcb6c45d47f2e0f0e3c469e5174a07a31cab..573ab8ffb59ffc19b1ac78eac5979821dbc4344e 100644 --- a/modules/mol/base/src/coord_group.hh +++ b/modules/mol/base/src/coord_group.hh @@ -28,9 +28,12 @@ #include "atom_handle.hh" #include "coord_source.hh" -namespace ost { namespace mol { +namespace geom { + // we should really have fw headers... + class Transform; +} -class Transform; +namespace ost { namespace mol { /// \brief coordinate group, for trajectories and such class DLLEXPORT_OST_MOL CoordGroupHandle { diff --git a/modules/mol/base/src/coord_source.hh b/modules/mol/base/src/coord_source.hh index a33162abc4e14a95a94e1414aa90401cb47bd0af..51cfe0717f2a98a408b7eecd87654a7bcff3ec4c 100644 --- a/modules/mol/base/src/coord_source.hh +++ b/modules/mol/base/src/coord_source.hh @@ -27,11 +27,14 @@ #include <ost/mol/coord_frame.hh> #include <ost/mol/entity_handle.hh> +namespace geom { + // we should really have fw headers... + class Transform; +} namespace ost { namespace mol { class CoordSource; -class Transform; typedef boost::shared_ptr<CoordSource> CoordSourcePtr; diff --git a/modules/mol/base/tests/CMakeLists.txt b/modules/mol/base/tests/CMakeLists.txt index c29dc6adfe3d5ec1bbe2e85a5a587940b35848c2..5085b0b10b257fab18361001a1cb7a55b796769d 100644 --- a/modules/mol/base/tests/CMakeLists.txt +++ b/modules/mol/base/tests/CMakeLists.txt @@ -10,7 +10,6 @@ set(OST_MOL_BASE_UNIT_TESTS test_query.cc test_surface.cc test_residue.cc - test_transform.cc test_view.cc test_view_op.cc tests.cc