]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move and fix std::enable_if to a template parameter, fix test 7584/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 30 Jan 2019 20:05:36 +0000 (21:05 +0100)
committerGiovanni Alzetta <giovannialzetta@hotmail.it>
Fri, 8 Feb 2019 09:14:09 +0000 (10:14 +0100)
doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth [new file with mode: 0644]
include/deal.II/base/point.h
tests/base/point_04.cc
tests/base/point_04.output

diff --git a/doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth b/doc/news/changes/minor/20190131GiovanniAlzettaDanielArndtWolfgangBangerth
new file mode 100644 (file)
index 0000000..882d29c
--- /dev/null
@@ -0,0 +1,4 @@
+New: added constructor to the class Point, which converts
+a boost::geometry::model::point to a dealii::Point
+<br>
+(Giovanni Alzetta, Daniel Arndt, Wolfgang Bangerth, 2019/01/31)
index d486ae36c85865c1087e8cf70e64187e429f8104..093c87eaa3d6d27729796dae11e9c8ba0ed36bc1 100644 (file)
@@ -148,11 +148,11 @@ public:
   /**
    * Convert a boost::geometry::point to a dealii::Point.
    */
-  template <int dummy_dim>
+  template <std::size_t dummy_dim,
+            typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0),
+                                    int>::type = 0>
   Point(const boost::geometry::model::
-          point<Number, dummy_dim, boost::geometry::cs::cartesian> &boost_pt,
-        typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0),
-                                int>::type = 0);
+          point<Number, dummy_dim, boost::geometry::cs::cartesian> &boost_pt);
 
   /**
    * Return a unit vector in coordinate direction <tt>i</tt>, i.e., a vector
@@ -371,11 +371,12 @@ inline Point<dim, Number>::Point(const Number x, const Number y, const Number z)
 
 
 template <int dim, typename Number>
-template <int dummy_dim>
+template <
+  std::size_t dummy_dim,
+  typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), int>::type>
 inline Point<dim, Number>::Point(
   const boost::geometry::model::
-    point<Number, dummy_dim, boost::geometry::cs::cartesian> &boost_pt,
-  typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), int>::type)
+    point<Number, dummy_dim, boost::geometry::cs::cartesian> &boost_pt)
 {
   Assert(dim <= 3, ExcNotImplemented());
   this->values[0]                = boost::geometry::get<0>(boost_pt);
index 7dbb62241b5f04db54f3507cd5138b2f5f19c065..97613ae51f9ed5fd8937bdc90372b9f6a0898ba1 100644 (file)
 
 namespace bg = boost::geometry;
 
-template <int dim>
 void
-check()
+check3d()
 {
-  bg::model::point<double, dim, bg::cs::cartesian> bg_point;
+  bg::model::point<double, 3, boost::geometry::cs::cartesian> 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<y_index>(42.0 + dim);
+  for (unsigned int i = 0; i < 3; ++i)
+    deallog << p(i) << ' ';
+  deallog << std::endl;
+}
 
-  if (dim >= 3)
-    bg_point.set<z_index>(42.0 + dim + 1);
+void
+check2d()
+{
+  bg::model::point<double, 2, bg::cs::cartesian> point(2.0, 3.0);
 
-  Point<dim> 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<double, 1, bg::cs::cartesian> 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();
 }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1990993133321c2cfc8babccdceac18217e41108 100644 (file)
@@ -0,0 +1,4 @@
+
+DEAL::12.0 
+DEAL::2.00 3.00 
+DEAL::-1.00 2.00 0.150 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.