Debian Codegraph @

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