示例#1
0
        public static void drawText_section(Rectangle3d tempBoundingBox, Rhino.Display.Text3d textToDraw, double tempScaleFactor, System.Windows.Point tempOrigin, ref Canvas UnitPlanCanvas, double fontSize, System.Windows.Media.Brush foreGround)
        {
            System.Windows.Point tempTransformedPoint = pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin);

            Border tempBorder = new Border();

            tempBorder.Height = 200;
            tempBorder.Width  = 200;
            Canvas.SetLeft(tempBorder, pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin).X - 200 / 2);
            Canvas.SetTop(tempBorder, pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin).Y - 200 / 2);

            TextBlock textBlockToDraw = new TextBlock();

            textBlockToDraw.Text                = textToDraw.Text;
            textBlockToDraw.Foreground          = foreGround;
            textBlockToDraw.FontSize            = fontSize;
            textBlockToDraw.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            textBlockToDraw.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;


            System.Windows.Media.RotateTransform tempRotater = new System.Windows.Media.RotateTransform(90);
            textBlockToDraw.RenderTransform       = tempRotater;
            textBlockToDraw.RenderTransformOrigin = new System.Windows.Point(.5, .5);

            tempBorder.Child = textBlockToDraw;

            UnitPlanCanvas.Children.Add(tempBorder);
        }
示例#2
0
        public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            if (_text.Count == 0)
            {
                return;
            }

            //Plane plane;
            //args.Viewport.GetFrustumFarPlane(out plane);

            for (int i = 0; i < _text.Count; i++)
            {
                string   text  = _text[i];
                Point3d  point = _point[i];
                double   size  = _size[i];
                Polyline tile  = _tile[i];

                Plane plane;
                args.Viewport.GetFrustumFarPlane(out plane);
                plane.Origin = point;

                Rhino.Display.Text3d drawText = new Rhino.Display.Text3d(text, plane, size);
                args.Display.Draw3dText(text, Color.Black, plane, size, null, false, false, Rhino.DocObjects.TextHorizontalAlignment.Center, Rhino.DocObjects.TextVerticalAlignment.Middle);
                args.Display.DrawPolyline(tile, Color.Black, 2);
                drawText.Dispose();
            }
        }
示例#3
0
        public override void DrawViewportWires(IGH_PreviewArgs args)
        {
            base.DrawViewportWires(args);

            if (texts.Count == 0)
            {
                return;
            }

            Plane plane;

            args.Viewport.GetFrustumFarPlane(out plane);

            for (int i = 0; i < texts.Count; i++)
            {
                string  text     = texts[i];
                double  size     = sizes[i];
                Point3d location = locations[i];
                plane.Origin = location;

                // Figure out the size. This means measuring the visible size in the viewport AT the current location.
                double pixPerUnit;
                Rhino.Display.RhinoViewport viewport = args.Viewport;
                viewport.GetWorldToScreenScale(location, out pixPerUnit);

                size = size / pixPerUnit;

                Rhino.Display.Text3d drawText = new Rhino.Display.Text3d(text, plane, size);

                args.Display.Draw3dText(drawText, args.WireColour);
                drawText.Dispose();
            }
        }
示例#4
0
        public Guid DrawObjectWithSpecificLayer(Rhino.Display.Text3d text, NamedLayer layername)
        {
            Rhino.RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(layerIndexes[(int)layername], false);
            Rhino.DocObjects.ObjectAttributes attribute = new Rhino.DocObjects.ObjectAttributes();

            var result = Rhino.RhinoDoc.ActiveDoc.Objects.AddText(text.Text, text.TextPlane, 200, "Arial", false, false, Rhino.Geometry.TextJustification.Center);

            Rhino.RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(0, false);
            return(result);
        }
示例#5
0
        private static Rhino.Display.Text3d centeredText(string text, double height, Point3d center)
        {
            Rhino.Display.Text3d tempRoomType = new Rhino.Display.Text3d(text, Plane.WorldXY, height);

            Vector3d tempVector = new Vector3d(center - tempRoomType.BoundingBox.Center);

            tempRoomType.TextPlane = new Plane(tempRoomType.TextPlane.Origin + tempVector, Vector3d.ZAxis);

            return(tempRoomType);
        }
