Ejemplo n.º 1
0
        /// <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)
        {
            string T = "";
            Plane  P = Plane.WorldXY;

            if (!DA.GetData(0, ref T))
            {
                return;
            }
            if (!DA.GetData(1, ref P))
            {
                return;
            }

            wPlane Pln = new wPlane(new wPoint(P.Origin.X, P.Origin.Y, P.Origin.Z), new wVector(P.XAxis.X, P.XAxis.Y, P.XAxis.Z), new wVector(P.YAxis.X, P.YAxis.Y, P.YAxis.Z));

            wText       Txt    = new wText(T);
            wTextObject TxtObj = new wTextObject(Txt, Pln);

            TxtObj.Angle = (Vector3d.VectorAngle(Vector3d.YAxis, P.YAxis, Plane.WorldXY) / Math.PI * 180);

            wShape           Shape  = new wShape(TxtObj);
            wShapeCollection Shapes = new wShapeCollection(Shape);

            Shapes.Type = "Text";

            Shapes.Graphics = new wGraphic().BlackFill();
            Shapes.Effects  = new wEffects();

            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 2
0
        /// <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)
        {
            Point3d P = new Point3d(0, 0, 0);
            double  R = 1.0;

            if (!DA.GetData(0, ref P))
            {
                return;
            }
            if (!DA.GetData(1, ref R))
            {
                return;
            }

            wPoint O   = new wPoint(P.X, P.Y, P.Z);
            wCurve Crv = new wCircle(O, R);

            wShape           Shape  = new wShape(Crv);
            wShapeCollection Shapes = new wShapeCollection(Shape);

            wPlane Pln = new wPlane().XYPlane();

            Pln.Origin = O;

            Shapes.Boundary = new wRectangle(Pln, R, R);
            Shapes.Type     = Crv.GetCurveType;

            Shapes.Graphics = new wGraphic().BlackFill();
            Shapes.Effects  = new wEffects();


            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 3
0
        public wCircle(wPlane BasePlane, double RadiusValue)
        {
            IsClosed = true;

            Plane  = BasePlane;
            Center = Plane.Origin;
            Radius = RadiusValue;
        }
Ejemplo n.º 4
0
        public wEllipse(wPlane BasePlane, double XRadius, double YRadius)
        {
            IsClosed = true;

            Plane   = BasePlane;
            Center  = Plane.Origin;
            RadiusX = XRadius;
            RadiusY = YRadius;
        }
Ejemplo n.º 5
0
        public wArc(wPlane BasePlane, double RadiusValue, double AngleStart, double AngleEnd)
        {
            Plane      = BasePlane;
            Center     = Plane.Origin;
            Radius     = RadiusValue;
            StartAngle = AngleStart;
            EndAngle   = AngleEnd;
            Angle      = EndAngle - StartAngle;

            StartPoint = new wPoint(Center.X + Radius * Math.Cos(Math.PI * StartAngle / 180), Center.Y + Radius * Math.Sin(Math.PI * StartAngle / 180), Center.Z);
            EndPoint   = new wPoint(Center.X + Radius * Math.Cos(Math.PI * EndAngle / 180), Center.Y + Radius * Math.Sin(Math.PI * EndAngle / 180), Center.Z);
        }
Ejemplo n.º 6
0
        /// <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)
        {
            IGH_Goo     Z = null;
            Rectangle3d R = new Rectangle3d(Plane.WorldXY, 150, 150);

            if (!DA.GetData(0, ref Z))
            {
                return;
            }
            if (!DA.GetData(0, ref R))
            {
                return;
            }

            Bitmap A = null;

            if (Z != null)
            {
                Z.CastTo(out A);
            }

            // Check if is pline
            Curve C = R.ToNurbsCurve();

            BoundingBox B = C.GetBoundingBox(true);
            wPoint      O = new wPoint(B.Center.X, B.Center.Y, B.Center.Z);

            wShape           Shape  = new wShape(new wRectangle());
            wShapeCollection Shapes = new wShapeCollection(Shape);

            wPlane Pln = new wPlane().XYPlane();

            Pln.Origin = O;

            Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y);
            //Shapes.Type = Crv.GetCurveType;

            if (C.IsClosed)
            {
                Shapes.Graphics = new wGraphic().BlackFill();
            }
            else
            {
                Shapes.Graphics = new wGraphic().BlackOutline();
            }
            Shapes.Effects = new wEffects();


            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 7
0
        public wRectangle(wPlane CenterPlane, double RectWidth, double RectHeight)
        {
            Plane  = CenterPlane;
            Center = Plane.Origin;

            Width  = RectWidth;
            Height = RectHeight;

            CornerPoints[0] = new wPoint(Center.X - Width / 2, Center.Y - Height / 2, Center.Z);
            CornerPoints[1] = new wPoint(Center.X + Width / 2, Center.Y - Height / 2, Center.Z);
            CornerPoints[2] = new wPoint(Center.X + Width / 2, Center.Y + Height / 2, Center.Z);
            CornerPoints[3] = new wPoint(Center.X + Width / 2, Center.Y + Height / 2, Center.Z);

            IsClosed = true;
        }
Ejemplo n.º 8
0
        /// <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   B = new Brep();
            double D = 0;
            double K = 0;

            if (!DA.GetData(0, ref B))
            {
                return;
            }
            if (!DA.GetData(1, ref D))
            {
                return;
            }
            if (!DA.GetData(2, ref K))
            {
                return;
            }

            Curve[] C = B.DuplicateNakedEdgeCurves(true, true);
            C = Curve.JoinCurves(C);

            wShapeCollection Shapes = new wShapeCollection();

            foreach (Curve Crv in C)
            {
                Shapes.Shapes.Add(new wShape(new RhCrvToWindCrv().ToPiecewiseBezier(Crv, D, K)));
            }

            BoundingBox X   = B.GetBoundingBox(true);
            wPoint      O   = new wPoint(X.Center.X, X.Center.Y, X.Center.Z);
            wPlane      Pln = new wPlane().XYPlane();

            Pln.Origin      = O;
            Shapes.Boundary = new wRectangle(Pln, X.Diagonal.X, X.Diagonal.Y);
            Shapes.Type     = "PolyCurveGroup";

            Shapes.Graphics = new wGraphic().BlackFill();

            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 9
0
        /// <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)
        {
            Mesh M = new Mesh();

            if (!DA.GetData(0, ref M))
            {
                return;
            }

            Polyline[]    P     = M.GetNakedEdges();
            List <wShape> Shape = new List <wShape>();

            foreach (Polyline Pline in P)
            {
                List <wPoint> Pts = new List <wPoint>();
                for (int i = 0; i < Pline.Count; i++)
                {
                    Pts.Add(new wPoint(Pline[i].X, Pline[i].Y, Pline[i].Z));
                }

                wCurve Crv = new wPolyline(Pts, true);

                Shape.Add(new wShape(Crv));
            }

            wShapeCollection Shapes = new wShapeCollection(Shape);

            BoundingBox B   = M.GetBoundingBox(true);
            wPoint      O   = new wPoint(B.Center.X, B.Center.Y, B.Center.Z);
            wPlane      Pln = new wPlane().XYPlane();

            Pln.Origin      = O;
            Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y);
            Shapes.Type     = "PolylineGroup";

            Shapes.Graphics = new wGraphic().BlackFill();

            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 10
0
        /// <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)
        {
            Curve  C = new Circle(new Point3d(0, 0, 0), 1).ToNurbsCurve();
            double D = 0;
            double K = 0;

            if (!DA.GetData(0, ref C))
            {
                return;
            }
            if (!DA.GetData(1, ref D))
            {
                return;
            }
            if (!DA.GetData(2, ref K))
            {
                return;
            }

            wCurve Crv = new wCircle(new wPoint(), 1);

            Curve[] Segments = C.DuplicateSegments();

            // Check if is pline
            if (Segments.Count() > 1)
            {
                Polyline P = new Polyline();
                if (C.TryGetPolyline(out P))
                {
                    List <wPoint> Pts = new List <wPoint>();
                    for (int i = 0; i < P.Count; i++)
                    {
                        Pts.Add(new wPoint(P[i].X, P[i].Y, P[i].Z));
                    }

                    Crv = new wPolyline(Pts, P.IsClosed);
                }
                else
                {
                    Crv = new RhCrvToWindCrv().ToPiecewiseBezier(C, D, K);
                }
            }
            else
            {
                Crv = new RhCrvToWindCrv(C).WindCurve;
            }

            BoundingBox B = C.GetBoundingBox(true);
            wPoint      O = new wPoint(B.Center.X, B.Center.Y, B.Center.Z);

            wShape           Shape  = new wShape(Crv);
            wShapeCollection Shapes = new wShapeCollection(Shape);

            wPlane Pln = new wPlane().XYPlane();

            Pln.Origin = O;

            Shapes.Boundary = new wRectangle(Pln, B.Diagonal.X, B.Diagonal.Y);
            Shapes.Type     = Crv.GetCurveType;

            if (C.IsClosed)
            {
                Shapes.Graphics = new wGraphic().BlackFill();
            }
            else
            {
                Shapes.Graphics = new wGraphic().BlackOutline();
            }
            Shapes.Effects = new wEffects();


            wObject WindObject = new wObject(Shapes, "Hoopoe", Shapes.Type);

            DA.SetData(0, WindObject);
        }
Ejemplo n.º 11
0
        /// <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)
        {
            string ID   = this.Attributes.InstanceGuid.ToString();
            string name = new GUIDtoAlpha(Convert.ToString(ID + Convert.ToString(this.RunCount)), false).Text;
            int    C    = this.RunCount;

            wObject  WindObject = new wObject();
            pElement Element    = new pElement();
            bool     Active     = Elements.ContainsKey(C);

            var pCtrl = new pDrawing(name);

            if (Elements.ContainsKey(C))
            {
                Active = true;
            }

            //Check if control already exists
            if (Active)
            {
                if (Elements[C] != null)
                {
                    WindObject = Elements[C];
                    Element    = (pElement)WindObject.Element;
                    pCtrl      = (pDrawing)Element.ParrotControl;
                }
            }
            else
            {
                pCtrl.SetProperties();
                Elements.Add(C, WindObject);
            }

            //Set Unique Control Properties

            List <IGH_Goo> Shps = new List <IGH_Goo>();
            Rectangle3d    B    = new Rectangle3d(Plane.WorldXY, 0, 0);
            Interval       Fx   = new Interval(600, 600);
            bool           D    = true;

            if (!DA.GetDataList(0, Shps))
            {
                return;
            }
            if (!DA.GetData(1, ref B))
            {
                return;
            }
            if (!DA.GetData(2, ref Fx))
            {
                return;
            }
            if (!DA.GetData(3, ref D))
            {
                return;
            }

            List <wShapeCollection> Shapes = new List <wShapeCollection>();

            Rectangle3d F = new Rectangle3d(Plane.WorldXY, Fx.T0, Fx.T1);

            wObject          Wx = new wObject();
            wShapeCollection Sx = new wShapeCollection();

            Shps[0].CastTo(out Wx);
            Sx = (wShapeCollection)Wx.Element;

            BoundingBox Box = new BoundingBox(Sx.Boundary.CornerPoints[0].X, Sx.Boundary.CornerPoints[0].Y, 0, Sx.Boundary.CornerPoints[2].X, Sx.Boundary.CornerPoints[2].Y, 0);

            foreach (IGH_Goo Obj in Shps)
            {
                wObject          W = new wObject();
                wShapeCollection S = new wShapeCollection();

                Obj.CastTo(out W);
                S = (wShapeCollection)W.Element;
                Shapes.Add(S);

                wPoint PtA = S.Boundary.CornerPoints[0];
                wPoint PtB = S.Boundary.CornerPoints[2];

                Box.Union(new Point3d(PtA.X, PtA.Y, PtA.Z));
                Box.Union(new Point3d(PtB.X, PtB.Y, PtB.Z));
            }

            if ((B.Width == 0.0) & (B.Height == 0.0))
            {
                Plane pln = Plane.WorldXY;
                pln.Origin = Box.Center;
                B          = new Rectangle3d(pln,
                                             new Interval(-Box.Diagonal.X / 2.0, Box.Diagonal.X / 2.0),
                                             new Interval(-Box.Diagonal.Y / 2.0, Box.Diagonal.Y / 2.0));
            }

            wPlane PlnB = new wPlane(
                new wPoint(B.Center.X, B.Center.Y, B.Center.Z),
                new wVector(B.Plane.XAxis.X, B.Plane.XAxis.Y, B.Plane.XAxis.Z),
                new wVector(B.Plane.YAxis.X, B.Plane.YAxis.Y, B.Plane.YAxis.Z));
            wPlane PlnF = new wPlane(
                new wPoint(F.Center.X, F.Center.Y, F.Center.Z),
                new wVector(F.Plane.XAxis.X, F.Plane.XAxis.Y, F.Plane.XAxis.Z),
                new wVector(F.Plane.YAxis.X, F.Plane.YAxis.Y, F.Plane.YAxis.Z));

            pCtrl.SetCanvasSize(new wRectangle(PlnF, F.Width, F.Height), new wRectangle(PlnB, B.Width, B.Height));

            pCtrl.Graphics.Width  = F.Width;
            pCtrl.Graphics.Height = F.Height;

            pCtrl.group.X = B.Center.X * pCtrl.Scale - B.Width / 2.0 * pCtrl.Scale;
            pCtrl.group.Y = B.Center.Y * pCtrl.Scale - B.Height / 2.0 * pCtrl.Scale;

            pCtrl.group.Width  = F.Width;
            pCtrl.group.Height = F.Height;

            pCtrl.SetSize();

            pCtrl.SetScale();
            if (D)
            {
                pCtrl.ClearDrawing();
            }

            foreach (wShapeCollection S in Shapes)
            {
                switch (S.Type)
                {
                case "PolyCurveGroup":
                    pCtrl.AddPolySpline(S);
                    break;

                case "PolylineGroup":
                    pCtrl.AddPolyFigure(S);
                    break;

                default:
                    pCtrl.AddShape(S);
                    break;
                }
            }

            pCtrl.SetCanvas();

            //Set Parrot Element and Wind Object properties
            if (!Active)
            {
                Element = new pElement(pCtrl.Element, pCtrl, pCtrl.Type);
            }
            WindObject          = new wObject(Element, "Parrot", Element.Type);
            WindObject.GUID     = this.InstanceGuid;
            WindObject.Instance = C;

            Elements[this.RunCount] = WindObject;

            DA.SetData(0, WindObject);
            DA.SetData(1, pCtrl.group);
            DA.SetData(2, pCtrl.GetBitmap());
        }
Ejemplo n.º 12
0
        /// <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)
        {
            //Set Unique Control Properties

            List <IGH_Goo> Shps = new List <IGH_Goo>();
            Rectangle3d    B    = new Rectangle3d(Plane.WorldXY, 0, 0);
            Interval       Fx   = new Interval(600, 600);
            bool           D    = true;

            if (!DA.GetDataList(0, Shps))
            {
                return;
            }
            if (!DA.GetData(1, ref B))
            {
                return;
            }
            if (!DA.GetData(2, ref Fx))
            {
                return;
            }
            if (!DA.GetData(3, ref D))
            {
                return;
            }

            List <wShapeCollection> Shapes = new List <wShapeCollection>();

            Rectangle3d F = new Rectangle3d(Plane.WorldXY, Fx.T0, Fx.T1);

            wObject          Wx = new wObject();
            wShapeCollection Sx = new wShapeCollection();

            Shps[0].CastTo(out Wx);
            Sx = (wShapeCollection)Wx.Element;

            BoundingBox bBox = new BoundingBox();

            if (D)
            {
                SavedBox = new BoundingBox();
            }
            else
            {
                bBox = SavedBox;
            }
            bBox.Union(new BoundingBox(Sx.Boundary.CornerPoints[0].X, Sx.Boundary.CornerPoints[0].Y, 0, Sx.Boundary.CornerPoints[2].X, Sx.Boundary.CornerPoints[2].Y, 0));

            SavedBox = bBox;

            foreach (IGH_Goo Obj in Shps)
            {
                wObject          W = new wObject();
                wShapeCollection S = new wShapeCollection();

                Obj.CastTo(out W);
                S = (wShapeCollection)W.Element;
                Shapes.Add(S);

                wPoint PtA = S.Boundary.CornerPoints[0];
                wPoint PtB = S.Boundary.CornerPoints[2];

                bBox.Union(new Point3d(PtA.X, PtA.Y, PtA.Z));
                bBox.Union(new Point3d(PtB.X, PtB.Y, PtB.Z));
            }

            if ((B.Width == 0.0) & (B.Height == 0.0))
            {
                Plane pln = Plane.WorldXY;
                pln.Origin = bBox.Center;
                B          = new Rectangle3d(pln,
                                             new Interval(-bBox.Diagonal.X / 2.0, bBox.Diagonal.X / 2.0),
                                             new Interval(-bBox.Diagonal.Y / 2.0, bBox.Diagonal.Y / 2.0));
            }

            wPlane PlnB = new wPlane(
                new wPoint(B.Center.X, B.Center.Y, B.Center.Z),
                new wVector(B.Plane.XAxis.X, B.Plane.XAxis.Y, B.Plane.XAxis.Z),
                new wVector(B.Plane.YAxis.X, B.Plane.YAxis.Y, B.Plane.YAxis.Z));
            wPlane PlnF = new wPlane(
                new wPoint(F.Center.X, F.Center.Y, F.Center.Z),
                new wVector(F.Plane.XAxis.X, F.Plane.XAxis.Y, F.Plane.XAxis.Z),
                new wVector(F.Plane.YAxis.X, F.Plane.YAxis.Y, F.Plane.YAxis.Z));

            CompileSVG SVGobject = new CompileSVG();

            double X = F.Width / B.Width;
            double Y = F.Height / B.Height;
            double Z = 1.0;

            if (X < Y)
            {
                Z = X;
            }
            else
            {
                Z = Y;
            }


            SVGobject.SetSize((int)F.Width, (int)F.Height, new wRectangle(PlnB, B.Width, B.Height), Z);
            SVGobject.SetQuality(QualityType);

            if (D)
            {
                SavedPathSets.Clear();
            }
            else
            {
                SVGobject.LoadPaths(SavedPathSets);
            }

            int i = 0;

            foreach (wShapeCollection S in Shapes)
            {
                SVGobject.SetShapeType(S, i);
                i += 1;
            }

            SavedPathSets = SVGobject.PathSet;

            if (SVGobject.FrameCount > 0)
            {
                SVGobject.SetFrames();
            }
            else
            {
                SVGobject.SetGroups();
            }


            SVGobject.Build();

            DA.SetData(0, SVGobject);
        }
Ejemplo n.º 13
0
 public wTextObject(wText WindText, wPlane PlaneObject)
 {
     Text  = WindText;
     Plane = PlaneObject;
 }