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


C# Polygon.AddHole方法代码示例

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


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

示例1: triangulate

        bool triangulate()
        {
            if (Outline == null || Outline.Spline == null) {
                Error = "Missing Outline Spline";
                return false;
            }
            if (!polyLineIsValid(Outline)){
                Error=Outline.Spline.name+": Angle must be >0";
                return false;
            }

            Vector3[] outlineVerts = Outline.getVertices();
            if (outlineVerts.Length < 3) {
                Error=Outline.Spline.name+": At least 3 Vertices needed!";
                return false;
            }
            p2t = new Polygon(outlineVerts);

            if (VertexLineOnly)
                return true;

            for (int i = 0; i < Holes.Count; i++) {
                if (Holes[i].Spline == null) {
                    Error = "Missing Hole Spline";
                    return false;
                }
                if (!polyLineIsValid(Holes[i])) {
                    Error = Holes[i].Spline.name + ": Angle must be >0";
                    return false;
                }
                Vector3[] verts=Holes[i].getVertices();
                if (verts.Length<3){
                    Error=Holes[i].Spline.name+": At least 3 Vertices needed!";
                    return false;
                }
                p2t.AddHole(new Polygon(verts));
            }
            try {
                P2T.Triangulate(p2t);
                return true;
            }
            catch (System.Exception e) {
                Error = e.Message;
            }

            return false;
        }
开发者ID:shaunvxc,项目名称:Infamy,代码行数:47,代码来源:CurvyUtility.cs

示例2: Refresh

        /*! \endcond */
        #endregion

        #region ### Public Methods ###

        public override void Refresh()
        {
            base.Refresh();
            CGVolume vol = InVolume.GetData<CGVolume>();
            var holes = InVolumeHoles.GetAllData<CGVolume>();

            if (vol)
            {
                bool genStart = (StartCap == CGYesNoAuto.Yes || (StartCap == CGYesNoAuto.Auto && !vol.Seamless));
                bool genEnd = (EndCap == CGYesNoAuto.Yes || (EndCap == CGYesNoAuto.Auto && !vol.Seamless));

                if (!genStart && !genEnd)
                {
                    OutVMesh.SetData(null);
                    return;
                }

                var vmesh = new CGVMesh();
                Vector3[] vtStart = new Vector3[0];
                Vector3[] vtEnd = new Vector3[0];



                Polygon pOuter;

                vmesh.AddSubMesh(new CGVSubMesh());
                CGVSubMesh submesh = vmesh.SubMeshes[0];
                Vector3[] points;

                if (genStart)
                {
                    #region --- Start Cap ---
                    points = make2DSegment(vol, 0);
                    if (points.Length < 3)
                    {
                        OutVMesh.SetData(null);
                        UIMessages.Add("Cross has <3 Vertices: Can't create Caps!");
                        return;
                    }

                    pOuter = new Polygon(points);

                    for (int h = 0; h < holes.Count; h++)
                    {
                        points = make2DSegment(holes[h], 0);
                        if (points.Length < 3)
                        {
                            OutVMesh.SetData(null);
                            UIMessages.Add("Hole Cross has <3 Vertices: Can't create Caps!");
                            return;
                        }
                        pOuter.AddHole(new Polygon(points));
                    }

                    try
                    {
                        P2T.Triangulate(pOuter);
                    }
                    catch (System.Exception e)
                    {
                        Debug.LogException(e);
                        OutVMesh.SetData(null);
                        return;
                    }

                    submesh.Material = StartMaterial;
                    pOuter.GetResults(out vtStart, out submesh.Triangles, ReverseTriOrder);
                    vmesh.Vertex = applyMat(vtStart, getMat(vol, 0, true));
                    if (GenerateUV)
                    {
                        vmesh.UV = new Vector2[vtStart.Length];
                        applyUV(vtStart, ref vmesh.UV, 0, vtStart.Length, pOuter.Bounds.Bounds, StartMaterialSettings);
                    }



                    #endregion
                }

                if (genEnd)
                {
                    #region --- End Cap ---

                    points = make2DSegment(vol, vol.Count - 1);
                    if (points.Length < 3)
                    {
                        OutVMesh.SetData(null);
                        UIMessages.Add("Cross has <3 Vertices: Can't create Caps!");
                        return;
                    }
                    pOuter = new Polygon(points);

                    for (int h = 0; h < holes.Count; h++)
                    {
                        points = make2DSegment(holes[h], holes[h].Count - 1);
//.........这里部分代码省略.........
开发者ID:scumbly,项目名称:Organ-Grinder,代码行数:101,代码来源:BuildVolumeCaps.cs


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