2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2013 enGits GmbH +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "cadinterface.h"
25 #include <QTextStream>
28 CadInterface::CadInterface()
30 QFile
file(":/resources/misc/raysphere.dat");
31 file
.open(QIODevice::ReadOnly
);
35 m_RayPoints
.resize(N
);
36 for (int i
= 0; i
< N
; ++i
) {
37 for (int j
= 0; j
< 3; ++j
) {
38 s
>> m_RayPoints
[i
][j
];
40 m_RayPoints
[i
].normalise();
43 m_LastNormal
= vec3_t(0,0,0);
46 vec3_t
CadInterface::snap(vec3_t x
)
53 foreach (vec3_t x_ray
, m_RayPoints
) {
60 if (shootRay(x
, v
, x_hit
, n_hit
, r_hit
) != Miss
) {
61 double L
= (x_hit
- x
).abs();
71 // shoot a "far-side return ray" ...
72 if (shootRay(x_hit
, -1*x_ray
, x_hit
, n_hit
, r_hit
)) {
73 double L
= (x_hit
- x
).abs();
83 // re-shoot standard ray with surface normal
84 if (shootRay(x
, v
, x_hit
, n_hit
, r_hit
) != Miss
) {
85 double L
= (x_hit
- x
).abs();
95 // re-shoot standard ray with surface normal in opposite direction
97 if (shootRay(x
, v
, x_hit
, n_hit
, r_hit
) != Miss
) {
98 double L
= (x_hit
- x
).abs();
113 m_LastNormal
= n_best
;
114 m_LastRadius
= r_best
;