示例#6
0
        public static RoomNamecard CreateRoomNamecard(Point3d CenterPoint, double RoomSize_squareMilimeter, double storiesHeight)
        {
            List <Curve> Form = CreateNamecardForm(CenterPoint);

            Rhino.Display.Text3d roomType   = centeredText("주거시설", 400, CenterPoint + new Point3d(0, 250, 0));
            Rhino.Display.Text3d roomSize   = centeredText(Math.Round(RoomSize_squareMilimeter / 1000000, 0).ToString() + "m\xB2", 400, CenterPoint + new Point3d(-500, -250, 0));
            Rhino.Display.Text3d roomHeight = centeredText("CH : " + Math.Round(storiesHeight, 0).ToString(), 400, CenterPoint + new Point3d(-500, -250, 0));

            Rhino.Display.Text3d[] text = { roomType, roomSize, roomHeight };

            return(new RoomNamecard(Form, text.ToList()));
        }
示例#7
0
            public Slider(Grasshopper.Kernel.Special.GH_NumberSlider slider, Plane p, string fontFace, double length, double textHeight, string name)
            {
                plane   = p;
                vMin    = (double)slider.Slider.Minimum;
                vMax    = (double)slider.Slider.Maximum;
                val     = (double)slider.CurrentValue;
                normVal = (val - vMin) / (vMax - vMin);

                range  = new Line(p.Origin, p.XAxis, length);
                sValue = new Line(p.Origin, p.XAxis, length * normVal);

                this.name       = name;
                this.textHeight = textHeight;
                this.fontFace   = fontFace;

                label        = new Rhino.Display.Text3d(name);
                label.Height = textHeight;

                Plane labPlane = new Plane(plane);

                labPlane.Translate(p.YAxis * -(textHeight * 1.8));
                label.TextPlane = labPlane;

                tMin = new Rhino.Display.Text3d(Convert.ToString(vMin));
                tMax = new Rhino.Display.Text3d(Convert.ToString(vMax));
                tVal = new Rhino.Display.Text3d(Convert.ToString(val));

                if (this.fontFace != "")
                {
                    tMin.FontFace  = this.fontFace;
                    tMax.FontFace  = this.fontFace;
                    tVal.FontFace  = this.fontFace;
                    label.FontFace = this.fontFace;
                }

                tMin.Height = textHeight;
                tMax.Height = textHeight;
                tVal.Height = textHeight * 1.2;
                Plane tPlane = new Plane(plane);

                tPlane.Translate(p.XAxis * -(textHeight * 0.8));
                tMin.TextPlane = tPlane;
                tPlane.Origin  = p.Origin + p.XAxis * length;
                tPlane.Translate(p.XAxis * (textHeight * 0.8));
                tMax.TextPlane = tPlane;
                tPlane.Origin  = p.Origin + p.XAxis * length * normVal;
                tPlane.Translate(p.YAxis * textHeight);
                tVal.TextPlane           = tPlane;
                tMin.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Right;
                tMax.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Left;
                tVal.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Center;
                tVal.Bold = true;
            }
            public PointUnited(Point3d rpoint)
            {
                float mousex = System.Windows.Forms.Cursor.Position.X;
                float mousey = System.Windows.Forms.Cursor.Position.Y;

                rPoint = rpoint;
                wPoint = new System.Windows.Point(mousex, mousey);

                Rhino.Display.Text3d text3d = new Rhino.Display.Text3d(rpoint.Z.ToString());

                Rhino.RhinoDoc.ActiveDoc.Objects.AddText(text3d);
            }
