2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2012 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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
24 #include "brlcadprojection.h"
26 BrlCadProjection::BrlCadProjection(QString file_name
, QString object_name
)
28 setupBrlCad(file_name
, object_name
);
33 BrlCadProjection::~BrlCadProjection()
38 vec3_t
BrlCadProjection::project(vec3_t x
, vtkIdType id_node
, bool, vec3_t v
)
45 n
= m_FPart
.globalNormal(id_node
);
47 if (!checkVector(x
)) {
50 if (!checkVector(n
)) {
51 cout
<< "vector defect (id_node=" << id_node
<< ")" << endl
;
60 vec3_t x_hit1
, n_hit1
, x_hit2
, n_hit2
;
61 double r_hit1
, r_hit2
;
62 HitType hit_type1
, hit_type2
;
64 hit_type1
= shootRay(x
, n
, x_hit1
, n_hit1
, r_hit1
);
65 if (hit_type1
== Miss
) {
67 hit_type1
= shootRay(x
, n
, x_hit1
, n_hit1
, r_hit1
);
69 if (hit_type1
== Miss
) {
75 hit_type2
= shootRay(x_hit1
, n
, x_hit2
, n_hit2
, r_hit2
);
77 m_LastNormal
= (-1)*n_hit1
;
78 m_LastRadius
= r_hit1
;
79 if (hit_type2
!= Miss
) {
80 if ((x
- x_hit2
).abs() < (x
- x_hit1
).abs()) {
82 m_LastNormal
= (-1)*n_hit2
;
83 m_LastRadius
= r_hit2
;
89 double BrlCadProjection::getRadius(vtkIdType id_node
)
92 m_FGrid
->GetPoint(id_node
, x
.data());