Ejemplo n.º 1
0
        public static AcDb.Polyline2d CreatePolyline2d(AcGe.Point2dCollection points, bool isClosed)
        {
            AcDb.Polyline2d polyLine2d = new AcDb.Polyline2d();
            AcDb.Vertex2d   vertex;

            foreach (AcGe.Point2d point in points)
            {
                vertex = new AcDb.Vertex2d(new AcGe.Point3d(point.X, point.Y, 0), 0, 0, 0, 0);
                polyLine2d.AppendVertex(vertex);
                polyLine2d.Closed = isClosed;
            }

            return(polyLine2d);
        }
Ejemplo n.º 2
0
        private static bool PolyInPoly(_AcDb.TransactionManager tm, _AcDb.ObjectId oid, _AcDb.ObjectId elFG)
        {
            using (_AcDb.DBObject pEntity = tm.GetObject(oid, _AcDb.OpenMode.ForRead, false))
            {
                using (_AcDb.DBObject pElFG = tm.GetObject(elFG, _AcDb.OpenMode.ForRead, false))
                {
                    if (pEntity is _AcDb.Polyline2d)
                    {
                        _AcDb.Polyline2d oldPolyline = (_AcDb.Polyline2d)pEntity;
                        foreach (_AcDb.ObjectId Vertex2d in oldPolyline)
                        {
                            using (_AcDb.DBObject dbobj = tm.GetObject(Vertex2d, _AcDb.OpenMode.ForRead, false))
                            {
                                _AcDb.Vertex2d vertex = dbobj as _AcDb.Vertex2d;

                                if (vertex == null)
                                {
                                    string msg = string.Format(CultureInfo.CurrentCulture, "Polylinie {0} gibt falsches Objekt {1} als Vertex zurück.", oldPolyline.Handle.ToString(), dbobj.GetType().ToString());
                                    throw new InvalidOperationException(string.Format(msg));
                                }

                                _AcGe.Point3d vertexPoint = oldPolyline.VertexPosition(vertex);
                                if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)pElFG))
                                {
                                    return(false);
                                }
                            }
                        }
                        return(true);
                    }
                    else if (pEntity is _AcDb.Polyline3d)
                    {
                        _AcDb.Polyline3d poly3d = (_AcDb.Polyline3d)pEntity;
                        foreach (_AcDb.ObjectId Vertex3d in poly3d)
                        {
                            using (_AcDb.DBObject dbobj = tm.GetObject(Vertex3d, _AcDb.OpenMode.ForRead, false))
                            {
                                _AcDb.PolylineVertex3d vertex = dbobj as _AcDb.PolylineVertex3d;

                                if (vertex == null)
                                {
                                    string msg = string.Format(CultureInfo.CurrentCulture, "3D-Polylinie {0} gibt falsches Objekt {1} als Vertex zurück.", poly3d.Handle.ToString(), dbobj.GetType().ToString());
                                    throw new InvalidOperationException(string.Format(msg));
                                }

                                _AcGe.Point3d vertexPoint = vertex.Position;
                                if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)pElFG))
                                {
                                    return(false);
                                }
                            }
                        }
                        return(true);
                    }
                    else if (pEntity is _AcDb.Polyline)
                    {
                        _AcDb.Polyline poly = pEntity as _AcDb.Polyline;
                        for (int i = 0; i < poly.NumberOfVertices; i++)
                        {
                            _AcGe.Point3d vertexPoint = poly.GetPoint3dAt(i);
                            if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)pElFG))
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private static bool PolyInPoly(_AcDb.Transaction tm, _AcDb.Entity inner, _AcDb.Entity outer)
        {
            if (inner == outer)
            {
                return(false);
            }
            if (!OverlapExtents(inner, outer))
            {
                return(false);
            }

            NrOfOverlaps++;

            if (inner is _AcDb.Polyline)
            {
                _AcDb.Polyline poly = inner as _AcDb.Polyline;
                for (int i = 0; i < poly.NumberOfVertices; i++)
                {
                    _AcGe.Point3d vertexPoint = poly.GetPoint3dAt(i);
                    if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)outer))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            else if (inner is _AcDb.Polyline2d)
            {
                _AcDb.Polyline2d oldPolyline = (_AcDb.Polyline2d)inner;
                foreach (_AcDb.ObjectId Vertex2d in oldPolyline)
                {
                    using (_AcDb.DBObject dbobj = tm.GetObject(Vertex2d, _AcDb.OpenMode.ForRead, false))
                    {
                        _AcDb.Vertex2d vertex = dbobj as _AcDb.Vertex2d;

                        if (vertex == null)
                        {
                            string msg = string.Format(CultureInfo.CurrentCulture, "Polylinie {0} gibt falsches Objekt {1} als Vertex zurück.", oldPolyline.Handle.ToString(), dbobj.GetType().ToString());
                            throw new InvalidOperationException(string.Format(msg));
                        }

                        _AcGe.Point3d vertexPoint = oldPolyline.VertexPosition(vertex);
                        if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)outer))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            else if (inner is _AcDb.Polyline3d)
            {
                _AcDb.Polyline3d poly3d = (_AcDb.Polyline3d)inner;
                foreach (_AcDb.ObjectId Vertex3d in poly3d)
                {
                    using (_AcDb.DBObject dbobj = tm.GetObject(Vertex3d, _AcDb.OpenMode.ForRead, false))
                    {
                        _AcDb.PolylineVertex3d vertex = dbobj as _AcDb.PolylineVertex3d;

                        if (vertex == null)
                        {
                            string msg = string.Format(CultureInfo.CurrentCulture, "3D-Polylinie {0} gibt falsches Objekt {1} als Vertex zurück.", poly3d.Handle.ToString(), dbobj.GetType().ToString());
                            throw new InvalidOperationException(string.Format(msg));
                        }

                        _AcGe.Point3d vertexPoint = vertex.Position;
                        if (!AreaEngine.InPoly(vertexPoint, (_AcDb.Entity)outer))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unknown entitytype '{0}'!", inner.GetType().Name));
        }