public static Sm.DrawingGroup ToGeometryGroup(this Drawing input) { Sm.DrawingGroup drawings = new Sm.DrawingGroup(); double scale = input.GetScale(); Rg.Curve curve = input.Frame.ToNurbsCurve(); double x0 = input.Frame.Center.X - input.Width / scale / 2; double x1 = input.Frame.Center.X + input.Width / scale / 2; double y0 = input.Frame.Center.Y - input.Height / scale / 2; double y1 = input.Frame.Center.Y + input.Height / scale / 2; Rg.Rectangle3d rect = new Rg.Rectangle3d(Rg.Plane.WorldXY, new Rg.Point3d(x0, y0, 0), new Rg.Point3d(x1, y1, 0)); drawings.Children.Add(new Shape(rect.ToNurbsCurve(), new Wg.Graphic(Wg.Strokes.Transparent, new Wg.Fill(input.Background))).ToGeometryDrawing()); foreach (Shape shape in input.Shapes) { drawings.Children.Add(shape.ToGeometryDrawing()); } drawings.ClipGeometry = input.Frame.ToPolyline().ToGeometry(); Sm.TransformGroup xform = new Sm.TransformGroup(); xform.Children.Add(new Sm.TranslateTransform(input.Frame.Center.X - input.Width / 2, input.Frame.Center.Y - input.Height / 2)); xform.Children.Add(new Sm.ScaleTransform(1, -1)); drawings.Transform = xform; return(drawings); }
public static Sm.DrawingVisual ToGeometryVisual(this Drawing input) { Sm.DrawingVisual drawings = new Sm.DrawingVisual(); double scale = input.GetScale(); Rg.Curve curve = input.Frame.ToNurbsCurve(); double x0 = input.Frame.Center.X - input.Width / scale / 2; double x1 = input.Frame.Center.X + input.Width / scale / 2; double y0 = input.Frame.Center.Y - input.Height / scale / 2; double y1 = input.Frame.Center.Y + input.Height / scale / 2; Rg.Rectangle3d rect = new Rg.Rectangle3d(Rg.Plane.WorldXY, new Rg.Point3d(x0, y0, 0), new Rg.Point3d(x1, y1, 0)); drawings.Children.Add(new Shape(rect.ToNurbsCurve(), new Wg.Graphic(Wg.Strokes.Transparent, new Wg.Fill(input.Background))).ToVisualDrawing()); foreach (Shape shape in input.Shapes) { drawings.Children.Add(shape.ToVisualDrawing()); } Sm.TransformGroup xform = new Sm.TransformGroup(); double shiftW = (input.Width / scale / 2 - input.Frame.Center.X); double shiftH = -(input.Height / scale / 2 + input.Frame.Center.Y); xform.Children.Add(new Sm.TranslateTransform(shiftW, shiftH)); xform.Children.Add(new Sm.ScaleTransform(scale, (-1) * scale)); drawings.Transform = xform; return(drawings); }
public Geometry(Rg.Rectangle3d rectangle3D) { curveType = CurveTypes.Rectangle; curve = rectangle3D.ToNurbsCurve(); }