Beispiel #1
0
 public override Plane GetPlane(double t, int part_index = 0)
 {
     if (part_index < 0 || part_index > Branches.Length + 1)
     {
         return(Plane.Unset);
     }
     if (part_index == 0)
     {
         return(Trunk.GetPlane(t));
     }
     else
     {
         return(Branches[part_index - 1].GetPlane(t));
     }
 }
Beispiel #2
0
 public override Plane GetPlane(double t, int part_index = 0)
 {
     return(Blank.GetPlane(t));
 }
Beispiel #3
0
        List <Curve> LamellaOutlines(Glulam g)
        {
            double[] t = g.Centreline.DivideByCount(g.Data.Samples, true);

            List <Plane> planes = t.Select(x => g.GetPlane(x)).ToList();

            Point3d[][] pts = new Point3d[4][];
            pts[0] = new Point3d[g.Data.NumWidth + 1];
            pts[1] = new Point3d[g.Data.NumHeight + 1];

            pts[2] = new Point3d[g.Data.NumWidth + 1];
            pts[3] = new Point3d[g.Data.NumHeight + 1];

            double hWidth  = g.Width / 2;
            double hHeight = g.Height / 2;

            // Create points for lamella corners
            for (int i = 0; i <= g.Data.NumWidth; ++i)
            {
                pts[0][i] = new Point3d(-hWidth + g.Data.LamWidth * i, -hHeight, 0);
                pts[2][i] = new Point3d(-hWidth + g.Data.LamWidth * i, hHeight, 0);
            }

            for (int i = 0; i <= g.Data.NumHeight; ++i)
            {
                pts[1][i] = new Point3d(-hWidth, -hHeight + g.Data.LamHeight * i, 0);
                pts[3][i] = new Point3d(hWidth, -hHeight + g.Data.LamHeight * i, 0);
            }

            List <Point3d>[][] crv_pts = new List <Point3d> [4][];

            crv_pts[0] = new List <Point3d> [g.Data.NumWidth + 1];
            crv_pts[1] = new List <Point3d> [g.Data.NumHeight + 1];
            crv_pts[2] = new List <Point3d> [g.Data.NumWidth + 1];
            crv_pts[3] = new List <Point3d> [g.Data.NumHeight + 1];

            Transform xform;
            Point3d   pt;

            // Create curve points
            foreach (Plane p in planes)
            {
                xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, p);
                for (int i = 0; i <= g.Data.NumWidth; ++i)
                {
                    pt = new Point3d(pts[0][i]);

                    pt.Transform(xform);
                    if (crv_pts[0][i] == null)
                    {
                        crv_pts[0][i] = new List <Point3d>();
                    }
                    crv_pts[0][i].Add(pt);

                    pt = new Point3d(pts[2][i]);

                    pt.Transform(xform);
                    if (crv_pts[2][i] == null)
                    {
                        crv_pts[2][i] = new List <Point3d>();
                    }
                    crv_pts[2][i].Add(pt);
                }

                for (int i = 0; i <= g.Data.NumHeight; ++i)
                {
                    pt = new Point3d(pts[1][i]);

                    pt.Transform(xform);
                    if (crv_pts[1][i] == null)
                    {
                        crv_pts[1][i] = new List <Point3d>();
                    }
                    crv_pts[1][i].Add(pt);

                    pt = new Point3d(pts[3][i]);

                    pt.Transform(xform);
                    if (crv_pts[3][i] == null)
                    {
                        crv_pts[3][i] = new List <Point3d>();
                    }
                    crv_pts[3][i].Add(pt);
                }
            }

            // Create lamella side curves
            List <Curve> crvs = new List <Curve>();

            for (int i = 0; i <= g.Data.NumWidth; ++i)
            {
                crvs.Add(Curve.CreateInterpolatedCurve(crv_pts[0][i], 3));
                crvs.Add(Curve.CreateInterpolatedCurve(crv_pts[2][i], 3));
            }

            for (int i = 0; i <= g.Data.NumHeight; ++i)
            {
                crvs.Add(Curve.CreateInterpolatedCurve(crv_pts[1][i], 3));
                crvs.Add(Curve.CreateInterpolatedCurve(crv_pts[3][i], 3));
            }

            // Create lamella end curves
            Point3d p0, p1;

            xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, planes.First());

            for (int i = 0; i <= g.Data.NumWidth; ++i)
            {
                p0 = new Point3d(pts[0][i]);
                p0.Transform(xform);

                p1 = new Point3d(pts[2][i]);
                p1.Transform(xform);

                crvs.Add(new Line(p0, p1).ToNurbsCurve());
            }

            for (int i = 0; i <= g.Data.NumHeight; ++i)
            {
                p0 = new Point3d(pts[1][i]);
                p0.Transform(xform);

                p1 = new Point3d(pts[3][i]);
                p1.Transform(xform);

                crvs.Add(new Line(p0, p1).ToNurbsCurve());
            }


            xform = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, planes.Last());

            for (int i = 0; i <= g.Data.NumWidth; ++i)
            {
                p0 = new Point3d(pts[0][i]);
                p0.Transform(xform);

                p1 = new Point3d(pts[2][i]);
                p1.Transform(xform);

                crvs.Add(new Line(p0, p1).ToNurbsCurve());
            }

            for (int i = 0; i <= g.Data.NumHeight; ++i)
            {
                p0 = new Point3d(pts[1][i]);
                p0.Transform(xform);

                p1 = new Point3d(pts[3][i]);
                p1.Transform(xform);

                crvs.Add(new Line(p0, p1).ToNurbsCurve());
            }

            return(crvs);
        }