コード例 #1
0
        public static IEnumerable <Rhino.Geometry.Curve> Offset(IEnumerable <Rhino.Geometry.Curve> curves, double distance, JoinType joinType, EndType endType, double miter, double arcTolerance, Plane?plane)
        {
            var curveList = curves as IList <Rhino.Geometry.Curve> ?? curves.ToList();

            plane = GetPlane(curveList, plane);


            var polylines2D = curveList.Select(o => Polyline2D.FromCurve(o, plane.Value))
                              .Where(o => o != null)
                              .ToList();


            double  unit;
            Point2d center;

            CalculateUnit(polylines2D, miter * distance, out unit, out center);


            var polylinesInt = polylines2D.Select(o => PolylineInt.FromPolyline2D(o, center, unit))
                               .ToList();


            var clipper = new ClipperOffset(miter, arcTolerance / unit);

            foreach (var polygon in polylinesInt)
            {
                clipper.AddPath(polygon, joinType, polygon.Closed ? EndType.etClosedPolygon : endType);
            }


            var solution = new List <List <IntPoint> >();

            clipper.Execute(ref solution, distance / unit);


            return(solution.Select(o => o.ToCurve(plane.Value, center, unit)));
        }