Example #1
0
        private double?[,] GetZArray(Point2dCollection[] collections, double sizeX)
        {
            var distance    = TechProcess.Tool.Diameter / 2;
            var countX      = (int)(sizeX / StepX2) + 1;
            var zArray      = new double?[collections.Length, countX];
            var intersector = new CurveCurveIntersector2d();

            Acad.SetLimitProgressor(collections.Length);

            var rays = Enumerable.Range(0, countX).Select(p => new Ray2d(new Point2d(p * StepX2, 0), Vector2d.YAxis)).ToList();

            for (int i = 0; i < collections.Length; i++)
            {
                Acad.ReportProgressor();

                if (collections[i] == null)
                {
                    continue;
                }

                var polylene    = new PolylineCurve2d(collections[i]);
                var offsetCurve = polylene.GetTrimmedOffset(distance, OffsetCurveExtensionType.Fillet)[0];

                for (int j = 0; j < countX; j++)
                {
                    intersector.Set(offsetCurve, rays[j]);
                    if (intersector.NumberOfIntersectionPoints == 1)
                    {
                        zArray[i, j] = intersector.GetIntersectionPoint(0).Y - distance;
                    }
                }
                //if (i < 50)
                //{
                //    Draw.Pline(polylene.GetSamplePoints(10).Select(p => new Point3d(p.X + i * 100, p.Y + 1000, 0)));
                //    Draw.Pline(offsetCurve.GetSamplePoints(10).Select(p => new Point3d(p.X + i * 100, p.Y + 1000, 0)));
                //}
                //else
                //{
                polylene.Dispose();
                offsetCurve.Dispose();
                //}
            }
            rays.ForEach(p => p.Dispose());
            intersector.Dispose();

            return(zArray);
        }
Example #2
0
        private Point2dCollection[] GetPointCollections(DbSurface offsetSurface, Point3d minPoint, Point3d maxPoint)
        {
            var countY      = (int)((maxPoint.Y - minPoint.Y) / StepY) + 1;
            var countX      = (int)((maxPoint.X - minPoint.X) / StepX1) + 1;
            var collections = new Point2dCollection[countY];

            Acad.SetLimitProgressor(countY);

            for (var i = 0; i < countY; i++)
            {
                Acad.ReportProgressor();
                var collection = new Point2dCollection();
                var dy         = i * StepY;

                for (var j = 0; j < countX; j++)
                {
                    var dx = j * StepX1;

                    offsetSurface.RayTest(minPoint + new Vector3d(dx, dy, 0), Vector3d.ZAxis, 0.0001, out SubentityId[] col, out DoubleCollection par);

                    if (par.Count == 1)
                    {
                        var point = new Point2d(dx, Math.Round(par[0], 2));
                        var ind   = collection.Count - 1;
                        if (ind > 0 && collection[ind - 1].GetVectorTo(collection[ind]).IsCodirectionalTo(collection[ind].GetVectorTo(point)))
                        {
                            collection[ind] = point;
                        }
                        else
                        {
                            collection.Add(point);
                        }
                    }
                }
                if (collection.Count > 1)
                {
                    collections[i] = collection;
                }
            }
            return(collections);
        }
