Beispiel #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="curves"></param>
        /// <param name="planes"></param>
        /// <param name="surfaces"></param>
        /// <param name="solids"></param>
        /// <param name="selectPoint"></param>
        /// <param name="autoExtend"></param>
        /// <returns></returns>
        public DSSurface Trim(DSCurve[] curves, DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint, bool autoExtend)
        {
            if (null == selectPoint)
                throw new System.ArgumentNullException("selectPoint");

            ICurveEntity[] hostCurves = curves.ConvertAll(DSGeometryExtension.ToEntity<DSCurve, ICurveEntity>);
            IPlaneEntity[] hostPlanes = planes.ConvertAll(DSGeometryExtension.ToEntity<DSPlane, IPlaneEntity>);
            ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity<DSSurface, ISurfaceEntity>);
            ISolidEntity[] hostSolids = solids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);

            IPointEntity hostPoint = selectPoint.PointEntity;

            if (hostCurves == null && hostPlanes == null && hostSurfaces == null && hostSolids == null)
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "DSGeometry", "DSSurface.Trim"));

            ISurfaceEntity trimSurface = SurfaceEntity.Trim(hostCurves, hostPlanes, hostSurfaces, hostSolids, hostPoint, autoExtend);

            //For trim operation, if the return value is not null, hide the original tools and surfaces.
            if (null != trimSurface)
            {
                Hide(curves);
                Hide(planes);
                Hide(surfaces);
                Hide(solids);
                SetVisibility(false);
            }

            return trimSurface.ToSurf(true, this);
        }
Beispiel #2
0
        public static DSSurface[] SelectTrim(DSSurface[] surfaces, DSSolid[] trimmingSolids, bool keepInside)
        {
            string kMethodName = "DSSurface.SelectTrim";
            ISurfaceEntity[] surfacehosts = surfaces.ConvertAll(DSGeometryExtension.ToEntity<DSSurface, ISurfaceEntity>);
            if (surfacehosts == null || surfacehosts.Length == 0)
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "surfaces", kMethodName), "surfaces");

            ISolidEntity[] solidhosts = trimmingSolids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);
            if (null == solidhosts || solidhosts.Length == 0)
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "trimmingSolids", kMethodName), "trimmingSolids");

            DSSurface[] result = null;
            if (solidhosts.Length == 1)
            {
                result = SelectTrimCore(surfacehosts, solidhosts[0], keepInside);
            }
            else
            {
                DSSolid unionSolid = DSSolid.UnionCore(solidhosts[0], solidhosts, false);
                if (null == unionSolid)
                    throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));

                result = SelectTrimCore(surfacehosts, unionSolid.SolidEntity, keepInside);
            }

            if (null != result)
            {
                Hide(surfaces);
                Hide(trimmingSolids);
            }

            return result;
        }
Beispiel #3
0
        // TODO: To be fixed - pratapa
        /// <summary>
        /// 
        /// </summary>
        /// <param name="planes"></param>
        /// <param name="surfaces"></param>
        /// <param name="solids"></param>
        /// <param name="selectPoint"></param>
        /// <returns></returns>
        public DSSolid Trim(DSPlane[] planes, DSSurface[] surfaces, DSSolid[] solids, DSPoint selectPoint)
        {
            IPlaneEntity[] hostPlanes = planes.ConvertAll(DSGeometryExtension.ToEntity<DSPlane, IPlaneEntity>);
            ISurfaceEntity[] hostSurfaces = surfaces.ConvertAll(DSGeometryExtension.ToEntity<DSSurface, ISurfaceEntity>);
            ISolidEntity[] hostSolids = solids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);
            if (selectPoint == null)
                throw new System.ArgumentNullException("selectPoint");
            IPointEntity hostPoint = selectPoint.PointEntity;
            if (hostPlanes == null && hostSurfaces == null && hostSolids == null)
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "DSGeometry", "DSSolid.Trim"));

            ISolidEntity trimSolid = SolidEntity.Trim(hostPlanes, hostSurfaces, hostSolids, hostPoint);
            if (null == trimSolid)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Trim"));

            Hide(planes);
            Hide(surfaces);
            Hide(solids);
            SetVisibility(false);

            return new DSSolid(trimSolid, true);
        }
Beispiel #4
0
        public static DSSurface[] SelectTrim(DSSurface[] surfaces, DSSolid trimmingSolid, bool keepInside)
        {
            string kMethodName = "DSSurface.SelectTrim";

            if (null == trimmingSolid)
                throw new System.ArgumentNullException("trimmingSolid");

            ISurfaceEntity[] surfacehosts = surfaces.ConvertAll(DSGeometryExtension.ToEntity<DSSurface, ISurfaceEntity>);
            if (surfacehosts == null || surfacehosts.Length == 0)
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "surfaces", kMethodName), "surfaces");

            ISolidEntity trimmingEntity = trimmingSolid.SolidEntity;
            DSSurface[] result = SelectTrimCore(surfacehosts, trimmingEntity, keepInside);
            if (null != result)
            {
                Hide(surfaces);
                Hide(trimmingSolid);
            }

            return result;
        }
Beispiel #5
0
 public DSSolid[] Slice(DSSurface[] surfaces, bool isRegular)
 {
     ISurfaceEntity[] surfaceHosts = surfaces.ConvertAll(DSGeometryExtension.ToEntity<DSSurface, ISurfaceEntity>);
     if (null == surfaceHosts || surfaceHosts.Length == 0)
         throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "surfaces", "DSSolid.Slice"), "surfaces");
     IGeometryEntity[] solids = null;
     if (isRegular)
         solids = SolidEntity.SliceWithSurfaces(surfaceHosts);
     else
         solids = new[] { SolidEntity.NonRegularSliceWithSurfaces(surfaceHosts) };
     if (solids == null || solids.Length == 0)
         throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Slice"));
     return solids.ToArray<DSSolid, IGeometryEntity>(true);
 }