Esempio n. 1
0
 public static AcGe.Point3dCollection Offset(
     AcGe.Point3dCollection collection,
     AcGe.Vector3d offset)
 {
     AcGe.Point3dCollection offsetCollection = new AcGe.Point3dCollection();
     foreach (AcGe.Point3d point in collection)
     {
         offsetCollection.Add(point.Add(offset));
     }
     return(offsetCollection);
 }
Esempio n. 2
0
        public static AcGe.Point3dCollection GetPoints3dFromIn4Polygon(In4Polygon curSR)
        {
            AcGe.Point3dCollection points = new AcGe.Point3dCollection();

            foreach (Point point in curSR.Border)
            {
                points.Add(new AcGe.Point3d(point.X, point.Y, 0));
            }

            return(points);
        }
Esempio n. 3
0
        public static bool InPoly(_AcGe.Point3d vertexPoint, double xOffs, double yOffs, _AcDb.Entity pElFG)
        {
            using (_AcDb.Ray ray = new _AcDb.Ray())
            {
                ray.BasePoint = vertexPoint;
                ray.UnitDir   = new _AcGe.Vector3d(xOffs, yOffs, 0.0);

                _AcGe.Point3dCollection col = new _AcGe.Point3dCollection();
                ((_AcDb.Entity)ray).IntersectWith(pElFG, _AcDb.Intersect.OnBothOperands, col, IntPtr.Zero, IntPtr.Zero);

                if ((col.Count % 2) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        protected override bool WorldDraw(AcGi.WorldDraw draw)
        {
            AcGi.WorldGeometry geo = draw.Geometry;
            if (geo != null)
            {
                geo.PushModelTransform(UCS);

                AcGe.Point3dCollection tempPts = new AcGe.Point3dCollection();
                foreach (AcGe.Point3d pt in allVertexes)
                {
                    tempPts.Add(pt);
                }
                if (lastVertex != null)
                {
                    if (tempPts.Count > 1)
                    {
                        AcDb.Line lastLine      = new AcDb.Line(allVertexes[allVertexes.Count - 2], allVertexes[allVertexes.Count - 1]);
                        double    offsetForward = ServiceGeodesy.GetProjectionOnLine(lastLine, lastVertex) - lastLine.Length;
                        double    offsetTowards = ServiceGeodesy.GetOffsetFromLine(lastLine, lastVertex);

                        AcDb.Xline xLine = new AcDb.Xline();
                        xLine.BasePoint = allVertexes[allVertexes.Count - 1];
                        xLine.UnitDir   = lastLine.Delta;

                        System.Windows.Forms.Keys mods = System.Windows.Forms.Control.ModifierKeys;
                        if ((mods & System.Windows.Forms.Keys.Control) > 0)
                        {
                            if (isMovingTowards)
                            {
                                lastVertex = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                        else
                        {
                            if (Math.Abs(offsetForward) > Math.Abs(offsetTowards))
                            {
                                isMovingTowards = true;
                                lastVertex      = xLine.GetPointAtDist(offsetForward);
                            }
                            else
                            {
                                isMovingTowards = false;
                                xLine.TransformBy(AcGe.Matrix3d.Rotation(Math.PI / 2 * -1, AcGe.Vector3d.ZAxis, xLine.BasePoint));
                                lastVertex = xLine.GetPointAtParameter(offsetTowards);
                            }
                        }
                    }
                    tempPts.Add(lastVertex);
                }
                if (tempPts.Count > 0)
                {
                    geo.Polyline(tempPts, AcGe.Vector3d.ZAxis, IntPtr.Zero);
                }

                geo.PopModelTransform();
            }

            return(true);
        }
Esempio n. 5
0
        // DBText extensions



        ///<summary>
        /// Gets the bounds of a DBText object.
        ///</summary>
        ///<param name="fac">Optional multiplier to increase/reduce buffer.</param>
        ///<returns>A collection of points defining the text's extents.</returns>
        public static _AcGe.Point3dCollection ExtractBounds(
            this _AcDb.DBText txt, double fac = 1.0
            )
        {
            var pts = new _AcGe.Point3dCollection();

            if (txt.Bounds.HasValue && txt.Visible)
            {
                // Create a straight version of the text object
                // and copy across all the relevant properties
                // (stopped copying AlignmentPoint, as it would
                // sometimes cause an eNotApplicable error)
                // We'll create the text at the WCS origin
                // with no rotation, so it's easier to use its
                // extents

                var txt2 = new _AcDb.DBText();

                txt2.Normal   = _AcGe.Vector3d.ZAxis;
                txt2.Position = _AcGe.Point3d.Origin;

                // Other properties are copied from the original
                txt2.TextString     = txt.TextString;
                txt2.TextStyleId    = txt.TextStyleId;
                txt2.LineWeight     = txt.LineWeight;
                txt2.Thickness      = txt2.Thickness;
                txt2.HorizontalMode = txt.HorizontalMode;
                txt2.VerticalMode   = txt.VerticalMode;
                txt2.WidthFactor    = txt.WidthFactor;
                txt2.Height         = txt.Height;
                txt2.IsMirroredInX  = txt2.IsMirroredInX;
                txt2.IsMirroredInY  = txt2.IsMirroredInY;
                txt2.Oblique        = txt.Oblique;

                // Get its bounds if it has them defined
                // (which it should, as the original did)
                if (txt2.Bounds.HasValue)
                {
                    var maxPt = txt2.Bounds.Value.MaxPoint;

                    // Only worry about this single case, for now
                    _AcGe.Matrix3d mat = _AcGe.Matrix3d.Identity;
                    if (txt.Justify == _AcDb.AttachmentPoint.MiddleCenter)
                    {
                        mat = _AcGe.Matrix3d.Displacement((_AcGe.Point3d.Origin - maxPt) * 0.5);
                    }

                    // Place all four corners of the bounding box
                    // in an array

                    double minX, minY, maxX, maxY;
                    if (txt.Justify == _AcDb.AttachmentPoint.MiddleCenter)
                    {
                        minX = -maxPt.X * 0.5 * fac;
                        maxX = maxPt.X * 0.5 * fac;
                        minY = -maxPt.Y * 0.5 * fac;
                        maxY = maxPt.Y * 0.5 * fac;
                    }
                    else
                    {
                        minX = 0;
                        minY = 0;
                        maxX = maxPt.X * fac;
                        maxY = maxPt.Y * fac;
                    }

                    var bounds =
                        new _AcGe.Point2d[] {
                        new _AcGe.Point2d(minX, minY),
                        new _AcGe.Point2d(minX, maxY),
                        new _AcGe.Point2d(maxX, maxY),
                        new _AcGe.Point2d(maxX, minY)
                    };

                    // We're going to get each point's WCS coordinates
                    // using the plane the text is on
                    var pl = new _AcGe.Plane(txt.Position, txt.Normal);

                    // Rotate each point and add its WCS location to the
                    // collection
                    foreach (_AcGe.Point2d pt in bounds)
                    {
                        pts.Add(
                            pl.EvaluatePoint(
                                pt.RotateBy(txt.Rotation, _AcGe.Point2d.Origin)
                                )
                            );
                    }
                }
            }
            return(pts);
        }