コード例 #1
0
ファイル: Point.cs プロジェクト: samuto/designscript
 public int IndexOfNearest(DSGeometry[] contextGeometries)
 {
     if (contextGeometries == null)
         throw new System.ArgumentNullException("contextGeometries");
     IGeometryEntity[] hostentities = contextGeometries.ConvertAll(DSGeometryExtension.ToEntity<DSGeometry, IGeometryEntity>);
     if(hostentities == null)
         throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "contextGeometries", "IndexOfNearest"), "contextGeometries");
     return GetIndexOfNearestGeometry(hostentities, PointEntity);
 }
コード例 #2
0
ファイル: Point.cs プロジェクト: samuto/designscript
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public DSGeometry SelectNearest(DSGeometry[] contextGeometries)
 {
     if (contextGeometries == null)
         throw new System.ArgumentNullException("contextGeometries");
     IGeometryEntity[] hostentities = contextGeometries.ConvertAll(DSGeometryExtension.ToEntity<DSGeometry, IGeometryEntity>);
     if(hostentities == null)
         throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "contextGeometries", "SelectNearest"), "contextGeometries");
     int nearestIndex = GetIndexOfNearestGeometry(hostentities, PointEntity);
     IGeometryEntity nearestGeom = hostentities[nearestIndex];
     return DSGeometry.ToGeometry(nearestGeom, false); //returning one of the existing geometry, so persist is no-op.
 }
コード例 #3
0
ファイル: Block.cs プロジェクト: samuto/designscript
        /// <summary>
        /// Creates a block with the given name, reference coordinate system and from the
        /// specified geometries
        /// </summary>
        /// <param name="blockName">the block name</param>
        /// <param name="referenceCoordinateSystem">the reference coordinate system</param>
        /// <param name="contents">the geometries contained in the block</param>
        /// <returns></returns>
        public static DSBlock FromGeometry(string blockName, DSCoordinateSystem referenceCoordinateSystem,
            DSGeometry[] contents)
        {
            string kMethodName = "DSBlock.FromGeometry";
            if (null == referenceCoordinateSystem)
                throw new ArgumentNullException("contextCoordinateSystem");
            if (string.IsNullOrEmpty(blockName))
                throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, blockName, kMethodName), "blockName");

            IGeometryEntity[] hosts = contents.ConvertAll(DSGeometryExtension.ToEntity<DSGeometry, IGeometryEntity>);
            if (null == hosts || hosts.Length == 0)
                throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, "geometries", kMethodName), "geometries");

            IBlockHelper helper = HostFactory.Factory.GetBlockHelper();
            if (null == helper)
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));

            if (helper.DefineBlock(referenceCoordinateSystem.CSEntity, blockName, hosts))
            {
                return new DSBlock(blockName);
            }

            return null;
        }