Exemple #1
0
 protected DSSolid(DSCurve[] crossSections, DSCurve path, bool persist)
     : base(LoftFromCrossSectionsPathCore(crossSections, path), persist)
 {
     InitializeGuaranteedProperties();
     CrossSections = crossSections;
     Path          = path;
 }
Exemple #2
0
        protected override DSGeometry GetGeometryCore(out bool autodispose)
        {
            DSCurve c = EdgeEntity.GetCurveGeometry().ToCurve(false, null);

            autodispose = true;
            return(c);
        }
Exemple #3
0
 protected DSSolid(DSCurve profile, DSCurve path, bool persist)
     : base(SweepCore(profile, path), persist)
 {
     InitializeGuaranteedProperties();
     Path    = path;
     Profile = profile;
 }
        private static ISurfaceEntity ByProfileAxisOriginDirectionAngleCore(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle)
        {
            if (null == profile)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "profile"), "profile");
            }

            if (null == axisOrigin)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "axis origin"), "axisOrigin");
            }

            if (null == axisDirection)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.NullArgument, "axis direction"), "axisDirection");
            }

            ISurfaceEntity entity = HostFactory.Factory.SurfaceByRevolve(profile.CurveEntity, axisOrigin.PointEntity, axisDirection.IVector, startAngle, sweepAngle);

            if (entity == null)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.Revolve"));
            }
            return(entity);
        }
Exemple #5
0
 protected DSSweptSurface(DSCurve profile, DSCurve path, bool persist)
     : base(ByProfilePathCore(profile, path), persist)
 {
     InitializeGuaranteedProperties();
     Profile = profile;
     Path    = path;
 }
Exemple #6
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);
        }
Exemple #7
0
        internal override IGeometryEntity[] ProjectOn(DSGeometry other, DSVector direction)
        {
            IVector   dir  = direction.IVector;
            DSSurface surf = other as DSSurface;

            if (null != surf)
            {
                return(surf.SurfaceEntity.Project(PointEntity, dir));
            }

            DSCurve curve = other as DSCurve;

            if (null != curve)
            {
                IPointEntity pt = curve.CurveEntity.Project(PointEntity, dir);
                return(new IGeometryEntity[] { pt });
            }

            DSPlane plane = other as DSPlane;

            if (null != plane)
            {
                IPointEntity pt = plane.PlaneEntity.Project(PointEntity, dir);
                return(new IGeometryEntity[] { pt });
            }

            DSSolid solid = other as DSSolid;

            if (null != solid)
            {
                return(solid.SolidEntity.Project(PointEntity, dir));
            }

            return(base.ProjectOn(other, direction));
        }
Exemple #8
0
        /// <summary>
        /// Constructors a plane on a curve by given distance. 
        /// </summary>
        /// <param name="contextCurve"></param>
        /// <param name="distance">Curvilinear distance.</param>
        /// <returns></returns>
        public static DSPlane AtDistance(DSCurve contextCurve, double distance)
        {
            if (null == contextCurve)
            {
                throw new ArgumentNullException("contextCurve");
            }

            return(contextCurve.PlaneAtDistance(distance));
        }
Exemple #9
0
        /// <summary>
        /// Constructors a plane at a point on the curve by given paramater and
        /// use the tangent at the point as Normal of the plane
        /// </summary>
        /// <param name="contextCurve"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static DSPlane AtParameter(DSCurve contextCurve, double t)
        {
            if (null == contextCurve)
            {
                throw new ArgumentNullException("contextCurve");
            }

            return(contextCurve.PlaneAtParameter(t));
        }
 protected DSRevolvedSurface(DSCurve profile, DSPoint axisOrigin, DSVector axisDirection, double startAngle, double sweepAngle, bool persist)
     : base(ByProfileAxisOriginDirectionAngleCore(profile, axisOrigin, axisDirection, startAngle, sweepAngle), persist)
 {
     InitializeGuaranteedProperties();
     Profile       = profile;
     AxisOrigin    = axisOrigin;
     AxisDirection = axisDirection;
     StartAngle    = startAngle;
     SweepAngle    = sweepAngle;
 }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="selectPoint"></param>
        /// <param name="autoExtend"></param>
        /// <returns></returns>
        public DSSurface Trim(DSCurve curve, DSPoint selectPoint, bool autoExtend)
        {
            if (null == curve)
            {
                throw new System.ArgumentNullException("curve");
            }

            DSCurve[] curves = { curve };
            return(Trim(curves, null, null, null, selectPoint, autoExtend));
        }
 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;
 }
Exemple #13
0
        public static ICurveEntity GetCurveEntity(DSCurve curve, bool checkClosed)
        {
            bool isClosed = curve.IsClosed;

            if ((checkClosed && isClosed) || (!checkClosed && !isClosed))
            {
                return(curve.CurveEntity);
            }

            return(null);
        }
