| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
#include "DogBone.h" |
| 14 |
|
| 15 |
// --- STL includes --- |
| 16 |
#include <utility> |
| 17 |
|
| 18 |
using std::make_pair; |
| 19 |
|
| 20 |
DogBone::DogBone() |
| 21 |
{} |
| 22 |
|
| 23 |
/*! |
| 24 |
\param c base point |
| 25 |
\param axis central axis |
| 26 |
\param l total length |
| 27 |
\param r total radius |
| 28 |
\param l2 length of cylindrical end pieces |
| 29 |
\param r2 center radius |
| 30 |
*/ |
| 31 |
DogBone::DogBone(const Vector3& c,const Vector3& axis,double l,double r,double l2,double r2) : CylinderVol(c,axis,l,r) |
| 32 |
{ |
| 33 |
// calc torus center |
| 34 |
Vector3 tcenter=c+0.5*l*axis; |
| 35 |
|
| 36 |
// torus inner radius |
| 37 |
double h=0.5*l-l2; |
| 38 |
double k=(r-r2); |
| 39 |
double ri=0.5*(k+(h*h)/k); |
| 40 |
|
| 41 |
// torus outer radius |
| 42 |
double ro=ri+r2; |
| 43 |
|
| 44 |
std::cout << "torus: " << tcenter << " - " << ro << " , " << ri << std::endl; |
| 45 |
m_tor=Torus(tcenter,axis,ro,ri,false); |
| 46 |
} |
| 47 |
|
| 48 |
const map<double,const AGeometricObject*> DogBone::getClosestObjects(const Vector3& P,int n) const |
| 49 |
{ |
| 50 |
map<double,const AGeometricObject*> res=CylinderVol::getClosestObjects(P,n); |
| 51 |
|
| 52 |
res.insert(make_pair(m_tor.getDist(P),&m_tor)); |
| 53 |
|
| 54 |
return res; |
| 55 |
} |
| 56 |
|
| 57 |
bool DogBone::isIn(const Vector3& P) const |
| 58 |
{ |
| 59 |
bool res=CylinderVol::isIn(P); |
| 60 |
|
| 61 |
bool in_torus=(m_tor.getDist(P)>0); |
| 62 |
|
| 63 |
return res && in_torus; |
| 64 |
} |
| 65 |
|
| 66 |
bool DogBone::isIn(const Sphere& S) |
| 67 |
{ |
| 68 |
bool res=CylinderVol::isIn(S); |
| 69 |
|
| 70 |
bool in_torus=(m_tor.getDist(S.Center())>S.Radius()); |
| 71 |
|
| 72 |
return res && in_torus; |
| 73 |
} |