Exemple #1
0
        public static bool IsInsidePolygon(Point3D pt, LinearPath outer)
        {
            Line[] outerLines = outer.ConvertToLines();


            Line l = new Line(pt,
                              new Point3D(CADConfig.Units == linearUnitsType.Meters ? pt.X + 1000 : pt.X + 100000, pt.Y, pt.Z));


            int countIntersect = 0;

            for (int j = 0; j < outerLines.Length; j++)
            {
                if (IsLineSegmentsIntersected(l, outerLines[j]))
                {
                    countIntersect++;
                }
            }
            if (countIntersect % 2 == 0)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static List <Line> LinesTrimWithPolygon(LinearPath polygon, Line line, bool isInside = true)
        {
            List <Line> lstLineSegment = new List <Line>();

            List <Point3D> lstIntersectionPts = MathHelper.PointsIntersectOfLineSegmentWithPolygon(polygon, line);


            ICurve[] lineSegments;
            line.SplitBy(lstIntersectionPts, out lineSegments);

            if (lineSegments.Count() == 0)
            {
                lstLineSegment.Add(line);
            }
            else
            {
                for (int i = 0; i < lineSegments.Length; i++)
                {
                    Line l = lineSegments[i] as Line;
                    if (l != null && MathHelper.IsInsidePolygon(l.MidPoint, polygon))
                    {
                        lstLineSegment.Add(l);
                    }
                }
            }

            return(lstLineSegment);
        }
Exemple #3
0
        private void CreateChair()
        {
            CreateBoxNTranslate(10, 10, 50, -30, 40, 0);  //front right leg chair
            CreateBoxNTranslate(10, 10, 50, 20, 40, 0);   //front left leg chair

            CreateBoxNTranslate(10, 10, 120, -30, 90, 0); //back right leg chair
            CreateBoxNTranslate(10, 10, 120, 20, 90, 0);  //back left leg chair

            CreateBoxNTranslate(70, 5, 20, -35, 90, 120); // chair top



            string ChairTopSlabName = "ChairTopSlab";
            Block  b = new Block();

            double width = 70;
            double depth = 5;
            double dimA  = 1000;
            double dimB  = 800;

            Point2D[] outerPoints = new Point2D[7];

            outerPoints[0] = new Point2D(0, dimB);
            outerPoints[1] = new Point2D(dimA, dimB);
            outerPoints[2] = new Point2D(dimA, 0);
            outerPoints[3] = new Point2D(width, 0);
            outerPoints[4] = new Point2D(width, depth);
            outerPoints[5] = new Point2D(0, depth);
            outerPoints[6] = (Point2D)
                             outerPoints[0].Clone();

            LinearPath outer = new LinearPath(Plane.XY, outerPoints);

            Point2D[] innerPoints = new Point2D[5];

            innerPoints[0] = new Point2D(-30, 0);
            innerPoints[1] = new Point2D(-30, 60);
            innerPoints[2] = new Point2D(30, 60);
            innerPoints[3] = new Point2D(30, 0);
            innerPoints[4] = (Point2D)innerPoints[0].Clone();

            LinearPath inner = new LinearPath(Plane.XY, innerPoints);

            devDept.Eyeshot.Entities.Region reg = new devDept.Eyeshot.Entities.Region(outer, inner);

            Mesh m2 = reg.ExtrudeAsMesh(10, 0.1, Mesh.natureType.Plain);

            m2.ColorMethod  = colorMethodType.byEntity;
            m2.Color        = Color.White;
            m2.MaterialName = ChairTopSlabName;

            b.Entities.Add(m2);

            viewportLayout1.Blocks.Add("ChairTopSlab", b);


            BlockReference reference = new BlockReference(0, 40, 60, "ChairTopSlab", 1, 1, 1, 0);

            viewportLayout1.Entities.Add(reference, 0);
        }
Exemple #4
0
        /// <summary>
        /// Creates the object related to the surrogate.
        /// </summary>
        ///<remarks>
        /// This method uses the <see cref="MyCircle.MyCircle(Plane, double)"/> constructor to create the object.
        /// When the content is <see cref="contentType.Tessellation"/> the resulting object is a <see cref="LinearPath"/>
        /// </remarks>
        /// <returns>The object created.</returns>
        protected override Entity ConvertToObject()
        {
            Entity ent;

            if (DeserializationContent == contentType.Tessellation)
            {
                // When the content is "Tessellation only" we create a LinearPath instead of a MyCircle.
                // If the entity was stored without vertices data, we add a Ghost entity as placeholder.

                if (CheckSurrogateData(DeserializationContent, String.Empty)) // pass string empty so no log is written
                {
                    ent = new LinearPath(Vertices);
                }
                else
                {
                    ent = new Ghost("MyCircle without tessellation data.");
                    WriteLog("MyCircle without tessellation data has been created as Ghost entity.");
                }
            }
            else
            {
                ent = new MyCircle(Plane, Radius);
            }

            CopyDataToObject(ent);

            return(ent);
        }
        public void LstRebarPopulate()
        {
            List <Point3D> points = new List <Point3D>();

            LstRebar = new List <Rebar>();
            LinearPath stirrupLinPath = (LinearPath)CadColumn.ColPath.Offset(-CadColumn.Cover * 1.2);

            Line[] stirrupBranches = stirrupLinPath.ConvertToLines();
            for (int i = 0; i < stirrupBranches.Length; i++)
            {
                Line  branch = stirrupBranches[i];
                Rebar rebarCorner1, rebarCorner2, rebarMid;

                if (!points.Contains(branch.StartPoint))
                {
                    rebarCorner1 = new Rebar(branch.StartPoint);
                    LstRebar.Add(rebarCorner1);
                }
                if (!points.Contains(branch.EndPoint))
                {
                    rebarCorner2 = new Rebar(branch.EndPoint);
                    LstRebar.Add(rebarCorner2);
                }
                rebarMid = new Rebar(branch.MidPoint);
                LstRebar.Add(rebarMid);
                points.AddRange(branch.Vertices);
            }
        }
        private void CreateBox()
        {
#if DEBUG
            double a = 80, b = 4.2, c = 2.6, d = 0.8;//dx  dy dz chamfer

            List <Point3D> pts = new List <Point3D>();
            pts.Add(new Point3D(0, -d, 0));
            pts.Add(new Point3D(0, b + d, 0));
            pts.Add(new Point3D(0, b, d));
            pts.Add(new Point3D(0, b, c));
            pts.Add(new Point3D(0, 0, c));
            pts.Add(new Point3D(0, 0, d));
            pts.Add(new Point3D(0, -d, 0));

            LinearPath lp  = new LinearPath(pts);
            Region     r   = new Region(lp);
            Mesh       box = r.ExtrudeAsMesh(new Vector3D(a, 0, 0), 0.01, Mesh.natureType.Plain);

            Transformation trans = new Transformation();
            trans.Translation(new Vector3D(-a / 2, -0.1, -0.1));
            box.TransformBy(trans);

            eyeshot.Entities.Add(box, 0, Color.Red);


            eyeshot.Invalidate();
            eyeshot.SetView(viewType.Left);
            eyeshot.ZoomFit();

            WriteSTL wStl = new WriteSTL(eyeshot, "d:/ChamferBox.stl");
            wStl.DoWork();
#endif
        }
Exemple #7
0
    /// <summary>
    /// SetLeg sets the leg to match segment with the foot upwards direction facing upwards.
    /// The leg mesh is generated using LinearPath with Width determining its thickness.
    /// Inverse kinematics are used for determining the knee position.
    /// </summary>
    public void SetLeg(Segment segment, Vector3 upwards)
    {
        segment.Target += Width * upwards.normalized;

        var(a, b, c) = LimbKinematics.Calculate(segment, (FemurLength, TibiaLength));

        Vector3 d = c - (0.5f * Width * upwards.normalized);
        Vector3 e = d + (FootLength * segment.Upwards.normalized);

        Femur = new Segment(a, b, segment.Upwards);
        Tibia = new Segment(b, c, segment.Upwards);
        Foot  = new Segment(d, e, upwards);

        (Vector3, Vector3)basis = (segment.Target - segment.Anchor, segment.Upwards);
        Vector3.OrthoNormalize(ref basis.Item1, ref basis.Item2);
        Plane plane = new Plane(basis, segment.Anchor);
        Func <Vector3, Vector2> projection = plane.Projection();

        Vector2[] path = new Vector2[]
        {
            projection(a),
            projection(b),
            projection(c),
            projection(d),
            projection(e)
        };

        var(vertices, triangles) = LinearPath.Mesh(path, Width, plane, -0.5f * Width, 0.5f * Width);

        meshFilter.mesh = new Mesh {
            vertices = vertices, triangles = triangles
        };
    }
Exemple #8
0
        public static List <LinearPath> EntitiesIntersectingSemelleGet(LinearPath semelleLinPath, List <LinearPath> lstCadFooting, out List <Line> lstSemelleLongLine)
        {
            //intersected footings
            HashSet <LinearPath> lstIntersectingEntity = new HashSet <LinearPath>();

            Line[] lstSemelleLine = semelleLinPath.ConvertToLines();

            lstSemelleLongLine = new List <Line>();

            for (int i = 0; i < lstSemelleLine.Length; i++)
            {
                int counter = 0;
                for (int j = 0; j < lstCadFooting.Count; j++)
                {
                    if (MathHelper.IsLineSegmentIntersectingPolygon(lstCadFooting[j], lstSemelleLine[i]) /*&& (lstCadFooting[j] != semelleLinPath)*/)
                    {
                        counter++;
                        lstIntersectingEntity.Add(lstCadFooting[j]);
                    }
                }
                if (counter >= 2)
                {
                    lstSemelleLongLine.Add(lstSemelleLine[i]);
                }
            }

            return(lstIntersectingEntity.ToList());
        }
Exemple #9
0
        private FootingBase RectFootingCreate(LinearPath pLine, double thickness, string type)
        {
            double width  = double.MaxValue;
            double length = 0;

            Point3D widthMidPt = Point3D.Origin;
            int     nVertices  = pLine.Vertices.Length;

            for (int j = 0; j < nVertices - 1; j++)
            {
                double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(pLine.Vertices[j], pLine.Vertices[j + 1]);
                width = Math.Min(width, dist);
                if (width == dist)
                {
                    widthMidPt = MathHelper.MidPoint3D(pLine.Vertices[j], pLine.Vertices[j + 1]);
                }
                length = Math.Max(length, dist);
            }


            Point3D center = (pLine.Vertices[0] + pLine.Vertices[2]) / 2.0;

            center.Z     = Level;
            widthMidPt.Z = Level;

            if (type == "RC")
            {
                return(new RCRectFooting(width, length, thickness, center, widthMidPt));
            }
            else
            {
                return(new PCRectFooting(width, length, thickness, center, widthMidPt));
            }
        }
Exemple #10
0
        public static bool IsInsidePolygon(LinearPath inner, LinearPath outer)

        {
            Line[] outerLines = outer.ConvertToLines();

            for (int i = 0; i < inner.Vertices.Length; i++)
            {
                Line l = new Line(inner.Vertices[i],
                                  new Point3D(CADConfig.Units == linearUnitsType.Meters ? inner.Vertices[i].X + 1000
                    : inner.Vertices[i].X + 100000, inner.Vertices[i].Y, inner.Vertices[i].Z));
                bool colinear = false;


                int countIntersect = 0;
                for (int j = 0; j < outerLines.Length; j++)
                {
                    if (IsLineSegmentsIntersected(l, outerLines[j], ref colinear))
                    {
                        countIntersect++;
                    }
                }

                if (!colinear && countIntersect % 2 == 0)
                {
                    return(false);
                }
            }
            return(true);
        }
    void OnEnable()
    {
        style.fontStyle        = FontStyle.Bold;
        style.normal.textColor = Color.white;

        _target = (LinearPath)target;
    }
Exemple #12
0
    private void OnSceneGUI()
    {
        m_path = target as LinearPath;

        if (m_path.ControlPointCount > 0)
        {
            // Transform the path into WorldSpace.
            m_handleTransform = m_path.transform;
            // Get the rotation mode.
            m_handleRotation = Tools.pivotRotation == PivotRotation.Local ?
                               m_handleTransform.rotation : Quaternion.identity;

            Vector3 p0 = ShowPoint(0);
            for (int i = 1; i < m_path.ControlPointCount; ++i)
            {
                // Create a handle for each point.
                Vector3 p1 = ShowPoint(i);

                // Draw the lines between handles.
                Handles.color = Color.white;
                Handles.DrawLine(p0, p1);

                p0 = p1;
            }
        }
    }
Exemple #13
0
 public RectColumn(double _width, double _length, Point3D _cntrPt, Point3D _ptLngthDir, LinearPath _colLinPath)
 {
     Width       = _width;
     Length      = _length;
     CenterPt    = _cntrPt;
     PtLengthDir = _ptLngthDir;
     ColPath     = _colLinPath;
 }
Exemple #14
0
        public override void ReinforcementPopulate()
        {
            LinearPath  BoundaryPath     = new LinearPath(Slab.LinPathSlab.Vertices.Select(e => new Point3D(e.X, e.Y, e.Z - DefaultValues.SlabThinkess + DefaultValues.ColumnCover)).ToArray());
            List <Line> lstBoundaryLines = CadHelper.BoundaryLinesGet(BoundaryPath);

            int nLong       = Convert.ToInt32(lstBoundaryLines[0].Length() / DefaultValues.LongBarSpacing);
            int nTransverse = Convert.ToInt32(lstBoundaryLines[1].Length() / DefaultValues.LongBarSpacing);

            //Vector3D uvLong = MathHelper.UnitVector3DFromPt1ToPt2(lstBoundaryLines[0].StartPoint, lstBoundaryLines[0].EndPoint);

            //Vector3D uvTransverse = MathHelper.UnitVector3DFromPt1ToPt2(lstBoundaryLines[1].StartPoint, lstBoundaryLines[1].EndPoint);

            for (int i = 0; i < nTransverse; i++)
            {
                Line rftTransverse = lstBoundaryLines[0].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line;

                List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(Slab.LinPathSlab, rftTransverse);

                for (int j = 0; j < lstRftLines.Count; j++)
                {
                    Rebar rebar = new Rebar(new LinearPath(lstRftLines[j].Vertices));
                    RFT.Add(rebar);
                }
            }


            for (int i = 0; i < nLong; i++)
            {
                Line rftLong = lstBoundaryLines[1].Offset(DefaultValues.LongBarSpacing * -i, Vector3D.AxisZ) as Line;

                List <Line> lstRftLines = CadHelper.LinesTrimWithPolygon(Slab.LinPathSlab, rftLong);


                for (int j = 0; j < lstRftLines.Count; j++)
                {
                    Rebar rebar = new Rebar(new LinearPath(lstRftLines[j].Vertices));
                    RFT.Add(rebar);
                }
            }

            for (int i = 0; i < Slab.Openings.Count; i++)
            {
                List <Rebar> lstRebar = new List <Rebar>();

                for (int k = 0; k < RFT.Count; k++)
                {
                    if (MathHelper.IsLineSegmentIntersectingPolygon(Slab.Openings[i].LinPathOpening, new Line(RFT[k].LinearPath.StartPoint, RFT[k].LinearPath.EndPoint)))
                    {
                        lstRebar.Add(RFT[k]);
                    }
                }
                OpeningsRFT.AddRange(lstRebar);
            }
            for (int i = 0; i < OpeningsRFT.Count; i++)
            {
                RFT.Remove(OpeningsRFT[i]);
            }
        }
        public void LstRebarPopulate()
        {
            LinearPath rftPath = CadWall.LinPathWall.Offset(DefaultValues.WallCover * -1) as LinearPath;

            Line[] rftPathLines = rftPath.ConvertToLines();

            Line longDirLine  = null;
            Line shortDirLine = null;

            double longDirLength  = double.MinValue;
            double shortDirLength = double.MaxValue;

            for (int i = 0; i < rftPathLines.Length; i++)
            {
                if (rftPathLines[i].Length() > longDirLength)
                {
                    longDirLine   = rftPathLines[i];
                    longDirLength = rftPathLines[i].Length();
                }

                if (rftPathLines[i].Length() < shortDirLength)
                {
                    shortDirLine   = rftPathLines[i];
                    shortDirLength = rftPathLines[i].Length();
                }
            }



            Vector3D uvLength = MathHelper.UnitVector3DFromPt1ToPt2(longDirLine.StartPoint, longDirLine.EndPoint);

            double dia = DefaultValues.BarDiameter;

            Vector3D uvWidth;

            if (longDirLine.Vertices.Contains(shortDirLine.StartPoint))
            {
                uvWidth = MathHelper.UnitVector3DFromPt1ToPt2(shortDirLine.StartPoint, shortDirLine.EndPoint);
            }
            else
            {
                uvWidth = MathHelper.UnitVector3DFromPt1ToPt2(shortDirLine.EndPoint, shortDirLine.StartPoint);
            }

            //placement
            int nRebar = Convert.ToInt32(longDirLine.Length() / DefaultValues.LongBarSpacing);

            for (int i = 0; i < nRebar; i++)
            {
                Point3D locationPt1 = longDirLine.StartPoint + uvLength * DefaultValues.LongBarSpacing * i;
                Point3D locationPt2 = locationPt1 + uvWidth * shortDirLength;
                Rebar   rebar1      = new Rebar(locationPt1);
                Rebar   rebar2      = new Rebar(locationPt2);
                LstRebar.Add(rebar1);
                LstRebar.Add(rebar2);
            }
        }
Exemple #16
0
        internal static bool IsLineSegmentIntersectingPolygon(LinearPath linPath, Line line2)
        {
            foreach (Line line1 in linPath.ConvertToLines())
            {
                //double a1 = line1.EndPoint.Y - line1.StartPoint.Y;
                //double b1 = line1.StartPoint.X - line1.EndPoint.X;
                //double c1 = a1 * line1.StartPoint.X + b1 * line1.StartPoint.Y;

                //double a2 = line2.EndPoint.Y - line2.StartPoint.Y;
                //double b2 = line2.StartPoint.X - line2.EndPoint.X;
                //double c2 = a2 * line2.StartPoint.X + b2 * line2.StartPoint.Y;

                //double delta = a1 * b2 - a2 * b1;
                //if (Math.Abs(delta) > 0.0001) // !=0
                //{
                int o1 = orientation(line1.StartPoint, line1.EndPoint, line2.StartPoint);
                int o2 = orientation(line1.StartPoint, line1.EndPoint, line2.EndPoint);
                int o3 = orientation(line2.StartPoint, line2.EndPoint, line1.StartPoint);
                int o4 = orientation(line2.StartPoint, line2.EndPoint, line1.EndPoint);

                if (o1 != o2 && o3 != o4)
                {
                    return(true);
                }

                // Special Cases
                // p1, q1 and p2 are colinear and p2 lies on segment p1q1
                if (o1 == 0 && onSegment(line1.StartPoint, line2.StartPoint, line1.EndPoint))
                {
                    return(true);
                }

                // p1, q1 and q2 are colinear and q2 lies on segment p1q1
                if (o2 == 0 && onSegment(line1.StartPoint, line2.EndPoint, line1.EndPoint))
                {
                    return(true);
                }

                // p2, q2 and p1 are colinear and p1 lies on segment p2q2
                if (o3 == 0 && onSegment(line2.StartPoint, line1.StartPoint, line2.EndPoint))
                {
                    return(true);
                }

                // p2, q2 and q1 are colinear and q1 lies on segment p2q2
                if (o4 == 0 && onSegment(line2.StartPoint, line1.EndPoint, line2.EndPoint))
                {
                    return(true);
                }
                //}
            }



            return(false); // Doesn't fall in any of the above cases
        }
Exemple #17
0
    ComplexPath loadLane(Transform lane)
    {
        ComplexPath cPath = new ComplexPath();

        for (int i = 0; i < lane.childCount; i++)
        {
            Transform vec = lane.GetChild(i);
            IPath     nextPath;
            int       next = i + 1;
            if (next == lane.childCount)
            {
                next = 0;
            }

            if (vec.childCount > 1)
            {
                // bezier path
                Transform start      = vec.GetChild(0);
                Vector2   startPoint = new Vector2(start.transform.position.x, start.transform.position.y);
                //Debug.Log("startPoint - x " + startPoint.X + " y: " + startPoint.Y);

                Transform ch1      = vec.GetChild(1);
                Vector2   ch1Point = new Vector2(ch1.transform.position.x, ch1.transform.position.y);
                //Debug.Log("ch1Point  - x " + ch1Point.X + " y: " + ch1Point.Y);

                Transform ch2      = vec.GetChild(2);
                Vector2   ch2Point = new Vector2(ch2.transform.position.x, ch2.transform.position.y);
                //Debug.Log("ch2Point - x " + ch2Point.X + " y: " + ch2Point.Y);

                Transform end      = vec.GetChild(3);
                Vector2   endPoint = new Vector2(end.transform.position.x, end.transform.position.y);
                //Debug.Log("endPoint - x " + endPoint.X + " y: " + endPoint.Y);

                nextPath = new BezierPath(startPoint, ch1Point, ch2Point, endPoint);
            }
            else
            {
                //lineal path
                Transform vec2 = lane.GetChild(next);
                if (vec2.childCount > 1)
                {
                    vec2 = vec2.GetChild(0);
                }
                float x  = vec.transform.position.x;
                float y  = vec.transform.position.y;
                float x2 = vec2.transform.position.x;
                float y2 = vec2.transform.position.y;
                nextPath = new LinearPath(new Vector2(x, y), new Vector2(x2, y2));
            }


            cPath.AddPathSegment(nextPath);
        }
        return(cPath);
    }
Exemple #18
0
        public void LstBranchPopulate(LinearPath stirrupPath)
        {
            int nVertices = stirrupPath.Vertices.Length;

            for (int i = 0; i < nVertices - 1; i++)
            {
                Point3D ptSt  = stirrupPath.Vertices[i];
                Point3D ptEnd = stirrupPath.Vertices[i + 1];
                LstBranch.Add(new Line(new Point3D(ptSt.X, ptSt.Y, ptSt.Z), new Point3D(ptEnd.X, ptEnd.Y, ptEnd.Z)));
            }
        }
Exemple #19
0
        public void TestSnapLinear()
        {
            var line = new LinearPath(Vector3.zero, Vector3.forward * 10);

            var point = new Vector3(15, 0, 5);

            line.SnapTo(point, out var snapped, out var distance);

            Assert.AreEqual(new Vector3(0, 0, 5), snapped);
            Assert.AreEqual(5, distance);
        }
Exemple #20
0
        public void StirrupPopulate()
        {
            LinearPath stirrupLp = (LinearPath)RectColumn.ColPath.Offset(-RectColumn.Cover * 1.2);

            for (int i = 0; i < stirrupLp.Vertices.Length; i++)
            {
                stirrupLp.Vertices[i].Z += CADConfig.Units == linearUnitsType.Meters?1:1000;
            }

            Stirrup = new Stirrup(stirrupLp);
        }
Exemple #21
0
        public TestPath(TestRoute route, TestPath source, int index)
        {
            this.route = route;

            var dir = (route.EndPosition - route.StartPosition).normalized;


            LoftPath        = new LinearPath(route.StartPosition, route.EndPosition);
            SideOffsetStart = source == null ? index * 2 : source.SideOffsetEnd;
            SideOffsetEnd   = index * 2;
            Index           = index;
        }
Exemple #22
0
        /// <summary>
        /// Returns List Of Columns and Shear Walls insidy Footing
        /// </summary>
        /// <param name="linPathFooting">Polygon of footing</param>
        /// <param name="lstColLinPath">List of Columns, Walls and Shear walls in the drawing</param>
        /// <returns></returns>
        public static List <LinearPath> EntitiesInsideFootingGet(LinearPath linPathFooting, List <LinearPath> lstEntityLinPath)
        {
            List <LinearPath> lstEntityInsideFooting = new List <LinearPath>();

            for (int i = 0; i < lstEntityLinPath.Count(); i++)
            {
                if (MathHelper.IsInsidePolygon(lstEntityLinPath[i], linPathFooting))
                {
                    lstEntityInsideFooting.Add(lstEntityLinPath[i]);
                }
            }
            return(lstEntityInsideFooting);
        }
Exemple #23
0
        public static Line ShortestLineGet(LinearPath linPath)
        {
            Line[] lineArr      = linPath.ConvertToLines();
            Line   shortestLine = null;
            double length       = double.MaxValue;

            for (int j = 0; j < lineArr.Length; j++)
            {
                shortestLine = lineArr[j].Length() < length ? lineArr[j] : shortestLine;
            }

            return(shortestLine);
        }
        public void StirrupPopulate()
        {
            LinearPath stirrupLp = (LinearPath)CadColumn.ColPath.Offset(-CadColumn.Cover);

            double dowelLength = (CADConfig.Units == linearUnitsType.Meters ? 1 : 1000);

            for (int i = 0; i < stirrupLp.Vertices.Length; i++)
            {
                stirrupLp.Vertices[i].Z += dowelLength;
            }

            Stirrup = new Stirrup(stirrupLp);
        }
        public void StirrupPopulate()
        {
            LinearPath stirrupLp = (LinearPath)ShearWall.ProfilePath.Offset(-DefaultValues.ShearWallCover * 1.2);

            double dowelLength = (CADConfig.Units == linearUnitsType.Meters ? 1 : 1000);

            for (int i = 0; i < stirrupLp.Vertices.Length; i++)
            {
                stirrupLp.Vertices[i].Z += dowelLength;
            }

            Stirrup = new Stirrup(stirrupLp);
        }
Exemple #26
0
        private void GetOpenings(ReadAutodesk cadFileReader, LinearPath path, double level)
        {
            Openings = new List <Opening>();

            List <LinearPath> lstPolyLine = CadHelper.PLinesGetByLayerName(cadFileReader, CadLayerName.Opening, true);
            List <LinearPath> PolyLines   = new List <LinearPath>();

            for (int i = 0; i < lstPolyLine.Count; i++)
            {
                if (MathHelper.IsInsidePolygon(lstPolyLine[i], path))
                {
                    PolyLines.Add(lstPolyLine[i]);
                }
            }

            for (int i = 0; i < PolyLines.Count; i++)
            {
                #region Old code using rectangule shape method
                //double width = double.MaxValue;
                //double length = 0;
                //List<Point2D> lstVertices = new List<Point2D>();

                //Point3D widthMidPt = Point3D.Origin;
                //int nVertices = PolyLines[i].Vertices.Length;

                //for (int j = 0; j < nVertices - 1; j++)
                //{
                //    double dist = MathHelper.CalcDistanceBetweenTwoPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]);
                //    width = Math.Min(width, dist);
                //    if (width == dist)
                //    {
                //        widthMidPt = MathHelper.MidPoint3D(PolyLines[i].Vertices[j], PolyLines[i].Vertices[j + 1]);
                //    }
                //    length = Math.Max(length, dist);
                //}


                //Point3D center = MathHelper.MidPoint3D(PolyLines[i].Vertices[0], PolyLines[i].Vertices[2]);

                //center.Z = level;
                //widthMidPt.Z = level;
                #endregion

                for (int j = 0; j < PolyLines[i].Vertices.Length; j++)
                {
                    PolyLines[i].Vertices[j].Z = level;
                }

                Openings.Add(new Opening(PolyLines[i]));
            }
        }
        private IfcSlab CreateIfcLanding(IfcStore model, LinearPath landingPline, double landingThickness)
        {
            //begin a transaction
            using (var trans = model.BeginTransaction("Create Wall"))
            {
                IfcSlab landing = model.Instances.New <IfcSlab>();


                IfcDirection extrusionDir = model.Instances.New <IfcDirection>();
                extrusionDir.SetXYZ(0, 0, -1);

                //Create a Definition shape to hold the geometry of the Stair 3D body
                IfcShapeRepresentation shape = IFCHelper.ShapeRepresentationCreate(model, "SweptSolid", "Body");


                IfcArbitraryClosedProfileDef stepProfile = IFCHelper.ArbitraryClosedProfileCreate(model, (landingPline.Vertices /*.Select(v => v * 1000)*/).ToList());

                IfcExtrudedAreaSolid body = IFCHelper.ProfileSweptSolidCreate(model, landingThickness, stepProfile, extrusionDir);


                body.BodyPlacementSet(model, 0, 0, 0);

                shape.Items.Add(body);

                //Create a Product Definition and add the model geometry to the wall
                IfcProductDefinitionShape prDefShape = model.Instances.New <IfcProductDefinitionShape>();
                prDefShape.Representations.Add(shape);

                landing.Representation = prDefShape;

                //Create Local axes system and assign it to the column
                IfcCartesianPoint location3D = model.Instances.New <IfcCartesianPoint>();
                location3D.SetXYZ(0, 0, 0);

                //var uvColLongDir = MathHelper.UnitVectorPtFromPt1ToPt2(cadSlab.CenterPt, cadSlab.PtLengthDir);

                IfcDirection localXDir = model.Instances.New <IfcDirection>();
                localXDir.SetXYZ(1, 0, 0);

                IfcDirection localZDir = model.Instances.New <IfcDirection>();
                localZDir.SetXYZ(0, 0, 1);

                IfcAxis2Placement3D ax3D = IFCHelper.LocalAxesSystemCreate(model, location3D, localXDir, localZDir);

                //now place the slab into the model
                IfcLocalPlacement lp = IFCHelper.LocalPlacemetCreate(model, ax3D);
                landing.ObjectPlacement = lp;
                trans.Commit();
                return(landing);
            }
        }
Exemple #28
0
        public LineNode(string label, IList<double[]> points)
            : base(label)
        {
            foreach (double[] p in points)
                    Add(new Point3DEntity(this, null, p));

               List<Point3D> pts = new List<Point3D>(Attributes.Count);
               foreach (IAttribute atr in Attributes)
                    if (atr is Point3Attribute)
                         pts.Add(new Point3D((atr as Point3Attribute).Value as double[]));

               LinearPath lp = new LinearPath(pts.ToArray(), System.Drawing.Color.Black);
               Length = lp.Length();
        }
Exemple #29
0
        public void Draw(Model model)
        {
            Point3D  origin;
            Vector3D camX, camY, camZ;

            Camera.GetFrame(out origin, out camX, out camY, out camZ);
            if (origin != null)
            {
                // Draws the View Volume
                Point3D[] pts   = new Point3D[24];
                int       count = 0;

                for (int i = 0; i < 4; i++)
                {
                    pts[count++] = pNear[i];
                    pts[count++] = pNear[(i + 1) % 4];
                    pts[count++] = pFar[(i + 1) % 4];
                    pts[count++] = pFar[i];
                    pts[count++] = origin;
                    pts[count++] = pNear[(i + 1) % 4];
                }

                LinearPath lp1 = new LinearPath(pts);
                lp1.Color       = Color.Gray;
                lp1.ColorMethod = colorMethodType.byEntity;
                model.Entities.Add(lp1, LayerName);

                //Draws the Camera
                const double widthB = 3, heightB = 5, depthB = 3, heightC = widthB / 2, radiusC = 1.5;

                Mesh cone = Mesh.CreateCone(radiusC, radiusC / 2, heightC, 10);
                cone.ColorMethod = colorMethodType.byEntity;
                cone.Color       = Color.GreenYellow;

                Mesh box = Mesh.CreateBox(widthB, depthB, heightB);
                box.ColorMethod = colorMethodType.byEntity;
                box.Color       = Color.GreenYellow;

                // centers the box to the world origin
                box.Translate(-widthB / 2, -depthB / 2, +heightC);

                // Aligns the Camera to the Camera view
                Transformation t = new Align3D(Plane.XY, new Plane(origin, camX, camY));
                box.TransformBy(t);
                cone.TransformBy(t);

                model.Entities.Add(cone, LayerName);
                model.Entities.Add(box, LayerName);
            }
        }
Exemple #30
0
        public static void Pocket(Model model)
        {
            Point2D[] pts = new Point2D[]
            {
                new Point2D(0, 0),
                new Point2D(40, 0),
                new Point2D(40, 20),
                new Point2D(60, 20),
                new Point2D(60, 10),
                new Point2D(100, 10),
                new Point2D(100, 60),
                new Point2D(60, 60),
                new Point2D(60, 30),
                new Point2D(40, 30),
                new Point2D(40, 80),
                new Point2D(0, 80),
                new Point2D(0, 0),
            };

            LinearPath outerContour = new LinearPath(Plane.XY, pts);

            outerContour.LineWeightMethod = colorMethodType.byEntity;
            outerContour.LineWeight       = 3;

            model.Entities.Add(outerContour, Color.OrangeRed);

            Circle innerContour = new Circle(20, 60, 0, 6);

            innerContour.LineWeightMethod = colorMethodType.byEntity;
            innerContour.LineWeight       = 3;

            model.Entities.Add(innerContour, Color.OrangeRed);

            Region r1 = new Region(new ICurve[] { outerContour, innerContour }, Plane.XY, true);

            ICurve[] passes = r1.Pocket(4, cornerType.Round, .1);

            const double zStep     = 2;
            const int    stepCount = 10;

            for (int i = 1; i < stepCount; i++)
            {
                foreach (Entity crv in passes)
                {
                    Entity en = (Entity)crv.Clone();
                    en.Translate(0, 0, -i * zStep);
                    model.Entities.Add(en, Color.DarkBlue);
                }
            }
        }
Exemple #31
0
        public LineNode(string label, double[,] points)
            : base(label)
        {
            for (int i = 0; i < points.GetLength(0); i++)
                    Add(new Point3DEntity(this, points[i, 0], points[i, 1], points[i, 2]));

               List<Point3D> pts = new List<Point3D>(Attributes.Count);
               foreach (IAttribute atr in Attributes)
                    if (atr is Point3Attribute)
                         pts.Add(new Point3D((atr as Point3Attribute).Value as double[]));

               LinearPath lp = new LinearPath(pts.ToArray(), System.Drawing.Color.Black);
               Length = lp.Length();
        }
Exemple #32
0
        public Entity CreateTarget(double xTarget, double yTarget)
        {
            this.xTarget = xTarget;
            this.yTarget = yTarget;

            lpTarget = new LinearPath(new Point3D(3, 3, 0), new Point3D(3, 8, 0), new Point3D(-3, 8, 0), new Point3D(-3, 3, 0),
                                      new Point3D(-8, 3, 0), new Point3D(-8, -3, 0), new Point3D(-3, -3, 0), new Point3D(-3, -8, 0), new Point3D(3, -8, 0),
                                      new Point3D(3, -3, 0), new Point3D(8, -3, 0), new Point3D(8, 3, 0), new Point3D(3, 3, 0));

            lpTarget.Rotate(-Math.PI / 4, Vector3D.AxisZ);
            lpTarget.Translate(xTarget, yTarget, 0);

            return(lpTarget);
        }
Exemple #33
0
 LinearPath CreateNormal(double s, ref Vect2 uv, ref Vect3 xyz, ref Vect3 xup)
 {
     LinearPath nor = new LinearPath(2);
     xVal(s, ref uv, ref xyz, ref xup);
     nor.Vertices[0] = Utilities.Vect3ToPoint3D(xyz);
     Vect3 xnor = xup - xyz;
     if (xnor.Magnitude > COMBMAX)//enforce maxmimum combheight
     {
         xnor.Magnitude = COMBMAX;
         xup = xyz + xnor;//ensure you passt he values back to the caller
     }
     nor.Vertices[1] = Utilities.Vect3ToPoint3D(xup);
     nor.EntityData = this;
     ///nor.GroupIndex = 0;
     return nor;
 }
Exemple #34
0
        public virtual List<Entity> CreateEntities(bool bFitPoints, double TolAngle, out double[] sPos)
        {
            if (!AllFitPointsValid())
            {
                sPos = null;
                return new List<Entity>();
            }

            List<double> spos = new List<double>();
            const int TEST = 8;
            int FitLength = FitPoints.Length;
            double[] stest = new double[(FitLength - 1) * TEST];
            Vect3[] xtest = new Vect3[(FitLength - 1) * TEST];
            Vect2 uv = new Vect2();
            Vect3 xyz = new Vect3();
            Vect3 dxp = new Vect3(), dxm = new Vect3();
            //initial 8 subdivisions per segment
            int nFit, nTest = 0;
            for (nFit = 1; nFit < FitLength; nFit++)
            {
                for (int i = 0; i < TEST; i++, nTest++)
                {
                    stest[nTest] = BLAS.interpolate(i, TEST, FitPoints[nFit].S, FitPoints[nFit - 1].S);
                    xtest[nTest] = new Vect3();
                    xVal(stest[nTest], ref uv, ref xtest[nTest]);
                }
            }

            //test the midpoint of each subsegment to determine required # of points
            int[] nAdd = new int[stest.Length];
            double cosA;
            double smid;
            int nTotal = FitLength;
            for (nTest = 1; nTest < stest.Length; nTest++)
            {
                //midpoint position
                smid = (stest[nTest] + stest[nTest - 1]) / 2.0;
                xVal(smid, ref uv, ref xyz);
                //forward and backward tangents
                dxp = xtest[nTest] - xyz;
                dxm = xtest[nTest - 1] - xyz;
                //change in angle between for and aft tans
                cosA = -(dxp.Dot(dxm)) / (dxp.Magnitude * dxm.Magnitude);
                Utilities.LimitRange(-1, ref cosA, 1);
                cosA = Math.Acos(cosA);
                //determine additional points and sum total
                nTotal += nAdd[nTest] = (int)(cosA / TolAngle + 1);
            }

            m_Length = 0;
            Vect3 xprev = new Vect3();
            Vect3 dx = new Vect3();
            List<Point3D> pnts = new List<Point3D>();
            List<Vect3> tans = new List<Vect3>();
            xVal(stest[0], ref uv, ref xprev);
            pnts.Add(new Point3D(xprev.ToArray()));
            spos.Add(stest[0]);
            for (nTest = 1; nTest < stest.Length; nTest++)
            {
                for (int i = 1; i <= nAdd[nTest]; i++)
                {
                    smid = ((nAdd[nTest] - i) * stest[nTest - 1] + i * stest[nTest]) / nAdd[nTest];
                    xVec(smid, ref uv, ref xyz, ref dx);
                    spos.Add(smid);
                    pnts.Add(new Point3D(xyz.ToArray()));
                    tans.Add(new Vect3(dx));
                    m_Length += xyz.Distance(xprev);
                    xprev.Set(xyz);
                }
            }

            if (EXTENDENTITY)
            {
                //add for-cast/back-cast points
                for (int i = 0; i < 2; i++)
                {
                    for (nTest = 0; nTest < 10; nTest++)
                    {
                        smid = BLAS.interpolant(nTest, 10) * 0.05;//scale down to .1 cast
                        if (i == 0)
                            smid = -smid;
                        else
                            smid += 1.0;

                        xVal(smid, ref uv, ref xyz);
                        if (i == 0)
                            pnts.Insert(0, new Point3D(xyz.ToArray()));
                        else
                            pnts.Add(new Point3D(xyz.ToArray()));
                    }
                }
            }

            LinearPath lp = new LinearPath(pnts);
            lp.EntityData = this;
            //lp.LineWeight = 3.0f;
            //lp.LineWeightMethod = colorMethodType.byEntity;
            List<Entity> tanpaths = new List<Entity>();
            tanpaths.Add(lp);
            if (bFitPoints)
            {
                //LinearPath path;
                //int npnt = 0;
                //foreach (Vect3 pnt in tans)
                //{
                //	pnt.Magnitude = 2;
                //	xyz = new Vect3(pnts[npnt].ToArray());
                //	xyz += pnt;
                //	path = new LinearPath(pnts[npnt], new Point3D(xyz.ToArray()));
                //	path.EntityData = this;
                //	tanpaths.Add(path);
                //	npnt++;
                //	//xVal(pnt.UV, ref xyz);
                //	//pnts.Add(new Point3D(xyz.ToArray()));
                //}
                pnts = new List<Point3D>();
                foreach (IFitPoint pnt in FitPoints)
                {
                    xVal(pnt.UV, ref xyz);
                    pnts.Add(new Point3D(xyz.ToArray()));
                }
                PointCloud pc = new PointCloud(pnts, 8f);
                pc.EntityData = this;
                tanpaths.Add(pc);
            }
            sPos = spos.ToArray();
            return tanpaths;
        }