Exemple #14
0
        public DSGeometry[] Intersect(DSGeometry other)
        {
            if (null == other)
            {
                throw new ArgumentNullException("other");
            }

            IGeometryEntity[] geoms = null;
            DSPlane           plane = other as DSPlane;

            if (plane != null)
            {
                geoms = IntersectWithPlane(plane);
            }
            else
            {
                DSSurface surf = other as DSSurface;
                if (surf != null)
                {
                    geoms = IntersectWithSurface(surf);
                }
                else
                {
                    DSSolid solid = other as DSSolid;
                    if (solid != null)
                    {
                        geoms = IntersectWithSolid(solid);
                    }
                    else
                    {
                        DSCurve curve = other as DSCurve;
                        if (curve != null)
                        {
                            geoms = IntersectWithCurve(curve);
                        }
                        else
                        {
                            DSPoint point = other as DSPoint;
                            if (null != point)
                            {
                                geoms = IntersectWithPoint(point);
                            }
                            else
                            {
                                throw new System.InvalidOperationException(string.Format(Properties.Resources.InvalidIntersect, GetType().Name, other.GetType().Name));
                            }
                        }
                    }
                }
            }

            return(geoms.ToArray <DSGeometry, IGeometryEntity>(true));
        }
        private static ISurfaceEntity ByProfileAxisAngleCore(DSCurve profile, DSLine axis, double startAngle, double sweepAngle)
        {
            if (null == axis)
            {
                throw new System.ArgumentNullException("axis");
            }
            ISurfaceEntity surf = ByProfileAxisOriginDirectionAngleCore(profile, axis.StartPoint, axis.Direction, startAngle, sweepAngle);

            if (null == surf)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSRevolvedSurface.ByProfileAxisAngle"));
            }
            return(surf);
        }
Exemple #16
0
        /// <summary>
        /// Constructors a point along a curve with a input distance from start point of the curve.
        /// </summary>
        /// <param name="contextCurve">Input Curve</param>
        /// <param name="distance">Distance value.</param>
        /// <returns>Point</returns>
        public static DSPoint AtDistance(DSCurve contextCurve, double distance)
        {
            if (contextCurve == null)
            {
                throw new ArgumentNullException("contextCurve");
            }

            var pt = contextCurve.PointAtDistance(distance);

            pt.Context  = contextCurve;
            pt.Distance = distance;
            pt.T        = contextCurve.ParameterAtDistance(distance);
            pt.Persist();
            return(pt);
        }
Exemple #17
0
        /// <summary>
        /// Constructs a point by projecting a point on a curve which which closest to the curve
        /// </summary>
        /// <param name="curve">the curve on which the projection is to be made.</param>
        /// <returns></returns>
        public DSPoint Project(DSCurve curve)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }

            var pt = curve.Project(this);

            pt.Context = curve;
            double param = curve.ParameterAtPoint(pt);

            pt.T              = param;
            pt.Distance       = curve.DistanceAtParameter(param);
            pt.ReferencePoint = this;
            pt.Persist();
            return(pt);
        }
        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);
        }
Exemple #19
0
        /// <summary>
        /// Constructs a point at a given parameter on the input curve.
        /// </summary>
        /// <param name="contextCurve">Input curve</param>
        /// <param name="parameter">Parameter value.</param>
        /// <returns>Point</returns>
        public static DSPoint AtParameter(DSCurve contextCurve, double parameter)
        {
            if (contextCurve == null)
            {
                throw new ArgumentNullException("contextCurve");
            }

            var pt = contextCurve.PointAtParameter(parameter);

            if (null == pt)
            {
                return(null);
            }
            pt.Context  = contextCurve;
            pt.T        = parameter;
            pt.Distance = contextCurve.DistanceAtParameter(parameter);
            pt.Persist();
            return(pt);
        }
Exemple #20
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);
        }
Exemple #21
0
        /// <summary>
        /// Constructs a point by projecting a point on a curve with given project direction.
        /// </summary>
        /// <param name="curve">the curve on which the projection is to be made.</param>
        /// <param name="direction">the direction vector of the projection</param>
        /// <returns></returns>
        public DSPoint Project(DSCurve curve, DSVector direction)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }
            else if (direction == null)
            {
                throw new ArgumentNullException("direction");
            }
            else if (direction.IsZeroVector())
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction"));
            }

            var pt = curve.Project(this, direction);

            pt.Context        = curve;
            pt.ReferencePoint = this;
            pt.Direction      = direction;
            pt.Persist();
            return(pt);
        }
Exemple #22
0
        private static ISolidEntity SweepCore(DSCurve profile, DSCurve path)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            if (!profile.IsClosed)
            {
                throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "profile"), "profile");
            }

            ISolidEntity entity = HostFactory.Factory.SolidBySweep(profile.CurveEntity, path.CurveEntity);

            if (entity == null)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, "DSSolid.Sweep"));
            }
            return(entity);
        }
Exemple #23
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));
 }
Exemple #24
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));
 }
Exemple #25
0
 internal override IGeometryEntity[] IntersectWithCurve(DSCurve curve)
 {
     return(curve.CurveEntity.IntersectWith(SurfaceEntity));
 }
Exemple #26
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));
 }
Exemple #27
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));
 }
Exemple #28
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));
 }
Exemple #29
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));
 }
Exemple #30
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));
 }