public static GeometryModel3D newPolygon3DOWN(HciLab.Utilities.Mathematics.Geometry2D.Polygon pPolygon, Color pColor, double pOffesetZ = 0) { GeometryModel3D model = new GeometryModel3D(); if (pPolygon != null) { HelixToolkit.Wpf.MeshBuilder meshBuilder = new HelixToolkit.Wpf.MeshBuilder(false, false); Int32Collection triangleIndexes = CuttingEarsTriangulatorNEW.Triangulate(pPolygon.Points); meshBuilder.Append(pPolygon.ToHelixToolkit3D(pOffesetZ).Points, triangleIndexes); model.Geometry = meshBuilder.ToMesh(); } model.Material = new DiffuseMaterial(new SolidColorBrush(pColor)); return(model); }
/// <summary> /// For 3D polygons /// </summary> /// <param name="pPolygon"></param> /// <returns></returns> internal static MeshGeometry3D FillPolygon(HelixToolkit.Wpf.Polygon3D pPolygon) { try { HelixToolkit.Wpf.MeshBuilder meshBuilder = new HelixToolkit.Wpf.MeshBuilder(false, false); HelixToolkit.Wpf.Polygon polygon = pPolygon.Flatten(); Int32Collection triangleIndexes = HelixToolkit.Wpf.CuttingEarsTriangulator.Triangulate(polygon.Points); meshBuilder.Append(pPolygon.Points, triangleIndexes); return(meshBuilder.ToMesh()); } catch (System.InvalidOperationException exp) { return(null); } }