1
// $Id: 2D_BGMesh.cpp,v 1.17 2006/01/06 00:34:25 geuzaine Exp $
3
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 2 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20
// Please report all bugs and problems to <gmsh@geuz.org>.
29
// Compute Calcul the charact. length on 1 pt by interpolating in the
32
double find_quality(MPoint center, DocRecord * BGMESH)
36
PointRecord *pPointArray;
38
double qual, q1, q2, q3, X[3], Y[3], u, v, det, Xp, Yp;
39
double Exp = 2., r, deno, nume;
41
if((del = Find_Triangle(center, BGMESH, BOF)) == NULL) {
42
Msg(GERROR, "Exterior point (%g,%g)", center.v, center.h);
46
pPointArray = BGMESH->points;
55
X[0] = pPointArray[a].where.h;
56
X[1] = pPointArray[b].where.h;
57
X[2] = pPointArray[c].where.h;
59
Y[0] = pPointArray[a].where.v;
60
Y[1] = pPointArray[b].where.v;
61
Y[2] = pPointArray[c].where.v;
63
q1 = pPointArray[a].quality;
64
q2 = pPointArray[b].quality;
65
q3 = pPointArray[c].quality;
67
det = (X[2] - X[0]) * (Y[1] - Y[0]) - (Y[2] - Y[0]) * (X[1] - X[0]);
70
u = ((Xp - X[0]) * (Y[1] - Y[0]) - (Yp - Y[0]) * (X[1] - X[0])) / det;
71
v = ((X[2] - X[0]) * (Yp - Y[0]) - (Y[2] - Y[0]) * (Xp - X[0])) / det;
74
Msg(WARNING, "Degenerated triangle (det=%g)", det);
78
if(u >= -1.e-8 && v >= -1.e-8 && 1. - u - v >= -1.e-8) {
79
qual = q1 * (1. - u - v) + q2 * v + q3 * u;
83
pPointArray = BGMESH->points;
85
for(i = 0; i < BGMESH->numPoints; i++) {
86
r = sqrt(DSQR(center.h - pPointArray[i].where.h) +
87
DSQR(center.v - pPointArray[i].where.v));
90
return (pPointArray[i].quality);
91
nume += pPointArray[i].quality / r;