Example #1
0
 public BakeGeometry GetBKGT(Rhino.Geometry.Polyline m)
 {
     return(new BakeGeometry((d, a, o) =>
     {
         Rhino.DocObjects.ObjectAttributes a2 = a.Duplicate();
         a2.LayerIndex = 4;
         o.Add(d.Objects.AddPolyline(m, a2));
     }));
 }
 public UpdateGeometry GetUPGR(Rhino.Geometry.Polyline m)
 {
     return(new UpdateGeometry((x, y, z) =>
     {
         m.Clear();
         for (int i = 0; i < pS.Value.__N; i++)
         {
             m.Add(pS.Value.particles[i, 0] + x, pS.Value.particles[i, 1] + y, pS.Value.particles[i, 2] + z);
         }
     }));
 }
        public static Rhino.Geometry.Polyline ConvertToRhinoPolyline(g3.PolyLine3d inputLine)
        {
            var pLine = new Rhino.Geometry.Polyline();

            foreach (var p in inputLine)
            {
                pLine.Add(p.x, p.y, p.z);
            }

            return(pLine);
        }
 public DrawViewPortWire GetDVPW(Rhino.Geometry.Polyline m)
 {
     return(new DrawViewPortWire((args) =>
     {
         if (Hidden)
         {
             return;
         }
         if (this.Attributes.Selected)
         {
             args.Display.DrawPolyline(m, System.Drawing.Color.Red, 3);
         }
         else
         {
             args.Display.DrawPolyline(m, System.Drawing.Color.DarkMagenta, 3);
         }
     }));
 }
Example #5
0
 public DrawViewPortWire GetDVPW(Rhino.Geometry.Polyline m)
 {
     return(new DrawViewPortWire((args) =>
     {
         if (Hidden)
         {
             return;
         }
         if (this.Attributes.Selected)
         {
             args.Display.DrawPolyline(m, System.Drawing.Color.Red, 3);
             args.Display.DrawPoints(m, Rhino.Display.PointStyle.Simple, 2, System.Drawing.Color.Yellow);
         }
         else
         {
             args.Display.DrawPolyline(m, System.Drawing.Color.Cyan, 3);
             args.Display.DrawPoints(m, Rhino.Display.PointStyle.Simple, 2, System.Drawing.Color.Yellow);
         }
     }));
 }
        protected static int ToPolylineBuffer
        (
            Rhino.Geometry.Polyline polyline,
            out VertexFormatBits vertexFormatBits,
            out VertexBuffer vb, out int vertexCount,
            out IndexBuffer ib
        )
        {
            int linesCount = 0;

            if (polyline.SegmentCount > 0)
            {
                linesCount  = polyline.SegmentCount;
                vertexCount = polyline.Count;

                vertexFormatBits = VertexFormatBits.Position;
                vb = new VertexBuffer(vertexCount * VertexPosition.GetSizeInFloats());
                vb.Map(vertexCount * VertexPosition.GetSizeInFloats());
                using (var vstream = vb.GetVertexStreamPosition())
                {
                    foreach (var v in polyline)
                    {
                        vstream.AddVertex(new VertexPosition(RawEncoder.ToHost(v)));
                    }
                }
                vb.Unmap();

                ib = IndexLinesBuffer(vertexCount);
            }
            else
            {
                vertexFormatBits = 0;
                vb = null; vertexCount = 0;
                ib = null;
            }

            return(linesCount);
        }
