From 37b8b74857bf1a60c1984213c97b7c235636c569 Mon Sep 17 00:00:00 2001 From: Alexander Grayver Date: Wed, 12 Feb 2020 16:08:50 +0100 Subject: [PATCH] Add extra CylindricalManifold constructor --- .../include/manifold_wrapper.h | 9 ++++- .../python-bindings/source/export_manifold.cc | 20 ++++++++-- .../source/export_tria_accessor.cc | 7 ++++ .../source/manifold_wrapper.cc | 40 +++++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) diff --git a/contrib/python-bindings/include/manifold_wrapper.h b/contrib/python-bindings/include/manifold_wrapper.h index 2e9f0c8eb1..dc7838ecc6 100644 --- a/contrib/python-bindings/include/manifold_wrapper.h +++ b/contrib/python-bindings/include/manifold_wrapper.h @@ -62,11 +62,18 @@ namespace python create_polar(const PointWrapper center); /** - * Create CylindricalManifold. + * Create CylindricalManifold along the fixed axis. */ void create_cylindrical(const int axis = 0, const double tolerance = 1e-10); + /** + * Create CylindricalManifold with the given orientation. + */ + void + create_cylindrical(const boost::python::list &direction, + const boost::python::list &axial_point); + /** * Create FunctionManifold with string expressions for the push * forward and pull back functions. diff --git a/contrib/python-bindings/source/export_manifold.cc b/contrib/python-bindings/source/export_manifold.cc index 87a3fe533d..dda1220f95 100644 --- a/contrib/python-bindings/source/export_manifold.cc +++ b/contrib/python-bindings/source/export_manifold.cc @@ -45,11 +45,16 @@ namespace python " forward and pull back functions. \n"; - const char create_cylindrical_docstring[] = - " Create cylindrical manifold along a given axis \n" + const char create_cylindrical_fixed_docstring[] = + " Create cylindrical manifold oriented along a given axis \n" " (0 - x, 1 - y, 2 - z). \n"; + const char create_cylindrical_direction_docstring[] = + " Create cylindrical manifold with an axis that points in \n" + " direction direction and goes through the given point on \n" + " axis. \n"; + void export_manifold() @@ -67,10 +72,17 @@ namespace python create_polar_docstring, boost::python::args("self", "center")) .def("create_cylindrical", - &ManifoldWrapper::create_cylindrical, + static_cast( + &ManifoldWrapper::create_cylindrical), create_cylindrical_overloads( boost::python::args("self", "axis", "tolerance"), - create_cylindrical_docstring)) + create_cylindrical_fixed_docstring)) + .def("create_cylindrical", + static_cast( + &ManifoldWrapper::create_cylindrical), + create_cylindrical_direction_docstring, + boost::python::args("self", "direction", "axial_point")) .def("create_function", &ManifoldWrapper::create_function, create_function_docstring, diff --git a/contrib/python-bindings/source/export_tria_accessor.cc b/contrib/python-bindings/source/export_tria_accessor.cc index 9ac2c0f66f..37b315d665 100644 --- a/contrib/python-bindings/source/export_tria_accessor.cc +++ b/contrib/python-bindings/source/export_tria_accessor.cc @@ -35,6 +35,9 @@ namespace python const char barycenter_docstring[] = "Return the barycenter of the current face \n"; + const char center_docstring[] = + "Return the center of the current face taking into account manifold.\n"; + const char set_vertex_docstring[] = " Set the ith vertex of the face to point_wrapper \n"; @@ -65,6 +68,10 @@ namespace python &TriaAccessorWrapper::get_barycenter, barycenter_docstring, boost::python::args("self")) + .def("center", + &TriaAccessorWrapper::get_center, + barycenter_docstring, + boost::python::args("self")) .def("set_vertex", &TriaAccessorWrapper::set_vertex, set_vertex_docstring, diff --git a/contrib/python-bindings/source/manifold_wrapper.cc b/contrib/python-bindings/source/manifold_wrapper.cc index f5ccf84f49..973dcc2308 100644 --- a/contrib/python-bindings/source/manifold_wrapper.cc +++ b/contrib/python-bindings/source/manifold_wrapper.cc @@ -57,6 +57,24 @@ namespace python + template + Manifold * + create_cylindrical_manifold(const boost::python::list &direction_list, + const boost::python::list &axial_point_list) + { + Tensor<1, spacedim> direction; + for (int d = 0; d < spacedim; ++d) + direction[d] = boost::python::extract(direction_list[d]); + + Point axial_point; + for (int d = 0; d < spacedim; ++d) + axial_point[d] = boost::python::extract(axial_point_list[d]); + + return new CylindricalManifold(direction, axial_point); + } + + + template Manifold * create_function_manifold(const std::string &push_forward, @@ -255,6 +273,28 @@ namespace python + void + ManifoldWrapper::create_cylindrical(const boost::python::list &direction, + const boost::python::list &axial_point) + { + if ((dim == 2) && (spacedim == 3)) + { + manifold_ptr = + internal::create_cylindrical_manifold<2, 3>(direction, axial_point); + } + else if ((dim == 3) && (spacedim == 3)) + { + manifold_ptr = + internal::create_cylindrical_manifold<3, 3>(direction, axial_point); + } + else + AssertThrow(false, + ExcMessage( + "Given dim-spacedim combination is not implemented.")); + } + + + void ManifoldWrapper::create_function_string(const std::string &push_forward, const std::string &pull_back) -- 2.39.5