コード例 #1
0
ファイル: Line.cs プロジェクト: radumg/DesignScriptStudio
        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);
        }
コード例 #2
0
        internal override IGeometryEntity[] IntersectWithPlane(Plane plane)
        {
            ILineEntity line = PlaneEntity.IntersectWith(plane.PlaneEntity);

            if (null != line)
            {
                return new IGeometryEntity[] { line }
            }
            ;

            return(null);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        /// <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());
                        }
                    }
                }
            }
        }
コード例 #6
0
        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));
                    }
                }
            }
        }
コード例 #7
0
ファイル: Line.cs プロジェクト: radumg/DesignScriptStudio
        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);
        }
コード例 #8
0
 internal static Line ToLine(this ILineEntity host, bool persist, Geometry context)
 {
     return(host.ToGeometry <Line, ILineEntity>(persist, context));
 }
コード例 #9
0
ファイル: Line.cs プロジェクト: radumg/DesignScriptStudio
 private DSLine(ILineEntity entity, bool persist = false)
     : base(entity, persist)
 {
     InitializeGuaranteedProperties();
 }
コード例 #10
0
ファイル: GeometryFactory.cs プロジェクト: hipigod/Dynamo
 public IPlaneEntity PlaneByLineAndPoint(ILineEntity line, IPointEntity point)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
ファイル: Line.cs プロジェクト: samuto/designscript
 private Line(ILineEntity entity, bool persist = false)
     : base(entity, persist)
 {
     InitializeGuaranteedProperties();
 }
コード例 #12
0
 public void WriteObject(ILineEntity line)
 {
     WriteEntity("StartPoint", line.StartPoint);
     WriteEntity("EndPoint", line.EndPoint);
 }
コード例 #13
0
ファイル: GeometryFactory.cs プロジェクト: RobertiF/Dynamo
 public IPlaneEntity PlaneByLineAndPoint(ILineEntity line, IPointEntity point) { throw new NotImplementedException(); }