示例#9
0
 public override void DrawViewportWires(IGH_PreviewArgs args)
 {
     args.Viewport.GetFrustumFarPlane(out Plane plane);
     Rhino.Display.RhinoViewport viewport = args.Viewport;
     //X軸
     for (int i = 0; i < _xline.Count; i++)
     {
         if (x_guideline == 1)
         {
             args.Display.DrawPatternedLine(_xline[i], Color.Black, 0x00001111, 1);
             double size = fontsize; Point3d point = _xline[i].From; plane.Origin = point;
             viewport.GetWorldToScreenScale(point, out double pixPerUnit); size /= pixPerUnit;
             Rhino.Display.Text3d drawText = new Rhino.Display.Text3d(_xlabel[i], plane, size);
             drawText.HorizontalAlignment = TextHorizontalAlignment.Center; drawText.VerticalAlignment = TextVerticalAlignment.Top;
             args.Display.Draw3dText(drawText, Color.Black);
             drawText.Dispose();
         }
     }
     //Y軸
     for (int i = 0; i < _yline.Count; i++)
     {
         if (y_guideline == 1)
         {
             args.Display.DrawPatternedLine(_yline[i], Color.Black, 0x00001111, 1);
             double size = fontsize; Point3d point = _yline[i].From; plane.Origin = point;
             viewport.GetWorldToScreenScale(point, out double pixPerUnit); size /= pixPerUnit;
             Rhino.Display.Text3d drawText = new Rhino.Display.Text3d(_ylabel[i], plane, size);
             drawText.HorizontalAlignment = TextHorizontalAlignment.Right; drawText.VerticalAlignment = TextVerticalAlignment.Middle;
             args.Display.Draw3dText(drawText, Color.Black);
             drawText.Dispose();
         }
     }
     //Z軸
     for (int i = 0; i < _zline.Count; i++)
     {
         if (z_guideline == 1)
         {
             args.Display.DrawPatternedLine(_zline[i], Color.Black, 0x00001111, 1);
             double size = fontsize; Point3d point = _zline[i].From; plane.Origin = point;
             viewport.GetWorldToScreenScale(point, out double pixPerUnit); size /= pixPerUnit;
             Rhino.Display.Text3d drawText = new Rhino.Display.Text3d(_zlabel[i], plane, size);
             drawText.HorizontalAlignment = TextHorizontalAlignment.Right; drawText.VerticalAlignment = TextVerticalAlignment.Middle;
             args.Display.Draw3dText(drawText, Color.Black);
             drawText.Dispose();
         }
     }
 }///ここからGUIの作成*****************************************************************************************
