IGH_Goo IGH_Goo.Duplicate()
        {
            GdiShapeGoo goo = new GdiShapeGoo(_points, _edges, _fills);

            goo.DrawFillsBeforeEdges = DrawFillsBeforeEdges;
            return(goo);
        }
Exemple #2
0
        protected override void SolveInstance(IGH_DataAccess access)
        {
            Curve  curve = null;
            string edge  = null;
            string fill  = null;

            if (!access.GetData(0, ref curve))
            {
                return;
            }
            access.GetData(1, ref edge);
            access.GetData(2, ref fill);

            if (string.IsNullOrWhiteSpace(edge) && string.IsNullOrWhiteSpace(fill))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Either an edge or a fill is required.");
                return;
            }

            Polyline polyline;

            if (!curve.TryGetPolyline(out polyline))
            {
                curve = curve.ToPolyline(0.1, RhinoMath.ToRadians(0.2), 0.01, 100);
                curve.TryGetPolyline(out polyline);
            }
            if (polyline == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Curve could not be converted to polyline.");
                return;
            }

            List <string> edges = new List <string>();
            List <string> fills = new List <string>();

            if (!string.IsNullOrWhiteSpace(edge))
            {
                edges.Add(edge);
            }
            if (!string.IsNullOrWhiteSpace(fill))
            {
                fills.Add(fill);
            }

            GdiShapeGoo goo = new GdiShapeGoo(polyline, edges, fills)
            {
                DrawFillsBeforeEdges = true
            };

            access.SetData(0, goo);
        }
Exemple #3
0
        protected override void SolveInstance(IGH_DataAccess access)
        {
            Curve         curve = null;
            List <string> edges = new List <string>();
            List <string> fills = new List <string>();
            bool          order = true;

            if (!access.GetData(0, ref curve))
            {
                return;
            }
            if (!access.GetData(3, ref order))
            {
                return;
            }

            access.GetDataList(1, edges);
            access.GetDataList(2, fills);

            for (int i = edges.Count - 1; i >= 0; i--)
            {
                if (string.IsNullOrWhiteSpace(edges[i]))
                {
                    edges.RemoveAt(i);
                }
            }

            for (int i = fills.Count - 1; i >= 0; i--)
            {
                if (string.IsNullOrWhiteSpace(fills[i]))
                {
                    fills.RemoveAt(i);
                }
            }

            if (edges.Count == 0 && fills.Count == 0)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "At least a single edge or fill is required.");
                return;
            }

            Polyline polyline;

            if (!curve.TryGetPolyline(out polyline))
            {
                curve = curve.ToPolyline(0.1, RhinoMath.ToRadians(0.2), 0.01, 100);
                curve.TryGetPolyline(out polyline);
            }
            if (polyline == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Curve could not be converted to polyline.");
                return;
            }

            GdiShapeGoo goo = new GdiShapeGoo(polyline, edges, fills)
            {
                DrawFillsBeforeEdges = order
            };

            access.SetData(0, goo);
        }