VDF常见问题整理(八):如何排除GroundSurface对象的三角形区域?

本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习,本节教程将会介绍如何排除GroundSurface对象的三角形区域。

VectorDraw Developer Framework试用版下载


    点开本篇文章,是否对矢量图形工具感兴趣呢看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!

问:

    如何排除GroundSurface对象的三角形区域/p>

答:

    在6022中添加了新方法VectorDraw.Geometry.Delaunay.Triangulate和GetSliceRegionPoints of gPoints。

public static gTriangles Triangulate(gPoints points,ushort precision)

  • 使用Delaunay算法对给定点进行三角测量。

  • 要点:输入样本点进行三角测量。

  • precision:传递点的小数精度。

  • 返回:gTriangles集合。

gPoints GetSliceRegionPoints(vdArray

    返回SliceRegions中所有点的集合,区域之间的所有交叉点以及区域段与此Triangle集合之间的所有交集。

  • SliceRegions:区域集合。

  • precision:传递点的小数精度。

  • 返回属于在此集合的三角形上投影的SliceRegions的所有点的集合。

    从三角测量中排除区域的示例

   //create an array of points that represent a mountain                gPoints pts = new gPoints();                                //add points from a 16 segments divided circle with radius 10 and elevation 50                pts += Globals.GetArcSamplePoints(16, 10, 0.0, Globals.VD_TWOPI, 50);                //add points from a 32 segments divided circle with radius 20 and elevation 40                pts += Globals.GetArcSamplePoints(32, 20, 0.0, Globals.VD_TWOPI,40);                //add points from a 48 segments divided circle with radius 30 and elevation 30                pts += Globals.GetArcSamplePoints(48, 30, 0.0, Globals.VD_TWOPI,30);                //add points from a 64 segments divided circle with radius 40 and elevation 20                pts += Globals.GetArcSamplePoints(64, 40, 0.0, Globals.VD_TWOPI,20);                //add points from a 78 segments divided circle with radius 50 and elevation 10                pts += Globals.GetArcSamplePoints(78, 50, 0.0, Globals.VD_TWOPI,10);                //add a point at the top of the mountain.                pts += new gPoint(0, 0, 60);                //create an array of points that defines a region that will not contains triangles inside                gPoints SliceRegionInside = new gPoints(new gPoint[] { new gPoint(-18, 3), new gPoint(-18, 18), new gPoint(-3, 18), new gPoint(-3, 3), new gPoint(-18, 3) });                //create an array of points that defines a region that will not contains triangles outside it.                gPoints SliceRegionOutside = new gPoints(new gPoint[] { new gPoint(-35, -35), new gPoint(-35, 35), new gPoint(35, 35), new gPoint(35, -35), new gPoint(-35, -35) });                //add all the regions into a collection                vdArray SliceRegions = new vdArray(new gPoints[] { SliceRegionInside, SliceRegionOutside });                ushort percision = 8;                //calculate the result triangles using decimal precision 8 for passed points.                gTriangles newtriangles = Delaunay.Triangulate(pts, percision);                //calculate all intersection points between SliceRegions and triangles.                //Z values of intersections are projected on triangles collection.                gPoints intPts = newtriangles.GetSliceRegionPoints(SliceRegions, percision);                //re-calculate the triangles using the basic input points and the calculated intersections.                newtriangles = Delaunay.Triangulate(pts + intPts, percision);                                //remove the triangles according to region usage.                gTriangles RemovedInsideTriangles = newtriangles.RemoveInsideTriangles(SliceRegionInside);                gTriangles RemovedOutsideTriangles = newtriangles.RemoveOutsideTriangles(SliceRegionOutside);                //create a new ground sourface with the calculating triangles.                vdGroundSurface gf = new vdGroundSurface();                gf.SetUnRegisterDocument(doc);                gf.setDocumentDefaults();                gf.Points = pts;                gf.SelectUserTriangles(newtriangles);                gf.DispMode = vdGroundSurface.DisplayMode.Triangle;                doc.Model.Entities.AddItem(gf);                doc.CommandAction.Zoom("e", null, null);

8月省钱式嗨购|Office 365三大版本免费送,云端办公更畅快!

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年7月16日
下一篇 2019年7月16日

相关推荐

发表回复

登录后才能评论