示例#10
0
        /***************************************************/

        // Create the preview of panels.
        public static void AddPanelPreview(this Rhino.Display.CustomDisplay display, Model model, IEnumerable <int> ids, out HashSet <int> nodeIds, double graphicFactor, double elementFactor, double textFactor, double forceFactor, bool showComponentNumbers, bool showElementNumbers, bool showLCS, bool showLoads, bool showLoadValues, bool showEdges, bool showThk = false, Grasshopper.GUI.Gradient.GH_Gradient gradient = null, string panelResultType = "None", bool showResultValues = false)
        {
            nodeIds = new HashSet <int>();
            if (model.Panels.Count == 0)
            {
                return;
            }

            // Take all results out first to determine min & max, otherwise could be done inside the loop.
            Dictionary <int, double> panelTopResults    = new Dictionary <int, double>();
            Dictionary <int, double> panelBottomResults = new Dictionary <int, double>();
            double panelMax = 0;
            double panelMin = 0;

            if (panelResultType != "None")
            {
                Dictionary <int, double[]> panelResults = model.Mesh.GetElementResults(panelResultType);
                foreach (KeyValuePair <int, double[]> elResult in panelResults)
                {
                    int      id              = elResult.Key;
                    double[] results         = elResult.Value;
                    int      halfResultCount = results.Length / 2;

                    panelTopResults.Add(id, results.Skip(halfResultCount).Average());
                    panelBottomResults.Add(id, results.Take(halfResultCount).Average());
                }

                panelMax = Math.Max(panelTopResults.Values.Max(), panelBottomResults.Values.Max());
                panelMin = Math.Min(panelTopResults.Values.Min(), panelBottomResults.Values.Min());
            }

            ids = ids.Count() == 0 ? Enumerable.Range(0, model.Panels.Count) : ids.Select(i => i - 1);

            foreach (int i in ids)
            {
                Panel panel = model.Panels[i];

                if (showComponentNumbers)
                {
                    Vector3d fOffset = panel.LCS.ZAxis * 0.002;
                    if (showThk)
                    {
                        fOffset += panel.LCS.ZAxis * 0.5 * panel.Thickness;
                    }

                    Plane fp = new Plane(panel.LCS.Origin + fOffset, panel.LCS.ZAxis);
                    Plane bp = new Plane(panel.LCS.Origin - fOffset, -panel.LCS.ZAxis);
                    Rhino.Display.Text3d ft = new Rhino.Display.Text3d("Panel " + panel.CCXId(), fp, elementFactor * 0.6 * textFactor);
                    Rhino.Display.Text3d bt = new Rhino.Display.Text3d("Panel " + panel.CCXId(), bp, elementFactor * 0.6 * textFactor);
                    ft.Bold = true;
                    bt.Bold = true;
                    display.AddText(ft, Color.DarkRed);
                    display.AddText(bt, Color.DarkRed);
                }

                foreach (Element element in panel.Elements)
                {
                    Element2D e   = element as Element2D;
                    int       eId = e.Id.AsInteger;
                    foreach (Node n in e.Nodes.Take(e.PrimaryNodeCount))
                    {
                        nodeIds.Add(n.Id.AsInteger);
                    }

                    Color bottomColor;
                    Color topColor;

                    if (panelResultType == "None")
                    {
                        bottomColor = topColor = Color.Aqua;
                    }
                    else
                    {
                        bottomColor = gradient.ColourAt((panelBottomResults[eId] - panelMin) / (panelMax - panelMin));
                        topColor    = gradient.ColourAt((panelTopResults[eId] - panelMin) / (panelMax - panelMin));
                    }

                    Point3d  centroid  = e.GetCentroid();
                    Vector3d normal    = e.GetNormal();
                    Vector3d minOffset = normal * 0.001;
                    Vector3d offset    = showThk ? normal * 0.5 * panel.Thickness : minOffset;

                    List <Point3d> front = new List <Point3d>();
                    List <Point3d> back  = new List <Point3d>();

                    foreach (Point3d v in e.GetVertices())
                    {
                        front.Add(v + offset);
                        back.Add(v - offset);
                    }
                    display.AddPolygon(front, topColor, Color.Black, true, showEdges);
                    display.AddPolygon(back, bottomColor, Color.Black, true, showEdges);

                    if (showThk)
                    {
                        front.Add(front[0]);
                        back.Add(back[0]);
                        for (int j = 0; j < front.Count - 1; j++)
                        {
                            List <Point3d> fv = front.GetRange(j, 2);
                            List <Point3d> bv = back.GetRange(j, 2);
                            bv.Reverse();
                            fv.AddRange(bv);
                            display.AddPolygon(fv, Color.Aqua, Color.Black, true, true);
                        }
                    }

                    Plane tp = new Plane(panel.LCS);
                    tp.Origin = centroid + offset + minOffset;
                    tp.XAxis *= -1;
                    tp.ZAxis *= -1;
                    Plane bp = new Plane(panel.LCS);
                    bp.Origin = centroid - offset - minOffset;

                    if (showResultValues && panelTopResults.Count != 0)
                    {
                        Rhino.Display.Text3d t1 = new Rhino.Display.Text3d(panelTopResults[eId].ToString("G2"), tp, elementFactor * 0.4 * textFactor);
                        t1.Bold = true;
                        display.AddText(t1, Color.Black);
                        Rhino.Display.Text3d t2 = new Rhino.Display.Text3d(panelBottomResults[eId].ToString("G2"), bp, elementFactor * 0.4 * textFactor);
                        t2.Bold = true;
                        display.AddText(t2, Color.Black);
                    }

                    if (showLCS)
                    {
                        display.AddVector(centroid, e.Orientation[0] * elementFactor * graphicFactor, Color.Red);
                        display.AddVector(centroid, e.Orientation[1] * elementFactor * graphicFactor, Color.Green);
                        display.AddVector(centroid, normal * elementFactor * graphicFactor, Color.Blue);
                    }

                    if (showLoads && e.Pressure != 0)
                    {
                        Vector3d       pv             = normal * e.Pressure / forceFactor * elementFactor * 5 * graphicFactor;
                        List <Point3d> pressurePoints = new List <Point3d>();
                        foreach (Point3d pt in e.PopulateWithPoints())
                        {
                            if (e.Pressure > 0)
                            {
                                display.AddVector(pt - pv - offset, pv);
                            }
                            else
                            {
                                display.AddVector(pt - pv + offset, pv);
                            }
                        }

                        if (showLoadValues)
                        {
                            Plane p;
                            if (e.Pressure > 0)
                            {
                                p = new Plane(e.GetCentroid() - pv * 1.1 - offset, Vector3d.XAxis, Vector3d.ZAxis);
                            }
                            else
                            {
                                p = new Plane(e.GetCentroid() - pv * 1.1 + offset, Vector3d.XAxis, Vector3d.ZAxis);
                            }

                            Rhino.Display.Text3d t = new Rhino.Display.Text3d(e.Pressure.ToString("G2"), p, elementFactor * 0.4 * textFactor);
                            t.Bold = true;
                            display.AddText(t, Color.Magenta);
                        }
                    }

                    if (showElementNumbers)
                    {
                        Rhino.Display.Text3d tt = new Rhino.Display.Text3d(e.CCXId(), tp, elementFactor * 0.4 * textFactor);
                        Rhino.Display.Text3d bt = new Rhino.Display.Text3d(e.CCXId(), bp, elementFactor * 0.4 * textFactor);
                        tt.Bold = true;
                        bt.Bold = true;
                        display.AddText(tt, Color.Black);
                        display.AddText(bt, Color.Black);
                    }
                }
            }
        }
