1 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + This file is part of enGrid. +
5 // + Copyright 2008-2014 enGits GmbH +
7 // + enGrid is free software: you can redistribute it and/or modify +
8 // + it under the terms of the GNU General Public License as published by +
9 // + the Free Software Foundation, either version 3 of the License, or +
10 // + (at your option) any later version. +
12 // + enGrid is distributed in the hope that it will be useful, +
13 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
14 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
15 // + GNU General Public License for more details. +
17 // + You should have received a copy of the GNU General Public License +
18 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 TriCoord::TriCoord(vtkUnstructuredGrid
* surf_grid
, vtkIdType id_tri
, vec3_t x
)
25 m_SurfGrid
= surf_grid
;
29 void TriCoord::setPosition(vec3_t x
)
32 bool intersects_face = GeometryTools::intersectEdgeAndTriangle(T.a, T.b, T.c, x1, x2, xi, ri);
33 if (!intersects_face) {
34 double kab = GeometryTools::intersection(T.a, T.b - T.a, xp, T.b - T.a);
35 double kac = GeometryTools::intersection(T.a, T.c - T.a, xp, T.c - T.a);
36 double kbc = GeometryTools::intersection(T.b, T.c - T.b, xp, T.c - T.b);
37 double dab = (T.a + kab*(T.b-T.a) - xp).abs();
38 double dac = (T.a + kac*(T.c-T.a) - xp).abs();
39 double dbc = (T.b + kbc*(T.c-T.b) - xp).abs();
41 if ((kab >= 0) && (kab <= 1)) {
43 xi = T.a + kab*(T.b-T.a);
48 if ((kac >= 0) && (kac <= 1)) {
50 xi = T.a + kac*(T.c-T.a);
55 if ((kbc >= 0) && (kbc <= 1)) {
57 xi = T.b + kbc*(T.c-T.b);
62 double da = (T.a - xp).abs();
63 double db = (T.b - xp).abs();
64 double dc = (T.c - xp).abs();