/// <summary> /// contructs a point with respect to another point and offset in x,y,z directions /// </summary> /// <param name="referencePoint">the point with respect to which the new point is contructed</param> /// <param name="deltaX">offset in the x direction</param> /// <param name="deltaY">offset in the y direction</param> /// <param name="deltaZ">offset in the z direction</param> /// <returns></returns> public static DSPoint ByOffset(DSPoint referencePoint, double deltaX, double deltaY, double deltaZ) { DSPoint newPnt = new DSPoint(referencePoint, deltaX, deltaY, deltaZ, true); newPnt.ReferencePoint = referencePoint; return(newPnt); }
protected override DSGeometry GetGeometryCore(out bool autodispose) { DSPoint p = VertexEntity.GetPointGeometry().ToPoint(false, null); autodispose = true; return(p); }
private static IConeEntity ByStartPointEndPointRadiusCore(DSPoint startPoint, DSPoint endPoint, double startRadius, double endRadius) { if (startRadius.LessThanOrEqualTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "start radius"), "startRadius"); } if (endRadius < 0.0) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "end radius"), "endRadius"); } if (null == startPoint) { throw new System.ArgumentNullException("startPoint"); } if (null == endPoint) { throw new System.ArgumentNullException("endPoint"); } if (startPoint.DistanceTo(endPoint).EqualsTo(0.0)) { throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroDistance, "start point", "end point"), "startPoint, endPoint"); } IConeEntity entity = HostFactory.Factory.ConeByPointsRadius(startPoint.PointEntity, endPoint.PointEntity, startRadius, endRadius); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCone.ByStartPointEndPointRadius")); } return(entity); }
private static IArcEntity ByCenterPointStartPointSweepPointCore(DSPoint centerPoint, DSPoint startPoint, DSPoint sweepPoint) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (startPoint == null) { throw new ArgumentNullException("startPoint"); } else if (sweepPoint == null) { throw new ArgumentNullException("sweepPoint"); } else if (startPoint.Equals(sweepPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "sweep point"), "startPoint, sweepPoint"); } else if (startPoint.Equals(centerPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "center point"), "startPoint, centerPoint"); } var arcEntity = HostFactory.Factory.ArcByCenterPointStartPointSweepPoint(centerPoint.PointEntity, startPoint.PointEntity, sweepPoint.PointEntity); if (null == arcEntity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSArc.ByCenterPointStartPointSweepPoint")); } return(arcEntity); }
/// <summary> /// Constructs a point by projecting a point on surface with given /// project direction. /// </summary> /// <param name="contextSurface">The surface on which the projection is to be made.</param> /// <param name="direction">The direction vector of the projection</param> /// <returns>Projected point on surface</returns> public DSPoint Project(DSSurface contextSurface, DSVector direction) { if (null == contextSurface) { 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(contextSurface, direction); pt.Context = contextSurface; pt.Direction = direction; pt.ReferencePoint = this; double[] parameters = contextSurface.ParameterAtPoint(pt); if (null != parameters) { pt.U = parameters[0]; pt.V = parameters[1]; } return(pt); }
protected DSCircle(DSPoint firstPoint, DSPoint secondPoint, DSVector normal,bool persist) : base(By2PointsCore(firstPoint, secondPoint, ref normal),persist) { InitializeGuaranteedProperties(); FirstPoint = firstPoint; SecondPoint = secondPoint; }
private static ICircleEntity ByCenterPointRadiusCore(DSPoint centerPoint, double radius, ref DSVector normal) { if (null == centerPoint) { throw new ArgumentNullException("centerPoint"); } if (null == normal) { throw new ArgumentNullException("normal"); } if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "normal"), "normal"); } if (radius <= 0.0) { throw new ArgumentException(Properties.Resources.IsZeroRadius); } normal = normal.IsNormalized ? normal : normal.Normalize(); ICircleEntity entity = HostFactory.Factory.CircleByCenterPointRadius(centerPoint.PointEntity, radius, normal.IVector); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSCircle.ByCenterPointRadius")); } return(entity); }
protected internal DSSubDivisionMesh(DSPoint[] vertices, int[][] faceIndices, int subDivisionLevel,bool persist) : base(ByVerticesFaceIndicesCore(vertices, faceIndices, subDivisionLevel),persist) { InitializeGuaranteedProperties(); SubDivisionLevel = subDivisionLevel; Vertices = vertices; }
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); }
protected DSCircle(DSPoint firstPoint, DSPoint secondPoint, DSVector normal, bool persist) : base(By2PointsCore(firstPoint, secondPoint, ref normal), persist) { InitializeGuaranteedProperties(); FirstPoint = firstPoint; SecondPoint = secondPoint; }
private static ILineEntity ByStartPointDirectionLengthCore(DSPoint startPt, DSVector direction, double length) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (direction == null) { throw new ArgumentNullException("direction"); } else if (direction.IsZeroVector() || length == 0.0) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction")); } else if (length == 0.0) { throw new ArgumentException(Properties.Resources.IsZeroLength); } //Temporary end point is created by translating, should be disposed DSVector offset = direction.Normalize().MultiplyBy(length); var endPt = startPt.Translate(offset, false); ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSLine.ByStartPointDirectionLength")); } return(entity); }
private static IArcEntity ByCenterPointRadiusAngleCore(DSPoint centerPoint, double radius, double startAngle, double sweepAngle, ref DSVector normal) { if (centerPoint == null) { throw new ArgumentNullException("centerPoint"); } else if (normal == null) { throw new ArgumentNullException("normal"); } else if (radius <= 0.0) { throw new ArgumentException(string.Format(Properties.Resources.LessThanZero, "radius")); } else if (normal.IsZeroVector()) { throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, normal), "normal"); } normal = normal.IsNormalized ? normal : normal.Normalize(); var endAngle = (startAngle + sweepAngle); IArcEntity entity = HostFactory.Factory.ArcByCenterPointRadiusAngle(centerPoint.PointEntity, radius, DSGeometryExtension.DegreesToRadians(startAngle), DSGeometryExtension.DegreesToRadians(endAngle), normal.IVector); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSArc.ByCenterPointRadiusAngle")); } return(entity); }
protected DSArc(DSPoint firstPoint, DSPoint secondPoint, DSPoint thirdPoint, bool persist) : base(ByPointsOnCurveCore(firstPoint, secondPoint, thirdPoint), persist) { InitializeGuaranteedProperties(); FirstPoint = firstPoint; SecondPoint = secondPoint; ThirdPoint = thirdPoint; }
protected DSBSplineCurve(DSPoint[] points, DSVector startTangent, DSVector endTangent, bool makePeriodic,bool persist) : base(ByPointsCore(ref points, startTangent, endTangent, makePeriodic),persist) { InitializeGuaranteedProperties(); Points = points; StartTangent = startTangent; EndTangent = endTangent; }
/// <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)); }
protected DSCircle(DSPoint firstPoint, DSPoint secondPoint, DSPoint thirdPoint,bool persist) : base(ByPointsOnCurveCore(firstPoint, secondPoint, thirdPoint),persist) { InitializeGuaranteedProperties(); FirstPoint = firstPoint; SecondPoint = secondPoint; ThirdPoint = thirdPoint; }
protected DSCone(DSPoint startPoint, DSPoint endPoint, double startRadius, double endRadius,bool persist) : base(ByStartPointEndPointRadiusCore(startPoint, endPoint, startRadius, endRadius),persist) { InitializeGuaranteedProperties(); StartPoint = startPoint; EndPoint = endPoint; StartRadius = startRadius; EndRadius = endRadius; }
/// <summary> /// Returns the U, V parameter at a given point of a surface /// </summary> /// <param name="point"></param> /// <returns>double[] == the first element is U, the second double is V</returns> public double[] ParameterAtPoint(DSPoint point) { System.Tuple <double, double> parametersTuple = SurfaceEntity.GetUVParameterAtPoint(point.PointEntity); List <double> parameters = new List <double>(); parameters.Add(parametersTuple.Item1); parameters.Add(parametersTuple.Item2); return(parameters.ToArray()); }
protected DSCone(DSPoint startPoint, DSPoint endPoint, double startRadius, double endRadius, bool persist) : base(ByStartPointEndPointRadiusCore(startPoint, endPoint, startRadius, endRadius), persist) { InitializeGuaranteedProperties(); StartPoint = startPoint; EndPoint = endPoint; StartRadius = startRadius; EndRadius = endRadius; }
/// <summary> /// /// </summary> /// <param name="planes"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSPlane[] planes, DSPoint selectPoint, bool autoExtend) { if (null == planes) { throw new System.ArgumentNullException("planes"); } return(Trim(null, planes, null, null, selectPoint, autoExtend)); }
/// <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)); }
protected internal DSPlane(DSPoint origin, DSVector normal, double size, bool display = false, DSGeometry context = null) : base(ByOriginNormalCore(origin, ref normal, size), false) { InitializeGuaranteedProperties(); Size = size; Context = context; if (display) mDisplayPolygon = CreatePlaneVisuals(size,true); }
/// <summary> /// Creates a block with the given name, reference point and from the /// specified geometries /// </summary> /// <param name="blockName">the block name</param> /// <param name="referencePoint">the reference point</param> /// <param name="contents">the geometries contained in the block</param> /// <returns></returns> public static DSBlock FromGeometry(string blockName, DSPoint referencePoint, DSGeometry[] contents) { DSCoordinateSystem referenceCoordinateSystem = DSCoordinateSystem.Identity(); referenceCoordinateSystem.Translate(referencePoint.X, referencePoint.Y, referencePoint.Z); return(FromGeometry(blockName, referenceCoordinateSystem, contents)); }
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; }
internal IGeometryEntity[] IntersectWithPoint(DSPoint point) { if (GeomEntity.DistanceTo(point.PointEntity).EqualsTo(0.0)) { return new IGeometryEntity[] { point.PointEntity } } ; return(null); }
/// <summary> /// /// </summary> /// <param name="surface"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSSurface surface, DSPoint selectPoint, bool autoExtend) { if (null == surface) { throw new System.ArgumentNullException("surface"); } DSSurface[] surfaces = { surface }; return(Trim(null, null, surfaces, null, selectPoint, autoExtend)); }
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; }
private static IPointEntity ByOffsetCore(DSPoint refPoint, double deltaX, double deltaY, double deltaZ) { if (refPoint == null) { throw new ArgumentNullException("refPoint"); } var pt = HostFactory.Factory.CreatePoint(refPoint.X + deltaX, refPoint.Y + deltaY, refPoint.Z + deltaZ); return(pt); }
protected internal DSPlane(DSPoint origin, DSVector normal, double size, bool display = false, DSGeometry context = null) : base(ByOriginNormalCore(origin, ref normal, size), false) { InitializeGuaranteedProperties(); Size = size; Context = context; if (display) { mDisplayPolygon = CreatePlaneVisuals(size, true); } }
public static bool ArePointsColinear(DSPoint one, DSPoint two, DSPoint three) { var onePos = one.PointEntity; var twoPos = two.PointEntity; var thrPos = three.PointEntity; var vec12 = onePos.GetVectorTo(twoPos); var vec23 = twoPos.GetVectorTo(thrPos); return(vec12.IsZeroVector() || vec23.IsZeroVector() || vec12.IsParallel(vec23)); }
private DSSurfaceCurvature(DSSurface contextSurface, double u, double v, ICoordinateSystemEntity coordinateSystemEntity) { FirstPrincipleCurvature = new DSVector(coordinateSystemEntity.XAxis); SecondPrincipleCurvature = new DSVector(coordinateSystemEntity.YAxis); GaussianCurvature = FirstPrincipleCurvature.Length * SecondPrincipleCurvature.Length; mPointOnSurface = DSPoint.ToGeometry(coordinateSystemEntity.Origin, false, contextSurface) as DSPoint; U = u; V = v; ContextSurface = contextSurface; mCoordinateSystem = DSCoordinateSystem.ToCS(coordinateSystemEntity, false); }
private DSSurfaceCurvature(DSSurface contextSurface, double u, double v, ICoordinateSystemEntity coordinateSystemEntity) { FirstPrincipleCurvature = new DSVector(coordinateSystemEntity.XAxis); SecondPrincipleCurvature = new DSVector(coordinateSystemEntity.YAxis); GaussianCurvature = FirstPrincipleCurvature.Length * SecondPrincipleCurvature.Length; mPointOnSurface = DSPoint.ToGeometry(coordinateSystemEntity.Origin, false, contextSurface) as DSPoint; U = u; V = v; ContextSurface = contextSurface; mCoordinateSystem = DSCoordinateSystem.ToCS(coordinateSystemEntity, false); }
private static ICircleEntity ByPointsOnCurveCore(DSPoint firstPoint, DSPoint secondPoint, DSPoint thirdPoint) { if (firstPoint == null) { throw new ArgumentNullException("firstPoint"); } else if (secondPoint == null) { throw new ArgumentNullException("secondPoint"); } else if (thirdPoint == null) { throw new ArgumentNullException("thirdPoint"); } else if (firstPoint.Equals(secondPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint"); } else if (secondPoint.Equals(thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "second point", "thrid point"), "secondPoint, thirdPoint"); } else if (thirdPoint.Equals(firstPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "third point", "first point"), "thirdPoint, firstPoint"); } else if (DSGeometryExtension.ArePointsColinear(firstPoint, secondPoint, thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.PointsColinear, "first, second and thrid points"), "firstPoint, secondPoint, thirdPoint"); } /* * Vector normal = null; * var centerPt = Utils.GetCircumCenter(firstPoint, secondPoint, thirdPoint, out normal); * if (centerPt == null || normal == null) * { * return null; * } * double rad = firstPoint.PointEntity.DistanceTo(centerPt.PointEntity); * if( rad <= 0.0) * { * return null; * } */ var entity = HostFactory.Factory.CircleByPointsOnCurve(firstPoint.PointEntity, secondPoint.PointEntity, thirdPoint.PointEntity); if (null == entity) { throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSCircle.ByPointsOnCurve")); } return(entity); }
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 ISphereEntity ByCenterPointRadiusCore(DSPoint centerPoint, double radius) { if (radius.LessThanOrEqualTo(0.0)) throw new ArgumentException(string.Format(Properties.Resources.LessThanZero, "radius"), "radius"); if (centerPoint == null) throw new ArgumentNullException("centerPoint"); ISphereEntity entity = HostFactory.Factory.SphereByCenterPointRadius(centerPoint.PointEntity, radius); if (null == entity) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSphere.ByCenterPointRadius")); return entity; }
public static DSVector ByCoordinates(DSCoordinateSystem coordinateSystem, double x, double y, double z) { if (coordinateSystem == null) { throw new System.ArgumentNullException("coordinateSystem"); } using (var p = DSPoint.ByCartesianCoordinates(coordinateSystem, x, y, z)) { DSVector vec = coordinateSystem.Origin.DirectionTo(p); vec.ContextCoordinateSystem = coordinateSystem; return(vec); } }
/// <summary> /// /// </summary> /// <param name="otherPoint"></param> /// <returns></returns> public DSVector DirectionTo(DSPoint otherPoint) { if (otherPoint == null) { return(null); } var delx = otherPoint.X - X; var dely = otherPoint.Y - Y; var delz = otherPoint.Z - Z; return(new DSVector(delx, dely, delz)); }
public double DistanceTo(DSPoint otherPoint) { if (otherPoint == null) { return(0.0); } var delx = otherPoint.X - X; var dely = otherPoint.Y - Y; var delz = otherPoint.Z - Z; var sqDist = delx * delx + dely * dely + delz * delz; return(Math.Sqrt(sqDist)); }
/// <summary> /// Returns a normal to the surface at the specified point /// </summary> /// <param name="pointOnSurface">Point on the surface at which the normal is required</param> /// <returns></returns> public DSVector NormalAtPoint(DSPoint pointOnSurface) { if (pointOnSurface == null) { throw new System.ArgumentNullException("pointOnSurface"); } IVector normal = SurfaceEntity.GetNormalAtPoint(pointOnSurface.PointEntity); if (normal == null) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.NormalAtPoint")); } return(new DSVector(normal)); }
/// <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); }
/// <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> /// /// </summary> /// <param name="planes"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSPlane[] planes, DSPoint selectPoint, bool autoExtend) { if(null == planes) throw new System.ArgumentNullException("planes"); return Trim(null, planes, null, null, selectPoint, autoExtend); }
/// <summary> /// /// </summary> /// <param name="surface"></param> /// <param name="selectPoint"></param> /// <param name="autoExtend"></param> /// <returns></returns> public DSSurface Trim(DSSurface surface, DSPoint selectPoint, bool autoExtend) { if(null == surface) throw new System.ArgumentNullException("surface"); DSSurface[] surfaces = {surface}; return Trim(null, null, surfaces, null, selectPoint, autoExtend); }
private static ICircleEntity ByPointsOnCurveCore(DSPoint firstPoint, DSPoint secondPoint, DSPoint thirdPoint) { if (firstPoint == null) { throw new ArgumentNullException("firstPoint"); } else if (secondPoint == null) { throw new ArgumentNullException("secondPoint"); } else if (thirdPoint == null) { throw new ArgumentNullException("thirdPoint"); } else if (firstPoint.Equals(secondPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "first point", "second point"), "firstPoint, secondPoint"); } else if (secondPoint.Equals(thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "second point", "thrid point"), "secondPoint, thirdPoint"); } else if (thirdPoint.Equals(firstPoint)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "third point", "first point"), "thirdPoint, firstPoint"); } else if (DSGeometryExtension.ArePointsColinear(firstPoint, secondPoint, thirdPoint)) { throw new ArgumentException(string.Format(Properties.Resources.PointsColinear, "first, second and thrid points"), "firstPoint, secondPoint, thirdPoint"); } /* Vector normal = null; var centerPt = Utils.GetCircumCenter(firstPoint, secondPoint, thirdPoint, out normal); if (centerPt == null || normal == null) { return null; } double rad = firstPoint.PointEntity.DistanceTo(centerPt.PointEntity); if( rad <= 0.0) { return null; } */ var entity = HostFactory.Factory.CircleByPointsOnCurve(firstPoint.PointEntity, secondPoint.PointEntity, thirdPoint.PointEntity); if (null == entity) throw new Exception(string.Format(Properties.Resources.OperationFailed, "DSCircle.ByPointsOnCurve")); 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); }
protected DSBSplineCurve(DSPoint[] controlVertices, int degree, bool makePeriodic,bool persist) : base(ByControlVerticesCore(controlVertices, ref degree, makePeriodic), persist) { InitializeGuaranteedProperties(); }
/// <summary> /// Constructs a Bspline curve interpolating the given set of input /// points and tangent to the first and second tangent vectors at the /// start and end points respectively with degree 3. /// </summary> /// <param name="points">Array of points</param> /// <param name="startTangent">Start tangent vector</param> /// <param name="endTangent">End tangent vector</param> /// <returns>BSplineCurve</returns> public static DSBSplineCurve ByPoints(DSPoint[] points, DSVector startTangent, DSVector endTangent) { if (startTangent == null || endTangent == null || startTangent.IsZeroVector() || endTangent.IsZeroVector()) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "points"), "points"); } return ByPoints(points, startTangent, endTangent, false); }
/// <summary> /// Constructs a Bspline curve from a given list of input points, The /// 'makePeriodic' flag determines if the curve should be closed with /// C1 continuity. The degree is 3. /// </summary> /// <param name="points">Array of points</param> /// <param name="makePeriodic">Flag to make it periodic</param> /// <returns>BSplineCurve</returns> public static DSBSplineCurve ByPoints(DSPoint[] points, bool makePeriodic) { return ByPoints(points, null, null, makePeriodic); }
/// <summary> /// Constructs a non-periodic Bspline curve by fitting the given array /// of points. The degree is 3. /// </summary> /// <param name="points">Array of points</param> /// <returns>BSplineCurve</returns> public static DSBSplineCurve ByPoints(DSPoint[] points) { return ByPoints(points, false); }
/// <summary> /// Constructs a Bspline curve from a given list of input control /// vertices and degree, The 'makePeriodic' flag determines if the /// curve should be closed with C1 continuity. /// </summary> /// <param name="controlVertices">Array of points</param> /// <param name="degree">Degree of the curve</param> /// <param name="makePeriodic">Flag to make it periodic</param> /// <returns>BSplineCurve</returns> public static DSBSplineCurve ByControlVertices(DSPoint[] controlVertices, int degree, bool makePeriodic) { return new DSBSplineCurve(controlVertices, degree, makePeriodic, true); }
/// <summary> /// Constructs a non-periodic BSplineCurve with given control vertices and degree. /// </summary> /// <param name="controlVertices">Array of points</param> /// <param name="degree">Degree of the curve</param> /// <returns>BSplineCurve</returns> public static DSBSplineCurve ByControlVertices(DSPoint[] controlVertices, int degree ) { return ByControlVertices(controlVertices, degree, false); }
private static IBSplineCurveEntity ByControlVerticesCore(DSPoint[] controlVertices, ref int degree, bool makePeriodic) { IPointEntity[] hosts = controlVertices.ConvertAll(DSGeometryExtension.ToEntity<DSPoint, IPointEntity>); if (hosts == null) throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "controlVertices", "DSBSplineCurve"), "controlVertices"); if (degree < 1 || degree > 11) { throw new System.ArgumentException(string.Format(Properties.Resources.LessThan, "degree", "one"), "degree"); } if (hosts.AreCoincident()) throw new System.ArgumentException(string.Format(Properties.Resources.PointsCoincident, "controlVertices"), "controlVertices"); //Can't create BSpline curve with all coincident points. // making sure if # of controlVertices > degree by atleast 1 int udiff = hosts.Length - degree; if (udiff < 1) degree += udiff - 1; //Fix DID DG-1464903 var ent = HostFactory.Factory.BSplineByControlVertices(hosts, degree, makePeriodic); if (null == ent) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSBSplineCurve.ByControlVertices")); return ent; }
/// <summary> /// Constructs a solid cone defined by a start and end point on its axis and the start and end radii of its base and top respectively. /// </summary> /// <param name="startPoint">The start point on the axis of the cone</param> /// <param name="endPoint">The end point on the axis of the cone</param> /// <param name="startRadius">The radius of the base of the cone</param> /// <param name="endRadius">The radius of the top of the cone</param> /// <returns></returns> public static DSCone ByStartPointEndPointRadius(DSPoint startPoint, DSPoint endPoint, double startRadius, double endRadius) { return new DSCone(startPoint, endPoint, startRadius, endRadius, true); }
/// <summary> /// Internal function to create BSplineCurve by fit points. /// </summary> /// <param name="points">Array of points</param> /// <param name="startTangent">Start tangent vector</param> /// <param name="endTangent">End tangent vector</param> /// <param name="makePeriodic">Flag to make it periodic</param> /// <returns>BSplineCurve</returns> private static DSBSplineCurve ByPoints(DSPoint[] points, DSVector startTangent, DSVector endTangent, bool makePeriodic) { return new DSBSplineCurve(points, startTangent, endTangent, makePeriodic, true); }
/// <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); }
private static IBSplineCurveEntity ByPointsCore(ref DSPoint[] points, DSVector startTangent, DSVector endTangent, bool makePeriodic) { IPointEntity[] hosts = points.ConvertAll(DSGeometryExtension.ToEntity<DSPoint, IPointEntity>); if (hosts == null || hosts.Length < 2) { throw new System.ArgumentException(string.Format(Properties.Resources.InvalidArguments, "points"), "points"); } if (hosts.AreCoincident()) throw new System.ArgumentException(string.Format(Properties.Resources.PointsCoincident, "points"), "points"); //Can't create BSpline curve with all coincident points. IBSplineCurveEntity ent = null; if (null != startTangent && null != endTangent) ent = HostFactory.Factory.BSplineByPoints(hosts, startTangent.IVector, endTangent.IVector); else ent = HostFactory.Factory.BSplineByPoints(hosts, makePeriodic); if (ent == null) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSBSplineCurve.ByPoints")); points = hosts.ToArray<DSPoint, IPointEntity>(false); return ent; }
/// <summary> /// Returns a normal to the surface at the specified point /// </summary> /// <param name="pointOnSurface">Point on the surface at which the normal is required</param> /// <returns></returns> public DSVector NormalAtPoint(DSPoint pointOnSurface) { if (pointOnSurface == null) throw new System.ArgumentNullException("pointOnSurface"); IVector normal = SurfaceEntity.GetNormalAtPoint(pointOnSurface.PointEntity); if(normal == null) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSSurface.NormalAtPoint")); return new DSVector(normal); }
/// <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); }
private static IConeEntity ByStartPointEndPointRadiusCore(DSPoint startPoint, DSPoint endPoint, double startRadius, double endRadius) { if (startRadius.LessThanOrEqualTo(0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "start radius"), "startRadius"); if (endRadius < 0.0) throw new System.ArgumentException(string.Format(Properties.Resources.LessThanZero, "end radius"), "endRadius"); if (null == startPoint) throw new System.ArgumentNullException("startPoint"); if (null == endPoint) throw new System.ArgumentNullException("endPoint"); if (startPoint.DistanceTo(endPoint).EqualsTo(0.0)) throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroDistance, "start point", "end point"), "startPoint, endPoint"); IConeEntity entity = HostFactory.Factory.ConeByPointsRadius(startPoint.PointEntity, endPoint.PointEntity, startRadius, endRadius); if (null == entity) throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCone.ByStartPointEndPointRadius")); return entity; }
/// <summary> /// Returns the U, V parameter at a given point of a surface /// </summary> /// <param name="point"></param> /// <returns>double[] == the first element is U, the second double is V</returns> public double[] ParameterAtPoint(DSPoint point) { System.Tuple<double, double> parametersTuple = SurfaceEntity.GetUVParameterAtPoint(point.PointEntity); List<double> parameters = new List<double>(); parameters.Add(parametersTuple.Item1); parameters.Add(parametersTuple.Item2); return parameters.ToArray(); }