示例#11
0
 public List<Rhino.Display.Text3d> MeshTopoVerticeGetEdgeID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshTopologyVertexList vs = x.TopologyVertices;
     Rhino.Geometry.Collections.MeshTopologyEdgeList el = x.TopologyEdges;
     for (int i = 0; i < vs.Count; i++)
     {
         Point3d f = vs[i];
         int[] fs = vs.ConnectedTopologyVertices(i);
         if (fs.Length > 1)
         {
             string str = "";
             for (int j = 0; j < fs.Length - 1; j++)
             {
                 str += el.GetEdgeIndex(fs[j], i).ToString() + "-";
             }
             str += el.GetEdgeIndex(fs[fs.Length - 1], i).ToString();
             Rhino.Display.Text3d te = new Rhino.Display.Text3d(str.ToString(), new Plane(f, Vector3d.ZAxis), 1);
             output.Add(te);
         }
     }
     return output;
 }
示例#12
0
        /***************************************************/

        // Create the preview of nodes.
        public static void AddNodePreview(this Rhino.Display.CustomDisplay display, Model model, IEnumerable <int> ids, double graphicFactor, double elementFactor, double textFactor, double forceFactor, bool showNodes, bool showNodeNumbers, bool showLoads, bool showLoadValues, Grasshopper.GUI.Gradient.GH_Gradient gradient = null, string nodeResultType = "None", bool showResultValues = false)
        {
            if (model.Mesh == null || model.Mesh.Nodes.Count == 0)
            {
                return;
            }

            List <double> nodeResults = new List <double>();
            double        nodeMax     = 0;
            double        nodeMin     = 0;

            if (nodeResultType != "None")
            {
                nodeResults = model.Mesh.GetNodeDisplacement(nodeResultType);
                nodeMax     = nodeResults.Max();
                nodeMin     = nodeResults.Min();
            }

            foreach (int i in ids)
            {
                Node n = model.Mesh.Nodes[i];
                if (!n.Primary)
                {
                    continue;
                }

                if (showNodes)
                {
                    if (nodeResults.Count > 0)
                    {
                        display.AddPoint(n.Location, gradient.ColourAt((nodeResults[i] - nodeMin) / (nodeMax - nodeMin)), Rhino.Display.PointStyle.Simple, Math.Max(1, Convert.ToInt32(5 * elementFactor * graphicFactor)));
                    }
                    else
                    {
                        display.AddPoint(n.Location, Color.DarkRed, Rhino.Display.PointStyle.Simple, Math.Max(1, Convert.ToInt32(5 * elementFactor * graphicFactor)));
                    }
                }

                if (showResultValues && nodeResults.Count > 0)
                {
                    Plane p = new Plane(n.Location + Vector3d.ZAxis * elementFactor, Vector3d.XAxis, Vector3d.ZAxis);
                    Rhino.Display.Text3d t = new Rhino.Display.Text3d(nodeResults[i].ToString("G2"), p, elementFactor * 0.4 * textFactor);
                    t.Bold = true;
                    display.AddText(t, Color.Black);
                }

                if (showLoads && n.ForceLoad.Length != 0)
                {
                    Vector3d dLoad = n.ForceLoad / forceFactor * elementFactor * 5 * graphicFactor;
                    display.AddVector(n.Location - dLoad, dLoad);

                    if (showLoadValues)
                    {
                        Plane p = new Plane(n.Location - dLoad * 1.1, Vector3d.XAxis, Vector3d.ZAxis);
                        Rhino.Display.Text3d t = new Rhino.Display.Text3d(n.ForceLoad.Length.ToString("G2"), p, elementFactor * 0.4 * textFactor);
                        t.Bold = true;
                        display.AddText(t, Color.Magenta);
                    }
                }

                if (showLoads && n.MomentLoad.Length != 0)
                {
                    Vector3d mLoad = n.MomentLoad;
                    Vector3d axis  = new Vector3d(mLoad.X, mLoad.Y, mLoad.Z);
                    Plane    ap    = new Plane(n.Location, axis);
                    Arc      mArc  = new Arc(new Circle(ap, 2.5 * elementFactor * graphicFactor), Math.PI * 1.5);
                    display.AddArc(mArc);
                    display.AddVector(mArc.EndPoint, mArc.TangentAt(Math.PI * 1.5));

                    if (showLoadValues)
                    {
                        Plane p = new Plane(n.Location - n.MomentLoad / forceFactor * elementFactor * 5 * graphicFactor * 1.1, Vector3d.XAxis, Vector3d.ZAxis);
                        Rhino.Display.Text3d t = new Rhino.Display.Text3d(n.MomentLoad.Length.ToString("G2"), p, elementFactor * 0.4 * textFactor);
                        t.Bold = true;
                        display.AddText(t, Color.Magenta);
                    }
                }

                if (showNodeNumbers)
                {
                    Plane p = new Plane(n.Location, Vector3d.XAxis, Vector3d.ZAxis);
                    Rhino.Display.Text3d t = new Rhino.Display.Text3d(n.CCXId(), p, elementFactor * 0.4 * textFactor);
                    t.Bold = true;
                    display.AddText(t, Color.Purple);
                }
            }
        }
