Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c4db4c5
DYN-9099 Voronoi Dealunay nodes Fix
RobertGlobant20 Jan 29, 2026
4a8fd36
DYN-9099 Voronoi Dealunay nodes Fix
RobertGlobant20 Jan 30, 2026
6023e86
DYN-9099 Voronoi Dealunay nodes Fix
RobertGlobant20 Jan 30, 2026
d032533
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 3, 2026
399c222
DYN-9099 Voronoi Dealunay nodes Code Review
RobertGlobant20 Feb 3, 2026
7bc648b
DYN-9099 Voronoi Dealunay nodes Code Review
RobertGlobant20 Feb 3, 2026
fddd922
DYN-9099 Voronoi Dealunay nodes Code Review
RobertGlobant20 Feb 10, 2026
258da45
DYN-9099 Voronoi Dealunay nodes Unit Tests
RobertGlobant20 Feb 12, 2026
84127c2
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 12, 2026
f28a5a3
DYN-9099 Voronoi Dealunay nodes Fix
RobertGlobant20 Feb 12, 2026
a3dc003
DYN-9099 Voronoi Dealunay nodes RefactorCode
RobertGlobant20 Feb 13, 2026
2a7edbb
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 18, 2026
22de43e
DYN-9099 Voronoi Dealunay nodes Conflicts
RobertGlobant20 Feb 18, 2026
5df02ca
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 23, 2026
c6b2c32
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 24, 2026
464c5be
DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Feb 24, 2026
c263a2a
DYN-9099 Voronoi Dealunay nodes Code Review
RobertGlobant20 Feb 26, 2026
e581e66
DYN-9099 VoronoiDelaunay Nodes Fix
RobertGlobant20 Feb 26, 2026
dcfa5df
DYN-9099 Voronoi Dealunay nodes Code Review
RobertGlobant20 Mar 2, 2026
18d03ab
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 2, 2026
c754244
Update Tessellation.csproj
RobertGlobant20 Mar 2, 2026
525e8f3
Update Tessellation.csproj
RobertGlobant20 Mar 2, 2026
c4140ba
Update Tessellation.csproj
RobertGlobant20 Mar 2, 2026
5d130cc
Update Tessellation.csproj
RobertGlobant20 Mar 2, 2026
3453020
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 2, 2026
e0c9607
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 3, 2026
10d29f2
Fixing the ComputeDelaunayTrianglesInScaledUvSpace method
RobertGlobant20 Mar 3, 2026
51b1a83
Fixing the tests
RobertGlobant20 Mar 3, 2026
f80ed6f
DYN-9099 VoronoiDelaunayNodes Fix Code Review
RobertGlobant20 Mar 6, 2026
a3044aa
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 6, 2026
79c5b0a
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 10, 2026
eee84f6
Merge Fixes
RobertGlobant20 Mar 10, 2026
e3727d6
Merge Fixes
RobertGlobant20 Mar 10, 2026
951f995
DYN-9099-VoronoiDelaunay-CodeReview
RobertGlobant20 Mar 11, 2026
c7b7f48
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 11, 2026
4235b3d
Merge branch 'master' into DYN-9099-VoronoiDelaunayNodes-Fix
RobertGlobant20 Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/check_file_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $excludedFiles = @(
"libSkiaSharp.dll", # https://jira.autodesk.com/browse/DYN-6598
"LiveChartsCore*.dll",
"Lucene.Net*.dll",
"MIConvexHull.NET Standard.dll",
"MIConvexHull.dll",
"Microsoft.*",
"MimeMapping.dll",
"Moq.dll",
Expand Down
13 changes: 13 additions & 0 deletions doc/distrib/xml/en-US/Tessellation.XML

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/Dynamo.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoUtilitiesTests", "..\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GeometryColorTests", "..\test\Libraries\GeometryColorTests\GeometryColorTests.csproj", "{F8D2E3E5-4505-4463-9367-2EB2629D7DCD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TessellationTests", "..\test\Libraries\TessellationTests\TessellationTests.csproj", "{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackageManagerTests", "..\test\Libraries\PackageManagerTests\PackageManagerTests.csproj", "{2A70F3B5-7AEA-42FE-8DD5-8427C28D0025}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DynamoMSOfficeTests", "..\test\Libraries\DynamoMSOfficeTests\DynamoMSOfficeTests.csproj", "{269039F1-126A-46CF-8BEA-257587EDCA6B}"
Expand Down Expand Up @@ -522,6 +524,10 @@ Global
{C4964946-B367-44EE-9ED2-451FF2A83D32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4964946-B367-44EE-9ED2-451FF2A83D32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4964946-B367-44EE-9ED2-451FF2A83D32}.Release|Any CPU.Build.0 = Release|Any CPU
{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F}.Release|Any CPU.Build.0 = Release|Any CPU
{773988FE-EDF6-45CB-A63F-482955EB3553}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{773988FE-EDF6-45CB-A63F-482955EB3553}.Debug|Any CPU.Build.0 = Debug|Any CPU
{773988FE-EDF6-45CB-A63F-482955EB3553}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -581,6 +587,7 @@ Global
{4A707244-154B-428F-B589-D65361F24401} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{AB735028-22B0-4083-9CC5-805C582818EA} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{F8D2E3E5-4505-4463-9367-2EB2629D7DCD} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{B5C64B59-6D12-4B8A-9A7B-1C0C5E7A1A2F} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{2A70F3B5-7AEA-42FE-8DD5-8427C28D0025} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{269039F1-126A-46CF-8BEA-257587EDCA6B} = {4CA0BC62-DCB3-456B-80D6-348247640BAB}
{2C6A6573-28B0-4239-BD33-6AECCD25106C} = {5B9B5B6B-0BA7-4606-B8E5-70C958346D57}
Expand Down
7 changes: 3 additions & 4 deletions src/Libraries/Tesellation/ConvexHull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Autodesk.DesignScript.Geometry;
using MIConvexHull;
Expand All @@ -18,11 +18,10 @@
public static IEnumerable<Curve> ByPoints(IEnumerable<Point> points)
{
var verts = points.Select(Vertex3.FromPoint).ToList();
const double DefaultPlaneDistanceTolerance = 1e-6;
var triResult = ConvexHull<Vertex3, TriangleFace>.Create(verts, DefaultPlaneDistanceTolerance);
var triResult = MIConvexHull.ConvexHull.Create<Vertex3, TriangleFace>(verts);

// make edges
foreach (var face in triResult.Faces)
foreach (var face in triResult.Result.Faces)

Check warning on line 24 in src/Libraries/Tesellation/ConvexHull.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Loop should be simplified by calling Select(face => face.Vertices))

See more on https://sonarcloud.io/project/issues?id=DynamoDS_Dynamo&issues=AZxFRgTcTK4TIKRjaXRe&open=AZxFRgTcTK4TIKRjaXRe&pullRequest=16862
{
// form lines for use in dynamo or revit
var start1 = face.Vertices[0].AsPoint();
Expand Down
35 changes: 23 additions & 12 deletions src/Libraries/Tesellation/Delaunay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Autodesk.DesignScript.Geometry;
using MIConvexHull;
Expand All @@ -19,8 +19,18 @@ public static class Delaunay
/// <search>uvs</search>
public static IEnumerable<Curve> ByParametersOnSurface(IEnumerable<UV> uvs, Surface face)
{
var verts = uvs.Select(Vertex2.FromUV).ToList();
var triangulation = DelaunayTriangulation<Vertex2, Cell2>.Create(verts);
var uvList = uvs?.ToList();
if (uvList == null || uvList.Count == 0 || face == null)
yield break;

// Get normalized UV scaling factors to handle anisotropic parameter spaces
var (normU, normV) = UvScalingUtilities.GetNormalizedUvScales(face);

// Build Delaunay in anisotropically scaled (u*normU, v*normV) space.
var verts = uvList.Select(uv => new Vertex2(uv.U * normU, uv.V * normV)).ToList();

const double PlaneDistanceTolerance = 1e-6;
var triangulation = DelaunayTriangulation<Vertex2, Cell2>.Create(verts, PlaneDistanceTolerance);

// there are three vertices per cell in 2D
foreach (var cell in triangulation.Cells)
Expand All @@ -29,9 +39,9 @@ public static IEnumerable<Curve> ByParametersOnSurface(IEnumerable<UV> uvs, Surf
var v2 = cell.Vertices[1].AsVector();
var v3 = cell.Vertices[2].AsVector();

var xyz1 = face.PointAtParameter(v1.X, v1.Y);
var xyz2 = face.PointAtParameter(v2.X, v2.Y);
var xyz3 = face.PointAtParameter(v3.X, v3.Y);
var xyz1 = face.PointAtParameter(v1.X / normU, v1.Y / normV);
var xyz2 = face.PointAtParameter(v2.X / normU, v2.Y / normV);
var xyz3 = face.PointAtParameter(v3.X / normU, v3.Y / normV);

if (xyz1.DistanceTo(xyz2) > 0.1)
{
Expand All @@ -41,14 +51,14 @@ public static IEnumerable<Curve> ByParametersOnSurface(IEnumerable<UV> uvs, Surf

if (xyz2.DistanceTo(xyz3) > 0.1)
{
var l1 = Line.ByStartPointEndPoint(xyz3, xyz2);
yield return l1;
var l2 = Line.ByStartPointEndPoint(xyz3, xyz2);
yield return l2;
}

if (xyz3.DistanceTo(xyz1) > 0.1)
{
var l1 = Line.ByStartPointEndPoint(xyz1, xyz3);
yield return l1;
var l3 = Line.ByStartPointEndPoint(xyz1, xyz3);
yield return l3;
}
}
}
Expand All @@ -60,7 +70,8 @@ public static IEnumerable<Curve> ByParametersOnSurface(IEnumerable<UV> uvs, Surf
public static IEnumerable<Curve> ByPoints(IEnumerable<Point> points)
{
var verts = points.Select(Vertex3.FromPoint).ToList();
var triResult = DelaunayTriangulation<Vertex3, Tetrahedron>.Create(verts);
const double PlaneDistanceTolerance = 1e-6;
var triResult = DelaunayTriangulation<Vertex3, Tetrahedron>.Create(verts, PlaneDistanceTolerance);

// make edges
foreach (var cell in triResult.Cells)
Expand Down Expand Up @@ -88,4 +99,4 @@ public static IEnumerable<Curve> ByPoints(IEnumerable<Point> points)
}
}
}
}
}
6 changes: 5 additions & 1 deletion src/Libraries/Tesellation/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand All @@ -9,3 +10,6 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("89ae6d07-95ef-49e7-b607-22dc7a7013cf")]

// Make internal types visible to test assembly
[assembly: InternalsVisibleTo("TessellationTests")]
7 changes: 3 additions & 4 deletions src/Libraries/Tesellation/Tessellation.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand All @@ -14,10 +14,9 @@
<NoWarn>MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MIConvexHull" version="1.1.19.1019" CopyPDB="true" />
<PackageReference Include="StarMath" version="2.0.17.1019" CopyPDB="true" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RobertGlobant20 have you explored updating the StarMath library as well? It's used specifically in this project for Voronoi and Delaunay computations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

StarMath is used as a small linear-algebra helper for circumcenter calculations. I can see that inside Cell2 class we are calling StarMath.determinant to compute triangle circumcenters from determinant formulas.
image

<PackageReference Include="DynamoVisualProgramming.LibG_232_0_0" Version="4.0.0.4313"/>

<PackageReference Include="MIConvexHull" version="1.1.17.411" CopyPDB="true" />
<PackageReference Include="StarMath" version="2.0.17.1019" CopyPDB="true" />
<PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
Expand Down
43 changes: 43 additions & 0 deletions src/Libraries/Tesellation/UvScalingUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Autodesk.DesignScript.Geometry;

namespace Tessellation
{
/// <summary>
/// Utility functions for UV scaling on surfaces.
/// </summary>
internal static class UvScalingUtilities
{
/// <summary>
/// Computes normalized UV scaling factors for a surface to handle anisotropic parameter spaces.
/// The scaling preserves the aspect ratio while keeping values in a reasonable numerical range.
/// </summary>
/// <param name="face">Surface to compute scaling factors for.</param>
/// <returns>Tuple containing normalized U and V scale factors.</returns>
internal static (double normU, double normV) GetNormalizedUvScales(Surface face)
{
// Physical scale per unit U/V based on iso-curve lengths along surface edges.
double scaleU;
double scaleV;
using (var uCurveV0 = face.GetIsoline(0, 0))
using (var uCurveV1 = face.GetIsoline(0, 1))
using (var vCurveU0 = face.GetIsoline(1, 0))
using (var vCurveU1 = face.GetIsoline(1, 1))
{
scaleU = (uCurveV0.Length + uCurveV1.Length) / 2.0;
scaleV = (vCurveU0.Length + vCurveU1.Length) / 2.0;
}

// Normalize scales to keep values in a reasonable range, preserve aspect ratio
var max = System.Math.Max(scaleU, scaleV);
if (max <= 1e-9) max = 1.0;

var normU = scaleU / max;
var normV = scaleV / max;

if (normU <= 1e-9) normU = 1.0;
if (normV <= 1e-9) normV = 1.0;

return (normU, normV);
}
}
}
38 changes: 28 additions & 10 deletions src/Libraries/Tesellation/Voronoi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Autodesk.DesignScript.Geometry;
using MIConvexHull;
Expand All @@ -19,16 +19,34 @@ public static class Voronoi
/// <search>uvs</search>
public static IEnumerable<Curve> ByParametersOnSurface(IEnumerable<UV> uvs, Surface face)
{
var verts = uvs.Select(Vertex2.FromUV).ToList();
var uvList = uvs?.ToList();
if (uvList == null || uvList.Count == 0 || face == null)
yield break;

// Get normalized UV scaling factors to handle anisotropic parameter spaces
var (normU, normV) = UvScalingUtilities.GetNormalizedUvScales(face);

// Anisotropic scaling only by aspect ratio
var verts = uvList.Select(uv => new Vertex2(uv.U * normU, uv.V * normV)).ToList();
var voronoiMesh = VoronoiMesh.Create<Vertex2, Cell2>(verts);

return from edge in voronoiMesh.Edges
let _from = edge.Source.Circumcenter
let to = edge.Target.Circumcenter
let start = face.PointAtParameter(_from.X, _from.Y)
let end = face.PointAtParameter(to.X, to.Y)
where start.DistanceTo(end) > 0.1
select Line.ByStartPointEndPoint(start, end);
foreach (var edge in voronoiMesh.Edges)
{
// Map circumcenters back to UV
var cFrom = edge.Source.Circumcenter;
var cTo = edge.Target.Circumcenter;

var u1 = cFrom.X / normU;
var v1 = cFrom.Y / normV;
var u2 = cTo.X / normU;
var v2 = cTo.Y / normV;

var start = face.PointAtParameter(u1, v1);
var end = face.PointAtParameter(u2, v2);

if (start.DistanceTo(end) > 0.1)
yield return Line.ByStartPointEndPoint(start, end);
}
}
}
}
}
Loading
Loading