added side info to projectOnTriangle
[engrid.git] / src / triangle.h
blobba48b8631d0c3d783da3828ddc99d497a888d8a0
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
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. +
12 // + +
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. +
17 // + +
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/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef TRIANGLE_H
24 #define TRIANGLE_H
26 #include "vtkIdList.h"
27 #include "vtkUnstructuredGrid.h"
28 #include "math/mathvector.h"
29 #include "math/smallsquarematrix.h"
30 #include <QVector>
32 class Triangle {
33 public:
34 vtkIdType id_a, id_b, id_c;
35 vec3_t a, b, c;
36 vec3_t g1, g2, g3;
37 mat3_t G, GI;
38 double A;
39 double smallest_length;
41 public:
42 QVector <bool> m_has_neighbour; ///< True if edge i has a neighbour in the grid
44 public:
45 Triangle();
46 Triangle(vec3_t a_a, vec3_t a_b, vec3_t a_c);
47 Triangle(vtkUnstructuredGrid* a_grid, vtkIdType a_id_a, vtkIdType a_id_b, vtkIdType a_id_c);
48 Triangle(vtkUnstructuredGrid* a_grid, vtkIdType a_id_cell);
49 void setupTriangle();
51 public:
52 /**
53 * Calculates the closest (NOT the projection!) point (xi,ri) of point xp on the triangle.
54 * @param xp Point to "project"
55 * @param xi Global 3D coordinates of the closest point on the triangle.
56 * @param ri Local 3D triangle coordinates of the closest point on the triangle. (0<=ri[0]<=1 and 0<=ri[1]<=1 and ri[2]=0)
57 * @param d Distance of xp to (xi,ri)
58 * @return True if (xi,ri) is the result of a direct projection on the triangle, else false.
60 bool projectOnTriangle(vec3_t xp, vec3_t &xi, vec3_t &ri, double &d, int& side, bool restrict_to_triangle);
62 vec3_t local3DToGlobal3D(vec3_t l_M);
63 vec3_t global3DToLocal3D(vec3_t g_M);
64 vec3_t local2DToGlobal3D(vec2_t l_M);
65 vec2_t global3DToLocal2D(vec3_t g_M);
68 #endif