Example #3
0
        public override void BuildProcessing(MillingCommandGenerator generator)
        {
            var railBase    = TechProcess.Rail?.GetCurve() ?? new Line(Point3d.Origin, Point3d.Origin + Vector3d.XAxis * TechProcess.Length.Value);
            var profile     = (Profile ?? TechProcess.ProcessingArea[0]).GetCurve();
            var processSide = ChangeProcessSide ? 1 : -1;

            CreateProfile3D(profile, railBase, processSide);

            var rail = CreateDepartureRail(railBase, Departure);

            if (Delta != 0)
            {
                var profileOffset = (Curve)profile.GetOffsetCurves(Delta)[0];
                profile = profileOffset.EndPoint.GetAsVector().Length < profile.EndPoint.GetAsVector().Length
                    ? (Curve)profile.GetOffsetCurves(-Delta)[0]
                    : profileOffset;
                CreateProfile3D(profile, railBase, processSide);
            }
            var offsetSign = processSide * (railBase is Line ? 1 : -1);

            if (railBase.IsNewObject)
            {
                railBase.Dispose();
            }

            var side = BuilderUtils.CalcEngineSide(rail.GetFirstDerivative(0).GetAngleTo(Vector3d.XAxis));

            if (ChangeEngineSide)
            {
                side = SideExt.Opposite(side);
            }
            var isMinToolCoord = IsA90
                ? TechProcess.MachineType.Value != MachineType.ScemaLogic
                : side == Side.Right ^ TechProcess.MachineType.Value == MachineType.ScemaLogic ^ ChangeProcessSide;

            generator.CuttingFeed = CuttingFeed;
            generator.SmallFeed   = TechProcess.PenetrationFeed;
            generator.EngineSide  = side;

            Curve outletCurve = null;

            if (IsA90 && IsOutlet)
            {
                outletCurve = rail.GetOffsetCurves(TechProcess.ZSafety * offsetSign)[0] as Curve;
                var angleC = BuilderUtils.CalcToolAngle(outletCurve, outletCurve.StartPoint, side);
                generator.Move(outletCurve.StartPoint.X, outletCurve.StartPoint.Y, angleC: angleC, angleA: 90);
            }
            var angleA = IsA90 ? 90 : 0;
            var index  = IsA90 ? 1 : 0;

            var profilePoints = BuilderUtils.GetProcessPoints(profile, index, ProfileStep, TechProcess.Tool.Thickness.Value, isMinToolCoord, ProfileBegin, ProfileEnd, IsExactlyBegin, IsExactlyEnd, true);

            var profilePline = new Polyline();

            Enumerable.Range(0, profilePoints.Count).ForEach(i => profilePline.AddVertexAt(i, profilePoints[i], 0, 0, 0));

            var railLength = rail.Length();

            Acad.SetLimitProgressor((int)(railLength / LongStep));

            for (double dist = 0; dist < railLength; dist += LongStep)
            {
                Acad.ReportProgressor();

                var point     = rail.GetPointAtDist(dist);
                var angleC    = BuilderUtils.CalcToolAngle(rail, point, side);
                var passPline = CalcPassPline(rail, point, profilePline, processSide);

                generator.Cutting(passPline, CuttingFeed, TechProcess.PenetrationFeed, angleC: angleC, angleA: angleA);

                if (IsOutlet)
                {
                    if (IsA90)
                    {
                        var pt = outletCurve.GetClosestPoint(generator.ToolPosition.Point);
                        generator.Move(pt.X, pt.Y);
                    }
                    else
                    {
                        generator.Uplifting();
                    }
                }
            }
            rail.Dispose();
        }
Example #4
0
        public void BuildProcessingOld(MillingCommandGenerator generator)
        {
            var sectionProfile = (SectionProfileTechProcess)TechProcess;
            var toolThickness  = TechProcess.Tool.Thickness.Value;

            var rail = sectionProfile.Rail != null?sectionProfile.Rail.GetCurve() as Line : new Line(Point3d.Origin, new Point3d(sectionProfile.Length.Value, 0, 0));

            var railVector  = rail.Delta.GetNormal();
            var passVector  = rail.Delta;
            var crossVector = railVector.RotateBy(-Math.PI / 2, Vector3d.ZAxis);
            var startPass   = rail.StartPoint;
            var shift       = TechProcess.MachineType == MachineType.Donatoni ^ BuilderUtils.CalcEngineSide(rail.Angle) == Side.Left ? toolThickness : 0;

            if (rail.IsNewObject)
            {
                rail.Dispose();
            }

            var profile = sectionProfile.ProcessingArea[0].GetCurve() as Polyline;

            if (profile == null)
            {
                throw new Exception("Профиль должен быть полилинией");
            }

            if (Delta != 0)
            {
                profile = (Polyline)profile.GetOffsetCurves(Delta)[0];
            }

            var endX          = Math.Max(profile.StartPoint.X, profile.EndPoint.X);
            var profilePoints = profile.GetPolylineFitPoints(ProfileStep).Select(p => new Point2d(endX - p.X, p.Y)).ToList();

            if (profilePoints[0].X > Consts.Epsilon)
            {
                profilePoints.Reverse();
            }
            profilePoints = profilePoints
                            .TakeWhile(p => p.X < toolThickness)
                            .Select(p => p - Vector2d.XAxis * toolThickness)
                            .Concat(profilePoints)
                            .ToList();
            var passPoints = profilePoints.Select((p, i) =>
            {
                var y = p.Y;
                for (int j = i + 1; j < profilePoints.Count && profilePoints[j].X - profilePoints[i].X < toolThickness; j++)
                {
                    if (profilePoints[j].Y > y)
                    {
                        y = profilePoints[j].Y;
                    }
                }
                return(new Point2d(p.X, y));
            })
                             .ToList();

            if (Departure > 0)
            {
                passPoints.Insert(0, new Point2d(-Departure, passPoints.First().Y));
                passPoints.Add(new Point2d(passPoints.Last().X + Departure, passPoints.Last().Y));
            }

            var sp = startPass + crossVector * (passPoints[0].X + shift) + passPoints[0].Y * Vector3d.ZAxis;

            generator.Move(sp.X, sp.Y, angleC: BuilderUtils.CalcToolAngle(railVector.GetAngleTo(Vector3d.XAxis)));

            var passPointsDirect = new List <Point2d>[2] {
                passPoints, Enumerable.Reverse(passPoints).ToList()
            };
            int direct = 0;

            Acad.SetLimitProgressor((int)(passVector.Length / LongStep));
            for (double x = 0; x < passVector.Length; x += LongStep)
            {
                Acad.ReportProgressor();
                passPointsDirect[direct].ForEach(p => generator.GCommand(CommandNames.Cutting, 1, point: startPass + crossVector * (p.X + shift) + p.Y * Vector3d.ZAxis + x * railVector, feed: CuttingFeed));
                direct = 1 - direct;
            }
        }