示例#13
0
        /***************************************************/

        // Create the preview of bars.
        public static void AddBarPreview(this Rhino.Display.CustomDisplay display, Model model, IEnumerable <int> ids, out HashSet <int> nodeIds, double graphicFactor, double elementFactor, double textFactor, bool showComponentNumbers, bool showElementNumbers, bool showLCS, bool showThk = false, string barResultType = "None", bool showResultValues = false)
        {
            nodeIds = new HashSet <int>();
            if (model.Bars.Count == 0)
            {
                return;
            }

            // Take all results out first to determine min & max, otherwise could be done inside the loop.
            Dictionary <int, double[]> barResults = new Dictionary <int, double[]>();
            double BFactor = 0;

            if (barResultType != "None")
            {
                barResults = model.Mesh.GetElementResults(barResultType);
                double barExtreme = barResults.Values.Select(r => Math.Max(Math.Abs(r[0]), Math.Abs(r[1]))).Max();
                BFactor = elementFactor / barExtreme * 10;
            }

            ids = ids.Count() == 0 ? Enumerable.Range(0, model.Bars.Count) : ids.Select(i => i - 1);

            foreach (int i in ids)
            {
                Bar   bar    = model.Bars[i];
                Plane locLCS = new Plane(bar.LCS);
                locLCS.Rotate(bar.Rotation, locLCS.ZAxis);
                locLCS.Translate(locLCS.XAxis * bar.Offset.X);
                locLCS.Translate(locLCS.YAxis * bar.Offset.Y);

                Vector3d hOffset = locLCS.XAxis * (bar.Profile.GetHeight() * 0.5);
                if (showThk)
                {
                    hOffset *= 2;
                }

                Plane tp = new Plane(locLCS.Origin, bar.LCS.YAxis, Vector3d.ZAxis);
                tp.Translate(hOffset);
                Curve[] profileCurves = bar.Profile.ToRhinoProfile();

                if (showComponentNumbers)
                {
                    Rhino.Display.Text3d t = new Rhino.Display.Text3d("Bar " + bar.CCXId(), tp, elementFactor * 0.6 * textFactor);
                    t.Bold = true;
                    display.AddText(t, Color.DarkRed);
                }

                foreach (Element element in bar.Elements)
                {
                    Element1D e   = element as Element1D;
                    int       eId = e.Id.AsInteger;

                    nodeIds.Add(e.Nodes.First().Id.AsInteger);
                    nodeIds.Add(e.Nodes.Last().Id.AsInteger);

                    Point3d[] endPts = e.GetVertices().ToArray();
                    Point3d   c      = (endPts[0] + endPts[1]) * 0.5;

                    display.AddLine(new Line(endPts[0], endPts[1]), Color.Aqua);

                    if (showThk)
                    {
                        Plane          eP = new Plane(locLCS);
                        List <Point3d> elementVertices = e.GetVertices().ToList();
                        eP.Translate(elementVertices[0] - bar.LCS.Origin);
                        Transform ptp = Transform.PlaneToPlane(Plane.WorldXY, eP);

                        // Use DisplayPipeline to get surface preview! Now a temporary solution given.
                        foreach (Curve pc in profileCurves)
                        {
                            Curve opc = pc.DuplicateCurve();
                            opc.Transform(ptp);
                            display.AddCurve(opc);
                            opc.Translate(elementVertices[1] - elementVertices[0]);
                            display.AddCurve(opc);
                        }
                    }

                    if (barResultType != "None")
                    {
                        Vector3d graphDir;
                        switch (barResultType)
                        {
                        case "Myy":
                            graphDir = locLCS.XAxis;
                            break;

                        case "Mxx":
                            graphDir = locLCS.YAxis;
                            break;

                        default:
                            string barResDir = barResultType.ToString().Substring(1, 1);
                            graphDir = barResDir == "y" ? locLCS.YAxis : locLCS.XAxis;
                            break;
                        }

                        graphDir *= BFactor * graphicFactor;
                        Point3d[] cPts = new Point3d[] { endPts[0], endPts[1], endPts[1] + graphDir * barResults[eId][1], endPts[0] + graphDir * barResults[eId][0] };
                        display.AddPolygon(cPts, Color.CornflowerBlue, Color.Black, true, true);

                        if (showResultValues && barResults.Count != 0)
                        {
                            Plane tp1 = new Plane(tp);
                            tp1.Translate(endPts[0] - tp1.Origin + graphDir * barResults[eId][0]);
                            Rhino.Display.Text3d t1 = new Rhino.Display.Text3d(barResults[eId][0].ToString("G2"), tp1, elementFactor * 0.4 * textFactor);
                            t1.Bold = true;
                            display.AddText(t1, Color.Black);
                            Plane tp2 = new Plane(tp);
                            tp2.Translate(endPts[1] - tp2.Origin + graphDir * barResults[eId][1]);
                            Rhino.Display.Text3d t2 = new Rhino.Display.Text3d(barResults[eId][1].ToString("G2"), tp2, elementFactor * 0.4 * textFactor);
                            t2.Bold = true;
                            display.AddText(t2, Color.Black);
                        }
                    }

                    if (showLCS)
                    {
                        display.AddVector(c, locLCS.XAxis * elementFactor * graphicFactor, Color.Red);
                        display.AddVector(c, locLCS.YAxis * elementFactor * graphicFactor, Color.Green);
                        display.AddVector(c, locLCS.ZAxis * elementFactor * graphicFactor, Color.Blue);
                    }

                    if (showElementNumbers)
                    {
                        Plane etp = new Plane(tp);
                        etp.Translate(c - bar.LCS.Origin);
                        Rhino.Display.Text3d t = new Rhino.Display.Text3d(e.CCXId(), etp, elementFactor * 0.4 * textFactor);
                        t.Bold = true;
                        display.AddText(t, Color.Black);
                    }
                }
            }
        }
