Esempio n. 1
0
        private hPolyline AddPolyline(wPolyline InputCurve)
        {
            hPolyline crv = new hPolyline(InputCurve);

            crv.BuildSVGCurve();
            return(crv);
        }
Esempio n. 2
0
        private bool FormsEar(int A, int B, int C)
        {
            wVector V0 = new wVector(pgon.Points[A], pgon.Points[B]);
            wVector V1 = new wVector(pgon.Points[C], pgon.Points[B]);

            if (V0.GetAngle(V1) > 0)
            {
                return(false);
            }

            wPolyline triangle = new wPolyline(new wPoint[] { pgon.Points[A], pgon.Points[B], pgon.Points[C] });

            for (int i = 0; i < pgon.Points.Count; i++)
            {
                if ((i != A) && (i != B) && (i != C))
                {
                    if (triangle.IsPointInside(pgon.Points[i]))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 3
0
 public hPolyline(wPolyline WindGeometry)
 {
     Points = WindGeometry.Points;
     if (WindGeometry.IsClosed)
     {
         Closed = "z ";
     }
 }
Esempio n. 4
0
        public PolylineToMesh(wPolyline polyline)
        {
            if (polyline.IsClockwise())
            {
                polyline.Flip();
            }
            polyline.OpenPolyline();

            this.SetVertices(polyline.Points);

            pgon = polyline;

            TriangulatePolyline();
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public Path WpfPolyline(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects)
        {
            Path                  X  = new Path();
            wPolyline             C  = (wPolyline)Shp;
            PathFigure            Pf = new PathFigure();
            PolyLineSegment       S  = new PolyLineSegment();
            PathGeometry          G  = new PathGeometry();
            PathFigureCollection  Fc = new PathFigureCollection();
            PathSegmentCollection Sc = new PathSegmentCollection();

            Pf.StartPoint = new System.Windows.Point(C.Points[0].X * Scale, C.Points[0].Y * Scale);

            for (int i = 1; i < C.Points.Count; i++)
            {
                wPoint P = C.Points[i];
                S.Points.Add(new System.Windows.Point(P.X * Scale, P.Y * Scale));
            }

            Sc.Add(S);
            Pf.Segments = Sc;
            Fc.Add(Pf);
            G.Figures = Fc;
            X.Data    = G;

            X.StrokeMiterLimit = 1.0;

            X.RenderTransform = Xform;

            X = SetPathFill(X, Graphics);
            X = SetPathStroke(X, Graphics);
            X = SetPathEffects(X, ShapeEffects);


            group.Shapes.Add(new wShape(G, Graphics));
            return(X);
        }
Esempio n. 7
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);
        }