From 2a130cea742ac26da0990f34312f3cc406a68289 Mon Sep 17 00:00:00 2001 From: wo80 Date: Tue, 27 Dec 2022 13:10:47 +0100 Subject: [PATCH] Always use aCute algorithm for mesh refinement by default (fixes #31). --- src/Triangle/Meshing/QualityMesher.cs | 17 ++++++++--------- src/Triangle/Meshing/QualityOptions.cs | 9 +++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Triangle/Meshing/QualityMesher.cs b/src/Triangle/Meshing/QualityMesher.cs index 147fd01..dfa19ec 100644 --- a/src/Triangle/Meshing/QualityMesher.cs +++ b/src/Triangle/Meshing/QualityMesher.cs @@ -33,6 +33,8 @@ namespace TriangleNet.Meshing // in SplitTriangle method. Triangle newvertex_tri; + bool enableAcute = true; + public QualityMesher(Mesh mesh, Configuration config) { badsubsegs = new Queue(); @@ -70,6 +72,8 @@ namespace TriangleNet.Meshing behavior.ConformingDelaunay = behavior.ConformingDelaunay || delaunay; mesh.steinerleft = quality.SteinerPoints == 0 ? -1 : quality.SteinerPoints; + + enableAcute = !quality.UseLegacyRefinement; } // TODO: remove @@ -434,7 +438,7 @@ namespace TriangleNet.Meshing #endregion - #region Maintanance + #region Maintenance /// /// Traverse the entire list of subsegments, and check each to see if it @@ -729,18 +733,13 @@ namespace TriangleNet.Meshing { errorflag = false; // Create a new vertex at the triangle's circumcenter. - - // Using the original (simpler) Steiner point location method - // for mesh refinement. - // TODO: NewLocation doesn't work for refinement. Why? Maybe - // reset VertexType? - if (behavior.fixedArea || behavior.VarArea) + if (enableAcute) { - newloc = predicates.FindCircumcenter(borg, bdest, bapex, ref xi, ref eta, behavior.offconstant); + newloc = newLocation.FindLocation(borg, bdest, bapex, ref xi, ref eta, true, badotri); } else { - newloc = newLocation.FindLocation(borg, bdest, bapex, ref xi, ref eta, true, badotri); + newloc = predicates.FindCircumcenter(borg, bdest, bapex, ref xi, ref eta, behavior.offconstant); } // Check whether the new vertex lies on a triangle vertex. diff --git a/src/Triangle/Meshing/QualityOptions.cs b/src/Triangle/Meshing/QualityOptions.cs index 393fca5..5f6529f 100644 --- a/src/Triangle/Meshing/QualityOptions.cs +++ b/src/Triangle/Meshing/QualityOptions.cs @@ -60,5 +60,14 @@ namespace TriangleNet.Meshing /// to meet the other quality constraints. /// public int SteinerPoints { get; set; } + + /// + /// Gets or sets a value indicating whether to use the legacy refinement strategy (default = false). + /// + /// + /// If this flag is set to true, the original Triangle refinement algorithm will be + /// used (Ruppert's algorithm). Otherwise the aCute algorithm used. + /// + public bool UseLegacyRefinement { get; set; } } }