Update QualityMeasure class.

This commit is contained in:
wo80
2022-07-19 00:53:01 +02:00
parent a3d960d5b7
commit 164318fd8e
3 changed files with 18 additions and 20 deletions
+7
View File
@@ -40,6 +40,13 @@ namespace TriangleNet
/// <summary>
/// Creates a rectangle contour.
/// </summary>
/// <param name="x">Minimum x value (left).</param>
/// <param name="y">Minimum y value (bottom).</param>
/// <param name="width">Width of the rectangle.</param>
/// <param name="height">Height of the rectangle.</param>
/// <param name="size">The desired boundary segment length.</param>
/// <param name="label">The vertices and boundary segment label.</param>
/// <returns></returns>
public static Contour Rectangle(double x, double y, double width, double height,
double size = 0d, int label = 0)
{
+1 -1
View File
@@ -18,7 +18,7 @@ namespace TriangleNet
Check("Example 8", Example8.Run());
Check("Example 9", Example9.Run());
Check("Example 10", Example10.Run());
Check("Example 11", Example10.Run());
Check("Example 11", Example11.Run());
}
static void Check(string item, bool success)
+10 -19
View File
@@ -9,6 +9,7 @@ namespace TriangleNet.Tools
{
using System;
using TriangleNet.Geometry;
using TriangleNet.Meshing;
/// <summary>
/// Provides mesh quality information.
@@ -57,16 +58,16 @@ namespace TriangleNet.Tools
AlphaMeasure alphaMeasure;
Q_Measure qMeasure;
Mesh mesh;
/// <summary>
/// Initializes a new instance of the <see cref="QualityMeasure" /> class.
/// </summary>
public QualityMeasure()
public QualityMeasure(IMesh mesh)
{
areaMeasure = new AreaMeasure();
alphaMeasure = new AlphaMeasure();
qMeasure = new Q_Measure();
Compute(mesh);
}
#region Public properties
@@ -161,23 +162,13 @@ namespace TriangleNet.Tools
#endregion
/// <summary>
/// Update all quality measures.
/// </summary>
public void Update(Mesh mesh)
private void Compute(IMesh mesh)
{
this.mesh = mesh;
// Reset all measures.
areaMeasure.Reset();
alphaMeasure.Reset();
qMeasure.Reset();
Compute();
}
private void Compute()
{
Point a, b, c;
double ab, bc, ca;
double lx, ly;
@@ -185,7 +176,7 @@ namespace TriangleNet.Tools
int n = 0;
foreach (var tri in mesh.triangles)
foreach (var tri in mesh.Triangles)
{
n++;
@@ -241,7 +232,7 @@ namespace TriangleNet.Tools
/// Because the finite element node adjacency relationship is symmetric,
/// we are guaranteed that ML = MU.
/// </remarks>
public int Bandwidth()
public static int Bandwidth(IMesh mesh)
{
if (mesh == null) return 0;
@@ -250,15 +241,15 @@ namespace TriangleNet.Tools
int gi, gj;
foreach (var tri in mesh.triangles)
foreach (var tri in mesh.Triangles)
{
for (int j = 0; j < 3; j++)
{
gi = tri.GetVertex(j).id;
gi = tri.GetVertexID(j);
for (int k = 0; k < 3; k++)
{
gj = tri.GetVertex(k).id;
gj = tri.GetVertexID(k);
mu = Math.Max(mu, gj - gi);
ml = Math.Max(ml, gi - gj);