找回密码
 立即注册
查看: 2189|回复: 0

[原创] 练习 LispFuntion选集的交并差

[复制链接]
发表于 2014-7-19 10:54:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
并集

  1.         /// <summary>
  2.         /// 选择集并集
  3.         /// </summary>
  4.         /// <param name="rb">(选集1 选集2)</param>
  5.         /// <returns>选集</returns>
  6.         [LispFunction("SSUnion")]
  7.         public static object SSetUnion (ResultBuffer rb)
  8.         {
  9.             TypedValue[] values = rb.AsArray();
  10.             if (values.Length == 2 && values[0].TypeCode == (int) LispDataType.SelectionSet &&
  11.                 values[1].TypeCode == (int) LispDataType.SelectionSet)
  12.             {
  13.                 SelectionSet ss1 = (SelectionSet) values[0].Value;
  14.                 SelectionSet ss2 = (SelectionSet) values[1].Value;
  15.                 ObjectId[] ids1 = ss1.GetObjectIds();
  16.                 ObjectId[] ids2 = ss2.GetObjectIds();
  17.                 ObjectId[] ids = new ObjectId[ids1.Length + ids2.Length];
  18.                 ids1.CopyTo(ids, 0);
  19.                 ids2.CopyTo(ids, ids1.Length);
  20.                 SelectionSet ss = SelectionSet.FromObjectIds(ids );
  21.                 return ss;
  22.             }
  23.             return null;
  24.         }
复制代码

交集
/// <summary> /// 选择集交集 /// </summary> /// <param name="rb">(选集1 选集2)</param> /// <returns>选集 or nil</returns> [LispFunction("SSIntersect")] public static object SSetInters(ResultBuffer rb) { TypedValue[] values = rb.AsArray(); if (values.Length == 2 && values[0].TypeCode == (int) LispDataType.SelectionSet && values[1].TypeCode == (int) LispDataType.SelectionSet) { SelectionSet ss1 = (SelectionSet) values[0].Value; SelectionSet ss2 = (SelectionSet) values[1].Value; List<ObjectId> lst1 = ss1.GetObjectIds().ToList(); List<ObjectId> lst2 = ss2.GetObjectIds().ToList(); if (lst1.Count < lst2.Count ) { var query = from id in lst1
展开

差集
[LispFunction("SSSubtrcat")] public static object SSetSubtrcat(ResultBuffer rb) { TypedValue[] values = rb.AsArray(); if (values.Length == 2 && values[0].TypeCode == (int)LispDataType .SelectionSet && values[1].TypeCode == (int)LispDataType .SelectionSet ) { SelectionSet ss1 = (SelectionSet) values[0].Value; SelectionSet ss2 = (SelectionSet) values[1].Value; List<ObjectId> lst1 = ss1.GetObjectIds().ToList(); List<ObjectId> lst2 = ss2.GetObjectIds().ToList(); var query = from id in lst1 where !lst2.Contains(id) select id; if (query.Count() > 0) { ObjectId[] ids = new ObjectId[query.Count()]; int i = 0; foreach (ObjectId objectId in query)
展开

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2026-12-1 21:59 , Processed in 0.175331 second(s), 24 queries , Gzip On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表