介绍
API地址:https://nettopologysuite.github.io/NetTopologySuite/api/NetTopologySuite.Triangulate.ConformingDelaunayTriangulationBuilder.html#NetTopologySuite_Triangulate_ConformingDelaunayTriangulationBuilder_Constraints
约束为线
效果图
红色线为约束线。
示例代码
var r = new WKTReader();
var wkt = "polygon((0 0,0 6,3 6,3 5,5 5,5 3,2 3,2 2,5 2,5 1,6 1,6 0,2 0,2 -1,7 -1,7 -2,-1 -2,-1 -1,0 -1,0 0))";
var geo = r.Read(wkt);var lineWkt = "linestring(4 4,3 0,5 -2)";
var line = r.Read(lineWkt);var tri = new ConformingDelaunayTriangulationBuilder();
tri.Constraints = line;//添加约束线
tri.SetSites(geo);
var tris = tri.GetEdges(GeometryFactory.Default);
约束为面
效果图
示例代码
var r = new WKTReader();
var wkt = "polygon((0 0,0 6,3 6,3 5,5 5,5 3,2 3,2 2,5 2,5 1,6 1,6 0,2 0,2 -1,7 -1,7 -2,-1 -2,-1 -1,0 -1,0 0))";
var geo = r.Read(wkt);var wkt2 = "polygon((4 4,3 0,5 -2,4 4))";
var geo2 = r.Read(wkt2);var tri = new ConformingDelaunayTriangulationBuilder();
tri.Constraints = geo2;//添加约束面
tri.SetSites(geo);
var tris = tri.GetEdges(GeometryFactory.Default);
可以自行将位于约束面内的三角边删掉。
不带约束
为了对比明显,再放一张不带约束的三角网: