/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Brep trimmed = null;
            bool shouhui = false;

            if (!DA.GetData(0, ref trimmed) || !DA.GetData(1, ref shouhui))
            {
                return;
            }
            //////////////////////////////////////////////////
            if (shouhui)
            {
                Rhino.Geometry.Collections.BrepFaceList bf = trimmed.Faces;
                bf.ShrinkFaces();
                List <Surface> sfs = new List <Surface>();
                for (int i = 0; i < bf.Count; i++)
                {
                    BrepFace bb = bf[i];
                    Surface  sf = bb.DuplicateSurface();
                    sfs.Add(sf);
                }
                DA.SetDataList(0, sfs);
            }
            else
            {
                trimmed.Faces.ShrinkFaces();
                DA.SetData(0, trimmed);
            }
        }
Beispiel #2
0
        private void GenerateLand()
        {
            //for 3x
            //  create random points
            //  create curve from points
            //  move the curve in y direction
            //get 3 curves and create loft surface

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

            for (int i = 0; i < 8; i++)
            {
                //create random points
                List <Point3d> pts = new List <Point3d>();
                double         dx  = (this.width / 7);

                for (int j = 0; j < 8; j++)
                {
                    pts.Add(new Point3d(dx * j, 0, rnd.NextDouble() * this.height));
                }

                //create the curve
                Curve c = Curve.CreateControlPointCurve(pts, 3);

                //move the curve
                double dy = (this.depth / 7);
                c.Translate(0, dy * i, 0);
                c.Reverse();
                curves.Add(c);
            }

            //loft the curves
            Brep[]   br = Brep.CreateFromLoft(curves, Point3d.Unset, Point3d.Unset, LoftType.Normal, false);
            BrepFace bf = br[0].Faces[0];

            this.land = bf.DuplicateSurface();

            //reparametrize the surface
            this.land.SetDomain(0, new Interval(0, 1));
            this.land.SetDomain(1, new Interval(0, 1));
        }