1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2007-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
#include "DifferenceVol.h"
//---
#include <cmath>
#include <cstdlib>
using std::cos;
using std::sin;
// --- STL includes ---
#include <utility>
using std::make_pair;
DifferenceVol::DifferenceVol()
{
std::cout << "WARNING: DifferenceVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl;
m_vol1 = NULL;
m_vol2 = NULL;
}
DifferenceVol::DifferenceVol(AVolume3D& v1, AVolume3D& v2)
{
std::cout << "WARNING: DifferenceVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl;
m_vol1 = &v1;
m_vol2 = &v2;
// std::cout << m_vol1 << std::endl;
// std::cout << m_vol2 << std::endl;
}
pair<Vector3,Vector3> DifferenceVol::getBoundingBox()
{
return m_vol1->getBoundingBox();
}
Vector3 DifferenceVol::getAPoint(int ivol) const
{
Vector3 aPoint;
bool found = false;
while (!(found)) {
aPoint = m_vol1->getAPoint(ivol);
found = !(m_vol2->isIn(aPoint));
}
return aPoint;
}
const map<double,const AGeometricObject*> DifferenceVol::getClosestObjects(const Vector3& P,int ival) const
{
map<double,const AGeometricObject*> res;
map<double,const AGeometricObject*> res2;
res = m_vol1->getClosestObjects(P,ival);
res2 = m_vol2->getClosestObjects(P,ival);
res.insert(res2.begin(), res2.end());
return res;
}
bool DifferenceVol::isIn(const Vector3& P) const
{
bool res = false;
if ((m_vol1->isIn(P)) && (!(m_vol2->isIn(P)))) {
res = true;
}
return res;
}
bool DifferenceVol::isIn(const Sphere& S)
{
return m_vol1->isIn(S) && m_vol2->isFullyOutside(S);
}
/*!
Check if a sphere is fully outside the volume. Tests if the sphere
is fully outside volume1 or fully inside volume2.
\param S the sphere
*/
bool DifferenceVol::isFullyOutside(const Sphere& S)
{
return m_vol2->isIn(S) || m_vol1->isFullyOutside(S);
}
ostream& operator << (ostream& ost,const DifferenceVol& T)
{
return ost;
}
|