Skip to content

Port upstream CDT refinement and topology updates - #32

Merged
MichaConrad merged 3 commits into
mainfrom
copilot/michaco-cdtnet-31-bulk-update
Oct 29, 2026
Merged

MichaConrad merged 3 commits into
mainfrom
copilot/michaco-cdtnet-31-bulk-update

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This update brings the applicable upstream changes into CDT.NET, including triangle refinement, conforming-edge robustness fixes, and third-party license attribution.

  • Triangle refinement: Add smallest-angle and largest-area criteria, vertex budgets, encroached-edge handling, and reporting for unrefined cases.
  • Topology APIs and fixes: Add collection/finalization workflows and winding verification; prevent circumcenters outside the input hull from expanding it.
  • Licensing: Attribute the BSD-licensed adaptive predicates and include both license texts in the NuGet package.
cdt.InsertVertices(vertices);
cdt.ConformToEdges(edges);

var toErase = cdt.CollectOuterTrianglesAndHoles();
var unrefined = cdt.RefineTriangles(
    maxVerticesToInsert: 10_000,
    refinementCriterion: RefinementCriterion.SmallestAngle,
    refinementThreshold: CdtUtils.DegToRad(20.0),
    toEraseOrNull: toErase);

cdt.FinalizeTriangulation(toErase);

Copilot AI linked an issue Oct 29, 2026 that may be closed by this pull request
@github-actions

Copy link
Copy Markdown
Contributor

Summary

Summary
Generated on: 10/29/2026 - 12:38:12 PM
Coverage date: 10/29/2026 - 12:38:09 PM
Parser: Cobertura
Assemblies: 1
Classes: 20
Files: 8
Line coverage: 87.5% (1763 of 2014)
Covered lines: 1763
Uncovered lines: 251
Coverable lines: 2014
Total lines: 4683
Branch coverage: 84.3% (957 of 1134)
Covered branches: 957
Total branches: 1134
Method coverage: Feature is only available for sponsors
Tag: 130_40861379781

Coverage

CDT.Core - 87.5%
Name Line Branch
CDT.Core 87.5% 84.3%
CDT.Box2d`1 73.6% 100%
CDT.CdtUtils 86.3% 76.5%
CDT.CovariantReadOnlyDictionary`3 18.1% 50%
CDT.DictionaryExtensions 100% 100%
CDT.DuplicatesInfo 100%
CDT.DuplicateVertexException 66.6%
CDT.Edge 83.3% 66.6%
CDT.IntersectingConstraintsException 0%
CDT.InvalidEdgeSplitVertexException 71.4%
CDT.KdTree`1 72.7% 65%
CDT.LayerDepth 0%
CDT.Predicates.PredicatesAdaptive 89.4% 82.1%
CDT.Predicates.PredicatesExact 35.3% 100%
CDT.TopologyVerifier 84.8% 71.7%
CDT.Triangle 66.6% 71.4%
CDT.Triangulation`1 95.6% 89.7%
CDT.TriangulationException 100%
CDT.TriangulationFinalizedException 100%
CDT.Unrefined 50%
CDT.V2d`1 44.4% 25%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical active issues remain in smallest-angle calculation, constrained-edge preservation during flips, and safe handling of caller-supplied removal sets, so correctness is not established.

3 open issues
What changed in this PR

This pull request ports upstream CDT refinement, topology, predicate, and licensing updates into CDT.NET.

Changes:

  • Adds smallest-angle and largest-area refinement with encroached-edge handling, vertex budgets, and unrefined-case reporting.
  • Adds collection/finalization workflows, winding verification, and constrained-edge robustness improvements.
  • Adds adaptive predicate attribution, NuGet license packaging, documentation, and regression coverage.

This pull request requires changes.

File Description
test/​CDT.Tests/​TriangulationTests.cs Tests winding validation and near-vertex constraint splitting.
test/​CDT.Tests/​RefinementTests.cs Tests refinement criteria, budgets, hull handling, and failure reporting.
test/​CDT.Tests/​PredicatesTests.cs Tests strict diametral-circle encroachment behavior.
test/​CDT.Tests/​GroundTruthTests.cs Extends conforming topology validation with winding checks.
test/​CDT.Tests/​expected/​issue-142-double-hanging-edge__conforming_auto_ignore_auto.txt Updates expected topology output for revised conforming-edge behavior.
src/​CDT.Core/​Types.cs Defines refinement criteria and unrefined-result counters.
src/​CDT.Core/​Triangulation.Refinement.cs Implements triangle refinement and encroached-edge resolution.
src/​CDT.Core/​Triangulation.cs Adds lifecycle APIs and constrained-topology robustness changes.
src/​CDT.Core/​TopologyVerifier.cs Adds counter-clockwise winding verification.
src/​CDT.Core/​Predicates/​PredicatesAdaptive.cs Adds the adaptive diametral-circle predicate and attribution.
src/​CDT.Core/​CdtUtils.cs Adds geometric helpers for refinement and encroachment detection.
src/​CDT.Core/​CDT.Core.csproj Updates license metadata and packages both license files.
README.md Documents refinement support and adaptive-predicate licensing.
LICENSE-predicates.txt Adds the BSD 3-Clause license for adaptive predicates.

Review effort: Lite

Comment thread src/CDT.Core/CdtUtils.cs
Comment on lines +581 to +585
T sideA = Distance(a, b);
T sideB = Distance(b, c);
if (sideA > sideB) (sideA, sideB) = (sideB, sideA);
sideA = T.Max(sideA, Distance(a, c));
T sine = (T.One + T.One) * Area(a, b, c) / sideA / sideB;
Comment on lines +883 to +888
var original1 = _pieceToOriginals.TryGetValue(e1, out var pieces1) && pieces1.Count > 0
? pieces1[0]
: e1;
var original2 = _pieceToOriginals.TryGetValue(e2, out var pieces2) && pieces2.Count > 0
? pieces2[0]
: e2;
Comment on lines +1573 to +1575
public void FinalizeTriangulation(IReadOnlySet<int> removedTriangles)
{
if (IsFinalized) throw new TriangulationFinalizedException();
@MichaConrad
MichaConrad marked this pull request as ready for review October 29, 2026 19:24
@MichaConrad
MichaConrad merged commit 7fc7ecc into main Oct 29, 2026
4 checks passed
@MichaConrad
MichaConrad deleted the copilot/michaco-cdtnet-31-bulk-update branch October 29, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants