2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
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 #ifndef BEZIERTRIANGLE_H
24 #define BEZIERTRIANGLE_H
26 #include "math/mathvector.h"
27 #include "math/linsolve.h"
28 #include "math/smallsquarematrix.h"
30 #include "egvtkobject.h"
33 #include <vtkUnstructuredGrid.h>
35 class BezierTriangle
: public Triangle
, public EgVtkObject
{
46 BezierTriangle(vec3_t X_200
, vec3_t X_020
, vec3_t X_002
, vec3_t X_011
, vec3_t X_101
, vec3_t X_110
);
48 void setControlPoints(vec3_t X_200
, vec3_t X_020
, vec3_t X_002
, vec3_t X_011
, vec3_t X_101
, vec3_t X_110
);
49 void getControlPoints(vec3_t
& X_200
, vec3_t
& X_020
, vec3_t
& X_002
, vec3_t
& X_011
, vec3_t
& X_101
, vec3_t
& X_110
);
50 vec2_t
BaryCentric2xy(vec3_t barycoords
);
51 vec3_t
xy2BaryCentric(vec2_t xycoords
);
52 vec3_t
Bezier(vec2_t xycoords
);
53 vec3_t
Bezier(vec3_t barycoords
);
54 vec3_t
Projection(vec2_t xycoords
);
55 vec3_t
Projection(vec3_t barycoords
);
56 void writeBezierSurface(QString filename
, int N
);
58 vec3_t
quadraticBezierTriangle(double u
, double v
, double w
);
59 vec3_t
quadraticBezierTriangle(vec2_t M
);
60 vec3_t
quadraticBezierTriangle_g(vec3_t g_M
);
62 vec3_t
projectOnQuadraticBezierTriangle(vec3_t g_M
, int output
= 0);
64 vec3_t
projectLocal2DOnQuadraticBezierTriangle(vec2_t t_M
);
66 // stuff used for projections on the Bezier surface
68 void setupFunctionVariables();
83 vec2_t
fixedPointFunction(vec2_t t_inputPoint
, double x
, double y
);
84 vec2_t
fixedPointFunction(vec2_t t_inputPoint
, vec2_t A
);
85 mat2_t
jacobiMatrix(double x
, double y
);
86 mat2_t
jacobiMatrix_numeric(vec2_t t_inputPoint
, double x
, double y
, double dx
, double dy
);
88 // mat3_t jacobiMatrix_no_projection(double x, double y);
89 vec3_t
surfaceNormal(vec2_t t_M
, int output
);
90 double z_func(vec2_t t_M
);
91 double z_func(double x
, double y
);
93 vec3_t
projectOnBezierSide(vec3_t g_M
, int side
, double& Lmin
, double& u
);
94 bool insideBezierSurface(vec3_t g_M
);
95 bool insideBezierSurface(vec2_t t_M
);
96 bool insideBezierCurve(vec2_t t_M
, int side
, vec2_t
& t_tangent
, double tol
= 1e-4);
98 vec3_t
closestPointOnBezierCurves(vec3_t g_M
, int& side
, double& Lmin
);