Esempio n. 1
0
        public IShape2D ToShape2D(Matrix4D matrix)
        {
            Polyline2DCollection polyline2Dcollection = new Polyline2DCollection(this.ilist_0.Count);

            foreach (Polyline4D polyline4D in (IEnumerable <Polyline4D>) this.ilist_0)
            {
                Polyline2D polyline2D = new Polyline2D(polyline4D.Count, polyline4D.Closed);
                foreach (Vector4D vector in (List <Vector4D>)polyline4D)
                {
                    polyline2D.Add(matrix.TransformToPoint2D(vector));
                }
                polyline2Dcollection.Add(polyline2D);
            }
            return((IShape2D)polyline2Dcollection);
        }
Esempio n. 2
0
        public static Polyline2DCollection GetFlattened(
            IShape2D shape,
            double epsilon)
        {
            if (epsilon == 0.0)
            {
                epsilon = -0.01;
            }
            Polyline2DCollection polyline2Dcollection = new Polyline2DCollection();

            if (epsilon < 0.0)
            {
                Bounds2D bounds = ShapeTool.GetBounds(shape);
                if (!bounds.Initialized)
                {
                    return(polyline2Dcollection);
                }
                epsilon *= -System.Math.Max(bounds.Delta.X, bounds.Delta.Y);
            }
            epsilon *= epsilon;
            ISegment2DIterator iterator = shape.CreateIterator();

            if (iterator.MoveNext())
            {
                Point2D[]  points   = new Point2D[3];
                Polyline2D polyline = (Polyline2D)null;
                do
                {
                    switch (iterator.Current(points, 0))
                    {
                    case SegmentType.MoveTo:
                        polyline = new Polyline2D();
                        polyline2Dcollection.Add(polyline);
                        polyline.Add(points[0]);
                        break;

                    case SegmentType.LineTo:
                        polyline.Add(points[0]);
                        break;

                    case SegmentType.QuadTo:
                        ShapeTool.smethod_7(polyline, polyline[polyline.Count - 1], points[0], points[1], epsilon);
                        break;

                    case SegmentType.CubicTo:
                        ShapeTool.smethod_11(polyline, polyline[polyline.Count - 1], points[0], points[1], points[2], epsilon);
                        break;

                    case SegmentType.Close:
                        polyline.Closed = true;
                        if (polyline.Count > 1 && polyline[polyline.Count - 1] == polyline[0])
                        {
                            polyline.RemoveAt(polyline.Count - 1);
                            break;
                        }
                        break;
                    }
                }while (iterator.MoveNext());
            }
            return(polyline2Dcollection);
        }