/// <summary>
        /// Gets the curve.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override Curve getCurve(Point3d point3d)
        {
            Point3d leftPoint  = new Point3d(point3d.X - (this.X / 2) + (Y / 2), point3d.Y, 0);
            Point3d rightPoint = new Point3d(point3d.X + (this.X / 2) - (Y / 2), point3d.Y, 0);

            Arc leftArc = new Arc(new Circle(leftPoint, Y / 2), Math.PI);

            leftArc.StartAngle = Math.PI / 2;
            leftArc.EndAngle   = 3 * Math.PI / 2;

            Arc rightArc = new Arc(new Circle(rightPoint, Y / 2), Math.PI);

            rightArc.StartAngle = -Math.PI / 2;
            rightArc.EndAngle   = Math.PI / 2;

            Line top    = new Line(point3d.X + (this.X / 2) - (Y / 2), point3d.Y + Y / 2, 0, point3d.X - (this.X / 2) + (Y / 2), point3d.Y + Y / 2, 0);
            Line bottom = new Line(point3d.X - (this.X / 2) + (Y / 2), point3d.Y - Y / 2, 0, point3d.X + (this.X / 2) - (Y / 2), point3d.Y - Y / 2, 0);

            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(leftArc);
            polyCurve.Append(bottom);
            polyCurve.Append(rightArc);
            polyCurve.Append(top);

            return(polyCurve);
        }
        /// <summary>
        /// Insides the specified closed curve.
        /// </summary>
        /// <param name="ClosedCurve">The closed curve.</param>
        /// <returns></returns>
        public override bool isInside(Curve closedCurve, Point3d point3d)
        {
            double  tolerance = Properties.Settings.Default.Tolerance;
            Point3d pt1       = new Point3d(point3d.X + X / 2 - tolerance, point3d.Y, point3d.Z);
            Point3d pt2       = new Point3d(point3d.X, point3d.Y + Y / 2 - tolerance, point3d.Z);
            Point3d pt3       = new Point3d(point3d.X - X / 2 + tolerance, point3d.Y, point3d.Z);
            Point3d pt4       = new Point3d(point3d.X, point3d.Y - Y / 2 + tolerance, point3d.Z);

            Arc top    = new Arc(pt1, pt2, pt3);
            Arc bottom = new Arc(pt3, pt4, pt1);

            PolyCurve currentToolCurve = new PolyCurve();

            currentToolCurve.Append(top);
            currentToolCurve.Append(bottom);

            if (Curve.PlanarClosedCurveRelationship(closedCurve, currentToolCurve, Plane.WorldXY, 0) == RegionContainment.BInsideA)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Gets the curve.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override Curve getCurve(Point3d point3d)
        {
            Point3d pt1 = new Point3d(point3d.X + 5.4161, point3d.Y - 7.0828, point3d.Z);
            Point3d pt2 = new Point3d(point3d.X + 3.4788, point3d.Y - 0, point3d.Z);
            Point3d pt3 = new Point3d(point3d.X + 5.4161, point3d.Y + 7.0828, point3d.Z);
            Point3d pt4 = new Point3d(point3d.X + 0.0000, point3d.Y + 8.5212, point3d.Z);
            Point3d pt5 = new Point3d(point3d.X - 5.4161, point3d.Y + 7.0828, point3d.Z);
            Point3d pt6 = new Point3d(point3d.X - 3.4788, point3d.Y - 0, point3d.Z);
            Point3d pt7 = new Point3d(point3d.X - 5.4161, point3d.Y - 7.0828, point3d.Z);
            Point3d pt8 = new Point3d(point3d.X + 0.0000, point3d.Y - 8.5212, point3d.Z);

            Arc right  = new Arc(pt1, pt2, pt3);
            Arc top    = new Arc(pt3, pt4, pt5);
            Arc left   = new Arc(pt5, pt6, pt7);
            Arc bottom = new Arc(pt7, pt8, pt1);

            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(right);
            polyCurve.Append(top);
            polyCurve.Append(left);
            polyCurve.Append(bottom);

            return(polyCurve);
        }
        public static PolyCurve ToNative(this SpecklePolycurve p)
        {
            PolyCurve myPolyc = new PolyCurve();

            foreach (var segment in p.Segments)
            {
                if (segment.Type == "Curve")
                {
                    myPolyc.Append((( SpeckleCurve )segment).ToNative());
                }

                if (segment.Type == "Line")
                {
                    myPolyc.Append((( SpeckleLine )segment).ToNative());
                }

                if (segment.Type == "Arc")
                {
                    myPolyc.Append((( SpeckleArc )segment).ToNative());
                }

                if (segment.Type == "Polyline")
                {
                    myPolyc.Append((( SpecklePolyline )segment).ToNative().ToNurbsCurve());
                }
            }
            myPolyc.UserDictionary.ReplaceContentsWith(p.Properties.ToNative());
            return(myPolyc);
        }
        public static PolyCurve ToNative(this SpecklePolycurve p)
        {
            PolyCurve myPolyc = new PolyCurve();

            foreach (var segment in p.Segments)
            {
                switch (segment)
                {
                case SpeckleCore.SpeckleCurve crv:
                    myPolyc.Append(crv.ToNative());
                    break;

                case SpeckleCore.SpeckleLine crv:
                    myPolyc.Append(crv.ToNative());
                    break;

                case SpeckleCore.SpeckleArc crv:
                    myPolyc.Append(crv.ToNative());
                    break;

                case SpeckleCore.SpecklePolyline crv:
                    myPolyc.Append(crv.ToNative());
                    break;
                }
            }
            myPolyc.UserDictionary.ReplaceContentsWith(p.Properties.ToNative());
            if (p.Domain != null)
            {
                myPolyc.Domain = p.Domain.ToNative();
            }
            return(myPolyc);
        }
        /// <summary>
        /// Insides the specified closed curve.
        /// </summary>
        /// <param name="ClosedCurve">The closed curve.</param>
        /// <returns></returns>
        public override bool isInside(Curve closedCurve, Point3d point)
        {
            double tolerance = Properties.Settings.Default.Tolerance;

            double yMin = point.Y - (Math.Sqrt(3) * X / 2) / 3 + tolerance;
            double yMax = point.Y + (Math.Sqrt(3) * X) / 3 - tolerance;
            double xMin = point.X - X / 2 + tolerance;
            double xMax = point.X + X / 2 - tolerance;

            Line      bottom    = new Line(xMax, yMin, 0, xMin, yMin, 0);
            Line      left      = new Line(xMin, yMin, 0, point.X, yMax, 0);
            Line      right     = new Line(point.X, yMax, 0, xMax, yMin, 0);
            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(bottom);
            polyCurve.Append(left);
            polyCurve.Append(right);


            if (Curve.PlanarClosedCurveRelationship(closedCurve, polyCurve, Plane.WorldXY, 0) == RegionContainment.BInsideA)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
        internal static void GenerateData(STPModelData md, IfcBuilding building, bool openings)
        {
            IfcMaterial         concrete         = new IfcMaterial(md, "Concrete", "", "");
            int                 thickness        = 200;
            IfcMaterialLayer    materialLayer    = new IfcMaterialLayer(md, concrete, thickness, false, "Core", "", "", 0);
            string              name             = thickness + "mm Concrete";
            IfcMaterialLayerSet materialLayerSet = new IfcMaterialLayerSet(md, materialLayer, name, "");

            materialLayerSet.Associates.GlobalId = "2l_enLhI93reVwnim9gXUq";
            md.NextObjectRecord = 300;
            IfcSlabType slabType = new IfcSlabType(md, new IfcElemTypeParams("0RSW$KKbzCZ9QaSm3GoEan", name, "", "", ""), materialLayerSet, null, IfcSlabTypeEnum.FLOOR);

            slabType.ObjectTypeOf.GlobalId = "3wwDcmW5T3HfafURQewdD0";
            PolyCurve polycurve = new PolyCurve();

            polycurve.Append(new Line(0, 0, 0, 1000, 0, 0));
            polycurve.Append(new Arc(new Point3d(1000, 0, 0), new Point3d(1400, 2000, 0), new Point3d(1000, 4000, 0)));
            polycurve.Append(new Line(1000, 4000, 0, 0, 4000, 0));
            polycurve.Append(new Arc(new Point3d(0, 4000, 0), new Point3d(-400, 2000, 0), new Point3d(0, 0, 0)));
            IfcSlabStandardCase slabStandardCase = new IfcSlabStandardCase(building, new IfcElemParams("1wAj$J2Az2V8wnBiVYd3bU", "", "", "", ""), slabType, polycurve, -200, true, null);

            slabStandardCase.Material.Associates.GlobalId = "3ESAzibgr9BvK9M75iV84w";
            if (openings)
            {
                IfcCircleProfileDef    cpd     = new IfcCircleProfileDef(md, IfcProfileTypeEnum.AREA, "100DIA", null, 50);
                IfcExtrudedAreaSolid   eas     = new IfcExtrudedAreaSolid(cpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(100, 300, -200), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), thickness);
                IfcOpeningStandardCase opening = new IfcOpeningStandardCase(slabStandardCase, new IfcElemParams("15RSTHd8nFVQWMRE7og7sd", "Opening", "", "", ""), null, eas);
                opening.VoidsElement.GlobalId = "0gqEDsyEzFXvY$fc_rUxyO";
                IfcRectangleProfileDef rpd = new IfcRectangleProfileDef(md, IfcProfileTypeEnum.AREA, "RecessRectangle", null, 500, 1000);
                eas = new IfcExtrudedAreaSolid(rpd, new IfcAxis2Placement3D(md, new Plane(new Point3d(500, 1000, -50), Vector3d.XAxis, Vector3d.YAxis)), new IfcDirection(md, 0, 0, 1), 50);
                IfcOpeningElement recess = new IfcOpeningElement(slabStandardCase, new IfcElemParams("0w93HZ19H2D99zbAVNb4o2", "Recess", "", "", ""), eas, IfcOpeningElementTypeEnum.RECESS);
                recess.VoidsElement.GlobalId = "3iUkij4q1DmxlXuHzQVJaM";
            }
        }
        /// <summary>
        /// Draws the cave tool.
        /// </summary>
        /// <param name="cx">The cx.</param>
        /// <param name="cy">The cy.</param>
        /// <param name="angleRad">The angle RAD.</param>
        public void drawCaveTool(double cx, double cy, double angleRad)
        {
            Guid      toolGuid = new Guid();
            Transform xform    = Transform.Rotation(angleRad, new Point3d(cx, cy, 0));

            // draw the top half circle
            Point3d pt = new Point3d(cx, cy, 0);
            //Arc topArc = new Arc(new Circle(pt, 10), Math.PI);
            //topArc.StartAngle = Math.PI/2;
            //topArc.EndAngle =  3*Math.PI/2;

            // Replace it with Triangle instead
            Line      topLeft   = new Line(cx, cy - 10, 0, cx - 10, cy, 0);
            Line      topRight  = new Line(cx - 10, cy, 0, cx, cy + 10, 0);
            Line      bottom    = new Line(cx, cy + 10, 0, cx, cy - 10, 0);
            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(topLeft);
            polyCurve.Append(topRight);
            polyCurve.Append(bottom);
            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);

            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);



            //Point3d topPoint = new Point3d(cx + 4.5,  cy+8, 0);
            //Point3d bottomPoint = new Point3d(cx + 4.5, cy-8, 0);

            //Arc topArc = new Arc(new Circle(topPoint, 1.5), Math.PI);
            //topArc.StartAngle = 0;
            //topArc.EndAngle = Math.PI;

            //Arc bottomArc = new Arc(new Circle(bottomPoint, 1.5), Math.PI);
            //bottomArc.StartAngle = Math.PI;
            //bottomArc.EndAngle = 2* Math.PI;

            //Line left = new Line(cx+3, cy+8,0, cx+3,cy-8,0);
            //Line right = new Line(cx+6, cy-8,0,cx+6,cy+8,0);

            //polyCurve = new PolyCurve();

            //polyCurve.Append(topArc);
            //polyCurve.Append(left);
            //polyCurve.Append(bottomArc);
            //polyCurve.Append(right);

            // Replace it with Triangle instead
            topLeft   = new Line(cx + 4.5, cy + 8, 0, cx + 9.5, cy, 0);
            topRight  = new Line(cx + 9.5, cy, 0, cx + 4.5, cy - 8, 0);
            bottom    = new Line(cx + 4.5, cy - 8, 0, cx + 4.5, cy + 8, 0);
            polyCurve = new PolyCurve();
            polyCurve.Append(topLeft);
            polyCurve.Append(topRight);
            polyCurve.Append(bottom);
            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);

            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);
        }
