Example #1
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;
        }
Example #2
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);
        }
Example #3
0
        /// <summary>
        /// Returns a solid by doing a non-regular unite (if 'isRegular' is set
        /// to false) of one solid with an array of solids (any combination of 
        /// manifold or non-manifold)
        /// </summary>
        /// <param name="otherSolids">An array of solids</param>
        /// <param name="isRegular">Switch for Regular or Non-regular Union</param>
        /// <returns>Returns a solid</returns>
        public DSSolid Union(DSSolid[] otherSolids, bool isRegular)
        {
            ISolidEntity[] othersolidhosts = otherSolids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);
            if (null == othersolidhosts || (othersolidhosts.Length == 0))
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "otherSolids", "DSSolid.Union"), "otherSolids");

            if (isRegular)
                return UnionCore(SolidEntity, othersolidhosts, true);

            ISolidEntity host = SolidEntity.NonRegularUnionWithMany(othersolidhosts);
            if (host == null)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));
            return host.ToSolid(true, this);
        }
Example #4
0
 /// <summary>
 /// Returns a solid by uniting one solid with an array of solids (any combination of manifold or non-manifold)
 /// </summary>
 /// <param name="otherSolids">An array of solids</param>
 /// <returns>Returns a Solid</returns>
 public DSSolid Union(DSSolid[] otherSolids)
 {
     ISolidEntity[] othersolidhosts = otherSolids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);
     if (null == othersolidhosts || (othersolidhosts.Length == 0))
         throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "otherSolids", "DSSolid.Union"), "otherSolids");
     return UnionCore(SolidEntity, othersolidhosts, true);
 }
Example #5
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);
        }
Example #6
0
 /// <summary>
 /// Returns a solid by uniting an array of solids (manifold or non-manifold)
 /// </summary>
 /// <param name="solids">The input array of solids</param>
 /// <returns>Returns a Solid</returns>
 public static DSSolid UnionAll(DSSolid[] solids)
 {
     ISolidEntity[] solidhosts = solids.ConvertAll(DSGeometryExtension.ToEntity<DSSolid, ISolidEntity>);
     if (null == solidhosts || (solidhosts.Length < 2))
         throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "solids", "DSSolid.UnionAll"), "solids");
     return UnionCore(solidhosts[0], solidhosts, true);
 }
Example #7
0
        public static DSSolid[] SelectTrim(DSSolid[] solids, DSSolid trimmingSolid, bool keepInside)
        {
            string kMethodName = "DSSolid.SelectTrim";

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

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

            ISolidEntity trimmingEntity = trimmingSolid.SolidEntity;
            DSSolid[] result = SelectTrimCore(solidhosts, trimmingEntity, keepInside);
            if (null != result)
            {
                Hide(solids);
                Hide(trimmingSolid);
            }
            return result;
        }