00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2011 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 #ifndef GEOM_ALIGNED_CUBOID_HH 00020 #define GEOM_ALIGNED_CUBOID_HH 00021 00022 /* 00023 Author: Marco Biasini 00024 */ 00025 00026 #include "vec3.hh" 00027 #include "module_config.hh" 00028 00029 namespace geom { 00030 00031 00035 class DLLEXPORT_OST_GEOM AlignedCuboid { 00036 public: 00037 AlignedCuboid() :min_(), max_() {} 00038 AlignedCuboid(const Vec3& mmin, const Vec3& mmax) :min_(mmin), max_(mmax) {} 00039 00040 Vec3 GetSize() const {return max_-min_;} 00041 00042 Real GetVolume() const { 00043 Vec3 s=max_-min_; 00044 return s[0]*s[1]*s[2]; 00045 } 00046 00047 const Vec3& GetMin() const {return min_;} 00048 00049 const Vec3& GetMax() const {return max_;} 00050 00051 Vec3 GetCenter() const {return 0.5*(max_+min_);} 00052 private: 00053 Vec3 min_; 00054 Vec3 max_; 00055 }; 00056 00057 inline std::ostream& operator<<(std::ostream& os, const AlignedCuboid& c) 00058 { 00059 os << "(" << c.GetMin() << "," << c.GetMax() << ")"; 00060 return os; 00061 } 00062 00063 AlignedCuboid DLLEXPORT_OST_GEOM Union(const AlignedCuboid& lhs, const AlignedCuboid& rhs); 00064 00065 } 00066 00067 00068 #endif