Exemple #9
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static PolyCurve RandomPolyCurve(Random random)
        {
            PolyCurve polycurve = new PolyCurve();

            polycurve.Append(RandomArc(random));
            polycurve.Append(RandomLine(random));
            polycurve.Append(RandomNurbsCurve(random));
            polycurve.Append(RandomPolylineCurve(random));
            return(polycurve);
        }
Exemple #10
0
        /// <summary>
        /// Joins A and B into a polycurve.
        /// Segment B will be reversed.
        /// </summary>
        private static PolyCurve JoinArcs(Arc A, Arc B)
        {
            B.Reverse();

            PolyCurve crv = new PolyCurve();

            crv.Append(A);
            crv.Append(B);

            return(crv);
        }
        /// <summary>
        /// Method to convert a NURBS curve into a PolyCurve made of lines and arcs.
        /// Automatically uses Rhino document tolerance if tolerance is not inputted
        /// </summary>
        /// <param name="crv"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>

        public static Tuple <PolyCurve, List <Point3d>, List <string> > ConvertMem1dCrv(Curve crv, double tolerance = -1)
        {
            PolyCurve      m_crv    = null;
            List <string>  crv_type = new List <string>();
            List <Point3d> m_topo   = new List <Point3d>();

            // arc curve
            if (crv.IsArc())
            {
                crv_type.Add("");
                crv_type.Add("A");
                crv_type.Add("");

                m_topo.Add(crv.PointAtStart);
                m_topo.Add(crv.PointAtNormalizedLength(0.5));
                m_topo.Add(crv.PointAtEnd);

                m_crv = new PolyCurve();
                m_crv.Append(crv);
            }
            else
            {
                if (crv.SpanCount > 1) // polyline (or assumed polyline, we will take controlpoints)
                {
                    m_crv = new PolyCurve();

                    if (tolerance < 0)
                    {
                        tolerance = GhSA.Units.Tolerance;
                    }

                    crv = crv.ToPolyline(tolerance * 20, 5, 0, 0);

                    Curve[] segments = crv.DuplicateSegments();

                    for (int i = 0; i < segments.Length; i++)
                    {
                        crv_type.Add("");
                        m_topo.Add(segments[i].PointAtStart);

                        m_crv.Append(segments[i]);
                    }
                    crv_type.Add("");
                    m_topo.Add(segments[segments.Length - 1].PointAtEnd);
                }
                else // single line segment
                {
                    crv_type.Add("");
                    crv_type.Add("");

                    m_topo.Add(crv.PointAtStart);
                    m_topo.Add(crv.PointAtEnd);

                    m_crv = new PolyCurve();
                    m_crv.Append(crv);
                }
            }

            return(new Tuple <PolyCurve, List <Point3d>, List <string> >(m_crv, m_topo, crv_type));
        }
