示例#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);
        }
示例#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;
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="toolSolid"></param>
        /// <returns></returns>
        public DSSurface[] Difference(DSSolid toolSolid)
        {
            string kMethod = "DSSurface.Difference";
            if (null == toolSolid)
                throw new System.ArgumentNullException("toolSolid");

            IGeometryEntity[] geoms = SurfaceEntity.SubtractFrom(toolSolid.SolidEntity);
            if (null == geoms)
                throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethod));

            return geoms.ConvertAll(
                (IGeometryEntity g) =>
                {
                    ISurfaceEntity s = g as ISurfaceEntity;
                    if (null == s)
                        return null;
                    return s.ToSurf(true, this);
                });
        }
示例#4
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);
        }
示例#5
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;
        }
示例#6
0
        /// <summary>
        /// Constructs a point by projecting a point on solid with given 
        /// project direction.
        /// </summary>
        /// <param name="contextSolid">The solid on which the projection is to be made.</param>
        /// <param name="direction">The direction vector of the projection</param>
        /// <returns>Projected point on solid</returns>
        public DSPoint Project(DSSolid contextSolid, DSVector direction)
        {
            if (null == contextSolid)
                throw new ArgumentNullException("contextSurface");
            if (null == direction || direction.IsZeroVector())
                throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, direction, "Project on surface"), "direction");

            DSPoint pt = ProjectOnGeometry(contextSolid, direction);
            pt.Context = contextSolid;
            pt.Direction = direction;
            pt.ReferencePoint = this;

            return pt;
        }
示例#7
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);
 }
示例#8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="solids"></param>
 /// <param name="selectPoint"></param>
 /// <returns></returns>
 public DSSolid Trim(DSSolid[] solids, DSPoint selectPoint)
 {
     return Trim(null, null, solids, selectPoint);
 }
示例#9
0
 /// <summary>
 /// Returns a solid by uniting one solid with another solid
 /// </summary>
 /// <param name="otherSolid">The other solid </param>
 /// <returns>Returns a Solid</returns>
 public DSSolid Union(DSSolid otherSolid)
 {
     return Union(otherSolid, true);
 }
示例#10
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);
        }
示例#11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="solid"></param>
 /// <param name="selectPoint"></param>
 /// <returns></returns>
 public DSSolid Trim(DSSolid solid, DSPoint selectPoint)
 {
     DSSolid[] solids = { solid };
     return Trim(null, null, solids, selectPoint);
 }
示例#12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="otherSolid"></param>
        /// <returns></returns>
        public DSSolid Intersect(DSSolid otherSolid)
        {
            if (otherSolid == null)
                throw new ArgumentNullException("otherSolid");

            IGeometryEntity[] solids = SolidEntity.IntersectWith(otherSolid.SolidEntity);
            if (solids == null || solids.Length == 0 || solids[0] == null)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Impose"));

            ISolidEntity host = solids[0] as ISolidEntity;
            return host.ToSolid(true, this);
        }
示例#13
0
        /// <summary>
        /// Returns a non-manifold solid by imposing the input regular solid onto 
        /// the given solid
        /// </summary>
        /// <param name="otherSolid">The other solid</param>
        /// <returns>Returns a Non-manifold Solid</returns>
        public DSNonManifoldSolid Impose(DSSolid otherSolid)
        {
            if (otherSolid == null)
                throw new ArgumentNullException("otherSolid");

            ISolidEntity host = SolidEntity.NonRegularImpose(otherSolid.SolidEntity);
            if (host == null)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Impose"));
            return host.ToSolid(true, this) as DSNonManifoldSolid;
        }
示例#14
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);
 }
示例#15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="solids"></param>
        /// <param name="selectPoint"></param>
        /// <param name="autoExtend"></param>
        /// <returns></returns>
        public DSSurface Trim(DSSolid[] solids, DSPoint selectPoint, bool autoExtend)
        {
            if(null == solids)
                throw new System.ArgumentNullException("solids");

            return Trim(null, null, null, solids, selectPoint, autoExtend);
        }
示例#16
0
        /// <summary>
        /// Returns a solid by doing a non-regular union (if 'isRegular' is set 
        /// to false) of two solids (manifold or non-manifold)
        /// </summary>
        /// <param name="otherSolid">The other solid</param>
        /// <param name="isRegular">Switch for Regular or Non-regular Union</param>
        /// <returns>Solid</returns>
        public DSSolid Union(DSSolid otherSolid, bool isRegular)
        {
            if (otherSolid == null)
                return this;
            IGeometryEntity[] solids = null;
            if (isRegular)
                solids = SolidEntity.UnionWith(otherSolid.SolidEntity);
            else
                solids = SolidEntity.NonRegularUnionWith(otherSolid.SolidEntity);

            if (null == solids || solids.Length == 0)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));

            ISolidEntity solidhost = solids[0] as ISolidEntity;
            if (solidhost == null)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.Union"));

            return solidhost.ToSolid(true, this);
        }
示例#17
0
 internal override IGeometryEntity[] IntersectWithSolid(DSSolid solid)
 {
     return solid.SolidEntity.IntersectWith(SurfaceEntity);
 }
示例#18
0
        /// <summary>
        /// Constructs a point by projecting a point on solid. It is equivalent 
        /// to finding the nearest point on the solid
        /// </summary>
        /// <param name="contextSolid">The solid on which the projection is to be made.</param>
        /// <returns>Projected point on solid</returns>
        public DSPoint Project(DSSolid contextSolid)
        {
            if (null == contextSolid)
                throw new ArgumentNullException("contextSolid");

            DSPoint pt = ProjectOnGeometry(contextSolid, null);
            if (null == pt)
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "Project on surface"));

            pt.Context = contextSolid;
            pt.ReferencePoint = this;
            return pt;
        }