Example #7
0
        public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            //base.DrawViewportWires(args);
            int defaultPointRadius = 2;

            for (int n = 0; n < m_obj.Count; n++)
            {
                object obj = m_obj[n];
                Rhino.DocObjects.ObjectAttributes att = m_att[n].Value;
                if (obj == null) continue;
                Type objectType = obj.GetType();
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Vector))
                {
                    Rhino.Geometry.Vector3d rh_vec = ((Grasshopper.Kernel.Types.GH_Vector)obj).Value;
                    args.Display.DrawArrow(new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(0, 0, 0), new Rhino.Geometry.Point3d(rh_vec)), att.ObjectColor);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Point))
                {
                    Rhino.Geometry.Point3d rh_point = ((Grasshopper.Kernel.Types.GH_Point)obj).Value;
                    if (att.PlotWeight == 0) args.Display.DrawPoint(rh_point, Rhino.Display.PointStyle.Simple, defaultPointRadius, att.ObjectColor);
                    else args.Display.DrawPoint(rh_point, Rhino.Display.PointStyle.Simple, (int)att.PlotWeight, att.ObjectColor);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Line))
                {
                    Rhino.Geometry.Line rh_line = ((Grasshopper.Kernel.Types.GH_Line)obj).Value;
                    if (att.PlotWeight == 0) args.Display.DrawLine(rh_line, att.ObjectColor);
                    else args.Display.DrawLine(rh_line, att.ObjectColor, (int)att.PlotWeight);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Mesh))
                {
                    Rhino.Geometry.Mesh rh_mesh = ((Grasshopper.Kernel.Types.GH_Mesh)obj).Value;
                    Rhino.Display.DisplayMaterial mat = new Rhino.Display.DisplayMaterial(att.ObjectColor, 0.5);
                    args.Display.DrawMeshShaded(rh_mesh, mat);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Curve))
                {
                    //TODO: deal with open polylines, curves, non-planar polycurves, etc
                    Rhino.Geometry.Curve rh_curve = ((Grasshopper.Kernel.Types.GH_Curve)obj).Value;

                    Rhino.Geometry.Polyline rh_pline = new Rhino.Geometry.Polyline();
                    if ((rh_curve.IsClosed) && (rh_curve.IsPlanar()) && (rh_curve.TryGetPolyline(out rh_pline)))
                    {
                        bool fill = true;
                        Rhino.Geometry.Intersect.CurveIntersections iev = Rhino.Geometry.Intersect.Intersection.CurveSelf(rh_curve, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
                        if (iev.Count > 0)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Found a self-intersecting polygon.  Fills will not be applied.");
                            fill = false;
                        }
                        args.Display.DrawPolygon(rh_pline, att.ObjectColor, false);

                        if (fill)
                        {
                            Rhino.Geometry.Mesh m = Rhino.Geometry.Mesh.CreateFromPlanarBoundary(rh_curve, Rhino.Geometry.MeshingParameters.Smooth);
                            args.Display.DrawMeshShaded(m, new Rhino.Display.DisplayMaterial(att.ObjectColor, 0.5));
                        }
                        continue;
                    }
                }

                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The component does not know how to handle this type of gh_geometry: " + objectType.FullName);
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(1, ref v);
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Curve c = null;
                if (!DA.GetData(0, ref c))
                {
                    return;
                }
                if (c.IsPolyline())
                {
                    Rhino.Geometry.Polyline pl = null;
                    if (c.TryGetPolyline(out pl))
                    {
                        nNewNodes = pl.Count();
                        nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);


                        mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]);
                        }
                        List <mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List <mikity.NumericalMethodHelper.elements.isoparametricElement>();
                        for (int i = 0; i < nElements; i++)
                        {
                            e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1));
                        }
                        lCV.Clear();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < e.Count; i++)
                        {
                            lCV.Add(new constrainVolumeObject(v / nElements));
                            lCV[i].addElement(e[i]);
                            pS.Value.addObject(lCV[i]);
                        }

                        lGeometry.Clear();
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lGeometry.Add(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2]);
                        }
                        this.DVPW = GetDVPW(lGeometry);
                        pS.DVPW   = GetDVPW(lGeometry2);
                        pS.UPGR   = GetUPGR(lGeometry2);
                        pS.BKGT   = GetBKGT(lGeometry2);
                        this.BKGT = GetBKGT(lGeometry);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }
            DA.SetData(0, pS);
            DA.SetDataList(1, newNodes);
        }