Exemple #12
0
        //gets the 2d edge loop for a surface in the parameter space of the surface
        public static Curve Get2dEdgeLoop(Surface surf)
        {
            Interval uDom = surf.Domain(0);
            Interval vDom = surf.Domain(1);

            Point2d A = new Point2d(uDom.T0, vDom.T0);
            Point2d B = new Point2d(uDom.T1, vDom.T0);
            Point2d C = new Point2d(uDom.T1, vDom.T1);
            Point2d D = new Point2d(uDom.T0, vDom.T1);

            List <Curve> curves = new List <Curve>();

            curves.Add(new LineCurve(A, B));
            curves.Add(new LineCurve(B, C));
            curves.Add(new LineCurve(C, D));
            curves.Add(new LineCurve(D, A));

            var loop = new PolyCurve();

            foreach (var curve in curves)
            {
                loop.Append(curve);
            }
            return(loop);
        }
        /// <summary>
        /// Gets the curve.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override Curve getCurve(Point3d point3d)
        {
            Point3d pt1 = new Point3d(point3d.X + X / 2, point3d.Y, point3d.Z);
            Point3d pt2 = new Point3d(point3d.X, point3d.Y + Y / 2, point3d.Z);
            Point3d pt3 = new Point3d(point3d.X - X / 2, point3d.Y, point3d.Z);
            Point3d pt4 = new Point3d(point3d.X, point3d.Y - Y / 2, point3d.Z);

            Arc top    = new Arc(pt1, pt2, pt3);
            Arc bottom = new Arc(pt3, pt4, pt1);

            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(top);
            polyCurve.Append(bottom);

            return(polyCurve);
        }
        private Curve RoundedRectangle(Plane plane, double width, double height, double radius)
        {
            var dw         = width * 0.5;
            var dh         = height * 0.5;
            var x_interval = new Interval(-dw, dw);
            var y_interval = new Interval(-dh, dh);

            var rect = new Rectangle3d(plane, x_interval, y_interval);
            var a    = rect.Corner(0);
            var b    = rect.Corner(1);
            var c    = rect.Corner(2);
            var d    = rect.Corner(3);

            var x = plane.XAxis * radius;
            var y = plane.YAxis * radius;

            var crv = new PolyCurve();

            // bottom edge
            if (width > 2 * radius)
            {
                crv.Append(new Line(a + x, b - x));
            }

            // lower right fillet
            crv.Append(new Arc(b - x, plane.XAxis, b + y));

            // right edge
            if (height > 2 * radius)
            {
                crv.Append(new Line(b + y, c - y));
            }

            // upper right fillet
            crv.Append(new Arc(c - y, plane.YAxis, c - x));

            // top edge
            if (width > 2 * radius)
            {
                crv.Append(new Line(c - x, d + x));
            }

            // upper left fillet
            crv.Append(new Arc(d + x, -plane.XAxis, d - y));

            // left edge
            if (height > 2 * radius)
            {
                crv.Append(new Line(d - y, a + y));
            }

            // bottom left fillet
            crv.Append(new Arc(a + y, -plane.YAxis, a + x));

            return(crv);
        }
Exemple #15
0
        public List <Curve> Write(ref Point3d position, Vector3d unitX, Vector3d unitY)
        {
            position -= Start * unitX;

            var curves = new List <Curve>(Vectors.Count);

            for (int i = 0; i < Vectors.Count; i++)
            {
                var pointCount = (Vectors[i].Count + 1) / 2;

                var curve = new PolyCurve();

                var localP = Vectors[i][0];

                var lastPoint = position + localP.X * unitX + localP.Y * unitY;

                for (int j = 1; j < pointCount; j++)
                {
                    localP = Vectors[i][j * 2];

                    var nextPoint = position + localP.X * unitX + localP.Y * unitY;

                    var localT = Vectors[i][j * 2 - 1];

                    if (localT.IsZero)
                    {
                        curve.Append(new Line(lastPoint, nextPoint));
                    }
                    else
                    {
                        var tangent = localT.X * unitX + localT.Y * unitY;

                        curve.Append(new Arc(lastPoint, tangent, nextPoint));
                    }

                    lastPoint = nextPoint;
                }

                curves.Add(curve);
            }

            position += End * unitX;

            return(curves);
        }
        /// <summary>
        /// Gets the curve.
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public override Curve getCurve(Point3d pt)
        {
            double yMin = pt.Y - (Math.Sqrt(3) * X / 2) / 3;
            double yMax = pt.Y + (Math.Sqrt(3) * X / 3);
            double xMin = pt.X - X / 2;
            double xMax = pt.X + X / 2;

            Line      bottom    = new Line(xMax, yMin, 0, xMin, yMin, 0);
            Line      left      = new Line(xMin, yMin, 0, pt.X, yMax, 0);
            Line      right     = new Line(pt.X, yMax, 0, xMax, yMin, 0);
            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(bottom);
            polyCurve.Append(left);
            polyCurve.Append(right);

            return(polyCurve);
        }
        public void DrawViewportWires(GH_PreviewWireArgs args)
        {
            if (Value == null)
            {
                return;
            }

            //Draw lines
            if (Value.Line != null)
            {
                if (args.Color == System.Drawing.Color.FromArgb(255, 150, 0, 0)) // this is a workaround to change colour between selected and not
                {
                    if (Value.Element.IsDummy)
                    {
                        args.Pipeline.DrawDottedLine(Value.Line.PointAtStart, Value.Line.PointAtEnd, UI.Colour.Dummy1D);
                    }
                    else
                    {
                        if ((System.Drawing.Color)Value.Colour != System.Drawing.Color.FromArgb(0, 0, 0))
                        {
                            args.Pipeline.DrawCurve(Value.Line, Value.Colour, 2);
                        }
                        else
                        {
                            System.Drawing.Color col = UI.Colour.ElementType(Value.Element.Type);
                            args.Pipeline.DrawCurve(Value.Line, col, 2);
                        }
                        args.Pipeline.DrawPoint(Value.Line.PointAtStart, Rhino.Display.PointStyle.RoundSimple, 3, UI.Colour.Element1dNode);
                        args.Pipeline.DrawPoint(Value.Line.PointAtEnd, Rhino.Display.PointStyle.RoundSimple, 3, UI.Colour.Element1dNode);
                    }
                }
                else
                {
                    if (Value.Element.IsDummy)
                    {
                        args.Pipeline.DrawDottedLine(Value.Line.PointAtStart, Value.Line.PointAtEnd, UI.Colour.Element1dSelected);
                    }
                    else
                    {
                        args.Pipeline.DrawCurve(Value.Line, UI.Colour.Element1dSelected, 2);
                        args.Pipeline.DrawPoint(Value.Line.PointAtStart, Rhino.Display.PointStyle.RoundControlPoint, 3, UI.Colour.Element1dNodeSelected);
                        args.Pipeline.DrawPoint(Value.Line.PointAtEnd, Rhino.Display.PointStyle.RoundControlPoint, 3, UI.Colour.Element1dNodeSelected);
                    }
                }
            }
            //Draw releases
            if (!Value.Element.IsDummy)
            {
                PolyCurve crv = new PolyCurve();
                crv.Append(Value.Line);
                double   angle = Value.Element.OrientationAngle;
                GsaBool6 start = Value.ReleaseStart;
                GsaBool6 end   = Value.ReleaseEnd;

                UI.Display.DrawReleases(args, crv, angle, start, end);
            }
        }
        public static PolyCurve BuildArcLineCurveFromPtsAndTopoType(List <Point3d> topology, List <string> topo_type = null)
        {
            PolyCurve crvs = new PolyCurve();

            for (int i = 0; i < topology.Count - 1; i++)
            {
                if (topo_type != null & topo_type[i + 1] == "A")
                {
                    crvs.Append(new Arc(topology[i], topology[i + 1], topology[i + 2]));
                    i++;
                }
                else
                {
                    crvs.Append(new Line(topology[i], topology[i + 1]));
                }
            }
            return(crvs);
        }