Example #5
0
        public override void BuildProcessing(ICommandGenerator generator)
        {
            var disk3DTechProcess = (Disk3DTechProcess)TechProcess;

            var offsetSurface = CreateOffsetSurface();

            var matrix = Matrix3d.Rotation(disk3DTechProcess.Angle.ToRad(), Vector3d.ZAxis, Point3d.Origin);

            if (disk3DTechProcess.Angle != 0)
            {
                offsetSurface.TransformBy(matrix);
            }
            var bounds = offsetSurface.GeometricExtents;

            generator.ZSafety             = bounds.MinPoint.Z + TechProcess.Thickness.Value + TechProcess.ZSafety;
            generator.ToolLocation.Point += Vector3d.ZAxis * generator.ZSafety;


            //var ray = new Ray { UnitDir = Vector3d.XAxis };
            //var y = StartPass;
            //do
            //{
            //    ray.BasePoint = new Point3d(0, y, 0);

            //    var curves = s.ProjectOnToSurface(point, Vector3d.ZAxis);
            //    curves[0].ColorIndex = 2;
            //    curves[0].AddToCurrentSpace();
            //    y += StepPass;
            //}
            //while (y < boundsModel.MaxPoint.Y);

            //var startTime = System.Diagnostics.Stopwatch.StartNew();
            //var point = new DBPoint();
            //int cnt = 0;
            //for (var y = boundsModel.MinPoint.Y + StartPass; y < boundsModel.MaxPoint.Y; y += StepPass)
            //{
            //    for (var x = boundsModel.MinPoint.X; x < boundsModel.MaxPoint.X; x += StepLong)
            //    {
            //        for (var s = 0; s <= 2; s += 4)
            //        {
            //            point.Position = new Point3d(x, y + s, 0);

            //            //line.StartPoint = new Point3d(x, y, 0);
            //            //line.EndPoint = new Point3d(x, y + 8, 0);

            //            try
            //            {
            //                var curves = offsetSurfaces.ProjectOnToSurface(point, Vector3d.ZAxis);
            //                cnt++;
            //                if (curves.Length == 0)
            //                    Acad.Write("111");
            //                curves[0].ColorIndex = 6;
            //                curves[0].AddToCurrentSpace();
            //            }
            //            catch
            //            {
            //            }
            //        }
            //    }
            //}
            //startTime.Stop();
            //var resultTime = startTime.Elapsed;
            //Acad.Write("timer=" + resultTime);
            //Acad.Write("cnt=" + cnt);


            //var startTime = System.Diagnostics.Stopwatch.StartNew();
            //var line = new Line();
            //int cnt = 0;
            //int err = 0;
            //for (var y = boundsModel.MinPoint.Y + StartPass; y < boundsModel.MaxPoint.Y; y += StepPass)
            //{
            //    for (var x = boundsModel.MinPoint.X; x < boundsModel.MaxPoint.X; x += StepLong)
            //    {
            //        for (var s = 0; s <= 2; s += 4)
            //        {
            //            line.StartPoint = new Point3d(x, y, 0);
            //            line.EndPoint = new Point3d(x, y + 8, 0);

            //            try
            //            {
            //                var curves = offsetSurfaces.ProjectOnToSurface(line, Vector3d.ZAxis);
            //                cnt++;
            //                if (curves.Length == 0)
            //                    Acad.Write("111");
            //                curves[0].ColorIndex = 6;
            //                curves[0].AddToCurrentSpace();
            //            }
            //            catch (Exception ex)
            //            {
            //                err++;
            //            }
            //        }
            //    }
            //}
            //startTime.Stop();
            //var resultTime = startTime.Elapsed;
            //Acad.Write("timer=" + resultTime);
            //Acad.Write("cnt=" + cnt);

            //var contour = NoDraw.Rectang(new Point3d(bounds.MinPoint.X, bounds.MinPoint.Y, 0), new Point3d(bounds.MaxPoint.X, bounds.MaxPoint.Y, 0));
            //var ray = new Ray
            //{
            //    BasePoint = contour.StartPoint,
            //    UnitDir = Vector3d.XAxis.RotateBy(((Disk3DTechProcess)TechProcess).Angle.ToRad(), Vector3d.ZAxis)
            //};
            //ray.BasePoint += ray.UnitDir.GetPerpendicularVector() * StartPass;
            //var crossVector = ray.UnitDir.GetPerpendicularVector() * StepPass;
            //var plane = new Plane();
            //while (true)
            //{
            //    var pc = new Point3dCollection();
            //    ray.IntersectWith(contour, Intersect.ExtendThis, plane, pc, IntPtr.Zero, IntPtr.Zero);
            //    if (pc.Count != 2)
            //        break;

            //        var vector = (points[1] - points[0]).GetNormal() * tactileTechProcess.TactileTechProcessParams.Departure;
            //        var startPoint = points[0] + passDir * s - vector - Vector3d.ZAxis * Depth;
            //        var endPoint = points[1] + passDir * s + vector - Vector3d.ZAxis * Depth;
            //        if (generator.IsUpperTool)
            //            generator.Move(startPoint.X, startPoint.Y, angleC: BuilderUtils.CalcToolAngle(ProcessingAngle.ToRad()));
            //        generator.Cutting(startPoint, endPoint, feed, tactileTechProcess.TactileTechProcessParams.TransitionFeed);

            //    ray.BasePoint += crossVector;
            //}

            var startY = bounds.MinPoint.Y + StartPass;
            var endY   = bounds.MaxPoint.Y - (disk3DTechProcess.IsExactlyEnd ? TechProcess.Tool.Thickness : 0);

            Acad.SetLimitProgressor((int)((endY - startY) / StepPass));
            var PassList = new List <List <Point3d> >();

            for (var y = startY; y < endY; y += StepPass)
            {
                Acad.ReportProgressor();
                var points = new Point3dCollection();
                for (var x = bounds.MinPoint.X; x <= bounds.MaxPoint.X; x += StepLong)
                {
                    double z = 0;
                    for (var s = 0; s <= TechProcess.Tool.Thickness; s += 1)
                    {
                        if (y + s > bounds.MaxPoint.Y)
                        {
                            break;
                        }
                        offsetSurface.RayTest(new Point3d(x, y + s, bounds.MinPoint.Z), Vector3d.ZAxis, 0.0001, out SubentityId[] col, out DoubleCollection par);
                        if (par.Count == 0)
                        {
                            z = 0;
                            break;
                        }
                        z = par[par.Count - 1] > z ? par[par.Count - 1] : z;
                    }
                    if (z > 0)
                    {
                        var point = new Point3d(x, y, bounds.MinPoint.Z + z);
                        var ind   = points.Count - 1;
                        if (ind > 0 && points[ind - 1].GetVectorTo(points[ind]).IsCodirectionalTo(points[ind].GetVectorTo(point)))
                        {
                            points[ind] = point;
                        }
                        else
                        {
                            points.Add(point);
                        }
                    }
                }
                if (points.Count > 1)
                {
                    PassList.Add(CalcOffsetPoints(points, bounds));
                }
            }
            offsetSurface.Dispose();

            matrix = matrix.Inverse();
            PassList.ForEach(p =>
            {
                var points = p;
                if (TechProcess.MachineType == MachineType.ScemaLogic) //Settongs.IsFrontPlaneZero
                {
                    points = points.ConvertAll(x => new Point3d(x.X, x.Y + TechProcess.Tool.Thickness.Value, x.Z));
                }
                if (disk3DTechProcess.Angle != 0)
                {
                    points = points.ConvertAll(x => x.TransformBy(matrix));
                }
                var loc = generator.ToolLocation;
                if (loc.IsDefined && loc.Point.DistanceTo(points.First()) > loc.Point.DistanceTo(points.Last()))
                {
                    points.Reverse();
                }

                BuildPass(generator, points);
            });
            //progressor.Stop();
        }
