Ejemplo n.º 1
0
        public List <Curve> GenBridge()
        {
            crvAPts = GetPtLiFromCrv(crvA);
            crvBPts = GetPtLiFromCrv(crvB);
            List <Seg> segLi = new List <Seg>();

            for (int i = 0; i < crvAPts.Count; i++)
            {
                Point3d p = crvAPts[i];
                for (int j = 0; j < crvBPts.Count; j++)
                {
                    Point3d q   = crvBPts[j];
                    Seg     seg = new Seg(p, q);
                    segLi.Add(seg);
                }
            }
            segLi.Sort(delegate(Seg x, Seg y)
            {
                return(x.dist.CompareTo(y.dist));
            });
            List <Line> lineLi = new List <Line>();

            for (int i = 0; i < segLi.Count; i++)
            {
                Line line = new Line(segLi[i].A, segLi[i].B);
                lineLi.Add(line);
            }

            BridgeCrvLi  = new List <Curve>();
            BridgeCrvPts = new List <Point3d>();
            Seg   s0          = segLi[0];
            Seg   s1          = segLi[1];
            Curve BridgePoly0 = GenBridgeCrv(s0, s1);
            Curve BridgePoly1 = GenBridgeCrv(s1, s0);

            BridgeCrvLi.Add(BridgePoly0);
            BridgeCrvLi.Add(BridgePoly1);

            return(BridgeCrvLi);
        }
Ejemplo n.º 2
0
        public Curve GenBridgeCrv(Seg s0, Seg s1)
        {
            Point3d        a      = s0.A;
            Point3d        b      = s0.B;
            Point3d        c      = s1.B;
            Point3d        d      = s1.A;
            double         normAD = a.DistanceTo(d);
            double         normBC = b.DistanceTo(c);
            Point3d        d1     = new Point3d(d.X + ((a.X - d.X) * BridgeDepth / normAD), d.Y + ((a.Y - d.Y) * BridgeDepth / normAD), 0);
            Point3d        c1     = new Point3d(c.X + ((b.X - c.X) * BridgeDepth / normBC), c.Y + ((b.Y - c.Y) * BridgeDepth / normBC), 0);
            List <Point3d> pts    = new List <Point3d> {
                d, c, c1, d1, d
            };
            PolylineCurve poly = new PolylineCurve(pts);
            Curve         crv  = poly;

            BridgeCrvPts.Add(c);
            BridgeCrvPts.Add(d);
            BridgeCrvPts.Add(c1);
            BridgeCrvPts.Add(d1);

            return(crv);
        }