- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[ 本帖最后由 csharp 于 2014-5-7 18:09 编辑 ]\n\n[url]http://read.pudn.com/downloads173/sourcecode/windows/csharp/802272/sCur.cs__.htm[/url]
- using System;
- using System.Diagnostics;
- using System.Windows.Forms;
- using System.Reflection;
- using System.IO;
- using System.Runtime.InteropServices;
- using Yekai.CsArx.Geometry;
- using Yekai.CsArx.Enum;
- using Yekai.CsArx.Function;
- using Yekai.CsArx.AcadCom;
-
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.Colors;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.Windows;
- using Autodesk.AutoCAD.GraphicsInterface;
- using Autodesk.AutoCAD.Interop.Common;
- using app = Autodesk.AutoCAD.ApplicationServices.Application;
- using AColor = Autodesk.AutoCAD.Colors.Color;
-
- namespace Yekai.CsArx
- {
- /// <summary>
- /// 曲线操作类
- /// Version : 2009.06.11
- /// 备注:上传[url]www.pudn.com[/url]
- /// </summary>
- public class sCur
- {
- #region Join Break Union Trim Loop Simulate Curve
- #region dealwith curve
- /// <summary>
- /// 获取封闭多义线外偏移线
- /// Version : 2007.11.05
- /// 本函数应被adb.OffsetLoop替代
- /// </summary>
- /// <param name="closeCur">封闭多义线</param>
- /// <param name="offsetDist">偏移距离</param>
- /// <param name="useSimulate">若直接偏移不成功是否使用模拟线</param>
- /// <param name="stepDist">使用模拟线时的节点距离</param>
- /// <returns>成功返回Polyline,否则返回null</returns>
- public static Polyline OffsetssOutLoop(Polyline closeCur, double offsetDist, bool useSimulate, double stepDist)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop start ");
- if (closeCur == null || !closeCur.Closed) return null;
- Polyline pLine = null;
-
- DBObjectCollection objClt = closeCur.GetOffsetCurves(offsetDist);
- if (objClt != null && objClt.Count == 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 1 ");
- pLine = (Polyline)objClt[0];
- if (pLine.Area > closeCur.Area)
- return pLine;
- }
- else if (objClt != null && objClt.Count > 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 2 ");
- pLine = sCur.LoopCurve(objClt);
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
-
- }
- objClt = closeCur.GetOffsetCurves(-offsetDist);
- if (objClt != null && objClt.Count == 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 3 ");
- pLine = (Polyline)objClt[0];
- if (pLine.Area > closeCur.Area)
- return pLine;
-
- }
- else if (objClt != null && objClt.Count > 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 4 ");
- pLine = sCur.LoopCurve(objClt);
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
- }
- Int16 OffsetGapType_old = (Int16)app.GetSystemVariable("OffsetGapType");
- //OffsetGapType_old = (int)tVar;
- if (OffsetGapType_old != 1)
- {
- app.SetSystemVariable("OffsetGapType", 1);
- pLine = sCur.OffsetLoop(closeCur, offsetDist, useSimulate, stepDist);
- app.SetSystemVariable("OffsetGapType", OffsetGapType_old);
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
- }
- if (useSimulate)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 5 ");
- pLine = sCur.SimulatePolyline(closeCur, stepDist);
- return sCur.OffsetLoop(pLine, offsetDist, false, 0);
- }
- return null;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 获取封闭多义线外偏移线
- /// Version: 2008.02.19
- /// </summary>
- /// <param name="closeCur">封闭多义线</param>
- /// <param name="offsetDist">偏移距离,负数向内偏移,正数向外偏移,等于0返回曲线拷贝</param>
- /// <param name="useSimulate">若直接偏移不成功是否使用模拟线</param>
- /// <param name="stepDist">使用模拟线时的节点距离</param>
- /// <returns>成功返回Polyline,否则返回null</returns>
- public static Polyline OffsetLoop(Polyline closeCur, double offsetDist, bool useSimulate, double stepDist)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop start ");
- if (closeCur == null || !closeCur.Closed) return null;
- if (offsetDist == 0.0) return (Polyline)closeCur.Clone();
- Polyline pLine = null;
-
- DBObjectCollection objClt = closeCur.GetOffsetCurves(offsetDist);
- if (objClt != null && objClt.Count == 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 1 ");
- pLine = (Polyline)objClt[0];
- if (offsetDist > 0)
- {
- if (pLine.Area > closeCur.Area)
- return pLine;
- }
- else
- {
- if (pLine.Area < closeCur.Area)
- return pLine;
- }
- }
- else if (objClt != null && objClt.Count > 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 2 ");
- pLine = sCur.LoopCurve(objClt);
- if (offsetDist > 0)
- {
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
- }
- else
- {
- if (pLine != null && pLine.Area < closeCur.Area)
- return pLine;
- }
- }
- objClt = closeCur.GetOffsetCurves(-offsetDist);
- if (objClt != null && objClt.Count == 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 3 ");
- pLine = (Polyline)objClt[0];
- if (offsetDist > 0)
- {
- if (pLine.Area > closeCur.Area)
- return pLine;
- }
- else
- {
- if (pLine.Area < closeCur.Area)
- return pLine;
- }
- }
- else if (objClt != null && objClt.Count > 1)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 4 ");
- pLine = sCur.LoopCurve(objClt);
- if (offsetDist > 0)
- {
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
- }
- else
- {
- if (pLine != null && pLine.Area < closeCur.Area)
- return pLine;
- }
- }
- Int16 OffsetGapType_old = (Int16)app.GetSystemVariable("OffsetGapType");
- //OffsetGapType_old = (int)tVar;
- if (OffsetGapType_old != 1)
- {
- app.SetSystemVariable("OffsetGapType", 1);
- pLine = sCur.OffsetLoop(closeCur, offsetDist, useSimulate, stepDist);
- app.SetSystemVariable("OffsetGapType", OffsetGapType_old);
- if (offsetDist > 0)
- {
- if (pLine != null && pLine.Area > closeCur.Area)
- return pLine;
- }
- else
- {
- if (pLine != null && pLine.Area < closeCur.Area)
- return pLine;
- }
- }
- if (useSimulate)
- {
- //smc.ed.WriteMessage("\nadb.OffsetOutLoop step 5 ");
- pLine = sCur.SimulatePolyline(closeCur, stepDist);
- return sCur.OffsetLoop(pLine, offsetDist, false, 0);
- }
- return null;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 从一个点获取点的AutoCAD实体包络线
- /// Version : 2009.03.011
- /// </summary>
- /// <param name="interP">点</param>
- /// <returns>成功返回一个封闭的Polyline曲线,否则返回null</returns>
- public static Curve GetLoop(Point3d interP)
- {
- try
- {
- PromptSelectionResult psRes1 = smc.ed.SelectLast();
- Curve reValue = null;
- if (psRes1.Status == PromptStatus.OK)
- {
- ObjectId lastId_Old = psRes1.Value.GetObjectIds()[0];
- //注意Boundary命令返回的轮廓实体有可能是Region或封闭的Polyline,此由AutoCAD系统变量HPBound来控制
- //HPBound == 1 是Polyline,HPBound == 0 是Region
- //也可以在Boundary命令中使用选项设定轮廓返回实体类型,
- //smc.doc.SendStringToExecute("._-Boundary A O P " + interP.X.ToString() + "," + interP.Y.ToString() + " ", true, false, false);
- CommandLine.Command("._-Boundary", interP, "");
- PromptSelectionResult psRes2 = smc.ed.SelectLast();
- ObjectId lastId_New = psRes2.Value.GetObjectIds()[0];
- if (lastId_New != lastId_Old)
- {
- using (Transaction ctrans = smc.db.TransactionManager.StartTransaction())
- {
- DBObject dbObj = ctrans.GetObject(lastId_New, OpenMode.ForWrite);
- if (dbObj is Curve)
- {
- Curve cur = (Curve)dbObj.Clone();
- if (cur.Closed)
- {
- reValue = cur;
- }
- }
- dbObj.Erase();
- ctrans.Commit();
- }
- }
- }
- return reValue;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- #endregion dealwith curve
- /// <summary>
- /// 将Line Arc LWPolyline 编辑成LWPolyline,能连接在一起的连接起来
- /// 要求端点相接
- /// Version : 2007.09.19
- /// 2007.11.01有改动,未做详细测试
- /// 2008.02.14 修改封闭曲线时导致出现零节点的问题
- /// </summary>
- /// <param name="cur1">第一曲线,若两条曲线连接成一条,则新曲线使用第一曲线一般属性(有例外),不应该为null</param>
- /// <param name="cur2">第二曲线,可以为null,这时是编辑单个实体</param>
- /// <param name="dTol">一个距离数值,用于作为判断两点重合的标准</param>
- /// <returns>成功返回Polyline,否则返回null</returns>
- public static Polyline JoinPolyline(Curve cur1, Curve cur2, double dTol)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.JoinPolyline start ");
- Polyline pline = null;
- if (cur1 == null || cur1.Closed) return null;
- if (!cur1.GetType().Equals(typeof(Polyline)))
- {
- #region !Polyline:Line Arc Polyline
- if (cur2 != null && cur2.GetType().Equals(typeof(Polyline)))
- {//第一曲线为非Polyline,而第二曲线为Polyline,这时以第二曲线作为第一曲线重新调用函数,此举只为减少代码
- return sCur.JoinPolyline(cur2, cur1, dTol);
- }
- pline = new Polyline();
- if (cur1.GetType().Equals(typeof(Line)))//Line:?
- {//曲线为 Line,使用其数据生成一个Polyline
- Line line = (Line)cur1;
- pline.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
- pline.AddVertexAt(1, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
- pline.SetPropertiesFrom(line);//使用原来实体属性
- if (cur2 != null)//若第二曲线不为空,则试图连接两者
- pline = sCur.JoinPolyline(pline, cur2, dTol);
- return pline;//将新生成的多义线提交到数据库
- }
- else if (cur1.GetType().Equals(typeof(Arc)))//Arc:?
- {//曲线为 Line,使用其数据生成一个Polyline
- Arc arc = (Arc)cur1;
- Point3d p1 = arc.GetPointAtParameter(arc.EndParam * 0.5 + arc.StartParam * 0.5);
- double dltAng = arc.EndAngle - arc.StartAngle;
- if (dltAng < 0.0) dltAng += smc.pi * 2;//圆弧的结束角比开始角大时
- double bulge = Math.Tan(dltAng / 4.0);
- if (fun.Clockwise(arc.StartPoint, p1, arc.EndPoint) == -1)//根据圆弧的时钟走向确定凸度正负
- bulge = -bulge;
- pline.AddVertexAt(0, new Point2d(arc.StartPoint.X, arc.StartPoint.Y), bulge, 0, 0);
- pline.AddVertexAt(1, new Point2d(arc.EndPoint.X, arc.EndPoint.Y), 0, 0, 0);
- pline.SetPropertiesFrom(arc);//使用原来实体属性
- if (cur2 != null)//若第二曲线不为空,则试图连接两者
- pline = sCur.JoinPolyline(pline, cur2, dTol);
- return pline;//将新生成的多义线提交到数据库
- }
- else
- {//本函数只处理Line Arc Polyline 三种类型曲线
- return null;
- }
- #endregion !Polyline:Line Arc Polyline
- }
- else if (cur1.GetType().Equals(typeof(Polyline)))
- {
- #region Polyline:Line Arc Polyline
-
- pline = (Polyline)cur1;
- if (pline.StartPoint.DistanceTo(pline.EndPoint) < dTol)
- {//曲线的起点和终点重合,将其封闭属性设置为true
- if (!pline.Closed)
- pline.Closed = true;
- return pline;
- }
- if (cur2 != null && cur2.GetType().Equals(typeof(Line)))
- {//第二曲线为Line,将其加入到多义线里,需注意是加入直线的远点
- #region Polyline:Line
- Line line = (Line)cur2;
- if (pline.EndPoint.DistanceTo(line.StartPoint) < dTol)
- {
- pline.AddVertexAt(pline.NumberOfVertices, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
- }
- else if (pline.EndPoint.DistanceTo(line.EndPoint) < dTol)
- {
- pline.AddVertexAt(pline.NumberOfVertices, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
- }
- else if (pline.StartPoint.DistanceTo(line.StartPoint) < dTol)
- {
- pline.AddVertexAt(0, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
- }
- else if (pline.StartPoint.DistanceTo(line.EndPoint) < dTol)
- {
- pline.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
- }
- #endregion Polyline:Line
- }
- else if (cur2 != null && cur2.GetType().Equals(typeof(Arc)))
- {
- #region Polyline:Arc
- //第二曲线为Arc,将其加入到多义线里,需注意凸度的计算及正负
- //凸度的大小由圆弧的圆周角计算可得,
- //凸度的正负先根据圆弧的时钟走向得到一个值,然后在根据圆弧的近点,中点,远点三点的时钟走向
- //还有在Polyline里是后加入还是前插入来最终确定正负
- Arc arc = (Arc)cur2;
- Point3d p1 = arc.GetPointAtParameter(arc.EndParam * 0.5 + arc.StartParam * 0.5);
- double dltAng = arc.EndAngle - arc.StartAngle;
- if (dltAng < 0.0) dltAng += smc.pi * 2;
- double bulge = Math.Tan(dltAng / 4.0);
- if (pline.EndPoint.DistanceTo(arc.StartPoint) < dTol)
- {//末端接入,根据圆弧近点,中点,远点确定凸度正负
- if (fun.Clockwise(arc.StartPoint, p1, arc.EndPoint) == -1)
- bulge = -bulge;
- pline.AddVertexAt(pline.NumberOfVertices, new Point2d(arc.EndPoint.X, arc.EndPoint.Y), 0, 0, 0);
- pline.SetBulgeAt(pline.NumberOfVertices - 2, bulge);//注意凸度段序号
- }
- else if (pline.EndPoint.DistanceTo(arc.EndPoint) < dTol)
- {//末端接入,根据圆弧近点,中点,远点确定凸度正负
- if (fun.Clockwise(arc.EndPoint, p1, arc.StartPoint) == -1)
- bulge = -bulge;
- pline.AddVertexAt(pline.NumberOfVertices, new Point2d(arc.StartPoint.X, arc.StartPoint.Y), 0, 0, 0);
- pline.SetBulgeAt(pline.NumberOfVertices - 2, bulge);
- }
- else if (pline.StartPoint.DistanceTo(arc.StartPoint) < dTol)
- {//开始端接入,根据圆弧远点,中点,近点确定凸度正负
- if (fun.Clockwise(arc.EndPoint, p1, arc.StartPoint) == -1)
- bulge = -bulge;
- pline.AddVertexAt(0, new Point2d(arc.EndPoint.X, arc.EndPoint.Y), bulge, 0, 0);
- }
- else if (pline.StartPoint.DistanceTo(arc.EndPoint) < dTol)
- {//开始端接入,根据圆弧远点,中点,近点确定凸度正负
- if (fun.Clockwise(arc.StartPoint, p1, arc.EndPoint) == -1)
- bulge = -bulge;
- pline.AddVertexAt(0, new Point2d(arc.StartPoint.X, arc.StartPoint.Y), bulge, 0, 0);
- }
- #endregion Polyline:Arc
- }
- else if (cur2 != null && cur2.GetType().Equals(typeof(Polyline)))
- {
- #region Polyline:Polyline
- Polyline pline2 = (Polyline)cur2;
- if (pline.EndPoint.DistanceTo(pline2.StartPoint) < dTol)
- { //第一曲线末端接入,第二曲线正向加入
- for (int i = 1; i < pline2.NumberOfVertices; i++)//一段段的读出,加入另外曲线
- {
- pline.AddVertexAt(pline.NumberOfVertices, pline2.GetPoint2dAt(i), 0, 0, 0);
- pline.SetBulgeAt(pline.NumberOfVertices - 2, pline2.GetBulgeAt(i - 1));//注意凸度段序号
- }
- }
- else if (pline.EndPoint.DistanceTo(pline2.EndPoint) < dTol)
- {//末端接入,第二曲线逆向加入,第二曲线原有凸度需反向
- for (int i = pline2.NumberOfVertices - 2; i >= 0; i--)
- {
- pline.AddVertexAt(pline.NumberOfVertices, pline2.GetPoint2dAt(i), 0, 0, 0);
- pline.SetBulgeAt(pline.NumberOfVertices - 2, -pline2.GetBulgeAt(i));
- }
- }
- else if (pline.StartPoint.DistanceTo(pline2.StartPoint) < dTol)
- {
- //第一曲线开始端入,第二曲线逆向加入,第二曲线原有凸度需反向
- for (int i = 1; i < pline2.NumberOfVertices; i++)
- {
- pline.AddVertexAt(0, pline2.GetPoint2dAt(i), 0, 0, 0);
- pline.SetBulgeAt(0, -pline2.GetBulgeAt(i - 1));
- }
- }
- else if (pline.StartPoint.DistanceTo(pline2.EndPoint) < dTol)
- {
- //第一曲线开始端入,第二曲线正向加入
- for (int i = pline2.NumberOfVertices - 2; i >= 0; i--)
- {
- pline.AddVertexAt(0, pline2.GetPoint2dAt(i), 0, 0, 0);
- pline.SetBulgeAt(0, pline2.GetBulgeAt(i));
- }
- }
- #endregion Polyline:Polyline
- }
- else
- {
- return null;
- }
- if (pline.StartPoint.DistanceTo(pline.EndPoint) < dTol) //如果曲线起点和终点重合,将Closed = true
- {
- pline.Closed = true;
- //2008.02.14注意:即使起点和终点已重合,pline.Closed = true还是会增加一个节点,导致多义线出现零节点
- pline.RemoveVertexAt(pline.NumberOfVertices - 1);
- }
- return pline;
- #endregion Polyline:Line Arc Polyline
- }
- return pline;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 连接多义线
- /// 对需要删除的实体调用erase函数,但没有提交
- /// 只能处理三种曲线类型Line Arc LWPolyline(Polyline)
- /// Version : 2008.01.23
- /// </summary>
- /// <param name="dbClt">实体集合,可以包含非多义线实体</param>
- /// <param name="dTol">连接的间隔</param>
- /// <returns>成功返回连接后的实体集合,可能包含非多义线实体,否则返回null</returns>
- public static DBObjectCollection JoinPolyline(DBObjectCollection dbClt, double dTol)
- {
- try
- {
- if (dbClt == null) return null;
- Point3dCollection stPs = new Point3dCollection();//起点集合
- Point3dCollection enPs = new Point3dCollection();//终点集合
- DBObjectCollection dbClt1 = new DBObjectCollection();
- DBObjectCollection dbClt2 = new DBObjectCollection();
- foreach (DBObject dbObj in dbClt)
- {
- if (dbObj.GetType().IsSubclassOf(typeof(Curve)))
- {
- Curve cur = (Curve)dbObj;
- if (cur.Closed)
- {
- dbClt1.Add(dbObj);
- }
- else
- {
- stPs.Add(fun.RoundPoint3d(cur.StartPoint));
- enPs.Add(fun.RoundPoint3d(cur.EndPoint));
- dbClt2.Add(dbObj);
- }
- }
- else
- {
- dbClt1.Add(dbObj);
- }
- }
- #region join Polyline
- DBObject[] arrObj = new DBObject[dbClt2.Count];
- //DBObject[] arrObj = (DBObject[])System.Array.CreateInstance(typeof(DBObject), dbClt2.Count);
- dbClt2.CopyTo(arrObj, 0);//将曲线id集合复制到数组,使用一个新集合应该耶可以,但担心会引用传递,没测试
- DBObjectCollection idClt = new DBObjectCollection();
- for (int i = 0; i < arrObj.Length; i++)
- {
- if (idClt.IndexOf(arrObj[i]) == -1)
- {//剔除已经处理过的曲线id,后面对ObjectId的检查应该是多余的,为保险而用
- Curve pline3 = (Curve)arrObj[i];
- Curve pline1 = pline3;
- if (!pline1.GetType().Equals(typeof(Polyline)))
- {
- pline1 = sCur.JoinPolyline(pline3, null, dTol);
- if (!pline3.IsNewObject)
- pline3.Erase();
- dbClt1.Add(pline1);
- }
- int pIndex2 = dbClt2.IndexOf(arrObj[i]);
- if (pIndex2 != -1)
- {
- stPs.RemoveAt(pIndex2);//从集合移除当前项,以免自己和自己连接
- enPs.RemoveAt(pIndex2);
- dbClt2.RemoveAt(pIndex2);
- }
- bool cont1 = true;
- while (cont1 && !pline1.Closed)
- {
- cont1 = false;
- int pIndex = stPs.IndexOf(fun.RoundPoint3d(pline1.StartPoint));
- if (pIndex == -1)
- pIndex = enPs.IndexOf(fun.RoundPoint3d(pline1.StartPoint));
- if (pIndex != -1)
- {//在起点或终点集合中找到当前曲线StartPoint重合点,下面对两条曲线连接
- Curve pline2 = (Curve)dbClt2[pIndex];
- Polyline pLine = sCur.JoinPolyline(pline1, pline2, dTol);
- if (!pline2.IsNewObject)
- pline2.Erase();
-
- cont1 = true;
- idClt.Add(dbClt2[pIndex]);//将处理过的项从集合移除
- stPs.RemoveAt(pIndex);
- enPs.RemoveAt(pIndex);
- dbClt2.RemoveAt(pIndex);
- pline1 = pLine;
- }
- if (!pline1.Closed)//曲线封闭,这个曲线的编辑结束
- {
- pIndex = enPs.IndexOf(fun.RoundPoint3d(pline1.EndPoint));
- if (pIndex == -1)
- pIndex = stPs.IndexOf(fun.RoundPoint3d(pline1.EndPoint));
- if (pIndex != -1)
- {//在起点或终点集合中找到当前曲线EndPoint重合点,下面对两条曲线连接
- Curve pline2 = (Curve)dbClt2[pIndex];
- Polyline pLine = sCur.JoinPolyline(pline1, pline2, dTol);
- if (!pline2.IsNewObject)
- pline2.Erase();
- cont1 = true;
- idClt.Add(dbClt2[pIndex]);//将处理过的项从集合移除
- stPs.RemoveAt(pIndex);
- enPs.RemoveAt(pIndex);
- dbClt2.RemoveAt(pIndex);
- pline1 = pLine;
- }
- }
- }
- }
- }
- return dbClt1;
- #endregion join Polyline
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 将多个组成环型的曲线连接起来
- /// Version : 2008.01.29
- /// </summary>
- /// <param name="curves">多个组成环型的曲线</param>
- /// <returns>成功返回Polyline,否则返回null</returns>
- public static Polyline LoopCurve(DBObjectCollection curves)
- {
- try
- {
- if (curves == null) return null;
- DBObjectCollection dbClt1 = new DBObjectCollection();
- foreach (DBObject dbObj in curves)
- {
- if (dbObj.GetType().IsSubclassOf(typeof(Curve)))
- {
- Curve cur = (Curve)dbObj;
- //曲线不封闭且头尾端点不相接的曲线
- if (!cur.Closed && cur.GetDistanceAtParameter(cur.EndParam) > 0.0001)
- {
- dbClt1.Add(cur);
- }
- }
- }
- if (dbClt1.Count == 0) return null;
- DBObjectCollection dbClt2 = new DBObjectCollection();
- Curve curCurve = (Curve)dbClt1[0];
- dbClt2.Add(curCurve);
- Point3d curEnd = curCurve.EndPoint;
- Point3dCollection prePClt = new Point3dCollection();
- Point3dCollection pstPClt = new Point3dCollection();
- prePClt.Add(curCurve.StartPoint);
- pstPClt.Add(curCurve.EndPoint);
- while (dbClt2.Count < dbClt1.Count)
- {
- bool firstValue = true;
- double curDist = 0;
- int nearIndex = 0;
- bool endStartType = true;
- for (int i = 0; i < dbClt1.Count; i++)
- {
- if (dbClt2.IndexOf(dbClt1[i]) < 0)
- {
- Curve cur2 = (Curve)dbClt1[i];
- double dist1 = curEnd.DistanceTo(cur2.StartPoint);
- double dist2 = curEnd.DistanceTo(cur2.EndPoint);
- if (firstValue)
- {
- if (dist1 < dist2)
- {
- curDist = dist1;
- endStartType = true;
- }
- else
- {
- curDist = dist2;
- endStartType = false;
- }
- firstValue = false;
- nearIndex = i;
- }
- else if (curDist > Math.Min(dist1, dist2))
- {
- if (dist1 < dist2)
- {
- curDist = dist1;
- endStartType = true;
- }
- else
- {
- curDist = dist2;
- endStartType = false;
- }
- nearIndex = i;
- }
- }
- }
- curCurve = (Curve)dbClt1[nearIndex];
- if (endStartType)
- {
- curEnd = curCurve.StartPoint;
- prePClt.Add(curCurve.StartPoint);
- pstPClt.Add(curCurve.EndPoint);
- }
- else
- {
- curEnd = curCurve.EndPoint;
- prePClt.Add(curCurve.EndPoint);
- pstPClt.Add(curCurve.StartPoint);
- }
- dbClt2.Add(curCurve);
- }
- DBObjectCollection dbClt3 = new DBObjectCollection();
- dbClt3.Add(dbClt2[0]);
- for (int i = 1; i < dbClt2.Count; i++)
- {
- if (pstPClt[i - 1].DistanceTo(prePClt[i]) > 0.0001)
- {
- Line tLine = new Line(pstPClt[i - 1], prePClt[i]);
- dbClt3.Add(tLine);
- }
- dbClt3.Add(dbClt2[i]);
- }
- if (pstPClt[dbClt2.Count - 1].DistanceTo(prePClt[0]) > 0.0001)
- {
- Line tLine = new Line(pstPClt[dbClt2.Count - 1], prePClt[0]);
- dbClt3.Add(tLine);
- }
- //Tolerance dTol = new Tolerance(0.0001, 0.0001);
- Polyline pLine = sCur.JoinPolyline((Curve)dbClt3[0], null, 0.0001);
- for (int i = 1; i < dbClt3.Count; i++)
- {
- //Curve cur = (Curve)dbClt3[i];
- //ent.ColorIndex = 50 + i;
- pLine = sCur.JoinPolyline(pLine, (Curve)dbClt3[i], 0.0001);
- }
- // adb.DrawEntity(dbClt3, sEntclls.Null, false);
-
- return pLine;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 剪切曲线,被剪切线的与切割线交点到trimPoint部分被切除
- /// Note :
- /// 1,trimPoint不要求在被剪切线上,
- /// 2,实体不提交到数据库,但对被删除实体使用了Erase()方法
- /// Version : 2008.01.08
- /// </summary>
- /// <param name="trimLine">切割线</param>
- /// <param name="curveBeTrim">被剪切曲线线</param>
- /// <param name="trimPoint">切除位置点,用于确认去除曲线的部分</param>
- /// <returns>成功返回剪切后剩下的实体集合,否则返回null</returns>
- public static DBObjectCollection TrimCurve(Curve trimLine, Curve curveBeTrim, Point3d trimPoint, bool extendTrimLine)
- {
- try
- {
- //smc.ed.WriteMessage("\nsCur.TrimCurve B1");
- if (trimLine == null || curveBeTrim == null) return null;
- Point3dCollection points = new Point3dCollection();
- if (extendTrimLine)
- {
- points = sEnt.IntersectWith(trimLine, curveBeTrim, Intersect.ExtendThis);
- }
- else
- {
- points = sEnt.IntersectWith(trimLine, curveBeTrim, Intersect.OnBothOperands);
- }
- if (points == null || points.Count == 0)
- {
- return null;
- }
- DoubleCollection dc1 = new DoubleCollection();
- for (int i = 0; i < points.Count; i++)
- {
- double param1 = curveBeTrim.GetParameterAtPoint(points[i]);
- if (dc1.Count == 0)
- {
- dc1.Add(param1);
- }
- else
- {
- if (param1 <= dc1[0])
- dc1.Insert(0, param1);
- else if (param1 > dc1[dc1.Count - 1])
- dc1.Add(param1);
- else
- {
- for (int j = 1; j < dc1.Count; j++)
- {
- if (param1 <= dc1[j])
- {
- dc1.Insert(j, param1);
- break;
- }
- }
- }
- }
- }
- DBObjectCollection reClt = new DBObjectCollection();
- DBObjectCollection dbClt1 = curveBeTrim.GetSplitCurves(dc1);
- if (dbClt1 != null)
- {
- foreach (DBObject dbObj in dbClt1)
- {
- Curve cur3 = (Curve)dbObj;
- Point3d p1 = cur3.GetPointAtParameter((cur3.EndParam + cur3.StartParam) / 2.0);
- Point3dCollection ps2 = new Point3dCollection();
- Line l1 = new Line(p1, trimPoint);
- if (extendTrimLine)
- {
- ps2 = sEnt.IntersectWith(trimLine, l1, Intersect.ExtendThis);
- }
- else
- {
- ps2 = sEnt.IntersectWith(trimLine, l1, Intersect.OnBothOperands);
- }
- if (ps2.Count % 2 == 1)//根据交点数判断曲线的位置,奇数为保留侧,偶数为去处侧
- {
- reClt.Add(cur3);
- }
- }
- }
- if (!curveBeTrim.IsNewObject)
- {
- curveBeTrim.Erase();
- }
- return reClt;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 取曲线内部一点有待改进
- /// 切除曲线里面或外面部分
- /// Version : 2008.03.12
- /// </summary>
- /// <param name="trimLine">切割线:封闭曲线或为null,为null时使用dbClt第一曲线为切割线</param>
- /// <param name="dbClt">被切割的曲线</param>
- /// <param name="trimOut">true切除切割线外面部分,false切除切割线里面部分</param>
- /// <returns>成功返回剪切后剩下的实体集合,否则返回null</returns>
- public static DBObjectCollection TrimCurve(Curve trimLine, DBObjectCollection dbClt, bool trimOut)
- {
- try
- {
- //smc.ed.WriteMessage("\nsCur.TrimCurve 1");
- if (dbClt == null || dbClt.Count == 0) return null;
- bool trimType = true;
- if (trimLine == null)
- {
- if (dbClt[0].GetType().IsSubclassOf(typeof(Curve)))
- {
- trimLine = (Curve)dbClt[0];
- trimType = false;
- }
- else
- {
- return null;
- }
- }
- if (!trimLine.Closed)
- {
- return null;
- }
- Point3d trimPoint = trimLine.GeomExtents.MaxPoint + new Vector3d(1, 1, 0);
- if (!trimOut)
- trimPoint = fun.MidPoint(trimLine.GeomExtents.MaxPoint, trimLine.GeomExtents.MinPoint);
-
- DBObjectCollection reValue = new DBObjectCollection();
- for (int i = (trimType ? 0 : 1); i < dbClt.Count; i++)
- {
- if (dbClt[i].GetType().IsSubclassOf(typeof(Curve)))
- {
- Curve cur = (Curve)dbClt[i];
-
- Point3dCollection points1 = sEnt.IntersectWith(trimLine, cur, Intersect.OnBothOperands);
- if (points1 == null || points1.Count == 0)
- {
- Line l1 = new Line(cur.StartPoint, trimPoint);
- Point3dCollection points2 = sEnt.IntersectWith(trimLine, l1, Intersect.OnBothOperands);
- if (points2.Count % 2 == 1)
- {
- reValue.Add(cur);
- }
- }
- else
- {
- fun.CollectionAdd(reValue, sCur.TrimCurve(trimLine, cur, trimPoint, false));
- }
- }
- }
- return reValue;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 方向性切除或内外切除,或视图式切除
- /// 切割线内外侧或一侧的实体被切除
- /// 切割线会在返回集合里面,并刚好封闭切口
- /// Version : 2008.12.02
- /// Note : 只测试了直线Line类型切割线
- /// </summary>
- /// <param name="trimLine">切割线</param>
- /// <param name="dbClt">被切割集合</param>
- /// <param name="trimPoint">切割点,决定切除侧</param>
- /// <returns>成功返回集合,否则返回null</returns>
- public static DBObjectCollection TrimSide(Curve trimLine, DBObjectCollection dbClt, Point3d trimPoint)
- {
- try
- {
- if (trimLine == null || dbClt == null || dbClt.Count == 0) return null;
- DBObjectCollection reValue = new DBObjectCollection();
- Point3dCollection pClt = new Point3dCollection();
- if (trimLine.Closed)
- {
- #region 切割线是封闭曲线
- Extents3d tExt = sEnt.GetExtend3d(dbClt);
- if (trimPoint.X > tExt.MinPoint.X && trimPoint.X < tExt.MaxPoint.X &&
- trimPoint.Y > tExt.MinPoint.Y && trimPoint.Y < tExt.MaxPoint.Y)
- reValue = sCur.TrimCurve(trimLine, dbClt, false);
- else
- reValue = sCur.TrimCurve(trimLine, dbClt, true);
- fun.CollectionAdd(reValue, trimLine);
- return reValue;
- #endregion 切割线是封闭曲线
- }
- else if (trimLine is Line)
- {
- #region 切割线是直线Line,方向性切割
- Line l1 = (Line)trimLine;
- Vector3d trimVec = fun.VerticalVector(trimPoint, l1);
- foreach (Entity ent in dbClt)
- {
- if (ent is Curve)
- {
- Curve cur = (Curve)ent;
- Point3dCollection points = sEnt.IntersectWith(l1, cur, Intersect.OnBothOperands);
- if (points == null || points.Count == 0)
- {
- if (fun.VerticalVector(cur.StartPoint, l1).Negate().IsCodirectionalTo(trimVec))
- {
- fun.CollectionAdd(reValue, cur);
- }
- }
- else
- {
- fun.CollectionAdd(reValue, sCur.TrimCurve(l1, cur, trimPoint, false));
- foreach (Point3d tp in points)
- {
- pClt.Add(tp);
- }
- }
- }
- else
- {
- if (fun.VerticalVector(fun.MidPoint(ent.GeomExtents), l1).Negate().IsCodirectionalTo(trimVec))
- {
- fun.CollectionAdd(reValue, ent);
- }
- }
- }
- if (pClt.Count > 0)
- {
- Point3d p21 = pClt[0];
- Point3d p22 = pClt[0];
- foreach (Point3d tp in pClt)
- {
- if (tp.DistanceTo(l1.StartPoint) < p21.DistanceTo(l1.StartPoint))
- p21 = tp;
- if (tp.DistanceTo(l1.EndPoint) < p22.DistanceTo(l1.EndPoint))
- p22 = tp;
- }
- l1.StartPoint = p21;
- l1.EndPoint = p22;
- fun.CollectionAdd(reValue, l1);
- }
- else
- fun.CollectionAdd(reValue, l1);
- #endregion 切割线是直线Line,方向性切割
- }
- else
- {
- #region 切割线是不封闭的曲线,方向性切割
-
- //smc.ed.WriteMessage("\nsCur.TrimSide dbClt.Count = {0}", dbClt.Count);
- int clockSize1 = fun.Clockwise(trimLine.StartPoint, trimPoint, trimLine.EndPoint);
- //Vector3d trimVec = fun.VerticalVector(trimPoint, trimLine);
- foreach (Entity ent in dbClt)
- {
- Point3dCollection points = sEnt.IntersectWith(trimLine, ent, Intersect.OnBothOperands);
- if (points == null || points.Count == 0)
- {
- Point3d p2 = trimLine.GetClosestPointTo(fun.MidPoint(ent.GeomExtents), false);
- double dist2 = trimLine.GetDistAtPoint(p2);
- double dist21 = dist2 - 0.001 < 0 ? 0 : dist2 - 0.001;
- double dist22 = dist2 + 0.001 > trimLine.GetDistanceAtParameter(trimLine.EndParam) ? trimLine.GetDistanceAtParameter(trimLine.EndParam) : dist2 + 0.001;
- Point3d p21 = trimLine.GetPointAtDist(dist21);
- Point3d p22 = trimLine.GetPointAtDist(dist22);
- int clockSize2 = fun.Clockwise(p21, fun.MidPoint(ent.GeomExtents), p22);
- if (clockSize1 != clockSize2)
- fun.CollectionAdd(reValue, ent);
- }
- else
- {
- if (ent is Curve)
- {
- DBObjectCollection dbClt1 = sCur.TrimCurve(trimLine, (Curve)ent, trimPoint, false);
- if (dbClt1 != null && dbClt1.Count > 0)
- {
- fun.CollectionAdd(reValue, dbClt1);
- foreach (Point3d tp in points)
- {
- pClt.Add(tp);
- }
- }
- }
- else
- {
- fun.CollectionAdd(reValue, ent);
- }
- }
- }
- smc.ed.WriteMessage("\nsCur.TrimSide ");
- //return null;
- if (pClt.Count > 0)
- {
-
- Point3d p21 = pClt[0];
- Point3d p22 = pClt[0];
- foreach (Point3d tp in pClt)
- {
- if (trimLine.GetParameterAtPoint(tp) < trimLine.GetParameterAtPoint(p21))
- p21 = tp;
- if (trimLine.GetParameterAtPoint(tp) > trimLine.GetParameterAtPoint(p22))
- p22 = tp;
- }
- if (trimLine.StartPoint.DistanceTo(p21) > 0.01 && trimLine.EndPoint.DistanceTo(p22) > 0.01)
- {
- smc.ed.WriteMessage(" A1 ");
- DoubleCollection dClt = new DoubleCollection();
- dClt.Add(trimLine.GetParameterAtPoint(p21));
- dClt.Add(trimLine.GetParameterAtPoint(p22));
- DBObjectCollection dbClt1 = trimLine.GetSplitCurves(dClt);
- if (dbClt1 != null && dbClt1.Count > 1)
- {
- foreach (DBObject dbObj in dbClt1)
- {
- if (dbObj == null)
- {
- }
- }
- fun.CollectionAdd(reValue, dbClt1[1]);
- }
- }
- else if (trimLine.StartPoint.DistanceTo(p21) > 0.01)
- {
- smc.ed.WriteMessage(" A2 ");
- DoubleCollection dClt = new DoubleCollection();
- dClt.Add(trimLine.GetParameterAtPoint(p21));
- DBObjectCollection dbClt1 = trimLine.GetSplitCurves(dClt);
- if (dbClt1 != null && dbClt1.Count > 1)
- {
- foreach (DBObject dbObj in dbClt1)
- {
- if (dbObj == null)
- {
- }
- }
- fun.CollectionAdd(reValue, dbClt1[1]);
- }
- }
- else if (trimLine.EndPoint.DistanceTo(p22) > 0.01)
- {
- smc.ed.WriteMessage(" A3 ");
- DoubleCollection dClt = new DoubleCollection();
- dClt.Add(trimLine.GetParameterAtPoint(p22));
- DBObjectCollection dbClt1 = trimLine.GetSplitCurves(dClt);
- if (dbClt1 != null && dbClt1.Count > 0)
- {
- foreach (DBObject dbObj in dbClt1)
- {
- if (dbObj == null)
- {
- }
- }
- fun.CollectionAdd(reValue, dbClt1[0]);
- }
- }
- else
- {
- smc.ed.WriteMessage(" A4 ");
- }
- }
- else
- {
- smc.ed.WriteMessage(" A5 ");
- fun.CollectionAdd(reValue, trimLine);
- }
- #endregion 切割线是不封闭的曲线,方向性切割
- }
- return reValue;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 视图弦切
- /// Version : 2009.01.16
- /// </summary>
- /// <param name="dbClt"></param>
- /// <param name="center"></param>
- /// <param name="chordVec"></param>
- /// <param name="direction"></param>
- /// <returns></returns>
- public static DBObjectCollection ChordTrim(DBObjectCollection dbClt, Point3d center, Vector3d chordVec, Directions direction)
- {
- try
- {
- if (dbClt == null || dbClt.Count == 0) return null;
- if (chordVec.IsZeroLength()) return dbClt;
- Extents3d ext = sEnt.GetExtend3d(dbClt);
- switch (direction)
- {
- case Directions.RIGHT:
- case Directions.FRONT:
- {
- int iDrec = chordVec.X > 0 ? 1 : -1;
- Point3d p1 = new Point3d(center.X + chordVec.Length*iDrec, ext.MaxPoint.Y, 0);
- Point3d p2 = new Point3d(center.X + chordVec.Length * iDrec, ext.MinPoint.Y, 0);
- Point3d p3 = p1 + new Vector3d(10 * iDrec, 0, 0);
- Line l1 = new Line(p1, p2);
- return sCur.TrimSide(l1, dbClt, p3);
- }
- case Directions.UP:
- default:
- {
- Vector3d tVec1 = chordVec.RotateBy(smc.pi2, Vector3d.ZAxis).GetNormal();
- Point3d p1 = center + chordVec + tVec1 * ext.MaxPoint.DistanceTo(ext.MinPoint);
- Point3d p2 = center + chordVec - tVec1 * ext.MaxPoint.DistanceTo(ext.MinPoint);
- Point3d p3 = p1 + chordVec;
- Line l1 = new Line(p1, p2);
- return sCur.TrimSide(l1, dbClt, p3);
- }
- }
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 打断曲线
- /// </summary>
- /// <param name="curve">曲线对象</param>
- /// <param name="p1">第一个打断点</param>
- /// <param name="p2">第二个打断点</param>
- /// <returns>正常结束返回true,否则返回false</returns>
- public static bool BreakCurve(Curve curve, Point3d p1, Point3d p2)
- {
- try
- {
- if (curve == null) return false;
- Point3d p11 = curve.GetClosestPointTo(p1, false);
- double param1 = curve.GetParameterAtPoint(p11);
- Point3d p21 = curve.GetClosestPointTo(p2, false);
- double param2 = curve.GetParameterAtPoint(p21);
- DoubleCollection dColl = new DoubleCollection(2);
- if (param1 < param2)
- {
- dColl.Add(param1);
- dColl.Add(param2);
- }
- else
- {
- dColl.Add(param2);
- dColl.Add(param1);
- }
- DBObjectCollection objColl = curve.GetSplitCurves(dColl);
- foreach (DBObject obj in objColl)
- {//完成对DBObjectCollection 的初始化,这是因为DBObjectCollection bug而采取的动作
- if (obj == null)
- throw new InvalidOperationException();
- }
- Entity ent;
- if (objColl.Count == 2)
- {
- ent = (Entity)objColl[1];
- adb.DrawEntity(ent);
- }
- else if (objColl.Count == 3)
- {
- ent = (Entity)objColl[0];
- adb.DrawEntity(ent);
- // ent = (Entity)objColl[1];//注意:若没有这一句,系统会捕捉到错误,如下:
- //here catch System.Exception ex
- //ex.Message = Insertion index was out of range. Must be non-negative and
- //less than or equal to size.
- //Parameter name: index
- //错误应该是不能访问objColl[2]
- //adb.DrawEntity(ent);
- ent = (Entity)objColl[2];//注意:若没有前面一句,系统会在这里捕捉到错误,如上:
- adb.DrawEntity(ent);
- }
- curve.Erase();
- return true;
- }
-
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return false;
- }
- }
- /// <summary>
- /// 延伸或缩短extendCur到frameCur曲线轮廓,使得extendCur的端点在frameCur曲线上
- /// Version : 2008.03.018
- /// 对多义线Polyline没有考虑周详
- /// </summary>
- /// <param name="extendCur"></param>
- /// <param name="frameCur"></param>
- /// <returns></returns>
- public static bool ExtendToCurve(Curve extendCur, Curve frameCur)
- {
- try
- {
- if (extendCur == null || frameCur == null) return false;
- if (!frameCur.Closed) return false;
- Point3dCollection inters = sEnt.IntersectWith(extendCur, frameCur, Intersect.ExtendThis);
- if (inters.Count != 2) return false;
- if (extendCur.Closed)
- {
- DBObjectCollection dbClt1 = new DBObjectCollection();
- dbClt1.Add(extendCur);
- DBObjectCollection dbClt2 = sCur.TrimCurve(frameCur, dbClt1, true);
- if (dbClt2 != null && dbClt2.Count > 0)
- {
- extendCur = (Curve)dbClt2[0];
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- if (extendCur.StartPoint.DistanceTo(inters[0]) < extendCur.EndPoint.DistanceTo(inters[1]))
- {
- extendCur.Extend(true, inters[0]);
- extendCur.Extend(false, inters[1]);
- }
- else
- {
- extendCur.Extend(false, inters[0]);
- extendCur.Extend(true, inters[1]);
- }
- return true;
- }
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return false;
- }
- }
- /// <summary>
- /// 从一个封闭曲线切除一部分
- /// </summary>
- /// <param name="beSubtractCur">被切除的封闭曲线</param>
- /// <param name="subtractCur">作为切除线的封闭曲线</param>
- /// <returns>成功返回一个封闭的多义线,否则返回null</returns>
- static public Polyline SubtractCurve(Curve beSubtractCur, Curve subtractCur)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionCurve(Curve cur1, Curve cur2)");
- if (subtractCur == null || beSubtractCur == null) return null;
- if (!subtractCur.Closed || !beSubtractCur.Closed) return null;
- Point3dCollection inters = sEnt.IntersectWith(subtractCur, beSubtractCur, Intersect.OnBothOperands);
- if (inters.Count < 2) return null;
-
- //若能使用在交点处打断曲线在连接的方式速度方面应该会快一些
- //但因曲线的形状和相交关系太复杂不能掌控,主要是没法判断去除打断后的哪一段曲线
- #region use Region union way
-
- DBObjectCollection dbClt1 = new DBObjectCollection();
- dbClt1.Add(beSubtractCur);
- DBObjectCollection dbClt2 = new DBObjectCollection();
- dbClt2.Add(subtractCur);
- DBObjectCollection dbClt3 = Region.CreateFromCurves(dbClt1);
- DBObjectCollection dbClt4 = Region.CreateFromCurves(dbClt2);
- if (dbClt3 == null || dbClt3.Count == 0)
- return null;
- if (dbClt4 == null || dbClt4.Count == 0)
- return null;
- Region reg1 = (Region)dbClt3[0];
- Region reg2 = (Region)dbClt4[0];
- reg1.BooleanOperation(BooleanOperationType.BoolSubtract, reg2);
- if (reg1.IsNull || reg1.Area == 0.0)
- {
- return null;
- }
- DBObjectCollection dbClt5 = new DBObjectCollection();
- reg1.Explode(dbClt5);
- DBObjectCollection dbClt6 = sCur.JoinPolyline(dbClt5, 0.001);
- if (dbClt6 == null || dbClt6.Count == 0)
- return null;
- //adb.DrawEntity(dbClt6,sEntclls.Null,false);
- if (dbClt6[0] is Polyline)
- {
- Polyline pline = (Polyline)dbClt6[0];
- if (pline.Closed)
- {
- return pline;
- }
- else
- {
- return null;
- }
- }
- else
- {
- return null;
- }
- #endregion use Region union way
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 连接两个封闭曲线的轮廓
- /// 需注意两个曲线必须在同一个平面,函数内有IntersectWith函数要求是Z轴0平面,即XY平面
- /// Version : 2008.02.13
- /// Note :
- /// 1,零长度和自封闭曲线会被过滤掉Tolerance(0.0001, 0.0001)
- /// </summary>
- /// <param name="cur1">曲线</param>
- /// <param name="cur2">曲线</param>
- /// <returns>成功返回封闭多义线,否则返回null,相离的两个曲线返回null</returns>
- static public Polyline UnionCurve(Curve cur1, Curve cur2)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionCurve(Curve cur1, Curve cur2)");
- if (cur1 == null || cur2 == null) return null;
- if (!cur1.Closed || !cur2.Closed) return null;
- Point3dCollection inters = sEnt.IntersectWith(cur1, cur2, Intersect.OnBothOperands);
- if (inters.Count < 2) return null;
-
- //若能使用在交点处打断曲线在连接的方式速度方面应该会快一些
- //但因曲线的形状和相交关系太复杂不能掌控,主要是没法判断去除打断后的哪一段曲线
- #region use Region union way
-
- DBObjectCollection dbClt1 = new DBObjectCollection();
- dbClt1.Add(cur1);
- DBObjectCollection dbClt2 = new DBObjectCollection();
- dbClt2.Add(cur2);
- DBObjectCollection dbClt3 = Region.CreateFromCurves(dbClt1);
- DBObjectCollection dbClt4 = Region.CreateFromCurves(dbClt2);
- if (dbClt3 == null || dbClt3.Count == 0)
- return null;
- if (dbClt4 == null || dbClt4.Count == 0)
- return null;
- Region reg1 = (Region)dbClt3[0];
- Region reg2 = (Region)dbClt4[0];
- reg1.BooleanOperation(BooleanOperationType.BoolUnite, reg2);
- DBObjectCollection dbClt5 = new DBObjectCollection();
- reg1.Explode(dbClt5);
- DBObjectCollection dbClt6 = sCur.JoinPolyline(dbClt5, 0.001);
- if (dbClt6 == null || dbClt6.Count == 0)
- return null;
- //adb.DrawEntity(dbClt6,sEntclls.Null,false);
- if (dbClt6[0].GetType().Equals(typeof(Polyline)))
- {
- Polyline pline = (Polyline)dbClt6[0];
- if (pline.Closed)
- {
- return pline;
- }
- else
- {
- return null;
- }
-
- }
- else
- {
- return null;
- }
- #endregion use Region union way
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 连接多个封闭的轮廓,不要求是封闭曲线,但应能封闭连接
- /// 函数不检查封闭的轮廓是否相交,若有多个封闭轮廓将以第一个轮廓为主执行与操作
- /// Version : 2008.02.14
- /// Note: 零长度(小于 0.00000001)曲线会被过滤掉
- /// </summary>
- /// <param name="dbClt">实体集合</param>
- /// <returns>成功返回多义线,否则返回null</returns>
- static public Polyline UnionCurve(DBObjectCollection dbClt)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionCurve(DBObjectCollection dbClt)");
- #region use Region union way
- if (dbClt == null) return null;
- DBObjectCollection dbClt3 = Region.CreateFromCurves(dbClt);
-
- if (dbClt3 == null || dbClt3.Count == 0)
- return null;
- Region reg1 = (Region)dbClt3[0];
- for (int i = 1; i < dbClt3.Count; i++)
- {
- Region reg2 = (Region)dbClt3[i];
- reg1.BooleanOperation(BooleanOperationType.BoolUnite, reg2);
- }
- DBObjectCollection dbClt5 = new DBObjectCollection();
- reg1.Explode(dbClt5);
- DBObjectCollection dbClt6 = sCur.JoinPolyline(dbClt5, 0.001);
-
- if (dbClt6 == null || dbClt6.Count == 0)
- return null;
- Polyline pline = (Polyline)dbClt6[0];
- return (Polyline)dbClt6[0];
- #endregion use Region union way
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 用直线段模拟曲线(Line Arc Circle Polyline)
- /// Version : 2007.11.01
- /// </summary>
- /// <param name="cur1">输入曲线</param>
- /// <param name="stepDist">模拟点距</param>
- /// <returns>成功返回一个Polyline对象,否则返回null</returns>
- public static Polyline SimulatePolyline(Curve cur1, double stepDist)
- {
- try
- {
- if (cur1 == null) return null;
- //smc.ed.WriteMessage("\nadb.SimulatePolyline start ");
- Polyline pline = new Polyline();
- if (cur1.GetType().Equals(typeof(Line)))//Line:?
- {//曲线为 Line,使用其数据生成一个Polyline
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 1 ");
- Line line = (Line)cur1;
- pline.AddVertexAt(0, new Point2d(line.StartPoint.X, line.StartPoint.Y), 0, 0, 0);
- pline.AddVertexAt(1, new Point2d(line.EndPoint.X, line.EndPoint.Y), 0, 0, 0);
- pline.SetPropertiesFrom(line);//使用原来实体属性
- return pline;
- }
- else if (cur1.GetType().Equals(typeof(Arc)))//Arc:?
- {//曲线为 Line,使用其数据生成一个Polyline
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 2 ");
- Arc arc = (Arc)cur1;
- double curLen = arc.GetDistanceAtParameter(arc.EndParam);
- int stepNum = (int)(curLen / stepDist);
- Point3d pt1;
-
- for (int i = 0; i <= stepNum; i++)
- {
- pt1 = arc.GetPointAtDist(i * stepDist);
- pline.AddVertexAt(i, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- if (curLen > stepDist * stepNum)
- {
- pt1 = arc.GetPointAtDist(curLen);
- pline.AddVertexAt(stepNum + 1, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- pline.SetPropertiesFrom(arc);//使用原来实体属性
- return pline;//将新生成的多义线提交到数据库
- }
- else if (cur1.GetType().Equals(typeof(Circle)))//Arc:?
- {//曲线为 Line,使用其数据生成一个Polyline
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 3 ");
- Circle cir = (Circle)cur1;
- double curLen = cir.GetDistanceAtParameter(cir.EndParam);
- int stepNum = (int)(curLen / stepDist);
- Point3d pt1;
-
- for (int i = 0; i <= stepNum; i++)
- {
- pt1 = cir.GetPointAtDist(i * stepDist);
- pline.AddVertexAt(i, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- if (curLen > stepDist * stepNum)
- {
- pt1 = cir.GetPointAtDist(curLen);
- pline.AddVertexAt(stepNum + 1, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- pline.SetPropertiesFrom(cir);//使用原来实体属性
- pline.Closed = true;
- return pline;//将新生成的多义线提交到数据库
- }
- else if (cur1.GetType().Equals(typeof(Polyline)))//Arc:?
- {//曲线为 Line,使用其数据生成一个Polyline
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 4 ");
- Polyline pline2 = (Polyline)cur1;
- if (pline2.IsOnlyLines)
- return (Polyline)pline2.Clone();
- int endParam = (int)pline2.EndParam;
- Point3d pt1;
- int curIndex = 0;
- Point3d startP = pline2.GetPointAtDist(0);
- pline.AddVertexAt(curIndex++, new Point2d(startP.X, startP.Y), 0, 0, 0);
- for (int j = 0; j < endParam; j++)
- {
- if (pline2.GetBulgeAt(j) == 0.0)
- {
- pt1 = pline2.GetPointAtParameter(j + 1);
- if (startP.DistanceTo(pt1) > 0.00001)
- pline.AddVertexAt(curIndex++, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- else
- {
- double curDist = pline2.GetDistanceAtParameter(j);
- double curLen = pline2.GetDistanceAtParameter(j + 1) - curDist;
- int stepNum = (int)(curLen / stepDist);
- for (int i = 1; i <= stepNum; i++)
- {
- pt1 = pline2.GetPointAtDist(curDist + i * stepDist);
- if (startP.DistanceTo(pt1) > 0.00001)
- pline.AddVertexAt(curIndex++, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- if (curLen > stepDist * stepNum)
- {
- pt1 = pline2.GetPointAtDist(curDist + curLen);
- if (startP.DistanceTo(pt1) > 0.00001)
- pline.AddVertexAt(curIndex++, new Point2d(pt1.X, pt1.Y), 0, 0, 0);
- }
- }
- }
- pline.SetPropertiesFrom(pline2);//使用原来实体属性
- if (pline2.Closed)
- pline.Closed = true;
- return pline;//将新生成的多义线提交到数据库
- }
- else
- {//本函数只处理Line Arc Polyline 三种类型曲线
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 5 ");
- return null;
- }
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- //smc.ed.WriteMessage("\nadb.SimulatePolyline 6 ");
- return null;
- }
- }
- /// <summary>
- /// 合并两个同线的直线段,合并后的直线反映在l1
- /// </summary>
- /// <param name="l1">直线1</param>
- /// <param name="l2">直线2</param>
- /// <param name="permitSpace">是否合并相离的同线直线</param>
- /// <returns>有合并动作就返回true,否则返回false</returns>
- static public bool UnionLine_old(Line l1, Line l2, bool permitSpace)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionLine(Line ,Line ,bool)");
- if (l1 == null || l2 == null) return false;
- Tolerance eTol = new Tolerance(0.0001, 0.0001);
- if (!fun.IsInLine(l1, l2, eTol)) return false;
- Vector3d vec1 = l1.EndPoint - l1.StartPoint;
- Vector3d vec2 = l2.EndPoint - l2.StartPoint;
- Point3d startP = l2.StartPoint;
- Point3d endP = l2.EndPoint;
- if (vec1.IsZeroLength(eTol) && vec2.IsZeroLength(eTol))
- {
- Vector3d vec4 = l2.StartPoint - l1.StartPoint;
- if (vec4.IsZeroLength(eTol))
- return true;
- else
- {
- if (permitSpace)
- {
- l1.EndPoint = l2.EndPoint;
- return true;
- }
- else
- return false;
- }
- }
- else if (vec1.IsZeroLength(eTol))
- {
- vec1 = vec2;
- }
- else if (vec2.IsZeroLength(eTol))
- {
- vec2 = vec1;
- }
- else
- {
- if (vec1.IsCodirectionalTo(vec2.Negate(), eTol))
- {
- startP = l2.EndPoint;
- endP = l2.StartPoint;
- }
- }
- Vector3d vec3 = startP - l1.StartPoint;
- if (vec3.IsZeroLength(eTol))
- {
- Vector3d vec4 = endP - l1.EndPoint;
- if (vec4.IsZeroLength(eTol))
- return true;
- else if (vec4.IsCodirectionalTo(vec1, eTol))
- {
- l1.EndPoint = endP;
- return true;
- }
- else
- return true;
- }
- else if (vec3.IsCodirectionalTo(vec1, eTol))
- {
- Vector3d vec4 = startP - l1.EndPoint;
- if (vec4.IsZeroLength(eTol))
- {
- l1.EndPoint = endP;
- return true;
- }
- else if (vec4.IsCodirectionalTo(vec1, eTol))
- {
- if (permitSpace)
- {
- l1.EndPoint = endP;
- return true;
- }
- else
- return false;
- }
- else
- {
- Vector3d vec5 = endP - l1.EndPoint;
- if (vec5.IsZeroLength(eTol))
- return true;
- else if (vec5.IsCodirectionalTo(vec1, eTol))
- {
- l1.EndPoint = endP;
- return true;
- }
- else
- return true;
- }
- }
- else
- {
- Vector3d vec4 = endP - l1.StartPoint;
- if (vec4.IsZeroLength(eTol))
- {
- l1.StartPoint = startP;
- return true;
- }
- else if (vec4.IsCodirectionalTo(vec1, eTol))
- {
- l1.StartPoint = startP;
- Vector3d vec5 = endP - l1.EndPoint;
- if (vec5.IsZeroLength(eTol))
- return true;
- else if (vec5.IsCodirectionalTo(vec1, eTol))
- {
- l1.EndPoint = endP;
- return true;
- }
- else
- return true;
- }
- else
- {
- if (permitSpace)
- {
- l1.StartPoint = startP;
- return true;
- }
- else
- return false;
- }
- }
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return false;
- }
- }
- static public bool UnionLine(Line l1, Line l2, double permitSpace)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionLine(Line ,Line ,bool)");
- if (l1 == null || l2 == null) return false;
- Tolerance eTol = new Tolerance(0.0001, 0.0001);
- if (!fun.IsInLine(l1, l2, eTol)) return false;
- Point3dCollection p3dClt1 = new Point3dCollection();
- p3dClt1.Add(l1.StartPoint);
- p3dClt1.Add(l1.EndPoint);
- p3dClt1.Add(l2.StartPoint);
- p3dClt1.Add(l2.EndPoint);
-
- Point3d p21 = l1.StartPoint;
- Point3d p22 = l1.EndPoint;
- double maxDist = p21.DistanceTo(p22);
- foreach (Point3d p11 in p3dClt1)
- {
- foreach (Point3d p12 in p3dClt1)
- {
- if (p11.DistanceTo(p12) > maxDist)
- {
- maxDist = p11.DistanceTo(p12);
- p21 = p11;
- p22 = p12;
- }
- }
- }
-
- Vector3d vec1 = p21 - p22;
- if (vec1.IsZeroLength(eTol))
- {
- return true;
- }
- else
- {
- if (permitSpace < 0)
- {
- l1.StartPoint = p21;
- l1.EndPoint = p22;
- return true;
- }
- else
- {
- if (maxDist < l1.EndParam + l2.EndParam + permitSpace)
- {
- l1.StartPoint = p21;
- l1.EndPoint = p22;
- return true;
- }
- else
- return false;
- }
- }
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return false;
- }
- }
- /// <summary>
- /// 合并同线直线
- /// 对因合并而需要删除的直线调用erase(),但没有提交
- /// </summary>
- /// <param name="dbClt">DBObject对象集合</param>
- /// <param name="permitSpace">是否合并相离的同线直线</param>
- /// <returns>返回合并后的DBObject对象集合</returns>
- static public DBObjectCollection UnionLine_old(DBObjectCollection dbClt, bool permitSpace)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionLine(DBObjectCollection) dbClt.Count = {0}", dbClt.Count);
- if (dbClt == null) return null;
- DBObjectCollection dbClt1 = new DBObjectCollection();
- DBObjectCollection reClt = new DBObjectCollection();
- Tolerance eTol = new Tolerance(0.0001, 0.0001);
- foreach (DBObject dbObj in dbClt)
- {
- if (dbObj.GetType().Equals(typeof(Line)))
- {
- dbClt1.Add(dbObj);
- }
- else
- {
- reClt.Add(dbObj);
- }
- }
- IntegerCollection intClt = new IntegerCollection();
- for (int i = 0; i < dbClt1.Count; i++)
- {
- if (intClt.IndexOf(i) == -1)
- {
- Line l1 = (Line)dbClt1[i];
- bool cont2 = true;
- intClt.Add(i);
- reClt.Add(dbClt1[i]);
- while (cont2)
- {
- cont2 = false;
- for (int j = 0; j < dbClt1.Count; j++)
- {
- if (intClt.IndexOf(j) == -1)
- {
- Line l2 = (Line)dbClt1[j];
- if (sCur.UnionLine_old(l1, l2, permitSpace))
- {
- l2.Erase();
- intClt.Add(j);
- cont2 = true;
- }
- }
- }
- }
- }
- }
- return reClt;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- static public DBObjectCollection UnionLine(DBObjectCollection dbClt, double permitSpace)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionLine(DBObjectCollection) dbClt.Count = {0}", dbClt.Count);
- if (dbClt == null) return null;
- DBObjectCollection dbClt1 = new DBObjectCollection();
- DBObjectCollection reClt = new DBObjectCollection();
- Tolerance eTol = new Tolerance(0.0001, 0.0001);
- foreach (DBObject dbObj in dbClt)
- {
- if (dbObj.GetType().Equals(typeof(Line)))
- {
- dbClt1.Add(dbObj);
- }
- else
- {
- reClt.Add(dbObj);
- }
- }
- IntegerCollection intClt = new IntegerCollection();
- for (int i = 0; i < dbClt1.Count; i++)
- {
- if (intClt.IndexOf(i) == -1)
- {
- Line l1 = (Line)dbClt1[i];
- bool cont2 = true;
- intClt.Add(i);
- reClt.Add(dbClt1[i]);
- while (cont2)
- {
- cont2 = false;
- for (int j = 0; j < dbClt1.Count; j++)
- {
- if (intClt.IndexOf(j) == -1)
- {
- Line l2 = (Line)dbClt1[j];
- if (sCur.UnionLine(l1, l2, permitSpace))
- {
- l2.Erase();
- intClt.Add(j);
- cont2 = true;
- }
- }
- }
- }
- }
- }
- return reClt;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return null;
- }
- }
- /// <summary>
- /// 合并同心等半径圆弧
- /// </summary>
- /// <param name="a1">第一圆弧</param>
- /// <param name="a2">第二圆弧</param>
- /// <param name="permitSpace">圆弧的合并间隔</param>
- /// <returns>成功返回true,否则返回false</returns>
- static public bool UnionArc(Arc a1, Arc a2, double permitSpace)
- {
- try
- {
- //smc.ed.WriteMessage("\nadb.UnionArc(a1 a2) 1");
- if (a1 == null || a2 == null) return false;
- Tolerance eTol = new Tolerance(0.0001, 0.0001);
- if (a1.Center.DistanceTo(a2.Center) > 0.001) return false;
- if (!a1.Normal.IsCodirectionalTo(a2.Normal, eTol)) return false;
- if (Math.Abs(a1.Radius - a2.Radius) > 0.001) return false;
- //smc.ed.WriteMessage("\nadb.UnionArc(a1 a2) 2");
- if (a1.StartAngle < a2.StartAngle)
- {
- //smc.ed.WriteMessage(" 21 ");
- if (a1.EndAngle >= a2.StartAngle)//交错
- {
- //smc.ed.WriteMessage(" 22 ");
- a1.EndAngle = Math.Max(a1.EndAngle, a2.EndAngle);
- }
- else
- {
- //smc.ed.WriteMessage(" 23 ");
- if (a2.EndAngle > smc.pi * 2)
- {
- //smc.ed.WriteMessage(" 24 ");
- if (a1.StartAngle <= a2.EndAngle - smc.pi * 2)//交错
- {
- //smc.ed.WriteMessage(" 25 ");
- a1.EndAngle += smc.pi * 2;
- a1.StartAngle = a2.StartAngle;
- }
- else if (permitSpace < 0 || a1.StartPoint.DistanceTo(a2.EndPoint) <= permitSpace) //相离
- {
- //smc.ed.WriteMessage(" 26 ");
- double dltAng1 = a2.StartAngle - a1.EndAngle;
- double dltAng2 = a1.StartAngle - (a2.EndAngle - smc.pi * 2);
- if (dltAng1 < dltAng2)
- {
- //smc.ed.WriteMessage(" 27 ");
- a1.EndAngle = a2.EndAngle;
- }
- else
- {
- //smc.ed.WriteMessage(" 28 ");
- a1.EndAngle += smc.pi * 2;
- a1.StartAngle = a2.StartAngle;
- }
- }
- }
- else if (permitSpace < 0 || a1.EndPoint.DistanceTo(a2.StartPoint) <= permitSpace) //相离
- {
- //smc.ed.WriteMessage(" 29 ");
- double dltAng1 = a2.StartAngle - a1.EndAngle;
- double dltAng2 = a1.StartAngle + (smc.pi * 2 - a2.EndAngle);
- if (dltAng1 < dltAng2)
- {
- //smc.ed.WriteMessage(" 2a");
- a1.EndAngle = a2.EndAngle;
- }
- else
- {
- //smc.ed.WriteMessage(" 2b ");
- a1.EndAngle += smc.pi * 2;
- a1.StartAngle = a2.StartAngle;
- }
- }
- }
- }
- else
- {
- double startAng = a2.StartAngle;
- double endAng = a2.EndAngle;
- //smc.ed.WriteMessage(" 31 ");
- if (a2.EndAngle >= a1.StartAngle)//交错
- {
- //smc.ed.WriteMessage(" 32 ");
- endAng = Math.Max(a1.EndAngle, a2.EndAngle);
- }
- else
- {
- //smc.ed.WriteMessage(" 33 ");
- if (a1.EndAngle > smc.pi * 2)
- {
- //smc.ed.WriteMessage(" 34 ");
- if (a2.StartAngle <= a1.EndAngle - smc.pi * 2)//交错
- {
- //smc.ed.WriteMessage(" 35 ");
- endAng = a2.EndAngle + smc.pi * 2;
- startAng = a1.StartAngle;
- }
- else if (permitSpace < 0 || a2.StartPoint.DistanceTo(a1.EndPoint) <= permitSpace) //相离
- {
- //smc.ed.WriteMessage(" 36 ");
- double dltAng1 = a1.StartAngle - a2.EndAngle;
- double dltAng2 = a2.StartAngle - (a1.EndAngle - smc.pi * 2);
- if (dltAng1 < dltAng2)
- {
- //smc.ed.WriteMessage(" 37 ");
- endAng = a1.EndAngle;
- }
- else
- {
- //smc.ed.WriteMessage(" 38 ");
- endAng = a2.EndAngle + smc.pi * 2;
- startAng = a1.StartAngle;
- }
- }
- }
- else if (permitSpace < 0 || a2.EndPoint.DistanceTo(a1.StartPoint) <= permitSpace) //相离
- {
- //smc.ed.WriteMessage(" 39 ");
- double dltAng1 = a1.StartAngle - a2.EndAngle;
- double dltAng2 = a2.StartAngle + (smc.pi * 2 - a1.EndAngle);
- if (dltAng1 < dltAng2)
- {
- //smc.ed.WriteMessage(" 3a");
- endAng = a1.EndAngle;
- }
- else
- {
- //smc.ed.WriteMessage(" 3b ");
- endAng = a2.EndAngle + smc.pi * 2;
- startAng = a1.StartAngle;
- }
- }
- }
- a1.StartAngle = startAng;
- a1.EndAngle = endAng;
- }
- return true;
- }
- catch (System.Exception ex)
- {
- smc.WriteLine(ex);
- return false;
- }
- }
-
-
|
|