Esempio n. 1
0
 protected DSSolid(DSCurve profile, DSCurve path, bool persist)
     : base(SweepCore(profile, path), persist)
 {
     InitializeGuaranteedProperties();
     Path = path;
     Profile = profile;
 }
Esempio n. 2
0
 protected DSSolid(DSCurve[] crossSections, DSCurve[] guides, bool persist)
     : base(LoftFromCrossSectionsGuidesCore(crossSections, guides), persist)
 {
     InitializeGuaranteedProperties();
     CrossSections = crossSections;
     Guides = guides;
 }
Esempio n. 3
0
 protected DSSolid(DSCurve[] crossSections, DSCurve path, bool persist)
     : base(LoftFromCrossSectionsPathCore(crossSections, path), persist)
 {
     InitializeGuaranteedProperties();
     CrossSections = crossSections;
     Path = path;
 }
Esempio n. 4
0
 protected DSSweptSurface(DSCurve profile, DSCurve path,bool persist)
     : base(ByProfilePathCore(profile, path),persist)
 {
     InitializeGuaranteedProperties();
     Profile = profile;
     Path = path;
 }
Esempio n. 5
0
 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;
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
 /// <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);
 }
Esempio n. 10
0
        /// <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;
        }
Esempio n. 11
0
        /// <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;
        }
Esempio n. 12
0
        /// <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);
        }
Esempio n. 13
0
 /// <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);
 }
Esempio n. 14
0
 /// <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);
 }
Esempio n. 15
0
 /// <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);
 }
Esempio n. 16
0
 /// <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);
 }
Esempio n. 17
0
 /// <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);
 }
Esempio n. 18
0
 /// <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);
 }
Esempio n. 19
0
 protected DSPatchSurface(DSCurve profile,bool persist)
     : base(FromCurveCore(profile), persist)
 {
     InitializeGuaranteedProperties();
     Profile = profile;
 }
Esempio n. 20
0
        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;
        }
Esempio n. 21
0
 /// <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);
 }
Esempio n. 22
0
        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;
        }
Esempio n. 23
0
 /// <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);
 }
Esempio n. 24
0
        /// <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;
        }
Esempio n. 25
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);
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
 internal override IGeometryEntity[] IntersectWithCurve(DSCurve curve)
 {
     return curve.CurveEntity.IntersectWith(SurfaceEntity);
 }
Esempio n. 28
0
        /// <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);
        }
Esempio n. 29
0
 /// <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);
 }
Esempio n. 30
0
 /// <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)
 {
 }