Example #9
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Curve c = null;
                if (!DA.GetData(0, ref c))
                {
                    return;
                }
                if (c.IsPolyline())
                {
                    Rhino.Geometry.Polyline pl = null;
                    if (c.TryGetPolyline(out pl))
                    {
                        int nNewNodes = pl.Count();
                        int nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);
                        GH_material mat = null;
                        GH_gravity  gvt = null;
                        if (!DA.GetData(1, ref mat))
                        {
                            return;
                        }
                        if (!DA.GetData(2, ref gvt))
                        {
                            return;
                        }


                        mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]);
                        }

                        eM = new generalSpring();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < nElements; i++)
                        {
                            mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(i, i + 1);
                            eM.addElement(e);
                        }
                        eM.setMaterial(mat.Value, gvt.Value);
                        pS.Value.addObject(eM);
                        lGeometry  = new Rhino.Geometry.Polyline();
                        lGeometry2 = new Rhino.Geometry.Polyline();

                        for (int i = 0; i < pS.Value.__N; i++)
                        {
                            lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]);
                        }

                        this.DVPW = GetDVPW(lGeometry);
                        pS.DVPW   = GetDVPW(lGeometry2);
                        pS.UPGR   = GetUPGR(lGeometry2);
                        pS.BKGT   = GetBKGT(lGeometry2);
                        this.BKGT = GetBKGT(lGeometry);

                        DA.SetData(0, pS);
                        DA.SetDataList(1, newNodes);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[2];
                List <GH_Point> tmpPointList = new List <GH_Point>();

                int[] nEdgeNodes = new int[_dim];
                eM = new generalSpring();
                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                DA.GetData(2, ref nEdgeNodes[0]);
                GH_material mat = null;
                if (!DA.GetData(3, ref mat))
                {
                    return;
                }
                GH_gravity gvt = null;
                if (!DA.GetData(4, ref gvt))
                {
                    return;
                }
                for (int i = 0; i < _dim; i++)
                {
                    if (nEdgeNodes[i] < 2)
                    {
                        AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2");
                        return;
                    }
                }
                //点群生成
                double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes);
                int nNewNodes = wt.GetLength(0);
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    particles[i] = new particle(0, 0, 0);
                    for (int j = 0; j < _nNodes; j++)
                    {
                        particles[i][0] += pointList[j].Value.X * wt[i, j];
                        particles[i][1] += pointList[j].Value.Y * wt[i, j];
                        particles[i][2] += pointList[j].Value.Z * wt[i, j];
                    }
                }
                el = MathUtil.isoparametricElements(nEdgeNodes);
                int nElements = el.Length;
                pS = new GH_particleSystem(particles);
                for (int i = 0; i < nElements; i++)
                {
                    eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i]));
                }
                eM.setMaterial(mat.Value, gvt.Value);
                pS.Value.addObject(eM);
                lGeometry  = new Rhino.Geometry.Polyline();
                lGeometry2 = new Rhino.Geometry.Polyline();

                for (int i = 0; i < pS.Value.__N; i++)
                {
                    lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]);
                }

                this.DVPW = GetDVPW(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }

            DA.SetData(0, pS);
        }
Example #11
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            newNodes.Clear();
            if (!DA.GetData(1, ref v))
            {
                return;
            }
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Curve c = null;
                if (!DA.GetData(0, ref c))
                {
                    return;
                }
                if (c.IsPolyline())
                {
                    Rhino.Geometry.Polyline pl = null;
                    if (c.TryGetPolyline(out pl))
                    {
                        int nNewNodes = pl.Count();
                        int nElements = nNewNodes - 1;
                        newNodes.AddRange(pl);

                        //メッシュ構築

                        mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]);
                        }
                        pS = new GH_particleSystem(particles);
                        node[] lNodes = new node[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lNodes[i] = new node(i);
                            lNodes[i].copyFrom(pS.Value.particles);
                        }
                        nF = new nodalForce(v.X, v.Y, v.Z);
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            nF.addNode(lNodes[i]);
                        }
                        pS.Value.addObject(nF);
                        lGeometry.Clear();
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lGeometry.Add(new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]));
                        }
                        this.DVPW = GetDVPW(lGeometry);
                        pS.DVPW   = GetDVPW(lGeometry2);
                        pS.UPGR   = GetUPGR(lGeometry2);
                        pS.BKGT   = GetBKGT(lGeometry2);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }
            DA.SetData(0, pS);
        }
