BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
bounding_box_helpers.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef bempp_bounding_box_helpers_hpp
22 #define bempp_bounding_box_helpers_hpp
23 
24 #include "common.hpp"
25 #include "armadillo_fwd.hpp"
26 #include "bounding_box.hpp"
27 
28 #include <cassert>
29 #include <cmath>
30 
31 namespace Bempp
32 {
33 
40 template <typename CoordinateType>
42  const arma::Mat<CoordinateType>& points)
43 {
44  assert(points.n_rows == 3);
45  for (size_t j = 0; j < points.n_cols; ++j) {
46  bbox.lbound.x =
47  std::min(bbox.lbound.x, points(0, j));
48  bbox.lbound.y =
49  std::min(bbox.lbound.y, points(1, j));
50  bbox.lbound.z =
51  std::min(bbox.lbound.z, points(2, j));
52  bbox.ubound.x =
53  std::max(bbox.ubound.x, points(0, j));
54  bbox.ubound.y =
55  std::max(bbox.ubound.y, points(1, j));
56  bbox.ubound.z =
57  std::max(bbox.ubound.z, points(2, j));
58  }
59 }
60 
66 template <typename CoordinateType>
68  const arma::Col<CoordinateType>& point)
69 {
70  assert(point.n_rows == 3);
71  bbox.reference.x = point(0);
72  bbox.reference.y = point(1);
73  bbox.reference.z = point(2);
74 }
75 
76 } // namespace Bempp
77 
78 #endif
Point3D< CoordinateType > ubound
Upper bound.
Definition: bounding_box.hpp:20
Point3D< CoordinateType > lbound
Lower bound.
Definition: bounding_box.hpp:18
Point3D< CoordinateType > reference
Reference point.
Definition: bounding_box.hpp:16
Bounding box with a reference point.
Definition: bounding_box.hpp:13
void extendBoundingBox(BoundingBox< CoordinateType > &bbox, const arma::Mat< CoordinateType > &points)
Extend the bounding box bbox to include all points contained in the columns of points.
Definition: bounding_box_helpers.hpp:41
void setBoundingBoxReference(BoundingBox< CoordinateType > &bbox, const arma::Col< CoordinateType > &point)
Set the reference point of the bounding box bbox to point.
Definition: bounding_box_helpers.hpp:67