Ejemplo n.º 1
0
 public void resetContours()
 {
     for (int i = 0; i < contours.Count; i++)
     {
         CContour2 con = contours[i];
         con.tbPLine.reset();
     }
 }
Ejemplo n.º 2
0
 public void addContour(List <Polyline3d> plines, double elevation)
 {
     //if (this.contours.Count > 3) return;
     for (int i = 0; i < plines.Count; i++)
     {
         CContour2 cc = new CContour2();
         cc.elevation = elevation;
         Polyline3d pl = plines[i];
         cc.tbPLine = new TBPLine(pl);
         this.contours.Add(cc);
     }
 }
Ejemplo n.º 3
0
        public void calcClosedRegion(MyDB2 mydb, List <System.Drawing.Color> cl)
        {
            Editor         ed        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ObjectId       layerId   = LayerUtil.CreateLayer(ccLayerNamePrefix + "_" + mydb.Resolution, 127, false);
            List <TBPoint> ps        = new List <TBPoint>();
            List <Loop>    boundarys = new List <Loop>();

            ed.WriteMessage("contours.count:" + contours.Count);
            for (int i = 0; i < contours.Count; i++)
            {
                CContour2 contour        = contours[i];
                Loop      closedBoundary = TraceBoundary.TraceBoundary.getClosedBoundary(contour.tbPLine, contour);
                if (closedBoundary != null)
                {
                    boundarys.Add(closedBoundary);
                    continue;
                }
                List <TBPLineSegment> segs = contour.tbPLine.SegmentedPlines;
                if (segs.Count <= 0)
                {
                    continue;
                }
                List <Point3d> boundaryPoints = new List <Point3d>();
                for (int j = 0; j < 2; j++)//两个方向都求边界,确保loop的elevation属于最小的contour的。
                {
                    Loop minBoundary =
                        TraceBoundary.TraceBoundary.getMinBoundary(segs[0], contour);
                    if (minBoundary == null)
                    {
                        //ed.WriteMessage("");
                        continue;
                    }
                    //minBoundary.userData = contour;
                    boundarys.Add(minBoundary);
                    List <LoopSeg> loopsegs = minBoundary.segments;
                    if (loopsegs == null)
                    {
                        continue;
                    }
                }
            }

            /*for (int j = 0; j < originalBoundarys.Count; j++)
             * {
             *  Loop minBoundary =
             *  TraceBoundary.TraceBoundary.getMinBoundary(originalBoundarys[j].segmentedPlines[0]);
             *  boundarys.Add(minBoundary);
             * }*/
            for (int k = 0; k < boundarys.Count - 1; k++)
            {
                try
                {
                    Loop boundary = boundarys[k];
                    TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys);
                    //TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys.GetRange(k+1,boundarys.Count-k-1));
                    //TraceBoundary.TraceBoundary.calcNeighbourInnerLoop(boundary);
                    //CContour2 contour = boundary.userData as CContour2;
                    //Color color = ColorizeBase.getColorIndex(mydb, contour.elevation);
                    //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(boundary), color);
                }
                catch (System.Exception ex)
                {
                    ed.WriteMessage("\n192 k:" + k + "--" + ex.Message);
                }
            }

            for (int kk = 0; kk < boundarys.Count; kk++)
            {
                DBObjectCollection outerLoopObjs = null;
                try
                {
                    Loop boundary = boundarys[kk];
                    //TraceBoundary.TraceBoundary.calcAllInnerLoop(boundary, boundarys);
                    TraceBoundary.TraceBoundary.calcNeighbourInnerLoop(boundary);
                    CContour2 contour = boundary.userData as CContour2;
                    Color     color   = ColorizeBase.getColorIndex(mydb, contour.elevation);
                    //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(boundary), color);
                    outerLoopObjs = boundary.getOuterLoopObjs();
                    Region region = MyRegion.NewRegion(outerLoopObjs, boundary.getInnerLoopObjsList(), color, layerId);
                    outerLoopObjs = null;
                }
                catch (System.Exception ex2)
                {
                    ed.WriteMessage("\n210 kk:" + kk + "--" + ex2.Message);
                    if (outerLoopObjs != null)
                    {
                        ed.WriteMessage("\nobjs:\n");
                        for (int ee = 0; ee < outerLoopObjs.Count; ee++)
                        {
                            Polyline3d pl = outerLoopObjs[ee] as Polyline3d;
                            if (pl != null)
                            {
                                ed.WriteMessage(pl.StartPoint.X + "," + pl.StartPoint.Y);
                                ed.WriteMessage("\n");
                                ed.WriteMessage(pl.EndPoint.X + "," + pl.EndPoint.Y);
                                ed.WriteMessage("\n");
                            }
                        }
                    }
                    ed.WriteMessage("\n210 kk:" + kk + "--" + ex2.Message);
                }
            }
            //Region region = MyRegion.NewRegion(MyConvert.toDBObjects(segs));
            //region.Color = ColorizeBase.getColorIndex(mydb, contour.elevation);
        }