Esempio n. 1
0
        private DbSurface CreateOffsetSurface()
        {
            DbSurface unionSurface = null;

            foreach (var dBObject in TechProcess.ProcessingArea.Select(p => p.ObjectId.QOpenForRead()))
            {
                DbSurface surface;
                switch (dBObject)
                {
                case DbSurface sf:
                    surface = sf.Clone() as DbSurface;
                    break;

                case Region region:
                    surface = new PlaneSurface();
                    ((PlaneSurface)surface).CreateFromRegion(region);
                    break;

                default:
                    throw new Exception(ErrorStatus.NotImplementedYet, $"Объект типа {dBObject.GetType()} не может быть обработан (1)");
                }
                if (unionSurface == null)
                {
                    unionSurface = surface;
                }
                else
                {
                    var res = unionSurface.BooleanUnion(surface);
                    if (res != null)
                    {
                        unionSurface.Dispose();
                        unionSurface = res;
                    }
                    surface.Dispose();
                }
            }
            if (Delta == 0)
            {
                return(unionSurface);
            }

            try
            {
                var offsetSurface = DbSurface.CreateOffsetSurface(unionSurface, Delta) as DbSurface;
                unionSurface.Dispose();
                return(offsetSurface);
            }
            catch
            {
                unionSurface.TransformBy(Matrix3d.Displacement(Vector3d.ZAxis * Delta));
                return(unionSurface);
            }
        }
Esempio n. 2
0
        private DbSurface CreateOffsetSurface()
        {
            DbSurface unionSurface = null;

            foreach (var dBObject in TechProcess.ProcessingArea.Select(p => p.ObjectId.QOpenForRead()))
            {
                DbSurface surface;
                switch (dBObject)
                {
                case DbSurface sf:
                    surface = sf.Clone() as DbSurface;
                    break;

                case Region region:
                    surface = new PlaneSurface();
                    ((PlaneSurface)surface).CreateFromRegion(region);
                    break;

                default:
                    throw new Exception($"Объект типа {dBObject.GetType()} не может быть обработан (1)");
                }
                if (unionSurface == null)
                {
                    unionSurface = surface;
                }
                else
                {
                    var res = unionSurface.BooleanUnion(surface);
                    if (res != null)
                    {
                        unionSurface.Dispose();
                        unionSurface = res;
                    }
                    surface.Dispose();
                }
            }
            var offsetSurface = DbSurface.CreateOffsetSurface(unionSurface, Delta) as DbSurface;

            unionSurface.Dispose();
            return(offsetSurface);
        }