/// <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); }
private DSSolid[] SliceWithPlanes(DSPlane[] planes, bool isRegular) { IPlaneEntity[] planeHosts = planes.ConvertAll(DSGeometryExtension.ToEntity<DSPlane, IPlaneEntity>); if (null == planeHosts || planeHosts.Length == 0) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "planes", "DSSolid.SliceWithPlanes"), "planes"); IGeometryEntity[] solids = null; if (isRegular) solids = SolidEntity.SliceWithPlanes(planeHosts); else solids = new IGeometryEntity[] { SolidEntity.NonRegularSliceWithPlanes(planeHosts) }; if (solids == null || solids.Length == 0) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSolid.SliceWithPlanes")); return solids.ToArray<DSSolid, IGeometryEntity>(true); }
// 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); }
/// <summary> /// Returns trimmed polygon after trimming this polygon using the /// given array of planes as half spaces. /// </summary> /// <param name="halfSpaces">Trimming planes.</param> /// <returns>Trimmed Polygon</returns> public DSPolygon Trim(DSPlane[] halfSpaces) { IPlaneEntity[] hosts = halfSpaces.ConvertAll(DSGeometryExtension.ToEntity<DSPlane, IPlaneEntity>); IPolygonEntity entity = PolygonEntity.Trim(hosts); if (null == entity) return null; Hide(this); Hide(halfSpaces); return new DSPolygon(entity, true); }