diff --git a/src/Triangle.Examples/Examples/Example9.cs b/src/Triangle.Examples/Examples/Example9.cs index 68d6157..72d264f 100644 --- a/src/Triangle.Examples/Examples/Example9.cs +++ b/src/Triangle.Examples/Examples/Example9.cs @@ -15,7 +15,7 @@ namespace TriangleNet.Examples { var pts = new List { - // The 4 corners of the square. + // The 4 corners of the rectangle. new Vertex(1.5, 1.0), new Vertex(1.5, -1.0), new Vertex(-1.5, -1.0), diff --git a/src/Triangle/Behavior.cs b/src/Triangle/Behavior.cs index a73f86e..05d8999 100644 --- a/src/Triangle/Behavior.cs +++ b/src/Triangle/Behavior.cs @@ -25,6 +25,7 @@ namespace TriangleNet bool conformDel = false; Func usertest; + Func exclude; int noBisect = 0; @@ -177,6 +178,15 @@ namespace TriangleNet set { usertest = value; } } + /// + /// Exclude triangles from being refined. + /// + public Func Exclude + { + get { return exclude; } + set { exclude = value; } + } + /// /// Enclose the convex hull with segments. /// diff --git a/src/Triangle/Meshing/QualityMesher.cs b/src/Triangle/Meshing/QualityMesher.cs index b1bae3f..4f82040 100644 --- a/src/Triangle/Meshing/QualityMesher.cs +++ b/src/Triangle/Meshing/QualityMesher.cs @@ -64,6 +64,7 @@ namespace TriangleNet.Meshing behavior.MaxAngle = quality.MaximumAngle; behavior.MaxArea = quality.MaximumArea; behavior.UserTest = quality.UserTest; + behavior.Exclude = quality.Exclude; behavior.VarArea = quality.VariableArea; behavior.ConformingDelaunay = behavior.ConformingDelaunay || delaunay; @@ -250,6 +251,11 @@ namespace TriangleNet.Meshing double maxangle; + if (behavior.Exclude != null && behavior.Exclude(testtri.tri)) + { + return; + } + torg = testtri.Org(); tdest = testtri.Dest(); tapex = testtri.Apex(); diff --git a/src/Triangle/Meshing/QualityOptions.cs b/src/Triangle/Meshing/QualityOptions.cs index 8b2372c..393fca5 100644 --- a/src/Triangle/Meshing/QualityOptions.cs +++ b/src/Triangle/Meshing/QualityOptions.cs @@ -34,6 +34,15 @@ namespace TriangleNet.Meshing /// public Func UserTest { get; set; } + /// + /// Gets or sets a test function for excluding triangles from refinement. + /// + /// + /// The exclude test takes higher priority than all other test, i.e. if a + /// triangle passes the exclude test, no other test will be executed. + /// + public Func Exclude { get; set; } + /// /// Gets or sets an area constraint per triangle. ///