Exemple #19
0
        private PolyCurve GetPolyCurve(SectionLoop loop)
        {
            var curve = new PolyCurve();

            if (loop.Count < 2)
            {
                return(curve);
            }

            // create lines
            var lines = new List <Line>();

            Point3d p1 = new Point3d(0.0, Points[loop[0]].Y, Points[loop[0]].Z);

            for (int i = 1; i < loop.Count; ++i)
            {
                Point3d p2 = new Point3d(0.0, Points[loop[i]].Y, Points[loop[i]].Z);

                lines.Add(new Line(p1, p2));
                p1 = p2;
            }

            // create polycurve
            for (int i = 0; i < lines.Count; ++i)
            {
                var l2 = lines[i];

                // create fillet
                if (Points[loop[i]].R > 0.0)
                {
                    var l1 = i == 0 ? lines.Last() : lines[i - 1];

                    var arc = CreateTrimFillet(Points[loop[i]].R, ref l1, ref l2);
                    if (arc.Radius > 1.0E-3)
                    {
                        curve.Append(arc);
                    }
                }
                curve.Append(l2);
            }

            return(curve);
        }
        /// <summary>
        /// Draws the tool.
        /// </summary>
        /// <param name="point3d">The point3d.</param>
        /// <returns></returns>
        public override Result drawTool(Point3d point3d)
        {
            double yMin = point3d.Y - (Math.Sqrt(3) * X / 2) / 3;
            double yMax = point3d.Y + (Math.Sqrt(3) * X) / 3;
            double xMin = point3d.X - X / 2;
            double xMax = point3d.X + X / 2;

            Line      bottom    = new Line(xMax, yMin, 0, xMin, yMin, 0);
            Line      left      = new Line(xMin, yMin, 0, point3d.X, yMax, 0);
            Line      right     = new Line(point3d.X, yMax, 0, xMax, yMin, 0);
            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(bottom);
            polyCurve.Append(left);
            polyCurve.Append(right);

            RhinoDoc.ActiveDoc.Objects.Add(polyCurve);

            return(Result.Success);
        }
Exemple #21
0
        /// <summary>
        /// Gets the curve.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override Curve getCurve(Point3d point3d)
        {
            Point3d pt1 = new Point3d(point3d.X, point3d.Y - Y / 2, point3d.Z);
            Point3d pt2 = new Point3d(point3d.X + X / 2, point3d.Y - Y / 4, point3d.Z);
            Point3d pt3 = new Point3d(point3d.X + X / 2, point3d.Y + Y / 4, point3d.Z);
            Point3d pt4 = new Point3d(point3d.X, point3d.Y + Y / 2, point3d.Z);
            Point3d pt5 = new Point3d(point3d.X - X / 2, point3d.Y + Y / 4, point3d.Z);
            Point3d pt6 = new Point3d(point3d.X - X / 2, point3d.Y - Y / 4, point3d.Z);

            Line one   = new Line(pt1, pt2);
            Line two   = new Line(pt2, pt3);
            Line three = new Line(pt3, pt4);
            Line four  = new Line(pt4, pt5);
            Line five  = new Line(pt5, pt6);
            Line six   = new Line(pt6, pt1);

            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(one);
            polyCurve.Append(two);
            polyCurve.Append(three);
            polyCurve.Append(four);
            polyCurve.Append(five);
            polyCurve.Append(six);
            return(polyCurve);
        }