Example #12
0
        public static string makeDocBox()
        {
            try
            {
                //If docBox has not been created, create it and place it on its natalus layer.

                /* Abandoning layer idea for now. Not working as intended.
                 * Rhino.DocObjects.Layer layer_D10 = new Rhino.DocObjects.Layer();
                 * int layer_D10_index = -1;
                 *
                 * if (RhinoDoc.ActiveDoc.Layers.FindName("D10").Index < 0)
                 * {
                 *  RhinoDoc.ActiveDoc.Layers.Add(layer_D10);
                 *  layer_D10_index = layer_D10.Index;
                 * }
                 * else
                 * {
                 *  layer_D10 = RhinoDoc.ActiveDoc.Layers.FindName("D10");
                 *  layer_D10_index = layer_D10.Index;
                 * }
                 */

                //Set initial dimensions and record to D01 if D01 does not exist.
                string D01_Path = utils.file_structure.getPathFor("D01");
                string D20_Path = utils.file_structure.getPathFor("D20");

                double docBox_width  = 12;
                double docBox_height = 12;

                Rhino.Geometry.Point3d refPoint = new Rhino.Geometry.Point3d(0, 0, 0);

                //Check if previous dim configuration existed.
                if (System.IO.File.Exists(D01_Path) == true)
                {
                    string[] dims = System.IO.File.ReadAllText(D01_Path).Split('|');

                    docBox_width  = Convert.ToDouble(dims[0]);
                    docBox_height = Convert.ToDouble(dims[1]);
                }
                else
                {
                    System.IO.File.WriteAllText(D01_Path, "12|12");
                }

                double adjust = 0;

                if (System.IO.File.Exists(D20_Path) == true)
                {
                    string[] coords = System.IO.File.ReadAllText(D20_Path).Split(',');

                    refPoint.X = Convert.ToDouble(coords[0]);
                    refPoint.Y = Convert.ToDouble(coords[1]);

                    adjust = docBox_height;
                }
                else if (System.IO.File.Exists(D20_Path) == false)
                {
                    adjust = 0;
                }

                Rhino.Geometry.Plane docBox_plane = Rhino.Geometry.Plane.WorldXY;
                docBox_plane.OriginX = refPoint.X;
                docBox_plane.OriginY = refPoint.Y - adjust;

                Rhino.Geometry.Rectangle3d docBox = new Rhino.Geometry.Rectangle3d(docBox_plane, docBox_width, docBox_height);

                Rhino.DocObjects.ObjectAttributes docBox_attributes = new Rhino.DocObjects.ObjectAttributes();

                //Until layer process resolved, docBox to be on any layer.
                int activeIndex = RhinoDoc.ActiveDoc.Layers.CurrentLayerIndex;
                docBox_attributes.LayerIndex = activeIndex;

                //(Rhino 5) Convert docBox Rectangle3D to polyline curve.
                Rhino.Geometry.Polyline docBoxPolyline = docBox.ToPolyline();

                //Freeze updating while docBox is created.
                string x10_path = utils.file_structure.getPathFor("x10");
                System.IO.File.WriteAllText(x10_path, "false");

                //Determine GUID and record to D10.
                Guid newGuid = RhinoDoc.ActiveDoc.Objects.AddPolyline(docBoxPolyline);

                Rhino.DocObjects.ObjRef      docBoxObj   = new Rhino.DocObjects.ObjRef(newGuid);
                Rhino.DocObjects.CurveObject docBoxCurve = docBoxObj.Object() as Rhino.DocObjects.CurveObject;

                string docBoxGUID = newGuid.ToString();

                string D10_Path = utils.file_structure.getPathFor("D10");
                if (System.IO.File.Exists(D10_Path) && System.IO.File.ReadAllText(D10_Path) != "")
                {
                    string D11_Path = utils.file_structure.getPathFor("D11");
                    System.IO.File.WriteAllText(D11_Path, System.IO.File.ReadAllText(D10_Path));
                }
                System.IO.File.WriteAllText(D10_Path, docBoxGUID);

                //Set curve to Illustrator orange.
                System.Drawing.Color docBoxColor = System.Drawing.Color.FromArgb(240, 120, 6);

                docBoxCurve.Attributes.ColorSource      = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
                docBoxCurve.Attributes.ObjectColor      = docBoxColor;
                docBoxCurve.Attributes.PlotColorSource  = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject;
                docBoxCurve.Attributes.PlotColor        = docBoxColor;
                docBoxCurve.Attributes.PlotWeightSource = Rhino.DocObjects.ObjectPlotWeightSource.PlotWeightFromObject;
                docBoxCurve.Attributes.PlotWeight       = 1.5;

                docBoxCurve.CommitChanges();

                //Label it!
                Rhino.Geometry.TextEntity label = new Rhino.Geometry.TextEntity();

                label.TextHeight = .4;

                Rhino.Geometry.Plane label_plane = Rhino.Geometry.Plane.WorldXY;
                label_plane.OriginX = docBox_plane.OriginX;
                label_plane.OriginY = docBox_plane.OriginY - .4 - .1;
                label.Plane         = label_plane;

                label.Text = ("Linked Illustrator Artboard");

                Guid docBoxLabel = RhinoDoc.ActiveDoc.Objects.AddText(label);

                Rhino.DocObjects.ObjRef     labelObj  = new Rhino.DocObjects.ObjRef(docBoxLabel);
                Rhino.DocObjects.TextObject labelText = labelObj.Object() as Rhino.DocObjects.TextObject;

                labelText.Attributes.ColorSource     = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
                labelText.Attributes.ObjectColor     = docBoxColor;
                labelText.Attributes.PlotColorSource = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject;
                labelText.Attributes.PlotColor       = docBoxColor;

                labelText.CommitChanges();

                string docBoxLabelGUID = docBoxLabel.ToString();

                string D30_Path = utils.file_structure.getPathFor("D30");
                if (System.IO.File.Exists(D30_Path) && System.IO.File.ReadAllText(D30_Path) != "")
                {
                    string D31_Path = utils.file_structure.getPathFor("D31");
                    System.IO.File.WriteAllText(D31_Path, System.IO.File.ReadAllText(D30_Path));
                }
                System.IO.File.WriteAllText(D30_Path, docBoxLabelGUID);


                //Unfreeze updating.
                System.IO.File.WriteAllText(x10_path, "true");

                //Update illustrator boundaries.
                int    conversion = utils.units.conversion();
                string jsxPath    = utils.file_structure.getJavascriptPath();

                echo.interop echo = new echo.interop();
                echo.docBounds(docBox_width, System.Math.Abs(docBox_height), conversion, jsxPath);

                return(docBoxGUID);
            }
            catch (Exception e)
            {
                debug.alert(e.Message + " | " + e.Source);

                return("error");
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Mesh m = null;
                if (!DA.GetData(0, ref m))
                {
                    return;
                }
                lGeometry.Clear();
                lGeometry2.Clear();
                var ms = mikity.GeometryProcessing.MeshStructure.CreateFrom(m);

                var edges    = ms.edges();
                var boundary = new Rhino.Geometry.Polyline();
                newNodes.Clear();
                newNodes.AddRange(m.Vertices.ToPoint3dArray());
                int nNewNodes = newNodes.Count;
                el = new List <int[]>();
                foreach (var e in edges)
                {
                    if (!e.isNaked)
                    {
                        el.Add(new int[2] {
                            e.P.N, e.next.P.N
                        });
                    }
                }
                var s = ms.boundaryStart.hf_begin;
                do
                {
                    var P = m.Vertices[s.P.N];
                    boundary.Add(new Rhino.Geometry.Point3d(P.X, P.Y, P.Z));
                    s = s.next.P.hf_begin;
                } while (s.P != ms.boundaryStart);

                boundary.Add(new Rhino.Geometry.Point3d(boundary[0]));
                var  boundary2 = new Rhino.Geometry.PolylineCurve(boundary);
                bool isJoin    = false;
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]);
                }

                eM = new generalSpring();
                pS = new GH_particleSystem(particles);
                if (!DA.GetData(3, ref isJoin))
                {
                    return;
                }
                if (isJoin)
                {
                    pS.simplify(el);
                }
                foreach (var e in el)
                {
                    var ee = new mikity.NumericalMethodHelper.elements.simplexElement(e);
                    eM.addElement(ee);
                    lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[e[0], 0], pS.Value.particles[e[0], 1], pS.Value.particles[e[0], 2], pS.Value.particles[e[1], 0], pS.Value.particles[e[1], 1], pS.Value.particles[e[1], 2]));
                }
                pS.Value.addObject(eM);
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
                DA.SetData(0, pS);
                DA.SetDataList(1, newNodes);
                DA.SetData(2, boundary);
                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(1, ref mat))
                {
                    return;
                }
                if (!DA.GetData(2, ref gvt))
                {
                    return;
                }
                eM.setMaterial(mat.Value, gvt.Value);
            }
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[8];
                List <GH_Point> tmpPointList = new List <GH_Point>();

                eM = new generalSpring();

                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                DA.GetData(2, ref pointList[2]);
                DA.GetData(3, ref pointList[3]);
                DA.GetData(4, ref pointList[4]);
                DA.GetData(5, ref pointList[5]);
                DA.GetData(6, ref pointList[6]);
                DA.GetData(7, ref pointList[7]);
                DA.GetData(8, ref nEdgeNodes[0]);
                DA.GetData(9, ref nEdgeNodes[1]);
                DA.GetData(10, ref nEdgeNodes[2]);
                GH_material mat = null;
                GH_gravity  gvt = null;
                if (!DA.GetData(11, ref mat))
                {
                    return;
                }
                if (!DA.GetData(12, ref gvt))
                {
                    return;
                }
                for (int i = 0; i < _dim; i++)
                {
                    if (nEdgeNodes[i] < 2)
                    {
                        AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2");
                        return;
                    }
                }
                //点群生成
                double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes);
                int nNewNodes = wt.GetLength(0);
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    particles[i] = new particle(0, 0, 0);
                    for (int j = 0; j < _nNodes; j++)
                    {
                        particles[i][0] += pointList[j].Value.X * wt[i, j];
                        particles[i][1] += pointList[j].Value.Y * wt[i, j];
                        particles[i][2] += pointList[j].Value.Z * wt[i, j];
                    }
                }
                el = MathUtil.isoparametricElements(nEdgeNodes);
                int nElements = el.Length;
                pS = new GH_particleSystem(particles);
                for (int i = 0; i < nElements; i++)
                {
                    eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i]));
                }
                eM.setMaterial(mat.Value, gvt.Value);
                pS.Value.addObject(eM);
                lGeometry.Clear();
                lGeometry2.Clear();
                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline();
                        lGeometry.Add(p);
                        for (int i = 0; i < nEdgeNodes[0]; i++)
                        {
                            p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        }
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline();
                        lGeometry.Add(p);
                        for (int j = 0; j < nEdgeNodes[1]; j++)
                        {
                            p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        }
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline();
                        lGeometry.Add(p);
                        for (int k = 0; k < nEdgeNodes[2]; k++)
                        {
                            p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        }
                    }
                }
                for (int i = 0; i < nEdgeNodes[0] * nEdgeNodes[1] + nEdgeNodes[1] * nEdgeNodes[2] + nEdgeNodes[2] * nEdgeNodes[0]; i++)
                {
                    lGeometry2.Add(new Rhino.Geometry.Polyline());
                }
                lBoundary.Clear();
                lBoundary2.Clear();
                ///////////////////////////////////////////////////////////////
                Rhino.Geometry.Mesh m  = new Rhino.Geometry.Mesh();
                Rhino.Geometry.Mesh m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        int i = 0;
                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[1], nEdgeNodes[2]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }
                m  = new Rhino.Geometry.Mesh();
                m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        int i = nEdgeNodes[0] - 1;

                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[1], nEdgeNodes[2]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }

                ///////////////////////////////////////////////////////////////
                m  = new Rhino.Geometry.Mesh();
                m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int j = 0; j < nEdgeNodes[1]; j++)
                {
                    for (int i = 0; i < nEdgeNodes[0]; i++)
                    {
                        int k = 0;
                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[0], nEdgeNodes[1]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }
                m  = new Rhino.Geometry.Mesh();
                m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int j = 0; j < nEdgeNodes[1]; j++)
                {
                    for (int i = 0; i < nEdgeNodes[0]; i++)
                    {
                        int k = nEdgeNodes[2] - 1;

                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[0], nEdgeNodes[1]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }

                ///////////////////////////////////////////////////////////////
                m  = new Rhino.Geometry.Mesh();
                m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        int j = 0;
                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[2], nEdgeNodes[0]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }
                m  = new Rhino.Geometry.Mesh();
                m2 = new Rhino.Geometry.Mesh();
                lBoundary.Add(m);
                lBoundary2.Add(m2);
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        int j = nEdgeNodes[1] - 1;

                        m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                        m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]);
                    }
                }
                el = MathUtil.isoparametricElements(new int[2] {
                    nEdgeNodes[2], nEdgeNodes[0]
                });
                for (int i = 0; i < el.Length; i++)
                {
                    m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                    m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]);
                }

                this.DVPW = GetDVPW(lGeometry, lBoundary);
                pS.DVPW   = GetDVPW(lGeometry2, lBoundary2);
                pS.UPGR   = GetUPGR(lGeometry2, lBoundary2);
            }

            DA.SetData(0, pS);
        }
        public UpdateGeometry GetUPGR(List <Rhino.Geometry.Polyline> m, List <Rhino.Geometry.Mesh> m2)
        {
            return(new UpdateGeometry((x, y, z) =>
            {
                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        Rhino.Geometry.Polyline p = m[j + k * nEdgeNodes[1]];
                        p.Clear();
                        for (int i = 0; i < nEdgeNodes[0]; i++)
                        {
                            p.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                        }
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        Rhino.Geometry.Polyline p = m[k + i * nEdgeNodes[2] + nEdgeNodes[1] * nEdgeNodes[2]];
                        p.Clear();
                        for (int j = 0; j < nEdgeNodes[1]; j++)
                        {
                            p.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                        }
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        Rhino.Geometry.Polyline p = m[j + i * nEdgeNodes[1] + nEdgeNodes[1] * nEdgeNodes[2] + nEdgeNodes[0] * nEdgeNodes[2]];
                        p.Clear();
                        for (int k = 0; k < nEdgeNodes[2]; k++)
                        {
                            p.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                        }
                    }
                }
                m2[0].Vertices.Clear();
                m2[1].Vertices.Clear();
                m2[2].Vertices.Clear();
                m2[3].Vertices.Clear();
                m2[4].Vertices.Clear();
                m2[5].Vertices.Clear();

                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        int i = 0;
                        m2[0].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
                for (int k = 0; k < nEdgeNodes[2]; k++)
                {
                    for (int j = 0; j < nEdgeNodes[1]; j++)
                    {
                        int i = nEdgeNodes[0] - 1;
                        m2[1].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
                for (int j = 0; j < nEdgeNodes[1]; j++)
                {
                    for (int i = 0; i < nEdgeNodes[0]; i++)
                    {
                        int k = 0;
                        m2[2].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
                for (int j = 0; j < nEdgeNodes[1]; j++)
                {
                    for (int i = 0; i < nEdgeNodes[0]; i++)
                    {
                        int k = nEdgeNodes[2] - 1;
                        m2[3].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        int j = 0;
                        m2[4].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
                for (int i = 0; i < nEdgeNodes[0]; i++)
                {
                    for (int k = 0; k < nEdgeNodes[2]; k++)
                    {
                        int j = nEdgeNodes[1] - 1;
                        m2[5].Vertices.Add(pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0] + x, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1] + y, pS.Value[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2] + z);
                    }
                }
            }));
        }
Example #16
0
        public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            //base.DrawViewportWires(args);
            int defaultPointRadius = 2;

            for (int n = 0; n < m_obj.Count; n++)
            {
                object obj = m_obj[n];
                Rhino.DocObjects.ObjectAttributes att = m_att[n].Value;
                if (obj == null)
                {
                    continue;
                }
                Type objectType = obj.GetType();
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Vector))
                {
                    Rhino.Geometry.Vector3d rh_vec = ((Grasshopper.Kernel.Types.GH_Vector)obj).Value;
                    args.Display.DrawArrow(new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(0, 0, 0), new Rhino.Geometry.Point3d(rh_vec)), att.ObjectColor);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Point))
                {
                    Rhino.Geometry.Point3d rh_point = ((Grasshopper.Kernel.Types.GH_Point)obj).Value;
                    if (att.PlotWeight == 0)
                    {
                        args.Display.DrawPoint(rh_point, Rhino.Display.PointStyle.Simple, defaultPointRadius, att.ObjectColor);
                    }
                    else
                    {
                        args.Display.DrawPoint(rh_point, Rhino.Display.PointStyle.Simple, (int)att.PlotWeight, att.ObjectColor);
                    }
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Line))
                {
                    Rhino.Geometry.Line rh_line = ((Grasshopper.Kernel.Types.GH_Line)obj).Value;
                    if (att.PlotWeight == 0)
                    {
                        args.Display.DrawLine(rh_line, att.ObjectColor);
                    }
                    else
                    {
                        args.Display.DrawLine(rh_line, att.ObjectColor, (int)att.PlotWeight);
                    }
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Mesh))
                {
                    Rhino.Geometry.Mesh           rh_mesh = ((Grasshopper.Kernel.Types.GH_Mesh)obj).Value;
                    Rhino.Display.DisplayMaterial mat     = new Rhino.Display.DisplayMaterial(att.ObjectColor, 0.5);
                    args.Display.DrawMeshShaded(rh_mesh, mat);
                    continue;
                }
                if (objectType == typeof(Grasshopper.Kernel.Types.GH_Curve))
                {
                    //TODO: deal with open polylines, curves, non-planar polycurves, etc
                    Rhino.Geometry.Curve rh_curve = ((Grasshopper.Kernel.Types.GH_Curve)obj).Value;

                    Rhino.Geometry.Polyline rh_pline = new Rhino.Geometry.Polyline();
                    if ((rh_curve.IsClosed) && (rh_curve.IsPlanar()) && (rh_curve.TryGetPolyline(out rh_pline)))
                    {
                        bool fill = true;
                        Rhino.Geometry.Intersect.CurveIntersections iev = Rhino.Geometry.Intersect.Intersection.CurveSelf(rh_curve, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
                        if (iev.Count > 0)
                        {
                            AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Found a self-intersecting polygon.  Fills will not be applied.");
                            fill = false;
                        }
                        args.Display.DrawPolygon(rh_pline, att.ObjectColor, false);

                        if (fill)
                        {
                            Rhino.Geometry.Mesh m = Rhino.Geometry.Mesh.CreateFromPlanarBoundary(rh_curve, Rhino.Geometry.MeshingParameters.Smooth);
                            args.Display.DrawMeshShaded(m, new Rhino.Display.DisplayMaterial(att.ObjectColor, 0.5));
                        }
                        continue;
                    }
                }

                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "The component does not know how to handle this type of gh_geometry: " + objectType.FullName);
            }
        }