Exemple #1
0
        public static IList <Point3dCollection> ProcessLidarFile(IList <Point2dCollection> boundary, string filename, string path)
        {
            if (boundary == null)
            {
                throw new ArgumentNullException(nameof(boundary));
            }
            if (filename == null)
            {
                throw new ArgumentNullException(nameof(filename));
            }
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            Point3dCollection         lidarpoints     = CreateAllSurface.ReadPointCloudFile.ReadFile(path, filename);
            Point2dCollection         points2D        = PGA.AcadUtilities.AcadUtilities.ConvertTo2d(lidarpoints);
            IList <Point3dCollection> parsecollection = new List <Point3dCollection>();

            foreach (Point2dCollection pline in boundary)
            {
                Point3dCollection local = new Point3dCollection();
                for (int i = 0; i < points2D.Count; i++)
                {
                    if (PointUtilities.PointInPolyline(pline, points2D[i]))
                    {
                        local.Add(lidarpoints[i]);
                    }
                }
                parsecollection.Add(local);
            }
            return(parsecollection);
        }
Exemple #2
0
        public static IList <PolylineChildren> CreatePolylineChildren(ACADDB.ObjectIdCollection polylines)
        {
            IList <PolylineChildren> children = new List <PolylineChildren>();

            foreach (ACADDB.ObjectId polyoid in polylines)
            {
                ACADDB.ObjectIdCollection collection  = null;
                Point2dCollection         innerpoints = null;
                Point2dCollection         outerpoints = null;

                outerpoints = PlineToPoints(polyoid);
                collection  = new ACADDB.ObjectIdCollection();

                //Is Polyline within Outer Polyline
                foreach (ACADDB.ObjectId polyline in polylines)
                {
                    innerpoints = PlineToPoints(polyline);
                    if (PointUtilities.PointInPolyline(outerpoints, innerpoints))
                    {
                        collection.Add(polyline);
                    }
                }
                children.Add(new PolylineChildren(polyoid, collection));
            }


            return(children);
        }
Exemple #3
0
        public static IList <Point3dCollection> Generate3DBreaklinesFromLidarFile(IList <Point2dCollection> boundary, DateTime time, string hole)
        {
            if (boundary == null)
            {
                throw new ArgumentNullException(nameof(boundary));
            }
            if (hole == null)
            {
                throw new ArgumentNullException(nameof(hole));
            }

            DatabaseCommands command = new DatabaseCommands();
            var path = command.GetPointPathByDate(time, hole);
            var dir  = Path.GetDirectoryName(path);
            var name = Path.GetFileName(path);

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Point3dCollection lidarpoints = CreateAllSurface.ReadPointCloudFile.ReadFile(dir, name);
            //Create a Surface called "ALL".



            Point2dCollection         points2D        = PGA.AcadUtilities.AcadUtilities.ConvertTo2d(lidarpoints);
            IList <Point3dCollection> parsecollection = new List <Point3dCollection>();

            foreach (Point2dCollection pline in boundary)
            {
                Point3dCollection local = new Point3dCollection();
                for (int i = 0; i < points2D.Count; i++)
                {
                    if (PointUtilities.PointInPolyline(pline, points2D[i]))
                    {
                        local.Add(lidarpoints[i]);
                    }
                }
                parsecollection.Add(local);
            }
            return(parsecollection);
        }
Exemple #4
0
        public static IList <Point3dCollection> ProcessLidarFileSubtractRegions(IList <Point2dCollection> boundary, DateTime time, string hole, Point3dCollection lidarpoints, ACADDB.ObjectIdCollection polylineCollection)
        {
            IList <PointsWithPolyId> processedpoints = new List <PointsWithPolyId>();

            if (boundary == null)
            {
                throw new ArgumentNullException(nameof(boundary));
            }
            if (hole == null)
            {
                throw new ArgumentNullException(nameof(hole));
            }

            DatabaseCommands command = new DatabaseCommands();
            var path = command.GetPointPathByDate(time, hole);
            var dir  = Path.GetDirectoryName(path);
            var name = Path.GetFileName(path);

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            //Point3dCollection lidarpoints = CreateAllSurface.ReadPointCloudFile.ReadFile(dir, name);
            Point2dCollection         points2D        = PGA.AcadUtilities.AcadUtilities.ConvertTo2d(lidarpoints);
            IList <Point3dCollection> parsecollection = new List <Point3dCollection>();

            try
            {
                foreach (Point2dCollection pline in boundary)
                {
                    Point3dCollection local = new Point3dCollection();
                    for (int i = 0; i < points2D.Count; i++)
                    {
                        if (PointUtilities.PointInPolyline(pline, points2D[i]))
                        {
                            local.Add(lidarpoints[i]);
                        }
                    }
                    parsecollection.Add(local);
                    //contains the points for each polyline
                    processedpoints.Add(new PointsWithPolyId(local, boundary.IndexOf(pline)));
                }

                m_PolylineChildren.Count();
                //subtract inner points
                foreach (ACADDB.ObjectId maspolyoid in polylineCollection)
                {
                    int masterregloc             = polylineCollection.IndexOf(maspolyoid);
                    PolylineChildren subChildren = m_PolylineChildren[masterregloc];

                    if (maspolyoid != subChildren.Oid)
                    {
                        throw new Exception("ProcesssLidarPoints: Subtract regions unordered!");
                    }



                    for (int i = 0; i < subChildren.Children.Count; i++)
                    {
                        ACADDB.ObjectId subregionoid = subChildren.Children[i];
                        //Filter Out == (Area,ObjectId)
                        if ((subregionoid != maspolyoid) ||
                            !(AcadUtilities.AcadUtilities.CompareAreasFromPolylines
                                  (subregionoid, maspolyoid)))
                        {
                            //var outterRegion = ACADDB.Region.FromAcadObject(maspolyoid);
                            var outterRegion = AddRegion(maspolyoid);
                            var innerRegion  = AddRegion(subregionoid);

                            if (outterRegion.Area > innerRegion.Area)

                            {
                                outterRegion.BooleanOperation(ACADDB.BooleanOperationType.BoolSubtract, innerRegion);
                                innerRegion.Dispose();
                            }
                            //Point3dCollection pointstodelete = new Point3dCollection();

                            //int subregloc = polylineCollection.IndexOf(subregionoid);
                            //if (subregloc != -1)
                            //{
                            //    ACADDB.Region.FromAcadObject(maspolyoid);
                            //    pointstodelete = parsecollection[subregloc];

                            //    for (int j = 0; j < parsecollection[subregloc].Count; j++)
                            //    {
                            //        foreach (Point3d point in pointstodelete)
                            //        {
                            //            if (parsecollection[masterregloc].Contains(point))
                            //                parsecollection[masterregloc].Remove(point);
                            //        }
                            //    }
                            //}
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DatabaseLogs.FormatLogs("ProcessLidarFileSubtractRegions" + ex.Message);
            }

            return(parsecollection);
        }