#include <deal.II/base/exceptions.h>
#include <deal.II/base/tensor.h>
+#include <boost/geometry.hpp>
+
#include <cmath>
DEAL_II_NAMESPACE_OPEN
*/
Point(const Number x, const Number y, const Number z);
+ /**
+ * Convert a boost::geometry::point to a dealii::Point.
+ */
+ template <int dummy_dim = dim>
+ Point(const boost::geometry::model::
+ point<Number, dim, boost::geometry::cs::cartesian> &boost_pt,
+ typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0),
+ int>::type = 0);
+
/**
* Return a unit vector in coordinate direction <tt>i</tt>, i.e., a vector
* that is zero in all coordinates except for a single 1 in the <tt>i</tt>th
}
+
+template <int dim, typename Number>
+template <int dummy_dim>
+inline Point<dim, Number>::Point(
+ const boost::geometry::model::
+ point<Number, dim, boost::geometry::cs::cartesian> &boost_pt,
+ typename std::enable_if<(dim == dummy_dim) && (dummy_dim != 0), int>::type)
+{
+ Assert(dim <= 3, ExcNotImplemented());
+ this->values[0] = boost::geometry::get<0>(boost_pt);
+ constexpr unsigned int y_index = (dim < 2) ? 0 : 1;
+ constexpr unsigned int z_index = (dim < 3) ? 0 : 2;
+
+ if (dim >= 2)
+ this->values[y_index] = boost::geometry::get<y_index>(boost_pt);
+
+ if (dim >= 3)
+ this->values[z_index] = boost::geometry::get<z_index>(boost_pt);
+}
+
+
+
template <int dim, typename Number>
inline Point<dim, Number>
Point<dim, Number>::unit_vector(unsigned int i)
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+// test for Point::operator()
+
+#include <deal.II/base/point.h>
+
+#include <deal.II/lac/vector.h>
+
+#include <boost/geometry.hpp>
+
+#include "../tests.h"
+
+namespace bg = boost::geometry;
+
+template <int dim>
+void
+check()
+{
+ bg::model::point<double, dim, bg::cs::cartesian> bg_point;
+
+ constexpr unsigned int y_index = (spacedim < 2) ? 0 : 1;
+ constexpr unsigned int z_index = (spacedim < 3) ? 0 : 2;
+
+ bg_point.set<0>(42.0);
+
+ if (dim >= 2)
+ bg_point.set<y_index>(42.0 + dim);
+
+ if (dim >= 3)
+ bg_point.set<z_index>(42.0 + dim + 1);
+
+ Point<dim> p(bg_point);
+
+ for (unsigned int i = 0; i < dim; ++i)
+ deallog << p(i) << ' ';
+ deallog << std::endl;
+}
+
+int
+main()
+{
+ initlog();
+ deallog << std::setprecision(3);
+
+ check<1>();
+ check<2>();
+ check<3>();
+}