From 165278a2279a79806cea1e3ffea24d4d02305420 Mon Sep 17 00:00:00 2001 From: Alexander Grayver Date: Thu, 3 Sep 2020 09:45:30 +0200 Subject: [PATCH] Add an incompatibility note and optional args --- .../include/triangulation_wrapper.h | 4 ++- .../source/export_triangulation.cc | 12 ++++++-- .../source/triangulation_wrapper.cc | 28 +++++++++++++++---- .../changes/incompatibilities/20200901Grayver | 3 ++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20200901Grayver diff --git a/contrib/python-bindings/include/triangulation_wrapper.h b/contrib/python-bindings/include/triangulation_wrapper.h index 18269119c8..4d34e525bc 100644 --- a/contrib/python-bindings/include/triangulation_wrapper.h +++ b/contrib/python-bindings/include/triangulation_wrapper.h @@ -236,7 +236,9 @@ namespace python /*! @copydoc GridGenerator::merge_triangulations */ void - merge_triangulations(boost::python::list &triangulations); + merge_triangulations(boost::python::list &triangulations, + const double duplicated_vertex_tolerance = 1.0e-12, + const bool copy_manifold_ids = false); /*! @copydoc GridGenerator::replicate_triangulation */ diff --git a/contrib/python-bindings/source/export_triangulation.cc b/contrib/python-bindings/source/export_triangulation.cc index 9c2db2508a..14b9163e73 100644 --- a/contrib/python-bindings/source/export_triangulation.cc +++ b/contrib/python-bindings/source/export_triangulation.cc @@ -111,6 +111,10 @@ namespace python find_active_cell_around_point, 1, 2) + BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(merge_triangulations_overloads, + merge_triangulations, + 1, + 3) const char n_active_cells_docstring[] = "Return the number of active cells. \n"; @@ -319,7 +323,7 @@ namespace python - const char merge_docstring[] = + const char merge_triangulations_docstring[] = "Given two or more triangulations, create the triangulation that \n" "contains the cells of given triangulations. \n"; @@ -622,8 +626,10 @@ namespace python boost::python::args("self", "scaling_factor")) .def("merge_triangulations", &TriangulationWrapper::merge_triangulations, - merge_docstring, - boost::python::args("self", "triangulations")) + merge_triangulations_overloads( + boost::python::args( + "self", "triangulations", "vertex_tolerance", "copy_manifolds"), + merge_triangulations_docstring)) .def("extrude_triangulation", &TriangulationWrapper::extrude_triangulation, extrude_docstring, diff --git a/contrib/python-bindings/source/triangulation_wrapper.cc b/contrib/python-bindings/source/triangulation_wrapper.cc index e5e48cb0db..019b79dc60 100644 --- a/contrib/python-bindings/source/triangulation_wrapper.cc +++ b/contrib/python-bindings/source/triangulation_wrapper.cc @@ -515,7 +515,9 @@ namespace python template void merge_triangulations(boost::python::list &triangulations, - void * triangulation) + void * triangulation, + const double duplicated_vertex_tolerance, + const bool copy_manifold_ids) { Triangulation *tria = static_cast *>(triangulation); @@ -531,7 +533,10 @@ namespace python tria_wrapper.get_triangulation())); } - GridGenerator::merge_triangulations(tria_ptrs, *tria); + GridGenerator::merge_triangulations(tria_ptrs, + *tria, + duplicated_vertex_tolerance, + copy_manifold_ids); } @@ -1436,7 +1441,9 @@ namespace python void TriangulationWrapper::merge_triangulations( - boost::python::list &triangulations) + boost::python::list &triangulations, + const double duplicated_vertex_tolerance, + const bool copy_manifold_ids) { AssertThrow(boost::python::len(triangulations) >= 2, ExcMessage( @@ -1457,11 +1464,20 @@ namespace python } if ((dim == 2) && (spacedim == 2)) - internal::merge_triangulations<2, 2>(triangulations, triangulation); + internal::merge_triangulations<2, 2>(triangulations, + triangulation, + duplicated_vertex_tolerance, + copy_manifold_ids); else if ((dim == 2) && (spacedim == 3)) - internal::merge_triangulations<2, 3>(triangulations, triangulation); + internal::merge_triangulations<2, 3>(triangulations, + triangulation, + duplicated_vertex_tolerance, + copy_manifold_ids); else - internal::merge_triangulations<3, 3>(triangulations, triangulation); + internal::merge_triangulations<3, 3>(triangulations, + triangulation, + duplicated_vertex_tolerance, + copy_manifold_ids); } diff --git a/doc/news/changes/incompatibilities/20200901Grayver b/doc/news/changes/incompatibilities/20200901Grayver new file mode 100644 index 0000000000..0715f29b4b --- /dev/null +++ b/doc/news/changes/incompatibilities/20200901Grayver @@ -0,0 +1,3 @@ +Replaced: Python wrapper for 'merge_triangulations' with a more generic equivalent. +
+(Alexander Grayver, 2020/09/01) -- 2.39.5