Exemplo n.º 1
0
 internal virtual IGeometryEntity[] ProjectOn(Geometry other, Vector direction)
 {
     throw new InvalidOperationException(string.Format(Properties.Resources.InvalidProjection, GetType().Name, other.GetType().Name));
 }
Exemplo n.º 2
0
        public Geometry[] Intersect(Geometry other)
        {
            if (null == other)
            {
                throw new ArgumentNullException("other");
            }

            IGeometryEntity[] geoms = null;
            Plane             plane = other as Plane;

            if (plane != null)
            {
                geoms = IntersectWithPlane(plane);
            }
            else
            {
                Surface surf = other as Surface;
                if (surf != null)
                {
                    geoms = IntersectWithSurface(surf);
                }
                else
                {
                    Solid solid = other as Solid;
                    if (solid != null)
                    {
                        geoms = IntersectWithSolid(solid);
                    }
                    else
                    {
                        Curve curve = other as Curve;
                        if (curve != null)
                        {
                            geoms = IntersectWithCurve(curve);
                        }
                        else
                        {
                            Point point = other as Point;
                            if (null != point)
                            {
                                geoms = IntersectWithPoint(point);
                            }
                            else
                            {
                                throw new System.InvalidOperationException(string.Format(Properties.Resources.InvalidIntersect, GetType().Name, other.GetType().Name));
                            }
                        }
                    }
                }
            }

            return(geoms.ToArray <Geometry, IGeometryEntity>(true));
        }
Exemplo n.º 3
0
        public void ToPDF(iTextSharp.text.pdf.PdfWriter w)
        {
            PdfContentByte cb = w.DirectContent;

            cb.SetLineWidth((float)Settings.Thickness);
            if (Settings.Fill != null)
            {
                cb.SetColorFill(Settings.Fill.ToPDFColor());
            }

            if (Settings.Stroke != null)
            {
                cb.SetColorStroke(Settings.Stroke.ToPDFColor());
            }

            if (Geometry.GetType() == typeof(Dyn.Arc))
            {
                Dyn.Arc arc = Geometry as Dyn.Arc;
                cb.MoveTo(arc.StartPoint.X, arc.EndPoint.Y);
                cb.CurveTo(arc.PointAtParameter(0.5).X, arc.PointAtParameter(0.5).Y, arc.EndPoint.X, arc.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Line))
            {
                Dyn.Line line = Geometry as Dyn.Line;
                cb.MoveTo(line.StartPoint.X, line.StartPoint.Y);
                cb.LineTo(line.EndPoint.X, line.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Circle))
            {
                Dyn.Circle circle = Geometry as Dyn.Circle;
                cb.Circle(circle.CenterPoint.X, circle.CenterPoint.Y, circle.Radius);
            }
            else if (Geometry.GetType() == typeof(Dyn.Ellipse))
            {
                Dyn.Ellipse ellipse = Geometry as Dyn.Ellipse;
                cb.Ellipse(ellipse.StartPoint.X, ellipse.StartPoint.Y, ellipse.EndPoint.X, ellipse.EndPoint.Y);
            }
            else if (Geometry.GetType() == typeof(Dyn.Rectangle))
            {
                Dyn.Rectangle rect = Geometry as Dyn.Rectangle;
                cb.Rectangle(rect.Center().X, rect.Center().Y, rect.Width, rect.Height);
            }
            else if (Geometry.GetType() == typeof(Dyn.Polygon))
            {
                Dyn.Polygon p = Geometry as Dyn.Polygon;
                foreach (var curve in p.Curves())
                {
                    CurveToPDF(curve, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.PolyCurve))
            {
                Dyn.PolyCurve pc = Geometry as Dyn.PolyCurve;
                foreach (var curve in pc.Curves())
                {
                    CurveToPDF(curve, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.NurbsCurve))
            {
                Dyn.NurbsCurve nc = Geometry as Dyn.NurbsCurve;

                foreach (var linearc in nc.ApproximateWithArcAndLineSegments())
                {
                    CurveToPDF(linearc, cb);
                }
            }
            else if (Geometry.GetType() == typeof(Dyn.Curve))
            {
                Dyn.Curve curve = Geometry as Dyn.Curve;
                CurveToPDF(curve, cb);
            }
            else
            {
                throw new Exception(Properties.Resources.NotSupported);
            }

            if (Settings.Fill != null && Settings.Stroke != null)
            {
                cb.FillStroke();
            }
            else
            {
                if (Settings.Stroke != null)
                {
                    cb.Stroke();
                }
                if (Settings.Fill != null)
                {
                    cb.Fill();
                }
            }
        }