Exemple #22
0
        /// <summary>
        /// Insides the specified closed curve.
        /// </summary>
        /// <param name="ClosedCurve">The closed curve.</param>
        /// <returns></returns>
        public override bool isInside(Curve closedCurve, Point3d point3d)
        {
            double  tolerance = Properties.Settings.Default.Tolerance;
            Point3d pt1       = new Point3d(point3d.X, point3d.Y - Y / 2 + tolerance, point3d.Z);
            Point3d pt2       = new Point3d(point3d.X + X / 2 - tolerance, point3d.Y - Y / 4 + tolerance, point3d.Z);
            Point3d pt3       = new Point3d(point3d.X + X / 2 - tolerance, point3d.Y + Y / 4 - tolerance, point3d.Z);
            Point3d pt4       = new Point3d(point3d.X, point3d.Y + Y / 2 - tolerance, point3d.Z);
            Point3d pt5       = new Point3d(point3d.X - X / 2 + tolerance, point3d.Y + Y / 4 - tolerance, point3d.Z);
            Point3d pt6       = new Point3d(point3d.X - X / 2 + tolerance, point3d.Y - Y / 4 + tolerance, point3d.Z);

            Line one   = new Line(pt1, pt2);
            Line two   = new Line(pt2, pt3);
            Line three = new Line(pt3, pt4);
            Line four  = new Line(pt4, pt5);
            Line five  = new Line(pt5, pt6);
            Line six   = new Line(pt6, pt1);

            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(one);
            polyCurve.Append(two);
            polyCurve.Append(three);
            polyCurve.Append(four);
            polyCurve.Append(five);
            polyCurve.Append(six);

            if (Curve.PlanarClosedCurveRelationship(closedCurve, polyCurve, Plane.WorldXY, 0) == RegionContainment.BInsideA)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        protected Curve ReconstructPath(int[] cameFrom, int currentNode, out int[] nodes, out int[] edges, out bool[] edgeDir, out double totLength)
        {
            List <int> resultNodes = new List <int>();

            for (; ;)
            {
                if (currentNode == -1)
                {
                    break;
                }
                resultNodes.Add(currentNode);
                currentNode = cameFrom[currentNode];
            }
            resultNodes.Reverse();
            nodes = resultNodes.ToArray();

            List <int>  resultEdges    = new List <int>();
            List <bool> resultEdgesRev = new List <bool>();

            currentNode = nodes[0];
            for (int i = 1; i < nodes.Length; i++)
            {
                int  nxt = nodes[i];
                bool rev;
                int  edgeIndex = FindEdge(currentNode, nxt, out rev);
                resultEdges.Add(edgeIndex);
                resultEdgesRev.Add(rev);
                currentNode = nxt;
            }
            edges   = resultEdges.ToArray();
            edgeDir = resultEdgesRev.ToArray();

            totLength = 0;
            PolyCurve pc = new PolyCurve();

            for (int i = 0; i < resultEdges.Count; i++)
            {
                int ei = resultEdges[i];
                var cv = m_top.CurveAt(ei).DuplicateCurve();
                if (!resultEdgesRev[i])
                {
                    cv.Reverse();
                }
                pc.Append(cv);
                totLength += m_dist[ei];
            }
            pc.RemoveNesting();

            return(pc);
        }
Exemple #24
0
        Curve CreateSpiral(Plane plane, double r0, double r1, Int32 turns)
        {
            Line l0 = new Line(plane.Origin + r0 * plane.XAxis, plane.Origin + r1 * plane.XAxis);
            Line l1 = new Line(plane.Origin - r0 * plane.XAxis, plane.Origin - r1 * plane.XAxis);

            Point3d[] p0;
            Point3d[] p1;

            l0.ToNurbsCurve().DivideByCount(turns, true, out p0);
            l1.ToNurbsCurve().DivideByCount(turns, true, out p1);

            PolyCurve spiral = new PolyCurve();

            for (int i = 0; i < p0.Length - 1; i++)
            {
                Arc arc0 = new Arc(p0[i], plane.YAxis, p1[i + 1]);
                Arc arc1 = new Arc(p1[i + 1], -plane.YAxis, p0[i + 1]);

                spiral.Append(arc0);
                spiral.Append(arc1);
            }

            return(spiral);
        }
Exemple #25
0
        /// <summary>
        /// Draws the cave tool.
        /// </summary>
        /// <param name="cx">The cx.</param>
        /// <param name="cy">The cy.</param>
        /// <param name="angleRad">The angle RAD.</param>
        public void drawFormTool(double cx, double cy, double angleRad)
        {
            Guid      toolGuid      = new Guid();
            Transform xform         = Transform.Rotation(angleRad, new Point3d(cx, cy, 0));
            Transform sixtyDeg      = Transform.Rotation(60 * Math.PI / 180, new Point3d(cx, cy, 0));
            Transform oneTwentyDeg  = Transform.Rotation(120 * Math.PI / 180, new Point3d(cx, cy, 0));
            Transform mSixtyDeg     = Transform.Rotation(-60 * Math.PI / 180, new Point3d(cx, cy, 0));
            Transform mOneTwentyDeg = Transform.Rotation(-120 * Math.PI / 180, new Point3d(cx, cy, 0));

            // draw the rectangle
            Point3d pt = new Point3d(cx, cy, 0);

            Line      top       = new Line(cx - 1.5, cy + 24.2487 + 1, 0, cx + 1.5, cy + 24.2487 + 1, 0);
            Line      right     = new Line(cx + 1.5, cy + 24.2487 + 1, 0, cx + 1.5, cy + 24.2487 - 1, 0);
            Line      bottom    = new Line(cx + 1.5, cy + 24.2487 - 1, 0, cx - 1.5, cy + 24.2487 - 1, 0);
            Line      left      = new Line(cx - 1.5, cy + 24.2487 - 1, 0, cx - 1.5, cy + 24.2487 + 1, 0);
            PolyCurve polyCurve = new PolyCurve();

            polyCurve.Append(top);
            polyCurve.Append(right);
            polyCurve.Append(bottom);
            polyCurve.Append(left);
            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);

            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, sixtyDeg, true);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);

            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, oneTwentyDeg, true);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);

            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, mSixtyDeg, true);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);

            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, mOneTwentyDeg, true);
            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);

            //Point3d topPoint = new Point3d(cx + 4.5,  cy+8, 0);
            //Point3d bottomPoint = new Point3d(cx + 4.5, cy-8, 0);

            //Arc topArc = new Arc(new Circle(topPoint, 1.5), Math.PI);
            //topArc.StartAngle = 0;
            //topArc.EndAngle = Math.PI;

            //Arc bottomArc = new Arc(new Circle(bottomPoint, 1.5), Math.PI);
            //bottomArc.StartAngle = Math.PI;
            //bottomArc.EndAngle = 2* Math.PI;

            //Line left = new Line(cx+3, cy+8,0, cx+3,cy-8,0);
            //Line right = new Line(cx+6, cy-8,0,cx+6,cy+8,0);

            //polyCurve = new PolyCurve();

            //polyCurve.Append(topArc);
            //polyCurve.Append(left);
            //polyCurve.Append(bottomArc);
            //polyCurve.Append(right);

            // Replace it with Triangle instead
            Line topLeft  = new Line(cx + 15, cy - 23.7487, 0, cx, cy - 23.7487 - 11, 0);
            Line topRight = new Line(cx, cy - 23.7487 - 11, 0, cx - 15, cy - 23.7487, 0);

            bottom    = new Line(cx - 15, cy - 23.7487, 0, cx + 15, cy - 23.7487, 0);
            polyCurve = new PolyCurve();
            polyCurve.Append(topLeft);
            polyCurve.Append(topRight);
            polyCurve.Append(bottom);
            toolGuid = RhinoDoc.ActiveDoc.Objects.Add(polyCurve);

            RhinoDoc.ActiveDoc.Objects.Transform(toolGuid, xform, true);
        }
