Debian Codegraph @

src/CylinderWithJointSet.cc

raw
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 "CylinderWithJointSet.h"
14
15 //---
16 #include <cmath>
17 #include <cstdlib>
18
19 using std::cos;
20 using std::sin;
21 using std::fabs;
22
23 // --- STL includes ---
24 #include <utility>
25
26 using std::make_pair;
27
28 CylinderWithJointSet::CylinderWithJointSet()
29 { }
30
31 CylinderWithJointSet::CylinderWithJointSet(const Vector3& c,const Vector3& axis,double l,double r): CylinderVol(c,axis,l,r)
32 { }
33
34 const map<double,const AGeometricObject*> CylinderWithJointSet::getClosestObjects(const Vector3& P,int) const
35 {
36 map<double,const AGeometricObject*> res;
37
38 res.insert(make_pair(m_cyl.getDist(P),&m_cyl));
39 res.insert(make_pair(m_bottom.getDist(P),&m_bottom));
40 res.insert(make_pair(m_top.getDist(P),&m_top));
41
42 for(vector<Triangle3D>::const_iterator iter=m_joints.begin();
43 iter!=m_joints.end();
44 iter++){
45 double ndist=iter->getDist(P);
46 res.insert(make_pair(ndist,&(*iter)));
47 }
48
49 return res;
50 }
51
52 void CylinderWithJointSet::addJoints(const TriPatchSet& t)
53 {
54 for(vector<Triangle3D>::const_iterator iter=t.triangles_begin();
55 iter!=t.triangles_end();
56 iter++){
57 m_joints.push_back(*iter);
58 }
59 }
60
61 bool CylinderWithJointSet::isIn(const Sphere& S)
62 {
63 double r=S.Radius();
64 Vector3 p=S.Center();
65
66 // check inside & planes via base class
67 bool res=CylinderVol::isIn(S);
68
69 if(res){
70 // check intersection with joints
71 vector<Triangle3D>::iterator iter=m_joints.begin();
72 double dist=2*r;
73 while((iter!=m_joints.end()) && res){
74 dist=iter->getDist(p);
75 res=(dist>r);
76 iter++;
77 }
78 }
79
80 return res;
81 }
82
83 ostream& operator << (ostream& ost,const CylinderWithJointSet& T)
84 {
85 return ost;
86 }
87