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 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
25 TriCoord::TriCoord(vtkUnstructuredGrid
* surf_grid
, vtkIdType id_tri
, vec3_t x
)
27 m_SurfGrid
= surf_grid
;
31 void TriCoord::setPosition(vec3_t x
)
34 bool intersects_face = GeometryTools::intersectEdgeAndTriangle(T.a, T.b, T.c, x1, x2, xi, ri);
35 if (!intersects_face) {
36 double kab = GeometryTools::intersection(T.a, T.b - T.a, xp, T.b - T.a);
37 double kac = GeometryTools::intersection(T.a, T.c - T.a, xp, T.c - T.a);
38 double kbc = GeometryTools::intersection(T.b, T.c - T.b, xp, T.c - T.b);
39 double dab = (T.a + kab*(T.b-T.a) - xp).abs();
40 double dac = (T.a + kac*(T.c-T.a) - xp).abs();
41 double dbc = (T.b + kbc*(T.c-T.b) - xp).abs();
43 if ((kab >= 0) && (kab <= 1)) {
45 xi = T.a + kab*(T.b-T.a);
50 if ((kac >= 0) && (kac <= 1)) {
52 xi = T.a + kac*(T.c-T.a);
57 if ((kbc >= 0) && (kbc <= 1)) {
59 xi = T.b + kbc*(T.c-T.b);
64 double da = (T.a - xp).abs();
65 double db = (T.b - xp).abs();
66 double dc = (T.c - xp).abs();