Exemple #26
0
        private bool ProcessCurveArrArray(HbCurveArrArray hbCurveArrArray)     // various kinds of lines, vertical wall, or planar floor
        {
            try {
                double brepTolerence = GH_Component.DocumentTolerance();  // Not sure what this is but suggested by McNeel
                if (brepTolerence <= 0.0)
                {
                    brepTolerence = 0.001;                                // Since we are not sure what the effect would be
                }
                List <Point3d> pointsInnerLoop;
                Curve          curveInnerLoop;
                List <Point3d> points = new List <Point3d>();
                List <Curve>   curves = new List <Curve>();
                PolyCurve      polyCurve;
                foreach (HbCurveArray hbCurveArray in hbCurveArrArray)
                {
                    //List<Curve> curvesInnerLoop = new List<Curve>();
                    polyCurve = new PolyCurve();
                    foreach (HbCurve hbCurve in hbCurveArray)
                    {
                        HbTypes hbType;
                        if (hbTypeDictionary.TryGetValue(hbCurve.GetType(), out hbType))
                        {
                            HbToRhino(hbCurve, out pointsInnerLoop, out curveInnerLoop);
                            if (pointsInnerLoop != null)
                            {
                                foreach (Point3d point3d in pointsInnerLoop)
                                {
                                    points.Add(point3d);
                                }
                            }
                            if (curveInnerLoop != null)
                            {
                                polyCurve.Append(curveInnerLoop);
                            }
                        }
                    }
                    if (polyCurve.SegmentCount > 0)
                    {
                        curves.Add(polyCurve);
                    }
                }
                // Obsolete w Revit 6
                // Brep brep = Brep.CreatePlanarBreps(curves)[0];
                Brep brep = Brep.CreatePlanarBreps(curves, brepTolerence)[0];

                // Add to outputs
                this.dataTreePoints.AddRange(points, new GH_Path(indexPoints));
                indexPoints++;
                this.dataTreeCurves.AddRange(curves, new GH_Path(indexCurves));
                indexCurves++;

                this.dataTreeBreps.AddRange(new List <Brep> {
                    brep
                }, new GH_Path(indexBreps));
                indexBreps++;

                // Create Geometry
                if (createGeometryPoints)
                {
                    foreach (Point3d point3d in points)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddPoint(point3d);
                    }
                }
                if (createGeometryCurves)
                {
                    foreach (Curve curveItem in curves)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curveItem);
                    }
                }
                if (createGeometrySurfaces)
                {
                    if (brep.Faces.Count > 0)
                    {
                        Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep);
                    }
                }

                return(true);
            }
            catch {
                return(false);
            }
        }
