Esempio n. 1
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);
        }
Esempio n. 2
0
        private static void CreateTinForDistinctSurfaces(IList <Point3dCollection> p3D,
                                                         ACADDB.ObjectIdCollection collection)
        {
            if (p3D.Count != collection.Count)
            {
                return;
            }
            PolylineChildren children;

            try
            {
                foreach (ACADDB.ObjectId polys in collection)
                {
                    children = new PolylineChildren();

                    foreach (PolylineChildren item in m_PolylineChildren)
                    {
                        if (item.Oid.Equals(polys))
                        {
                            for (int i = 0; i < item.Children.Count; i++)
                            {
                                if (item.Children[i].Equals(polys))
                                {
                                    item.Children.RemoveAt(i);
                                }
                                else if (PGA.AcadUtilities.AcadUtilities.CompareAreasFromPolylines(polys,
                                                                                                   item.Children[i]))
                                {
                                    item.Children.RemoveAt(i);
                                }
                            }

                            children = item;
                            break;
                        }
                    }
                    var layer = PGA.SimplifyPolylines.Commands.GetPolylineName(polys);
                    var index = collection.IndexOf(polys);
                    CreateAllSurface.CreateTINSurface pTinSurface;
                    C3D.PasteSurfaces surfaces = new C3D.PasteSurfaces();

                    TinSurface theSurface;
                    if (index < p3D.Count)
                    {
                        pTinSurface = new CreateAllSurface.CreateTINSurface();
                        theSurface  = pTinSurface.CreateTINSurfaceByPointCollection(p3D[index], layer);
                        surfaces.AddBoundariesForSurfaces(PlineToPoints(children.Oid), theSurface.ObjectId);
                        // ACADDB.ObjectId materId = ACADDB.Material.FromAcadObject(theSurface.AcadObject);

                        //adds outer
                        //Adds hide polylines
                        for (int i = 0; i < children.Children.Count; i++)
                        {
                            var polyboundary = new  ACADDB.ObjectIdCollection();
                            polyboundary.Add(children.Oid);
                            SurfaceMaskCreationData mask = new SurfaceMaskCreationData
                                                               (String.Format("Hide-{0}", i), "Hide", theSurface.ObjectId, polyboundary, 3, theSurface.MaterialId, SurfaceMaskType.InSide, false);
                            if (!PGA.AcadUtilities.AcadUtilities.CompareAreasFromPolylines(polys, children.Children[i]))
                            {
                                surfaces.AddStandardBoundary(children.Children[i], theSurface.Name, theSurface);
                                //theSurface.Masks.Add(mask);
                            }
                        }
                    }
                }
            }
            catch (Exception ex1)
            {
                DatabaseLogs.FormatLogs(ex1.Message);
            }
        }