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


C# Curve.TryGetPolyline方法代码示例

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


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

示例1: SilkwormSegment

        public SilkwormSegment(Curve curve, int mainSegmentCount, int subSegmentCount, double maxAngleRadians, double maxChordLengthRatio, double maxAspectRatio, double tolerance, double minEdgeLength, double maxEdgeLength, bool keepStartPoint)
        {
            if (curve != null)
            {
                //See if curve can be represented as a polyline already
                if (curve.TryGetPolyline(out Pline))
                {
                    PolylineCurve plinecurve = new PolylineCurve(Pline);
                    //Segments = plinecurve.DuplicateSegments().ToList();
                    Segments = DuplicateSegments(plinecurve);
                }

                //Try to see if conversion will work
                if (curve.ToPolyline(mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint) != null)
                {
                    //Convert
                    PolylineCurve plinec = curve.ToPolyline(mainSegmentCount, subSegmentCount, maxAngleRadians, maxChordLengthRatio, maxAspectRatio, tolerance, minEdgeLength, maxEdgeLength, keepStartPoint);

                    if (plinec.TryGetPolyline(out Pline))
                    {
                        PolylineCurve plinecurve = new PolylineCurve(Pline);
                        //Segments = plinecurve.DuplicateSegments().ToList();
                        Segments = DuplicateSegments(plinecurve);
                    }
                }

            }
        }
开发者ID:samuto,项目名称:Silkworm,代码行数:28,代码来源:Segmenter.cs

示例2: ExtractTMesh

        public static TurtleMesh ExtractTMesh(Curve c)
        {
            var m = new TurtleMesh();
            Polyline pl;
            c.TryGetPolyline(out pl);

            TurtleFace f = new TurtleFace(pl.Count - 1);

            for (int j = 0; j < pl.Count - 1; j++)
            {
                var v = pl[j];
                f.Add(m.VertexCount);
                m.AddVertex(new TurtleVertex((float)v.X, (float)v.Y, (float)v.Z));
            }
            m.AddFace(f);
            return m;
        }
开发者ID:goznauk,项目名称:TurtleMesh,代码行数:17,代码来源:RhinoMeshSupport.cs

示例3: CurveSegments

 protected bool CurveSegments(List<Curve> L, Curve crv, bool recursive)
 {
     if (crv == null) { return false; }
     PolyCurve polycurve = crv as PolyCurve;
     if (polycurve != null)
     {
         if (recursive) { polycurve.RemoveNesting(); }
         Curve[] segments = polycurve.Explode();
         if (segments == null) { return false; }
         if (segments.Length == 0) { return false; }
         if (recursive)
         {
             foreach (Curve S in segments)
             {
                 CurveSegments(L, S, true);
             }
         }
         else
         {
             foreach (Curve S in segments)
             {
                 L.Add(S.DuplicateShallow() as Curve);
             }
         }
         return true;
     }
     PolylineCurve polyline = crv as PolylineCurve;
     if (polyline != null)
     {
         if (recursive)
         {
             for (int i = 0; i < (polyline.PointCount - 1); i++)
             {
                 L.Add(new LineCurve(polyline.Point(i), polyline.Point(i + 1)));
             }
         }
         else
         {
             L.Add(polyline.DuplicateCurve());
         }
         return true;
     }
     Polyline p;
     if (crv.TryGetPolyline(out p))
     {
         if (recursive)
         {
             for (int i = 0; i < (p.Count - 1); i++)
             {
                 L.Add(new LineCurve(p[i], p[i + 1]));
             }
         }
         else
         {
             L.Add(new PolylineCurve(p));
         }
         return true;
     }
     //Maybe it's a LineCurve?
     LineCurve line = crv as LineCurve;
     if (line != null)
     {
         L.Add(line.DuplicateCurve());
         return true;
     }
     //It might still be an ArcCurve...
     ArcCurve arc = crv as ArcCurve;
     if (arc != null)
     {
         L.Add(arc.DuplicateCurve());
         return true;
     }
     //Nothing else worked, lets assume it's a nurbs curve and go from there...
     NurbsCurve nurbs = crv.ToNurbsCurve();
     if (nurbs == null) { return false; }
     double t0 = nurbs.Domain.Min;
     double t1 = nurbs.Domain.Max;
     int LN = L.Count;
     do
     {
       double t;
       if (!nurbs.GetNextDiscontinuity(Continuity.C1_locus_continuous, t0, t1, out t)) { break; }
         Interval trim = new Interval(t0, t);
         if (trim.Length < 1e-10)
         {
             t0 = t;
             continue;
         }
         Curve M = nurbs.DuplicateCurve();
         M = M.Trim(trim);
         if (M.IsValid) { L.Add(M); }
         t0 = t;
     } while (true);
     if (L.Count == LN) { L.Add(nurbs); }
     return true;
 }
开发者ID:ramonvanderheijden,项目名称:Lyrebird,代码行数:96,代码来源:GHClient.cs


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