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); }
internal override IGeometryEntity[] IntersectWithPlane(Plane plane) { ILineEntity line = PlaneEntity.IntersectWith(plane.PlaneEntity); if (null != line) { return new IGeometryEntity[] { line } } ; return(null); }
public string WriteEntity(ILineEntity line, string paramName = null) { if (string.IsNullOrEmpty(paramName)) { paramName = string.Format("__line_{0}", ++id); } string start = WriteEntity(line.StartPoint); string end = WriteEntity(line.EndPoint); mExpression.AppendFormat("{0} = Line.ByStartPointEndPoint({1}, {2});", paramName, start, end); mExpression.AppendLine(); return(paramName); }
private static ILineEntity GetPerpBisector(Point startPt, Point endPt, IPlaneEntity planeOfCircle) { Vector dir = startPt.DirectionTo(endPt); dir = dir.Normalize(); IPointEntity midPt = HostFactory.Factory.CreatePoint((startPt.X + endPt.X) / 2, (startPt.Y + endPt.Y) / 2, (startPt.Z + endPt.Z) / 2); // get the perpendicular plane to plane of circle at mid point of segment[startPt, endPt] // IPlaneEntity perpPlane = HostFactory.Factory.PlaneByOriginNormal(midPt, dir.IVector); // this intersection results in line perp to segment[startPt, endPt] & plane normal // and happens to be the perpBisector of mentioned segment in planeOfCircle // ILineEntity perpBisector = planeOfCircle.IntersectWith(perpPlane); return(perpBisector); }
/// <summary> /// Internal utility method /// </summary> /// <param name="profile"></param> /// <param name="distance"></param> /// <param name="direction"></param> /// <returns></returns> internal static IBSplineSurfaceEntity[] ExtrudeAsBSplineSurfaces(this ICurveEntity profile, double distance, Vector direction) { if (null == profile || direction.IsZeroVector()) { return(null); } using (IPointEntity startPt = profile.PointAtParameter(0.5)) { Vector offset = direction.Normalize().Scale(distance); using (IPointEntity endPt = startPt.CopyAndTranslate(offset.IVector) as IPointEntity) { using (ILineEntity path = HostFactory.Factory.LineByStartPointEndPoint(startPt, endPt)) { using (ISurfaceEntity surf = HostFactory.Factory.SurfaceBySweep(profile, path)) { return(surf.ConvertToBSplineSurface()); } } } } }
private static Point GetCircumCenter(Point firstPt, Point secondPt, Point thirdPt, Vector normal) { var one = firstPt.PointEntity; var two = secondPt.PointEntity; var thr = thirdPt.PointEntity; using (IPlaneEntity planeOfCircle = HostFactory.Factory.PlaneByOriginNormal(one, normal.IVector)) { using (ILineEntity perpBisector1 = GetPerpBisector(firstPt, secondPt, planeOfCircle)) { using (ILineEntity perpBisector2 = GetPerpBisector(secondPt, thirdPt, planeOfCircle)) { IPointEntity[] circumCntr = perpBisector1.IntersectWith(perpBisector2); if (circumCntr == null || circumCntr.Length < 1) { return(null); } return(circumCntr[0].ToPoint(false, null)); } } } }
private static ILineEntity ByStartPointEndPointCore(DSPoint startPt, DSPoint endPt) { if (startPt == null) { throw new ArgumentNullException("startPt"); } else if (endPt == null) { throw new ArgumentNullException("endPt"); } else if (startPt.Equals(endPt)) { throw new ArgumentException(string.Format(Properties.Resources.EqualGeometry, "start point", "end point")); } ILineEntity entity = HostFactory.Factory.LineByStartPointEndPoint(startPt.PointEntity, endPt.PointEntity); if (null == entity) { throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSLine.ByStartPointEndPoint")); } return(entity); }
internal static Line ToLine(this ILineEntity host, bool persist, Geometry context) { return(host.ToGeometry <Line, ILineEntity>(persist, context)); }
private DSLine(ILineEntity entity, bool persist = false) : base(entity, persist) { InitializeGuaranteedProperties(); }
public IPlaneEntity PlaneByLineAndPoint(ILineEntity line, IPointEntity point) { throw new NotImplementedException(); }
private Line(ILineEntity entity, bool persist = false) : base(entity, persist) { InitializeGuaranteedProperties(); }
public void WriteObject(ILineEntity line) { WriteEntity("StartPoint", line.StartPoint); WriteEntity("EndPoint", line.EndPoint); }