public wCurve ToPiecewiseBezier(Curve RhinoCurve, double DistanceTol, double KinkTol) { NurbsCurve N = RhinoCurve.ToNurbsCurve(); N.MakePiecewiseBezier(true); BezierCurve[] B = BezierCurve.CreateCubicBeziers(N, DistanceTol, KinkTol); Point3d PtA = B[0].GetControlVertex3d(0); Point3d PtB = B[0].GetControlVertex3d(1); Point3d PtC = B[0].GetControlVertex3d(2); Point3d PtD = B[0].GetControlVertex3d(3); wBezierSpline pCurve = new wBezierSpline(new wPoint(PtA.X, PtA.Y, PtA.Z), new wPoint(PtB.X, PtB.Y, PtB.Z), new wPoint(PtC.X, PtC.Y, PtC.Z), new wPoint(PtD.X, PtD.Y, PtD.Z)); for (int i = 1; i < B.Count(); i++) { PtA = B[i].GetControlVertex3d(0); PtB = B[i].GetControlVertex3d(1); PtC = B[i].GetControlVertex3d(2); PtD = B[i].GetControlVertex3d(3); pCurve.AddSpan(new wPoint(PtA.X, PtA.Y, PtA.Z), new wPoint(PtB.X, PtB.Y, PtB.Z), new wPoint(PtC.X, PtC.Y, PtC.Z), new wPoint(PtD.X, PtD.Y, PtD.Z)); } WindCurve = pCurve; return(WindCurve); }
public Path WpfCompoundPolyline(wShapeCollection Shapes) { Path X = new Path(); PathFigureCollection Fc = new PathFigureCollection(); PathGeometry G = new PathGeometry(); Fc.Clear(); foreach (wShape Shp in Shapes.Shapes) { PathSegmentCollection Sc = new PathSegmentCollection(); PathFigure Pf = new PathFigure(); wCurve Crv = Shp.Curve; wPoint StartPoint = Crv.Points[0]; Pf.StartPoint = new System.Windows.Point(StartPoint.X * Scale, StartPoint.Y * Scale); PathGeometry Geo = (PathGeometry)WpfPolyline(Crv, Shapes.Graphics, Shapes.Effects).Data; PathFigureCollection Fig = (PathFigureCollection)Geo.Figures; PathFigure PFig = (PathFigure)(Fig[0]); PathSegmentCollection Seg = (PathSegmentCollection)PFig.Segments; PolyLineSegment Pl = (PolyLineSegment)Seg[0]; PolyLineSegment S = new PolyLineSegment(Pl.Points, true); Pf.IsClosed = true; Sc.Add(S); Pf.Segments = Sc; Fc.Add(Pf); } G.Figures = Fc; X.Data = G; X.RenderTransform = Xform; wGraphic Graphics = Shapes.Graphics; wEffects ShapeEffects = Shapes.Effects; X = SetPathFill(X, Graphics); X = SetPathStroke(X, Graphics); X = SetPathEffects(X, ShapeEffects); group.Shapes.Add(new wShape(G, Graphics)); return(X); }
public RhCrvToWindCrv(Curve RhinoCurve) { Circle R = new Circle(); Arc A = new Arc(); Ellipse S = new Ellipse(); Polyline P = new Polyline(); if (RhinoCurve.TryGetCircle(out R)) { WindCurve = new wCircle(new wPoint(R.Center.X, R.Center.Y), R.Radius); } else if (RhinoCurve.TryGetArc(out A)) { WindCurve = new wArc( new wPoint(A.Center.X, A.Center.Y, A.Center.Z), A.Radius, Vector3d.VectorAngle(Vector3d.XAxis, new Vector3d(A.StartPoint - A.Center), Plane.WorldXY) / Math.PI * 180.0, Vector3d.VectorAngle(Vector3d.XAxis, new Vector3d(A.EndPoint - A.Center), Plane.WorldXY) / Math.PI * 180.0); } else if (RhinoCurve.TryGetEllipse(out S)) { Box bBox = new Box(); RhinoCurve.GetBoundingBox(S.Plane, out bBox); double RadiusX = (bBox.X.T1 - bBox.X.T0) / 2; double RadiusY = (bBox.Y.T1 - bBox.Y.T0) / 2; double Rotation = Vector3d.VectorAngle(Vector3d.YAxis, S.Plane.YAxis, Plane.WorldXY) / Math.PI * 180.0; WindCurve = new wEllipse(new wPoint(S.Plane.Origin.X, S.Plane.Origin.Y), RadiusX, RadiusY, Rotation); } else if (RhinoCurve.IsLinear()) { Point3d PtA = RhinoCurve.PointAtStart; Point3d PtB = RhinoCurve.PointAtEnd; WindCurve = new wLine(new wPoint(PtA.X, PtA.Y, PtA.Z), new wPoint(PtB.X, PtB.Y, PtB.Z)); } else if (RhinoCurve.TryGetPolyline(out P)) { WindCurve = new wPolyline(RhPlineToWindPoints(P), P.IsClosed); } else { WindCurve = ToPiecewiseBezier(RhinoCurve, 0, 0); } }
public Path WpfLine(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects) { Path X = new Path(); wLine C = (wLine)Shp; LineGeometry L = new LineGeometry(); L.StartPoint = new System.Windows.Point(C.Start.X * Scale, C.Start.Y * Scale); L.EndPoint = new System.Windows.Point(C.End.X * Scale, C.End.Y * Scale); X.Data = L; X.RenderTransform = Xform; X = SetPathEffects(X, ShapeEffects); X = SetPathStroke(X, Graphics); group.Shapes.Add(new wShape(L, Graphics)); return(X); }
public Path WpfArc(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects) { wArc C = (wArc)Shp; ArcSegment S = new ArcSegment(); S.Point = new System.Windows.Point(C.EndPoint.X * Scale, C.EndPoint.Y * Scale); S.Size = new System.Windows.Size(C.Radius * Scale, C.Radius * Scale); if (C.Clockwise) { S.SweepDirection = SweepDirection.Clockwise; } else { S.SweepDirection = SweepDirection.Counterclockwise; } Path X = new Path(); PathFigure Pf = new PathFigure(); PathGeometry G = new PathGeometry(); PathFigureCollection Fc = new PathFigureCollection(); PathSegmentCollection Sc = new PathSegmentCollection(); Pf.StartPoint = new System.Windows.Point(C.StartPoint.X * Scale, C.StartPoint.Y * Scale); Sc.Add(S); Pf.Segments = Sc; Fc.Add(Pf); G.Figures = Fc; X.Data = G; X.RenderTransform = Xform; X = SetPathFill(X, Graphics); X = SetPathStroke(X, Graphics); X = SetPathEffects(X, ShapeEffects); group.Shapes.Add(new wShape(G, Graphics)); return(X); }
public Path WpfCircle(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects) { Path X = new Path(); wCircle C = (wCircle)Shp; EllipseGeometry E = new EllipseGeometry(); E.Center = new System.Windows.Point((C.Center.X) * Scale, (C.Center.Y) * Scale); E.RadiusX = C.Radius * Scale; E.RadiusY = C.Radius * Scale; X.Data = E; X.RenderTransform = Xform; X = SetPathFill(X, Graphics); X = SetPathStroke(X, Graphics); X = SetPathEffects(X, ShapeEffects); group.Shapes.Add(new wShape(E, Graphics)); return(X); }
public Path WpfText(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects) { Path X = new Path(); wTextObject Z = (wTextObject)Shp; wText Y = Z.Text; wFontMedia F = Y.Font.ToMediaFont(); FormattedText T = new FormattedText("Test", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Arial"), 24, new SolidColorBrush(Colors.Black)); //FormattedText T = new FormattedText(Y.Text,CultureInfo.GetCultureInfo("en-us"),FlowDirection.LeftToRight, F.GetTypeFace(),F.Size, Graphics.WpfFill); X.Data = T.BuildGeometry(new System.Windows.Point(Z.Plane.Origin.X, Z.Plane.Origin.Y)); X.RenderTransform = Xform; //X = SetPathFill(X, Graphics); //X = SetPathEffects(X, ShapeEffects); //X = SetPathStroke(X, Graphics); group.Shapes.Add(new wShape(Shp, Graphics)); return(X); }
public Path WpfSpline(wCurve Shp, wGraphic Graphics, wEffects ShapeEffects) { wBezierSpline C = (wBezierSpline)Shp; PathFigure Pf = new PathFigure(); PolyBezierSegment S = new PolyBezierSegment(); PathGeometry G = new PathGeometry(); PathFigureCollection Fc = new PathFigureCollection(); PathSegmentCollection Sc = new PathSegmentCollection(); Path X = new Path(); 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); }