Boprs/Contour.cs
2024-09-04 09:04:07 +02:00

84 lines
2 KiB
C#

#if ACAD24
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Colors;
using AcAp = Autodesk.AutoCAD.ApplicationServices;
#elif BCAD
using Bricscad.EditorInput;
using Teigha.Geometry;
using Teigha.DatabaseServices;
using Teigha.Colors;
using AcAp = Bricscad.ApplicationServices;
#endif
using System;
using System.Collections.Generic;
namespace Boprs
{
/// <summary>
/// Simple closed polygon.
/// </summary>
public class Contour
{
/// <summary>
/// Parent of this contour, null if external.
/// </summary>
public Contour Parent { get; internal set; }
/// <summary>
/// Vertices of the contour.
/// </summary>
public List<Point2d> Vertices { get; }
/// <summary>
/// Are the vertices of the contour arranged in clockwise manner?
/// </summary>
/// <returns><c>true</c> if the contour is clockwise, <c>false</c> if counter-clockwise.</returns>
public bool IsClockwise()
{
throw new NotImplementedException();
}
/// <summary>
/// Reverse the orientation of the contour.
/// </summary>
public void Reverse()
{
throw new NotImplementedException();
}
/// <summary>
/// Constructor.
/// </summary>
public Contour()
{
Vertices = new List<Point2d>();
}
#if DEBUG
internal void Draw(Color color = null)
{
AcAp.Document acDoc = AcAp.Application.DocumentManager.MdiActiveDocument;
Database acDb = acDoc.Database;
using (Transaction acTrans = acDb.TransactionManager.StartTransaction())
{
// Open the BlockTableRecord
BlockTable acBlkTbl = (BlockTable)acTrans.GetObject(acDb.BlockTableId, OpenMode.ForRead);
BlockTableRecord acBlkTblRec =
(BlockTableRecord)acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
for(int i = 0; i < Vertices.Count; i++)
{
Line asLine = new Line(Vertices[i].To3d(), Vertices[(i + 1) % Vertices.Count].To3d());
acBlkTblRec.AppendEntity(asLine);
acTrans.AddNewlyCreatedDBObject(asLine, true);
}
acTrans.Commit();
}
}
#endif
}
}