--- /dev/null
+New: Added BoundingBox::extend() that allows extending and shrinking of BoundingBox objects.
+<br>
+(Luca Heltai, 2019/04/11)
bool
point_inside(const Point<spacedim, Number> &p) const;
+ /**
+ * Increase (or decrease) the size of the bounding box by the given amount.
+ *
+ * If you call this method with a negative number, and one of the axes of the
+ * original bounding box is smaller than amount/2, the method will trigger
+ * an assertion.
+ */
+ void
+ extend(const Number &amount);
+
/**
* Compute the volume (i.e. the dim-dimensional measure) of the BoundingBox.
*/
this->boundary_points = boundary_points;
}
+template <int spacedim, typename Number>
+inline void
+BoundingBox<spacedim, Number>::extend(const Number &amount)
+{
+ for (unsigned int d = 0; d < spacedim; ++d)
+ {
+ boundary_points.first[d] -= amount;
+ boundary_points.second[d] += amount;
+ Assert(boundary_points.first[d] <= boundary_points.second[d],
+ ExcMessage("Bounding Box can't be shrinked this much: the points' "
+ "order should remain bottom left, top right."));
+ }
+}
+
template <int spacedim, typename Number>
template <class Archive>
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 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 BoundingBox::extend
+
+#include <deal.II/base/bounding_box.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+
+template <int dim>
+void
+test()
+{
+ Point<dim> p0, p1;
+ for (unsigned int d = 0; d < dim; ++d)
+ p1[d] = 1;
+
+ BoundingBox<dim> box({p0, p1});
+
+ box.extend(.5);
+
+ deallog << "New points: " << box.get_boundary_points().first << ", "
+ << box.get_boundary_points().second << std::endl;
+
+
+ box.extend(-.8);
+
+ deallog << "New points: " << box.get_boundary_points().first << ", "
+ << box.get_boundary_points().second << std::endl;
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test<1>();
+ test<2>();
+ test<3>();
+}
--- /dev/null
+
+DEAL::New points: -0.500000, 1.50000
+DEAL::New points: 0.300000, 0.700000
+DEAL::New points: -0.500000 -0.500000, 1.50000 1.50000
+DEAL::New points: 0.300000 0.300000, 0.700000 0.700000
+DEAL::New points: -0.500000 -0.500000 -0.500000, 1.50000 1.50000 1.50000
+DEAL::New points: 0.300000 0.300000 0.300000, 0.700000 0.700000 0.700000