Example #6
0
        public override void BuildProcessing(MillingCommandGenerator generator)
        {
            var disk3DTechProcess = (Disk3DTechProcess)TechProcess;

            var offsetSurface = CreateOffsetSurface();

            //generator.ZSafety = offsetSurface.GeometricExtents.MinPoint.Z + TechProcess.Thickness.Value + TechProcess.ZSafety;
            //generator.ToolPosition.Point += Vector3d.ZAxis * generator.ZSafety;
            //generator.ToolLocation.Set(new Point3d(double.NaN, double.NaN, generator.ZSafety), 0, TechProcess.IsA90 ? 90 : 0);

            generator.SetZSafety(TechProcess.ZSafety, offsetSurface.GeometricExtents.MinPoint.Z + TechProcess.Thickness.Value);

            Matrix3d?matrix = null;

            if (TechProcess.IsA90)
            {
                matrix = Matrix3d.Rotation(-Math.PI / 2, Vector3d.XAxis, Point3d.Origin);
            }
            if (TechProcess.Angle != 0)
            {
                var m = Matrix3d.Rotation(disk3DTechProcess.Angle.ToRad(), Vector3d.ZAxis, Point3d.Origin);
                matrix = matrix.HasValue ? matrix.Value * m : m;
            }
            if (matrix.HasValue)
            {
                offsetSurface.TransformBy(matrix.Value);
            }
            var bounds = offsetSurface.GeometricExtents;

            //generator.ZSafety = bounds.MinPoint.Z + TechProcess.Thickness.Value + TechProcess.ZSafety;
            //generator.ToolLocation.Point += Vector3d.ZAxis * generator.ZSafety;

            //var ray = new Ray { UnitDir = Vector3d.XAxis };
            //var y = StartPass;
            //do
            //{
            //    ray.BasePoint = new Point3d(0, y, 0);

            //    var curves = s.ProjectOnToSurface(point, Vector3d.ZAxis);
            //    curves[0].ColorIndex = 2;
            //    curves[0].AddToCurrentSpace();
            //    y += StepPass;
            //}
            //while (y < boundsModel.MaxPoint.Y);

            //var startTime = System.Diagnostics.Stopwatch.StartNew();
            //var point = new DBPoint();
            //int cnt = 0;
            //for (var y = boundsModel.MinPoint.Y + StartPass; y < boundsModel.MaxPoint.Y; y += StepPass)
            //{
            //    for (var x = boundsModel.MinPoint.X; x < boundsModel.MaxPoint.X; x += StepLong)
            //    {
            //        for (var s = 0; s <= 2; s += 4)
            //        {
            //            point.Position = new Point3d(x, y + s, 0);

            //            //line.StartPoint = new Point3d(x, y, 0);
            //            //line.EndPoint = new Point3d(x, y + 8, 0);

            //            try
            //            {
            //                var curves = offsetSurfaces.ProjectOnToSurface(point, Vector3d.ZAxis);
            //                cnt++;
            //                if (curves.Length == 0)
            //                    Acad.Write("111");
            //                curves[0].ColorIndex = 6;
            //                curves[0].AddToCurrentSpace();
            //            }
            //            catch
            //            {
            //            }
            //        }
            //    }
            //}
            //startTime.Stop();
            //var resultTime = startTime.Elapsed;
            //Acad.Write("timer=" + resultTime);
            //Acad.Write("cnt=" + cnt);


            //var startTime = System.Diagnostics.Stopwatch.StartNew();
            //var line = new Line();
            //int cnt = 0;
            //int err = 0;
            //for (var y = boundsModel.MinPoint.Y + StartPass; y < boundsModel.MaxPoint.Y; y += StepPass)
            //{
            //    for (var x = boundsModel.MinPoint.X; x < boundsModel.MaxPoint.X; x += StepLong)
            //    {
            //        for (var s = 0; s <= 2; s += 4)
            //        {
            //            line.StartPoint = new Point3d(x, y, 0);
            //            line.EndPoint = new Point3d(x, y + 8, 0);

            //            try
            //            {
            //                var curves = offsetSurfaces.ProjectOnToSurface(line, Vector3d.ZAxis);
            //                cnt++;
            //                if (curves.Length == 0)
            //                    Acad.Write("111");
            //                curves[0].ColorIndex = 6;
            //                curves[0].AddToCurrentSpace();
            //            }
            //            catch (Exception ex)
            //            {
            //                err++;
            //            }
            //        }
            //    }
            //}
            //startTime.Stop();
            //var resultTime = startTime.Elapsed;
            //Acad.Write("timer=" + resultTime);
            //Acad.Write("cnt=" + cnt);

            //var contour = NoDraw.Rectang(new Point3d(bounds.MinPoint.X, bounds.MinPoint.Y, 0), new Point3d(bounds.MaxPoint.X, bounds.MaxPoint.Y, 0));
            //var ray = new Ray
            //{
            //    BasePoint = contour.StartPoint,
            //    UnitDir = Vector3d.XAxis.RotateBy(((Disk3DTechProcess)TechProcess).Angle.ToRad(), Vector3d.ZAxis)
            //};
            //ray.BasePoint += ray.UnitDir.GetPerpendicularVector() * StartPass;
            //var crossVector = ray.UnitDir.GetPerpendicularVector() * StepPass;
            //var plane = new Plane();
            //while (true)
            //{
            //    var pc = new Point3dCollection();
            //    ray.IntersectWith(contour, Intersect.ExtendThis, plane, pc, IntPtr.Zero, IntPtr.Zero);
            //    if (pc.Count != 2)
            //        break;

            //        var vector = (points[1] - points[0]).GetNormal() * tactileTechProcess.TactileTechProcessParams.Departure;
            //        var startPoint = points[0] + passDir * s - vector - Vector3d.ZAxis * Depth;
            //        var endPoint = points[1] + passDir * s + vector - Vector3d.ZAxis * Depth;
            //        if (generator.IsUpperTool)
            //            generator.Move(startPoint.X, startPoint.Y, angleC: BuilderUtils.CalcToolAngle(ProcessingAngle.ToRad()));
            //        generator.Cutting(startPoint, endPoint, feed, tactileTechProcess.TactileTechProcessParams.TransitionFeed);

            //    ray.BasePoint += crossVector;
            //}

            var startY = StartPass == 0 ? bounds.MinPoint.Y : StartPass;
            var endY   = (EndPass == 0 ? bounds.MaxPoint.Y : EndPass) - (disk3DTechProcess.IsExactlyEnd ? TechProcess.Tool.Thickness : 0);

            //double startY, endY;
            //if (!TechProcess.IsA90)
            //{
            //    startY = bounds.MinPoint.Y + StartPass;
            //    var endY = EndPass != 0 ? bounds.MinPoint.Y + EndPass : bounds.MaxPoint.Y;
            //}
            //if (startY < endY)
            //{
            //    if (disk3DTechProcess.IsExactlyEnd)
            //        endY -= TechProcess.Tool.Thickness.Value;
            //}
            //else
            //{
            //    startY -= TechProcess.Tool.Thickness.Value;
            //    if (!disk3DTechProcess.IsExactlyEnd)
            //        endY -= TechProcess.Tool.Thickness.Value;
            //    StepPass *= -1;
            //}

            //var count = bounds.MaxPoint.Y - (disk3DTechProcess.IsExactlyEnd ? TechProcess.Tool.Thickness : 0);
            //Acad.SetLimitProgressor((int)((endY - startY) / StepPass));
            //var PassList = new List<List<Point3d>>();
            //for (var y = startY; StepPass > 0 ? y < endY : y > endY; y += StepPass)



            // расчет точек начала и конца поверхности

            //var boundCurves = new List<Curve>();
            //var entitySet = new DBObjectCollection();
            //offsetSurface.Explode(entitySet);
            //for (int i = 0; i < entitySet.Count; i++)
            //{
            //    if (entitySet[i] is DbSurface)
            //    {
            //        var subEntitySet = new DBObjectCollection();
            //        ((Entity)entitySet[i]).Explode(subEntitySet);
            //        boundCurves.AddRange(subEntitySet.Cast<Curve>());
            //    }
            //    else
            //    {
            //        boundCurves.Add(entitySet[i] as Curve);
            //    }
            //}

            //var boundCurves2d = new List<Curve>();
            //var plene = new Plane(Point3d.Origin, Vector3d.ZAxis);
            //foreach (var curve in boundCurves)
            //{
            //    if (curve != null)
            //    {
            //        boundCurves2d.Add(curve.ToCurve2dArray GetOrthoProjectedCurve(plene));
            //    }
            //}

            Acad.SetLimitProgressor((int)((endY - startY) / StepPass));
            var PassList = new List <List <Point3d> >();

            for (var y = startY; y < endY; y += StepPass)
            {
                Acad.ReportProgressor();
                var points = new Point3dCollection();

                //var pass = new Line2d(new Point2d(bounds.MinPoint.X, y), new Point2d(bounds.MinPoint.X, y));
                //foreach (var cv in boundCurves2d)
                //{
                //    pass.IntersectWith(cv.to);
                //}

                for (var x = bounds.MinPoint.X; x <= bounds.MaxPoint.X; x += StepLong)
                {
                    double z = 0;
                    for (double s = 0; s <= TechProcess.Tool.Thickness; s += TechProcess.Tool.Thickness.Value)
                    {
                        if (y + s > bounds.MaxPoint.Y)
                        {
                            break;
                        }
                        offsetSurface.RayTest(new Point3d(x, y + s, bounds.MinPoint.Z), Vector3d.ZAxis, 0.0001, out SubentityId[] col, out DoubleCollection par);
                        //if (par.Count == 0)
                        //{
                        //    z = 0;
                        //    break;
                        //}
                        if (par.Count > 0)
                        {
                            z = par[par.Count - 1] > z ? par[par.Count - 1] : z;
                        }
                    }
                    if (z > 0)
                    {
                        var point = new Point3d(x, y, bounds.MinPoint.Z + z);
                        var ind   = points.Count - 1;
                        if (ind > 0 && points[ind - 1].GetVectorTo(points[ind]).IsCodirectionalTo(points[ind].GetVectorTo(point)))
                        {
                            points[ind] = point;
                        }
                        else
                        {
                            points.Add(point);
                        }
                        //Draw.Point(point);
                    }
                }
                if (points.Count > 1)
                {
                    PassList.Add(CalcOffsetPoints(points, bounds));
                }
            }
            offsetSurface.Dispose();


            if (matrix.HasValue)
            {
                matrix = matrix.Value.Inverse();
            }
            if (TechProcess.IsA90 && PassList.First()[0].TransformBy(matrix.Value).Z < PassList.Last()[0].TransformBy(matrix.Value).Z)
            {
                PassList.Reverse();
            }
            if (IsReverse)
            {
                PassList.Reverse();
            }

            if (TechProcess.IsA90)
            {
                generator.Matrix = matrix;
            }

            Point3d?lastPoint = null;

            PassList.ForEach(p =>
            {
                var points = p;
                if (TechProcess.MachineType == MachineType.ScemaLogic) //Settongs.IsFrontPlaneZero
                {
                    points = points.ConvertAll(x => new Point3d(x.X, x.Y + TechProcess.Tool.Thickness.Value, x.Z));
                }
                if (matrix.HasValue && !TechProcess.IsA90)
                {
                    points = points.ConvertAll(x => x.TransformBy(matrix.Value));
                }
                var loc = generator.ToolPosition;
                if (lastPoint.HasValue && lastPoint.Value.DistanceTo(points.First()) > lastPoint.Value.DistanceTo(points.Last()))
                {
                    points.Reverse();
                }

                if (TechProcess.IsA90)
                {
                    lastPoint = BuildPassA90(generator, points, matrix.Value, bounds.MinPoint.Z + PenetrationAll);
                }
                else
                {
                    lastPoint = BuildPass(generator, points);
                }
            });
            if (TechProcess.IsA90)
            {
                generator.Move(lastPoint.Value.Add(Vector3d.ZAxis * 100));
            }

            if (generator is DonatoniCommandGenerator donatoniCommandGenerator)
            {
                donatoniCommandGenerator.IsSupressMoveHome = true;
            }
            //progressor.Stop();
        }