Esempio n. 1
0
        public SectionLoop Duplicate()
        {
            var res = new SectionLoop();

            res.Type = Type;
            foreach (var i in this)
            {
                res.Add(i);
            }
            return(res);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public static Section CreateSection(Brep brp, Plane pln)
        {
            var    sec = new Section();
            string id  = "P101";

            var tx = Transform.ChangeBasis(Plane.WorldYZ, Util.SofiSectionBasePlane) * Transform.ChangeBasis(Plane.WorldXY, pln);

            int pointIndex = 0;

            foreach (var lp in brp.Loops)
            {
                var crv = lp.To3dCurve();

                crv.Transform(tx);

                var polyLine = Util.CreatePolyLine(crv);
                if (polyLine != null)
                {
                    var secLp = new SectionLoop();
                    secLp.Type = lp.LoopType == BrepLoopType.Outer ? SectionLoopType.Outer : SectionLoopType.Inner;
                    foreach (var pt in polyLine)
                    {
                        var secPt = new SectionPoint()
                        {
                            Id = id,
                            R  = 0,
                            Y  = pt.Y,
                            Z  = pt.Z,
                        };
                        id = Util.CountStringUp(id);

                        secLp.Add(pointIndex++);
                        sec.Points.Add(secPt);
                    }
                    sec.Loops.Add(secLp);
                }
            }

            return(sec);
        }