protected DSSolid(DSCurve profile, DSCurve path, bool persist) : base(SweepCore(profile, path), persist) { InitializeGuaranteedProperties(); Path = path; Profile = profile; }
protected DSSolid(DSCurve[] crossSections, DSCurve[] guides, bool persist) : base(LoftFromCrossSectionsGuidesCore(crossSections, guides), persist) { InitializeGuaranteedProperties(); CrossSections = crossSections; Guides = guides; }
protected DSSolid(DSCurve[] crossSections, DSCurve path, bool persist) : base(LoftFromCrossSectionsPathCore(crossSections, path), persist) { InitializeGuaranteedProperties(); CrossSections = crossSections; Path = path; }
protected DSSweptSurface(DSCurve profile, DSCurve path,bool persist) : base(ByProfilePathCore(profile, path),persist) { InitializeGuaranteedProperties(); Profile = profile; Path = path; }
protected DSSolid(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle, bool persist) : base(RevolveCore(profile, axisOrigin, axisDirection, startAngle, sweepAngle), persist) { InitializeGuaranteedProperties(); Profile = profile; AxisOrigin = axisOrigin; AxisDirection = axisDirection; StartAngle = startAngle; SweepAngle = sweepAngle; }
protected DSRevolvedSurface(DSCurve profile, DSLine axis, double startAngle, double sweepAngle, bool persist) : base(ByProfileAxisAngleCore(profile, axis, startAngle, sweepAngle), persist) { InitializeGuaranteedProperties(); Profile = profile; AxisOrigin = axis.StartPoint; AxisDirection = axis.Direction; StartAngle = startAngle; SweepAngle = sweepAngle; Axis = axis; }
private static ISurfaceEntity FromCurveCore(DSCurve profile) { if (null == profile) throw new System.ArgumentNullException("profile"); if (!profile.IsClosed || profile.IsSelfIntersecting) throw new System.ArgumentException(string.Format(Properties.Resources.CurveNotClosed), "profile"); ISurfaceEntity entity = HostFactory.Factory.SurfacePatchFromCurve(profile.CurveEntity); if (entity == null) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.CreateFromCurve")); return entity; }
private static ISurfaceEntity ByProfilePathCore(DSCurve profile, DSCurve path) { if (null == profile) throw new System.ArgumentNullException("profile"); if (null == path) throw new System.ArgumentNullException("path"); ISurfaceEntity entity = HostFactory.Factory.SurfaceBySweep(profile.CurveEntity, path.CurveEntity); if (entity == null) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSweptSurface.ByProfilePath")); return entity; }
/// <summary> /// Construct a LoftedSurface by lofting an array of curve cross sections and /// using a curve as lofting path to control the lofting direction. /// </summary> /// <param name="crossSections">crossSections (curves) needs to be all closed or all open.</param> /// <param name="path">lofting path curve.</param> /// <returns>Loftedsurface</returns> public static DSLoftedSurface LoftFromCrossSectionsPath(DSCurve[] crossSections, DSCurve path) { return DSLoftedSurface.FromCrossSectionsPath(crossSections, path); }
/// <summary> /// Constructor that does the same as CoordinateSystem.AtParameter but that it checks if the z-axis is /// in the same general direction as the given upVector. If not, it flips the z-axis to make it point /// in the same overall direction as the upVector and also flips the y-axis accordingly to preserve /// the right-handed CoordinateSystem rule. /// </summary> /// <param name="contextCurve"></param> /// <param name="t"></param> /// <param name="upVector"></param> /// <returns></returns> public static DSCoordinateSystem AtParameter(DSCurve contextCurve, double t, DSVector upVector) { if (contextCurve == null) throw new System.ArgumentNullException("contextCurve"); else if (upVector == null) throw new System.ArgumentNullException("upVector"); else if (upVector.IsZeroVector()) throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "up vector"), "upVector"); var cs = contextCurve.CoordinateSystemAtParameterCore(t, upVector); if (null == cs) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.AtParameter")); // property assigments // cs.ContextCurve = contextCurve; cs.T = t; cs.Distance = contextCurve.DistanceAtParameter(t); cs.UpVector = upVector; return cs; }
/// <summary> /// Constructs a a CoordinateSystem with its origin at the given parameter on the given curve. Its x-axis is tangential to the curve, /// y-axis is along the normal and z-axis is along bi-normal at that point. This method is complementary to the /// CoordinateSystemAtParameterAlongCurve() method in Curve class and has consistent behavior. /// </summary> /// <param name="contextCurve"></param> /// <param name="t"></param> /// <returns></returns> public static DSCoordinateSystem AtParameter(DSCurve contextCurve, double t) { if (contextCurve == null) throw new System.ArgumentNullException("contextCurve"); var cs = contextCurve.CoordinateSystemAtParameterCore(t, null); if (null == cs) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.AtParameter")); cs.ContextCurve = contextCurve; cs.T = t; cs.Distance = contextCurve.DistanceAtParameter(t); return cs; }
/// <summary> /// def SweepAsSurface : Surface (path : Curve) /// /// Return a surface by sweeping this curve as profile on a given path /// curve /// </summary> /// <param name="path">Path Curve for sweeping</param> /// <returns>Swept Surface</returns> public DSSurface SweepAsSurface(DSCurve path) { if (path == null) throw new System.ArgumentNullException("path"); return DSSurface.Sweep(this, path); }
/// <summary> /// Constructs a patch surface from the give closed non-self intersecting /// profile curve. /// </summary> /// <param name="profile">Profile curve for patch surface</param> /// <returns>Patch Surface</returns> public static DSPatchSurface CreateFromCurve(DSCurve profile) { return DSPatchSurface.FromCurve(profile); }
/// <summary> /// Construct a Surface by sweeping a profile curve along a path curve. /// </summary> /// <param name="profile">Profile curve for sweep.</param> /// <param name="path">Path curve to sweep along.</param> /// <returns>SweptSurface</returns> public static DSSweptSurface Sweep(DSCurve profile, DSCurve path) { return DSSweptSurface.ByProfilePath(profile, path); }
/// <summary> /// /// </summary> /// <param name="curves"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSCurve[] curves, DSPoint selectPoint, bool autoExtend) { if (null == curves) throw new System.ArgumentNullException("curves"); return Trim(curves, null, null, null, selectPoint, autoExtend); }
/// <summary> /// Construct a Surface by revolving curve about a line axis. startAngle /// determines where the curve starts to revolve, sweepAngle determines /// the revolving angle. /// </summary> /// <param name="profile">Profile Curve for revolve surface.</param> /// <param name="axis">Line to define axis of revolution.</param> /// <param name="startAngle">Start Angle in degreee at which curve starts to revolve.</param> /// <param name="sweepAngle">Sweep Angle in degree to define the extent of revolve.</param> /// <returns>RevolvedSurface</returns> public static DSRevolvedSurface Revolve(DSCurve profile, DSLine axis, double startAngle, double sweepAngle) { return DSRevolvedSurface.ByProfileAxisAngle(profile, axis, startAngle, sweepAngle); }
/// <summary> /// Construct a Surface by revolving the profile curve about an axis /// defined by axisOrigin point and axisDirection Vector. startAngle /// determines where the curve starts to revolve, sweepAngle determines /// the extent of the revolve. /// </summary> /// <param name="profile">Profile Curve for revolve surface.</param> /// <param name="axisOrigin">Origin Point for axis of revolution.</param> /// <param name="axisDirection">Direction Vector for axis of revolution.</param> /// <param name="startAngle">Start Angle in degreee at which curve starts to revolve.</param> /// <param name="sweepAngle">Sweep Angle in degree to define the extent of revolve.</param> /// <returns>RevolvedSurface</returns> public static DSRevolvedSurface Revolve(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle) { return DSRevolvedSurface.ByProfileAxisOriginDirectionAngle(profile, axisOrigin, axisDirection, startAngle, sweepAngle); }
/// <summary> /// Constructs a patch surface from the give closed non-self intersecting /// profile curve. /// </summary> /// <param name="profile">Profile curve for patch surface</param> /// <returns>Patch Surface</returns> public static DSPatchSurface FromCurve(DSCurve profile) { return new DSPatchSurface(profile, true); }
protected DSPatchSurface(DSCurve profile,bool persist) : base(FromCurveCore(profile), persist) { InitializeGuaranteedProperties(); Profile = profile; }
private static ISolidEntity RevolveCore(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle) { if (profile == null) throw new ArgumentNullException("profile"); if (axisOrigin == null) throw new ArgumentNullException("axisOrigin"); if (axisDirection == null) throw new ArgumentNullException("axisDirection"); if (!profile.IsPlanar) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "profile"), "profile"); if (DSGeometryExtension.Equals(axisDirection.Length, 0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "axisDirection"), "axisDirection"); if (DSGeometryExtension.Equals(sweepAngle, 0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "sweepAngle"), "sweepAngle"); ISolidEntity entity = HostFactory.Factory.SolidByRevolve(profile.CurveEntity, axisOrigin.PointEntity, axisDirection.IVector, startAngle, sweepAngle); if (entity == null) throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.Revolve")); return entity; }
/// <summary> /// Construct a Surface by revolving the profile curve about an axis /// defined by axisOrigin point and axisDirection Vector. /// Assuming sweep angle = 360 and start angle = 0. /// </summary> /// <param name="profile">Profile Curve for revolve surface.</param> /// <param name="axisOrigin">Origin Point for axis of revolution.</param> /// <param name="axisDirection">Direction Vector for axis of revolution.</param> /// <returns>RevolvedSurface</returns> public static DSRevolvedSurface Revolve(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection) { return DSRevolvedSurface.ByProfileAxisOriginDirection(profile, axisOrigin, axisDirection); }
internal static List<ICurveEntity> GetHostCurves(DSCurve[] contextCurves, out ICurveEntity firstCurve) { firstCurve = null; List<ICurveEntity> hostCurves = new List<ICurveEntity>(); foreach (var curve in contextCurves) { if (null == curve) continue; if (null == firstCurve) firstCurve = curve.CurveEntity; else hostCurves.Add(curve.CurveEntity); } if (null == firstCurve) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "contextCurves"), "contextCurves"); return hostCurves; }
/// <summary> /// Construct a Surface by revolving curve about a line axis. Assuming /// sweep angle = 360 and start angle = 0. /// </summary> /// <param name="profile">Profile Curve for revolve surface.</param> /// <param name="axis">Line to define axis of revolution.</param> /// <returns>SRevolvedSurface</returns> public static DSRevolvedSurface Revolve(DSCurve profile, DSLine axis) { return DSRevolvedSurface.ByProfileAxis(profile, axis); }
/// <summary> /// Returns the composite curve by joining a given set of input curves /// Argument Requirement: /// no input curves can be closed /// </summary> /// <param name="contextCurves"></param> /// <returns></returns> public static DSCurve Composite(DSCurve[] contextCurves) { string kMethodName = "DSCurve.Composite"; if (null == contextCurves) throw new System.ArgumentNullException("contextCurves"); ICurveEntity firstCurve; List<ICurveEntity> hostCurves = GetHostCurves(contextCurves, out firstCurve); if (hostCurves.Count == 0) return firstCurve.ToCurve(false, null); IBSplineCurveEntity entity = firstCurve.JoinWith(hostCurves.ToArray()); if (null == entity) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); return entity.ToCurve(true, null) as DSCurve; }
/// <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); }
public static DSCurve[] Composite(DSCurve[] contextCurves, double bridgeTolerance) { string kMethodName = "DSCurve.Composite"; ICurveEntity firstCurve; List<ICurveEntity> hostCurves = GetHostCurves(contextCurves, out firstCurve); if (hostCurves.Count == 0) return new DSCurve[] { firstCurve.ToCurve(false, null) }; ICurveEntity[] entities = firstCurve.JoinWith(hostCurves.ToArray(), bridgeTolerance); if (null == entities) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); return entities.ToArray<DSCurve, ICurveEntity>(true); }
internal override IGeometryEntity[] IntersectWithCurve(DSCurve curve) { return curve.CurveEntity.IntersectWith(SurfaceEntity); }
/// <summary> /// Return a closest point on another curve to the curve. /// </summary> /// <param name="other">Curve</param> /// <returns>Closest Point</returns> public DSPoint ClosestPointTo(DSCurve other) { string kMethodName = "DSCurve.ClosestPointTo"; if (null == other) throw new System.ArgumentNullException("other"); IPointEntity closestPt = CurveEntity.GetClosestPointTo(other.CurveEntity); if (null == closestPt) throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName)); return closestPt.ToPoint(true, this); }
/// <summary> /// Constructs a LoftedSurface by lofting an array of curve cross sections. /// </summary> /// <param name="crossSections">crossSections (curves) needs to be all closed or all open.</param> /// <returns>Loft surface.</returns> public static DSLoftedSurface LoftFromCrossSections(DSCurve[] crossSections) { return DSLoftedSurface.FromCrossSections(crossSections); }
/// <summary> /// Copy contructor as well as a mechanism for subclassing from external /// libraries. /// </summary> /// <param name="curve"></param> /// <param name="persist"></param> protected DSCurve(DSCurve curve, bool persist) : base(curve.CurveEntity.Clone(), persist) { }