|
ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 00014 #ifndef ESYS_LSM_IMPLINTERSECTIONVOLCALCULATOR_H 00015 #define ESYS_LSM_IMPLINTERSECTIONVOLCALCULATOR_H 00016 00017 #include <math.h> 00018 00019 namespace esys 00020 { 00021 namespace lsm 00022 { 00023 namespace impl 00024 { 00025 double square(double val); 00026 00027 template <int tmplDim, typename TmplVec> 00028 class DimBasicBox 00029 { 00030 public: 00031 typedef TmplVec Vec; 00032 DimBasicBox(const Vec &minPt, const Vec &maxPt); 00033 00034 const Vec &getMinPt() const; 00035 00036 const Vec &getMaxPt() const; 00037 00038 double getVolume() const; 00039 00040 template <typename TmplSphere> 00041 bool intersectsWith(const TmplSphere &sphere) const; 00042 00043 bool intersectsWith(const Vec &pt) const; 00044 00045 template <typename TmplSphere> 00046 bool contains(const TmplSphere &sphere) const; 00047 00048 private: 00049 Vec m_minPt; 00050 Vec m_maxPt; 00051 }; 00052 00053 template <int tmplDim, typename TmplVec> 00054 class DimPlane 00055 { 00056 public: 00057 typedef TmplVec Vec; 00058 00059 static double norm(const Vec &pt); 00060 00061 static double dot(const Vec &p1, const Vec &p2); 00062 00063 DimPlane(); 00064 00065 DimPlane(const Vec &normal, const Vec &pt); 00066 00067 DimPlane(const DimPlane &plane); 00068 00069 DimPlane &operator=(const DimPlane &plane); 00070 00071 double getSignedDistanceTo(const Vec &pt) const; 00072 00073 double getDistanceTo(const Vec &pt) const; 00074 00075 const Vec &getNormal() const; 00076 00077 private: 00078 Vec m_normal; 00079 Vec m_pt; 00080 double m_invNormalNorm; 00081 }; 00082 00083 template <int tmplDim, typename TmplVec> 00084 class DimBasicSphere 00085 { 00086 public: 00087 typedef TmplVec Vec; 00088 typedef DimPlane<tmplDim, Vec> Plane; 00089 00090 static const double FOUR_THIRDS_PI; 00091 static const double ONE_THIRD_PI; 00092 00093 DimBasicSphere(); 00094 00095 DimBasicSphere(const Vec ¢rePt, double radius); 00096 00097 DimBasicSphere(const DimBasicSphere &sphere); 00098 00099 DimBasicSphere &operator=(const DimBasicSphere &sphere); 00100 00101 double getRadius() const; 00102 00103 const Vec &getCentre() const; 00104 00105 double getVolume() const; 00106 00107 double getVolume(const Vec &minPt, const Vec &maxPt,DimBasicSphere(); 00094