示例#14
0
 public List<Rhino.Display.Text3d> MeshFaceID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     for (int i = 0; i < x.Faces.Count; i++)
     {
         Point3d f = new Point3d();
         if (x.Faces[i].IsQuad)
         {
             f += x.Vertices[x.Faces[i].A];
             f += x.Vertices[x.Faces[i].B];
             f += x.Vertices[x.Faces[i].C];
             f += x.Vertices[x.Faces[i].D];
             f /= 4;
         }
         else if (x.Faces[i].IsTriangle)
         {
             f += x.Vertices[x.Faces[i].A];
             f += x.Vertices[x.Faces[i].B];
             f += x.Vertices[x.Faces[i].C];
             f /= 3;
         }
         Rhino.Display.Text3d te = new Rhino.Display.Text3d(i.ToString(), new Plane(f, Vector3d.ZAxis), 1);
         output.Add(te);
     }
     return output;
 }
示例#15
0
 public List<Rhino.Display.Text3d> MeshID(List<Mesh> x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     for (int i = 0; i < x.Count; i++)
     {
         Point3d p;
         p = x[i].GetBoundingBox(true).Center;
         Rhino.Display.Text3d text = new Rhino.Display.Text3d(i.ToString(), new Plane(p, Vector3d.ZAxis), 1);
         output.Add(text);
     }
     return output;
 }
示例#16
0
 public List<Rhino.Display.Text3d> MeshEdgeID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshTopologyEdgeList el = x.TopologyEdges;
     for (int i = 0; i < el.Count; i++)
     {
         Point3d f = new Point3d();
         Line l1 = el.EdgeLine(i);
         f = l1.PointAt(0.5);
         Rhino.Display.Text3d te = new Rhino.Display.Text3d(i.ToString(), new Plane(f, Vector3d.ZAxis), 1);
         output.Add(te);
     }
     return output;
 }
