From: Daniel Arndt Date: Wed, 30 Jan 2019 20:05:36 +0000 (+0100) Subject: Move and fix std::enable_if to a template parameter, fix test X-Git-Tag: v9.1.0-rc1~360^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7584%2Fhead;p=dealii.git Move and fix std::enable_if to a template parameter, fix test --- diff --git a/doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth b/doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth new file mode 100644 index 0000000000..882d29c7cb --- /dev/null +++ b/doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth @@ -0,0 +1,4 @@ +New: added constructor to the class Point, which converts +a boost::geometry::model::point to a dealii::Point +
+(Giovanni Alzetta, Daniel Arndt, Wolfgang Bangerth, 2019/01/31) diff --git a/include/deal.II/base/point.h b/include/deal.II/base/point.h index d486ae36c8..093c87eaa3 100644 --- a/include/deal.II/base/point.h +++ b/include/deal.II/base/point.h @@ -148,11 +148,11 @@ public: /** * Convert a boost::geometry::point to a dealii::Point. */ - template + template ::type = 0> Point(const boost::geometry::model:: - point &boost_pt, - typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), - int>::type = 0); + point &boost_pt); /** * Return a unit vector in coordinate direction i, i.e., a vector @@ -371,11 +371,12 @@ inline Point::Point(const Number x, const Number y, const Number z) template -template +template < + std::size_t dummy_dim, + typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), int>::type> inline Point::Point( const boost::geometry::model:: - point &boost_pt, - typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), int>::type) + point &boost_pt) { Assert(dim <= 3, ExcNotImplemented()); this->values[0] = boost::geometry::get<0>(boost_pt); diff --git a/tests/base/point_04.cc b/tests/base/point_04.cc index 7dbb62241b..97613ae51f 100644 --- a/tests/base/point_04.cc +++ b/tests/base/point_04.cc @@ -26,37 +26,50 @@ namespace bg = boost::geometry; -template void -check() +check3d() { - bg::model::point bg_point; + bg::model::point point(-1.0, + 2.0, + 0.15); - constexpr unsigned int y_index = (spacedim < 2) ? 0 : 1; - constexpr unsigned int z_index = (spacedim < 3) ? 0 : 2; + Point<3> p(point); - bg_point.set<0>(42.0); - - if (dim >= 2) - bg_point.set(42.0 + dim); + for (unsigned int i = 0; i < 3; ++i) + deallog << p(i) << ' '; + deallog << std::endl; +} - if (dim >= 3) - bg_point.set(42.0 + dim + 1); +void +check2d() +{ + bg::model::point point(2.0, 3.0); - Point p(bg_point); + Point<2> p(point); - for (unsigned int i = 0; i < dim; ++i) + for (unsigned int i = 0; i < 2; ++i) deallog << p(i) << ' '; deallog << std::endl; } +void +check1d() +{ + bg::model::point point(12.0); + + Point<1> p(point); + + deallog << p(0) << ' '; + deallog << std::endl; +} + int main() { initlog(); deallog << std::setprecision(3); - check<1>(); - check<2>(); - check<3>(); + check1d(); + check2d(); + check3d(); } diff --git a/tests/base/point_04.output b/tests/base/point_04.output index e69de29bb2..1990993133 100644 --- a/tests/base/point_04.output +++ b/tests/base/point_04.output @@ -0,0 +1,4 @@ + +DEAL::12.0 +DEAL::2.00 3.00 +DEAL::-1.00 2.00 0.150