Ejemplo n.º 1
0
        private PointSet method_3(Autodesk.AutoCAD.DatabaseServices.Circle circle_0, double double_1)
        {
            PointSet result;

            try
            {
                PointSet pointSet = new PointSet();
                ngeometry.VectorGeometry.Circle circle = Conversions.ToCeometricCircle(circle_0);
                if (double_1 > 0.0 && double_1 < circle.Circumference)
                {
                    int    num   = Math.Max((int)Math.Ceiling(circle.Circumference / double_1), 4);
                    double num2  = 6.2831853071795862 / (double)num;
                    Point  point = Conversions.ToCeometricPoint(circle_0.StartPoint);
                    for (int i = 0; i < num; i++)
                    {
                        ngeometry.VectorGeometry.Matrix3d rotationMatrix = ngeometry.VectorGeometry.Matrix3d.RotationArbitraryAxis(circle.NormalVector, (double)i * num2);
                        pointSet.Add(point.Rotate(circle.Center, rotationMatrix));
                    }
                }
                else
                {
                    pointSet.Add(circle.Center);
                }
                result = pointSet;
            }
            catch (System.Exception ex)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Can not subdivide circle (handle: " + circle_0.Handle.ToString() + ")\n");
                result = null;
            }
            return(result);
        }
Ejemplo n.º 2
0
 public bool IsTangentTo(Circle circle)
 {
     return(circle.IsTangentTo(this));
 }
Ejemplo n.º 3
0
 public bool IsParallelTo(Circle circle)
 {
     return(this.vector3d_0.IsOrthogonalTo(circle.NormalVector));
 }
Ejemplo n.º 4
0
 public bool IsCoplanarTo(Circle circle)
 {
     return(Plane.smethod_0(circle.Center, circle.NormalVector, this.point_0) && circle.NormalVector.IsOrthogonalTo(this.vector3d_0));
 }
Ejemplo n.º 5
0
 public bool Intersects3d(Circle circle)
 {
     return(this.method_7(circle) != null);
 }
Ejemplo n.º 6
0
        public bool Intersects2d(Circle circle)
        {
            PointSet pointSet = this.method_1(circle);

            return(pointSet != null && pointSet.Count != 0);
        }
Ejemplo n.º 7
0
        public static void ComputeMinEnclosingCircle(ObjectId[] idArray, CoordinateSystem actualCS)
        {
            Editor        editor          = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            ProgressMeter progressMeter   = new ProgressMeter();
            MessageFilter value           = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(value);
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    progressMeter.SetLimit(idArray.Length);
                    if ((double)idArray.Length > 10000.0)
                    {
                        progressMeter.Start("Computing min. enclosing circle...");
                    }
                    CoordinateTransformator coordinateTransformator = new CoordinateTransformator(CoordinateSystem.Global(), actualCS);
                    CoordinateTransformator inverseTransformation   = coordinateTransformator.GetInverseTransformation();
                    BlockTable       blockTable       = (BlockTable)transaction.GetObject(workingDatabase.BlockTableId, (OpenMode)1);
                    BlockTableRecord blockTableRecord = (BlockTableRecord)transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], (OpenMode)1);
                    ObjectId         layerId          = DBManager.CurrentLayerId();
                    DBManager.CurrentLayerName();
                    PointSet pointSet = new PointSet();
                    for (int i = 0; i < idArray.Length; i++)
                    {
                        progressMeter.MeterProgress();
                        DBPoint dBPoint = (DBPoint)transaction.GetObject(idArray[i], (OpenMode)0, true);
                        Point   point   = new Point(dBPoint.Position.X, dBPoint.Position.Y, dBPoint.Position.Z);
                        coordinateTransformator.Transform(point);
                        pointSet.Add(point);
                    }
                    ConvexHull2d convexHull2d = new ConvexHull2d();
                    convexHull2d.InitialPoints = pointSet;
                    convexHull2d.ComputeHull();
                    PointSet vertices = convexHull2d.Vertices;
                    double   z        = vertices[0].Z;
                    for (int j = 0; j < vertices.Count; j++)
                    {
                        vertices[j].Z = z;
                    }
                    SmallestEnclosingCircle         smallestEnclosingCircle = new SmallestEnclosingCircle(vertices);
                    ngeometry.VectorGeometry.Circle circle = smallestEnclosingCircle.ComputeCircle();
                    Point center = circle.Center;
                    Point point2 = circle.NormalVector.ToPoint();
                    inverseTransformation.Transform(center);
                    inverseTransformation.Transform(point2);
                    Autodesk.AutoCAD.DatabaseServices.Circle circle2 = new Autodesk.AutoCAD.DatabaseServices.Circle(new Autodesk.AutoCAD.Geometry.Point3d(center.X, center.Y, center.Z), new Autodesk.AutoCAD.Geometry.Vector3d(point2.X, point2.Y, point2.Z), circle.Radius);
                    circle2.LayerId = (layerId);
                    blockTableRecord.AppendEntity(circle2);
                    transaction.AddNewlyCreatedDBObject(circle2, true);
                    editor.WriteMessage("\nMinimum enclosing circle properties:");
                    editor.WriteMessage("\n------------------------------------");
                    editor.WriteMessage("\nRadius          : " + circle.Radius.ToString(DBManager.GetFormatFromLUPREC()));
                    editor.WriteMessage("\nArea            : " + circle.Area.ToString(DBManager.GetFormatFromLUPREC()));
                    editor.WriteMessage("\nPerimeter length: " + circle.Circumference.ToString(DBManager.GetFormatFromLUPREC()));
                    transaction.Commit();
                }
                progressMeter.Stop();
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
        }