示例#17
0
 public List<Rhino.Display.Text3d> MeshFaceGetTopoVerticeID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshTopologyVertexList vs = x.TopologyVertices;
     for (int i = 0; i < x.Faces.Count; i++)
     {
         Point3d f = new Point3d(); String outputText = "";
         int[] data = vs.IndicesFromFace(i);
         if (x.Faces[i].IsQuad)
         {
             int a = x.Faces[i].A, b = x.Faces[i].B, c = x.Faces[i].C, d = x.Faces[i].D;
             f += x.Vertices[a];
             f += x.Vertices[b];
             f += x.Vertices[c];
             f += x.Vertices[d];
             f /= 4;
             outputText += data[0].ToString() + "-";
             outputText += data[1].ToString() + "-";
             outputText += data[2].ToString() + "-";
             outputText += data[3].ToString();
         }
         else if (x.Faces[i].IsTriangle)
         {
             f += x.Vertices[x.Faces[i].A];
             f += x.Vertices[x.Faces[i].B];
             f += x.Vertices[x.Faces[i].C];
             f /= 3;
             outputText += data[0].ToString() + "-";
             outputText += data[1].ToString() + "-";
             outputText += data[2].ToString();
         }
         Rhino.Display.Text3d te = new Rhino.Display.Text3d(outputText, new Plane(f, Vector3d.ZAxis), 1);
         output.Add(te);
     }
     return output;
 }
示例#18
0
 public List<Rhino.Display.Text3d> MeshVerticeID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshVertexList vs = x.Vertices;
     for (int i = 0; i < vs.Count; i++)
     {
         Point3d f = vs[i];
         Rhino.Display.Text3d te = new Rhino.Display.Text3d(i.ToString(), new Plane(f, Vector3d.ZAxis), 1);
         output.Add(te);
     }
     return output;
 }
示例#19
0
 // <summary>
 public List<Rhino.Display.Text3d> MeshVerticeGetFaceID(Mesh x)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshVertexList vs = x.Vertices;
     for (int i = 0; i < vs.Count; i++)
     {
         Point3d f = vs[i];
         int[] fs = vs.GetVertexFaces(i);
         if (fs.Length > 1)
         {
             string str = "";
             for (int j = 0; j < fs.Length - 1; j++)
             {
                 str += fs[j].ToString() + "-";
             }
             str += fs[fs.Length - 1].ToString();
             Rhino.Display.Text3d te = new Rhino.Display.Text3d(str.ToString(), new Plane(f, Vector3d.ZAxis), 1);
             output.Add(te);
         }
     }
     return output;
 }
示例#20
0
        public static List<Rhino.Display.Text3d> DisplayRef(List<Vertice4> vs)
        {
            List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();

            for (int i = 0; i < vs.Count; i++)
            {
                Point3d f = vs[i].pos;
                List<int> fs = vs[i].refer;
                List<int> fs2 = vs[i].refer2;
                List<int> fs3 = vs[i].refer3;
                string str = "";
                for (int j = 0; j < fs2.Count; j++)
                {
                    str += fs2[j].ToString() + "-";
                }
                Rhino.Display.Text3d te = new Rhino.Display.Text3d(str.ToString(), new Plane(f, Vector3d.ZAxis), 1);
                output.Add(te);
            }
            return output;
        }
示例#21
0
 public List<Rhino.Display.Text3d> MeshTopoVerticeData(Mesh x, List<double> data)
 {
     List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
     Rhino.Geometry.Collections.MeshTopologyVertexList vs = x.TopologyVertices;
     if (data.Count < vs.Count) return output;
     for (int i = 0; i < vs.Count; i++)
     {
         Point3d f = vs[i];
         Rhino.Display.Text3d te = new Rhino.Display.Text3d(data[i].ToString(), new Plane(f, Vector3d.ZAxis), 1);
         output.Add(te);
     }
     return output;
 }
示例#22
0
        // <summary>
        public List<Rhino.Display.Text3d> GeoID(List<Object> x)
        {
            List<Rhino.Display.Text3d> output = new List<Rhino.Display.Text3d>();
            for (int i = 0; i < x.Count; i++)
            {
                Point3d p;
                // index.Add(i);
                if (x[i].GetType() == typeof(Line))
                {
                    Line l = (Line)(x[i]);
                    p = (l.From + l.To) / 2;
                }
                else
                {
                    Rhino.Geometry.GeometryBase base1 = (Rhino.Geometry.GeometryBase)x[i];
                    // pos.Add(base1.GetBoundingBox(true).Center);
                    p = base1.GetBoundingBox(true).Center;
                }

                Rhino.Display.Text3d text = new Rhino.Display.Text3d(i.ToString(), new Plane(p, Vector3d.ZAxis), 1);
                output.Add(text);
            }
            return output;
        }