本帖最后由 作者 于 2010-11-2 22:23:41 编辑
你那些Ge曲线类文章都是很好的参考,我用VB.NET转换了第一个例子,缺少ToCurve,无法编译。
- ''' <summary>
- ''' 使用Ge曲线的简单例子
- ''' 对直线和圆求交点,并返回交点分隔的部分
- ''' </summary>
- <CommandMethod("t9")> Public Sub t9()
- 'Ge直线
- Dim l2d As New Line2d(Point2d.Origin, Vector2d.XAxis)
- 'Ge圆
- Dim ca2d As New CircularArc2d(New Point2d(5, 5), 15)
- '交点集合
- Dim pnts As New List(Of Point2d)
- '交点处的参数集合
- Dim pars1 = New List(Of Double)
- Dim pars2 = New List(Of Double)
- '求交
- Using cci2d As New CurveCurveIntersector2d(l2d, ca2d)
- Dim i As Integer = 0
- Do While i < cci2d.NumberOfIntersectionPoints
- pnts.Add(cci2d.GetIntersectionPoint(i))
- Dim k = cci2d.GetIntersectionParameters(i)
- pars1.Add(k(0))
- pars2.Add(k(1))
- i += 1
- Loop
- End Using
- Dim Ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
- Dim Db As Database = HostApplicationServices.WorkingDatabase
- Dim j As Integer = 1
- pnts.ForEach(Sub(p)
- Ed.WriteMessage(vbLf & "第{0}个交点为:{1}", j, p)
- j += 1
- End Sub)
- '转换结果为Db曲线()
- Using tr = Db.TransactionManager.StartTransaction
- Dim btr As BlockTableRecord = Db.CurrentSpaceId.GetObject(OpenMode.ForWrite)
- pars1.Sort()
- Dim ls2d As New LineSegment2d(l2d.EvaluatePoint(pars1(0)), l2d.EvaluatePoint(pars1(1)))
- Dim line = ls2d.ToCurve(Matrix3d.Identity)
- btr.AppendEntity(line)
- tr.AddNewlyCreatedDBObject(line, True)
- pars2.Sort()
- ca2d.SetInterval(New Interval(pars2(0), pars2(1), 0))
- Dim arc = ca2d.ToCurve(Matrix3d.Identity)
- btr.AppendEntity(arc)
- tr.AddNewlyCreatedDBObject(arc, True)
- tr.Commit()
- End Using
- End Sub
|