OpenStructure
aligned_cuboid.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef GEOM_ALIGNED_CUBOID_HH
20 #define GEOM_ALIGNED_CUBOID_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 
26 #include "vec3.hh"
27 #include "module_config.hh"
28 
29 namespace geom {
30 
31 
36 public:
37  AlignedCuboid() :min_(), max_() {}
38  AlignedCuboid(const Vec3& mmin, const Vec3& mmax) :min_(mmin), max_(mmax) {}
39 
40  Vec3 GetSize() const {return max_-min_;}
41 
42  Real GetVolume() const {
43  Vec3 s=max_-min_;
44  return s[0]*s[1]*s[2];
45  }
46 
47  const Vec3& GetMin() const {return min_;}
48 
49  const Vec3& GetMax() const {return max_;}
50 
51  Vec3 GetCenter() const {return 0.5*(max_+min_);}
52 private:
53  Vec3 min_;
54  Vec3 max_;
55 };
56 
57 inline std::ostream& operator<<(std::ostream& os, const AlignedCuboid& c)
58 {
59  os << "(" << c.GetMin() << "," << c.GetMax() << ")";
60  return os;
61 }
62 
64 
65 }
66 
67 
68 #endif
axis-aligned cuboid
Vec3 GetSize() const
Vec3 GetCenter() const
AlignedCuboid(const Vec3 &mmin, const Vec3 &mmax)
Real GetVolume() const
const Vec3 & GetMin() const
const Vec3 & GetMax() const
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
#define DLLEXPORT_OST_GEOM
float Real
Definition: base.hh:44
AlignedCuboid DLLIMPORT Union(const AlignedCuboid &lhs, const AlignedCuboid &rhs)
std::ostream & operator<<(std::ostream &os, const AlignedCuboid &c)