Exemple #27
0
        private IfcBeam GenerateIPE200(STPModelData md, IfcBuilding building, bool tessellated)
        {
            IfcElemParams elemParams = new IfcElemParams("0EF5_zZRv0pQPddeofU3KT", "ExampleBeamName", "ExampleBeamDescription", "", "Tag");

            if (tessellated)
            {
                List <Point3d> coords = new List <Point3d>()
                {
                    new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 14.8, 91.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(500.0, 2.8, 79.5), new Point3d(500.0, 14.8, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 50.0, 91.5), new Point3d(500.0, 14.8, 91.5), new Point3d(500.0, 50.0, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 50.0, 100.0), new Point3d(500.0, 50.0, 91.5), new Point3d(500.0, 50.0, 100.0), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, -50.0, 100.0), new Point3d(500.0, 50.0, 100.0), new Point3d(500.0, -50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, -50.0, 91.5), new Point3d(500.0, -50.0, 100.0), new Point3d(500.0, -50.0, 91.5), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(500.0, -50.0, 91.5), new Point3d(500.0, -14.8, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, 79.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(500.0, -14.8, 91.5), new Point3d(500.0, -2.8, 79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(500.0, -2.8, 79.5), new Point3d(500.0, -2.8, -79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -14.8, -91.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(500.0, -2.8, -79.5), new Point3d(500.0, -14.8, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -50.0, -91.5), new Point3d(500.0, -14.8, -91.5), new Point3d(500.0, -50.0, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -50.0, -100.0), new Point3d(500.0, -50.0, -91.5), new Point3d(500.0, -50.0, -100.0), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, 50.0, -100.0), new Point3d(500.0, -50.0, -100.0), new Point3d(500.0, 50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, 50.0, -91.5), new Point3d(500.0, 50.0, -100.0), new Point3d(500.0, 50.0, -91.5), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(500.0, 50.0, -91.5), new Point3d(500.0, 14.8, -91.5)
                };
                IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(md, coords);
                cartesianPointList3D.Comments.Add("the geometric representation of the beam is provided as a triangulated face set");
                cartesianPointList3D.Comments.Add("the meshing depends on the creating software system");

                List <CoordIndex> coordIndex = new List <CoordIndex>()
                {
                    new CoordIndex(6, 5, 4), new CoordIndex(15, 8, 6), new CoordIndex(6, 4, 3), new CoordIndex(10, 11, 9), new CoordIndex(16, 10, 7), new CoordIndex(14, 11, 10), new CoordIndex(7, 8, 16), new CoordIndex(6, 2, 15), new CoordIndex(2, 3, 1), new CoordIndex(3, 2, 6), new CoordIndex(10, 16, 14), new CoordIndex(14, 13, 12), new CoordIndex(11, 14, 12), new CoordIndex(8, 15, 16), new CoordIndex(24, 23, 22), new CoordIndex(17, 26, 24), new CoordIndex(22, 21, 20), new CoordIndex(28, 29, 27), new CoordIndex(32, 28, 25), new CoordIndex(30, 29, 28), new CoordIndex(18, 25, 26), new CoordIndex(24, 20, 17), new CoordIndex(20, 21, 19), new CoordIndex(32, 31, 30), new CoordIndex(28, 32, 30), new CoordIndex(33, 34, 37), new CoordIndex(36, 35, 38), new CoordIndex(40, 44, 43), new CoordIndex(41, 43, 44), new CoordIndex(46, 50, 49), new CoordIndex(47, 49, 50), new CoordIndex(56, 55, 51), new CoordIndex(55, 56, 54), new CoordIndex(57, 58, 62), new CoordIndex(60, 59, 61), new CoordIndex(63, 64, 68), new CoordIndex(66, 65, 67), new CoordIndex(69, 70, 74), new CoordIndex(72, 71, 73), new CoordIndex(80, 79, 75), new CoordIndex(79, 80, 78), new CoordIndex(81, 82, 86), new CoordIndex(84, 83, 85), new CoordIndex(88, 92, 91), new CoordIndex(89, 91, 92), new CoordIndex(94, 98, 97), new CoordIndex(95, 97, 98), new CoordIndex(104, 103, 99), new CoordIndex(103, 104, 102), new CoordIndex(105, 106, 110), new CoordIndex(108, 107, 109), new CoordIndex(111, 112, 116), new CoordIndex(114, 113, 115), new CoordIndex(117, 118, 122), new CoordIndex(120, 119, 121), new CoordIndex(128, 127, 123), new CoordIndex(127, 128, 126), new CoordIndex(22, 20, 24), new CoordIndex(32, 25, 18), new CoordIndex(18, 26, 17), new CoordIndex(33, 37, 38), new CoordIndex(36, 38, 37), new CoordIndex(40, 43, 39), new CoordIndex(41, 44, 42), new CoordIndex(46, 49, 45), new CoordIndex(47, 50, 48), new CoordIndex(56, 51, 52), new CoordIndex(55, 54, 53), new CoordIndex(57, 62, 61), new CoordIndex(60, 61, 62), new CoordIndex(63, 68, 67), new CoordIndex(66, 67, 68), new CoordIndex(69, 74, 73), new CoordIndex(72, 73, 74), new CoordIndex(80, 75, 76), new CoordIndex(79, 78, 77), new CoordIndex(81, 86, 85), new CoordIndex(84, 85, 86), new CoordIndex(88, 91, 87), new CoordIndex(89, 92, 90), new CoordIndex(94, 97, 93), new CoordIndex(95, 98, 96), new CoordIndex(104, 99, 100), new CoordIndex(103, 102, 101), new CoordIndex(105, 110, 109), new CoordIndex(108, 109, 110), new CoordIndex(111, 116, 115), new CoordIndex(114, 115, 116), new CoordIndex(117, 122, 121), new CoordIndex(120, 121, 122), new CoordIndex(128, 123, 124), new CoordIndex(127, 126, 125)
                };
                IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(md, cartesianPointList3D, null, true, coordIndex, null);

                return(new IfcBeam(building, elemParams, triangulatedFaceSet));
            }

            List <Point3d> points = new List <Point3d>()
            {
                new Point3d(2.8, -79.5, 0), new Point3d(2.8, 79.5, 0), new Point3d(6.314719, 87.985281, 0), new Point3d(14.8, 91.5, 0), new Point3d(50.0, 91.5, 0), new Point3d(50.0, 100.0, 0), new Point3d(-50.0, 100.0, 0), new Point3d(-50.0, 91.5, 0), new Point3d(-14.8, 91.5, 0), new Point3d(-6.314719, 87.985281, 0), new Point3d(-2.8, 79.5, 0), new Point3d(-2.8, -79.5, 0), new Point3d(-6.314719, -87.985281, 0), new Point3d(-14.8, -91.5, 0), new Point3d(-50.0, -91.5, 0), new Point3d(-50.0, -100.0, 0), new Point3d(50.0, -100.0, 0), new Point3d(50.0, -91.5, 0), new Point3d(14.8, -91.5, 0), new Point3d(6.314719, -87.985281, 0)
            };
            PolyCurve pc = new PolyCurve();

            pc.Append(new Line(points[0], points[1]));
            pc.Append(new Arc(points[1], points[2], points[3]));
            pc.Append(new Line(points[3], points[4]));
            pc.Append(new Line(points[4], points[5]));
            pc.Append(new Line(points[5], points[6]));
            pc.Append(new Line(points[6], points[7]));
            pc.Append(new Line(points[7], points[8]));
            pc.Append(new Arc(points[8], points[9], points[10]));
            pc.Append(new Line(points[10], points[11]));
            pc.Append(new Arc(points[11], points[12], points[13]));
            pc.Append(new Line(points[13], points[14]));
            pc.Append(new Line(points[14], points[15]));
            pc.Append(new Line(points[15], points[16]));
            pc.Append(new Line(points[16], points[17]));
            pc.Append(new Line(points[17], points[18]));
            pc.Append(new Arc(points[18], points[19], points[0]));
            IfcBoundedCurve boundedCurve = IfcBoundedCurve.ConvertCurve(md, pc);
            IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA, "IPE200", boundedCurve);
            IfcAxis2Placement3D          axis2Placement3D          = new IfcAxis2Placement3D(new IfcCartesianPoint(md, 0, 0, 0), new IfcDirection(md, 0, 1, 0), new IfcDirection(md, 1, 0, 0));
            IfcExtrudedAreaSolid         extrudedAreaSolid         = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, axis2Placement3D, new IfcDirection(md, 0, 0, 1), 1000);

            return(new IfcBeam(building, elemParams, extrudedAreaSolid));
        }
        public static Tuple <PolyCurve, List <Point3d>, List <string> > _notUsedConvertMem2dCrv(Curve crv, double tolerance = -1)
        {
            PolyCurve      m_crv    = null;
            List <string>  crv_type = new List <string>();
            List <Point3d> m_topo   = new List <Point3d>();

            if (crv.Degree > 1)
            {
                if (!crv.IsArc() | crv.IsClosed)
                {
                    if (tolerance < 0)
                    {
                        tolerance = Tolerance.RhinoDocTolerance();
                    }

                    m_crv = crv.ToArcsAndLines(tolerance * 20, 5, 0, 0);
                    Curve[] segments;
                    if (m_crv != null)
                    {
                        segments = m_crv.DuplicateSegments();
                    }
                    else
                    {
                        segments = new Curve[] { crv }
                    };

                    for (int i = 0; i < segments.Length; i++)
                    {
                        m_topo.Add(segments[i].PointAtStart);
                        crv_type.Add("");
                        if (segments[i].IsArc())
                        {
                            m_topo.Add(segments[i].PointAtNormalizedLength(0.5));
                            crv_type.Add("A");
                        }
                    }
                    m_topo.Add(segments[segments.Length - 1].PointAtEnd);
                    crv_type.Add("");
                }
                else
                {
                    crv_type.Add("");
                    crv_type.Add("A");
                    crv_type.Add("");

                    m_topo.Add(crv.PointAtStart);
                    m_topo.Add(crv.PointAtNormalizedLength(0.5));
                    m_topo.Add(crv.PointAtEnd);

                    m_crv = new PolyCurve();
                    m_crv.Append(crv);
                }
            }
            else if (crv.Degree == 1)
            {
                if (crv.SpanCount > 1)
                {
                    m_crv = new PolyCurve();
                    Curve[] segments = crv.DuplicateSegments();
                    for (int i = 0; i < segments.Length; i++)
                    {
                        crv_type.Add("");
                        m_topo.Add(segments[i].PointAtStart);

                        m_crv.Append(segments[i]);
                    }
                    crv_type.Add("");
                    m_topo.Add(segments[segments.Length - 1].PointAtEnd);
                }
                else
                {
                    crv_type.Add("");
                    crv_type.Add("");

                    m_topo.Add(crv.PointAtStart);
                    m_topo.Add(crv.PointAtEnd);

                    m_crv = new PolyCurve();
                    m_crv.Append(crv);
                }
            }

            return(new Tuple <PolyCurve, List <Point3d>, List <string> >(m_crv, m_topo, crv_type));
        }
