当前位置: 首页>>代码示例>>C#>>正文


C# Contour.AddRange方法代码示例

本文整理汇总了C#中Contour.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Contour.AddRange方法的具体用法?C# Contour.AddRange怎么用?C# Contour.AddRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contour的用法示例。


在下文中一共展示了Contour.AddRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddHole

        // Assumes that points being passed in the list are connected and form a polygon.
        // Note that some error checking is done for robustness, but for the most part,
        // we have to rely on the user to feed us "correct" data
        public bool AddHole(List<TriangulationPoint> points, string name)
        {
            if (points == null)
            {
                return false;
            }

            //// split our self-intersection sections into their own lists
            List<Contour> pts = new List<Contour>();
            int listIdx = 0;
            {
                Contour c = new Contour(this, points, WindingOrderType.Unknown);
                pts.Add(c);

                // only constrain the points if we actually HAVE a bounding rect
                if (mPoints.Count > 1)
                {
                    // constrain the points to bounding rect
                    int numPoints = pts[listIdx].Count;
                    for (int i = 0; i < numPoints; ++i)
                    {
                        ConstrainPointToBounds(pts[listIdx][i]);
                    }
                }
            }

            while (listIdx < pts.Count)
            {
                // simple sanity checking - remove duplicate coincident points before
                // we check the polygon: fast, simple algorithm that eliminate lots of problems
                // that only more expensive checks will find
                pts[listIdx].RemoveDuplicateNeighborPoints();
                pts[listIdx].WindingOrder = Point2DList.WindingOrderType.Default;

                bool bListOK = true;
                Point2DList.PolygonError err = pts[listIdx].CheckPolygon();
                while (bListOK && err != PolygonError.None)
                {
                    if ((err & PolygonError.NotEnoughVertices) == PolygonError.NotEnoughVertices)
                    {
                        bListOK = false;
                        continue;
                    }
                    if ((err & PolygonError.NotSimple) == PolygonError.NotSimple)
                    {
                        // split the polygons, remove the current list and add the resulting list to the end
                        //List<Point2DList> l = TriangulationUtil.SplitSelfIntersectingPolygon(pts[listIdx], pts[listIdx].Epsilon);
                        List<Point2DList> l = PolygonUtil.SplitComplexPolygon(pts[listIdx], pts[listIdx].Epsilon);
                        pts.RemoveAt(listIdx);
                        foreach (Point2DList newList in l)
                        {
                            Contour c = new Contour(this);
                            c.AddRange(newList);
                            pts.Add(c);
                        }
                        err = pts[listIdx].CheckPolygon();
                        continue;
                    }
                    if ((err & PolygonError.Degenerate) == PolygonError.Degenerate)
                    {
                        pts[listIdx].Simplify(this.Epsilon);
                        err = pts[listIdx].CheckPolygon();
                        continue;
                        //err &= ~(PolygonError.Degenerate);
                        //if (pts[listIdx].Count < 3)
                        //{
                        //    err |= PolygonError.NotEnoughVertices;
                        //    bListOK = false;
                        //    continue;
                        //}
                    }
                    if ((err & PolygonError.AreaTooSmall) == PolygonError.AreaTooSmall ||
                        (err & PolygonError.SidesTooCloseToParallel) == PolygonError.SidesTooCloseToParallel ||
                        (err & PolygonError.TooThin) == PolygonError.TooThin ||
                        (err & PolygonError.Unknown) == PolygonError.Unknown)
                    {
                        bListOK = false;
                        continue;
                    }
                    // non-convex polygons are ok
                    //if ((err & PolygonError.NotConvex) == PolygonError.NotConvex)
                    //{
                    //}
                }
                if (!bListOK && pts[listIdx].Count != 2)
                {
                    pts.RemoveAt(listIdx);
                }
                else
                {
                    ++listIdx;
                }
            }

            bool bOK = true;
            listIdx = 0;
            while (listIdx < pts.Count)
//.........这里部分代码省略.........
开发者ID:GaelicGamer,项目名称:Tiled2Unity,代码行数:101,代码来源:ConstrainedPointSet.cs

示例2: btnTriangulate_Click

        // Julia
        private void btnTriangulate_Click(object sender, EventArgs e)
        {
            //Evgenij
            _contourPoints = new Contour(_singleContour.Index);
            _contourPoints.AddRange(_singleContour);
            //end Evgenij

            Triangulator triangulator = new Triangulator();
            _triangleList = (triangulator.Triangulate(_singleContour)) as List<Triangle>;
            tabCtrlContours.TabPages.Clear();
            _tabControlHelper.CreatePageForContour(_singleContour);
            _geometryDrawer.DrawTriangles(Pens.Black, _triangleList.ToArray());
            //Evgeniya
            ButtonController.Instance().CurrentState = ButtonState.TriangulationPressed;
            ButtonController.Instance().changeButtonState(btnClear, btnCompleteInput, btnGetSingleContour, btnNetReculc, btnTriangulate, btnRenumerator, btnSolve);
            //end Evgeniya
        }
开发者ID:StanislavUshakov,项目名称:NumericalMethods,代码行数:18,代码来源:FormMain.cs


注:本文中的Contour.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。