Exemple #29
0
        private void createStripe(int firstVertexIndex, int secondVertexIndex, int thirdVertexIndex)
        {
            Point3d a = bottomCps[firstVertexIndex];
            Point3d A = topCps[firstVertexIndex];

            Point3d aA = 0.5 * (a + A);

            Point3d b = bottomCps[secondVertexIndex];
            Point3d B = topCps[secondVertexIndex];

            Point3d c = bottomCps[thirdVertexIndex];
            Point3d C = topCps[thirdVertexIndex];

            Point3d ab = 0.5 * (a + b);
            Point3d AB = 0.5 * (A + B);

            Point3d ac = 0.5 * (a + c);
            Point3d AC = 0.5 * (A + C);

            Point3d m = 0.33333 * (ab + ac + 0.5 * (b + c));
            Point3d M = 0.33333 * (AB + AC + 0.5 * (B + C));

            Point3d AAB = iTangentScale * A + (1.0 - iTangentScale) * AB;
            Point3d aab = iTangentScale * a + (1.0 - iTangentScale) * ab;

            Point3d AAC = iTangentScale * A + (1.0 - iTangentScale) * AC;
            Point3d aac = iTangentScale * a + (1.0 - iTangentScale) * ac;

            Curve profileCurve1 = Curve.CreateControlPointCurve(new List <Point3d>()
            {
                ab, aab, aA, AAB, AB
            });
            Curve profileCurve2 = Curve.CreateControlPointCurve(new List <Point3d>()
            {
                ac, aac, aA, AAC, AC
            });

            if (iPolySrf)
            {
                PolyCurve polyCurve1 = new PolyCurve();
                polyCurve1.Append(new LineCurve(m, ab));
                polyCurve1.Append(profileCurve1);
                polyCurve1.Append(new LineCurve(AB, M));

                PolyCurve polyCurve2 = new PolyCurve();
                polyCurve2.Append(new LineCurve(m, ac));
                polyCurve2.Append(profileCurve2);
                polyCurve2.Append(new LineCurve(AC, M));

                oDebugBreps1.Add(
                    Brep.CreateFromLoft(
                        new List <Curve>()
                {
                    polyCurve1, polyCurve2
                },
                        Point3d.Unset, Point3d.Unset,
                        LoftType.Normal,
                        false
                        )[0]
                    );

                oDebugCurves1.Add(profileCurve1);
                oDebugCurves2.Add(profileCurve2);
            }
            else
            {
                profileCurve1 = Curve.JoinCurves(
                    new List <Curve>()
                {
                    new LineCurve(b, ab), profileCurve1, new LineCurve(AB, B)
                },
                    documentTolerance,
                    true)[0];

                profileCurve2 = Curve.JoinCurves(
                    new List <Curve>()
                {
                    new LineCurve(c, ac), profileCurve2, new LineCurve(AC, C)
                },
                    documentTolerance,
                    true)[0];

                Brep brep = Brep.CreateFromLoft(
                    new List <Curve>()
                {
                    profileCurve1, profileCurve2
                },
                    Point3d.Unset, Point3d.Unset,
                    LoftType.Normal,
                    false
                    )[0];

                // =============================================
                // Trim the brep using planes
                // =============================================

                double   offsetAmount = 0.2;
                Vector3d normal;
                Brep[]   breps;

                normal = Vector3d.CrossProduct(B - A, C - A);

                Point3d A_ = A + offsetAmount * normal;

                breps = brep.Trim(new Plane(A_, AB, M), documentTolerance);
                if (breps.Length > 0)
                {
                    brep = breps[0];
                }
                else
                {
                    oDebugBreps2.Add(brep); return;
                }

                breps = brep.Trim(new Plane(A_, M, AC), documentTolerance);
                if (breps.Length > 0)
                {
                    brep = breps[0];
                }
                else
                {
                    oDebugBreps2.Add(brep); return;
                }

                normal = Vector3d.CrossProduct(b - a, c - a);

                Point3d a_ = a - offsetAmount * normal;

                breps = brep.Trim(new Plane(a_, m, ab), documentTolerance);
                if (breps.Length > 0)
                {
                    brep = breps[0];
                }
                else
                {
                    oDebugBreps2.Add(brep); return;
                }

                breps = brep.Trim(new Plane(a_, ac, m), documentTolerance);
                if (breps.Length > 0)
                {
                    brep = breps[0];
                }
                else
                {
                    oDebugBreps2.Add(brep); return;
                }

                //PolyCurve polyCurve1 = new PolyCurve();
                //polyCurve1.Append(new LineCurve(m, ab));
                //polyCurve1.Append(profileCurve1);
                //polyCurve1.Append(new LineCurve(AB, M));

                //PolyCurve polyCurve2 = new PolyCurve();
                //polyCurve2.Append(new LineCurve(m, ac));
                //polyCurve2.Append(profileCurve2);
                //polyCurve2.Append(new LineCurve(AC, M));

                //oDebugBreps1.Add(
                //    Brep.CreateFromLoft(
                //       new List<Curve>() { polyCurve1, polyCurve2 },
                //       Point3d.Unset, Point3d.Unset,
                //       LoftType.Normal,
                //       false
                //       )[0]
                //   );

                oDebugBreps1.Add(brep);
                oDebugCurves1.Add(profileCurve1);
                oDebugCurves2.Add(profileCurve2);
            }
        }
Exemple #30
0
        private PolyCurve GetPolyCurve(SectionLoop loop)
        {
            var curve = new PolyCurve();

            if (loop.Count < 2)
            {
                return(curve);
            }

            var lines    = new List <Line>();
            var fillets  = new Dictionary <int, NurbsCurve>();
            var chamfers = new Dictionary <int, Line>();

            // create lines
            Point3d p1 = new Point3d(0.0, Points[loop[0]].Y, Points[loop[0]].Z);

            for (int i = 1; i < loop.Count; ++i)
            {
                Point3d p2 = new Point3d(0.0, Points[loop[i]].Y, Points[loop[i]].Z);

                lines.Add(new Line(p1, p2));
                p1 = p2;
            }

            // create Edge Transitions
            for (int i = 0; i < lines.Count; ++i)
            {
                var pt = Points[loop[i]];

                // create EdgeTransition
                if ((pt.EType == EdgeTransitionType.Fillet && pt.EdgeTransitionValue1 > 1.0E-6) || (pt.EType == EdgeTransitionType.Chamfer && pt.EdgeTransitionValue1 > 1.0E-6 && pt.EdgeTransitionValue2 > 1.0E-6))
                {
                    var l1 = i == 0 ? lines.Last() : lines[i - 1];
                    var l2 = lines[i];
                    if (l1.Length > 1.0E-6 && l2.Length > 1.0E-6)
                    {
                        bool writeBackLines = false;
                        if (pt.EType == EdgeTransitionType.Fillet)
                        {
                            var arc = CreateTrimFillet(pt.EdgeTransitionValue1, ref l1, ref l2);
                            if (arc.Radius > 1.0E-3)
                            {
                                fillets.Add(i, arc.ToNurbsCurve());
                                writeBackLines = true;
                            }
                        }
                        if (pt.EType == EdgeTransitionType.Chamfer)
                        {
                            var chamfer = CreateTrimChamfer(pt.EdgeTransitionValue1, pt.EdgeTransitionValue2, ref l1, ref l2);
                            if (chamfer.Length > 1.0E-6)
                            {
                                chamfers.Add(i, chamfer);
                                writeBackLines = true;
                            }
                        }
                        if (writeBackLines)
                        {
                            lines[i] = l2;
                            if (i == 0)
                            {
                                lines[lines.Count - 1] = l1;
                            }
                            else
                            {
                                lines[i - 1] = l1;
                            }
                        }
                    }
                }
            }

            // create polycurve
            for (int i = 0; i < lines.Count; ++i)
            {
                if (fillets.TryGetValue(i, out var fillet))
                {
                    curve.Append(fillet);
                }
                if (chamfers.TryGetValue(i, out var chamfer))
                {
                    curve.Append(chamfer);
                }
                if (i < lines.Count - 1 && lines[i].Length > 1.0E-6)
                {
                    curve.Append(lines[i]);
                }
            }
            if (curve.PointAtStart.DistanceTo(curve.PointAtEnd) > 1.0E-6)
            {
                curve.Append(new Line(curve.PointAtEnd, curve.PointAtStart));
            }

            return(curve);
        }