Esempio n. 1
0
    // Use this for initialization
    void Awake()
    {
#if UNITY_EDITOR
        LayerUtil.CreateLayer("Units");
        LayerUtil.CreateLayer("Terrain");
        LayerUtil.CreateLayer("CameraDragLayer");
#endif
        Camera c = gameObject.GetComponent <Camera>();
        c.cullingMask = ~(1 << LayerMask.NameToLayer("Units"));
    }
Esempio n. 2
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);
        }
Esempio n. 3
0
        internal void genContour2(ObjectId[] objectId_0, CoordinateSystem coordinateSystem_0)
        {
            Editor        editor        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            ProgressMeter progressMeter = new ProgressMeter();
            MessageFilter messageFilter = new MessageFilter();

            System.Windows.Forms.Application.AddMessageFilter(messageFilter);
            CoordinateSystem coordinateSystem = CoordinateSystem.Global();

            try
            {
                if (objectId_0 == null)
                {
                    throw new ArgumentException("No faces selected.");
                }
                string   layerName       = UserCmd.contourLNPrefix + cmd.mydb.Resolution;
                string   assistLayerName = "contour_assist_" + cmd.mydb.Resolution;
                ObjectId layerId         = LayerUtil.CreateLayer(layerName, 127, true, false);
                ObjectId assistLayerId   = LayerUtil.CreateLayer(assistLayerName, 127, true, false);
                int      num             = DBManager.SetEpsilon();
                int      num2            = (int)Convert.ToInt16(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("LUPREC").ToString());
                num = Math.Min(num2 + 2, num);
                List <Triangle> list = Conversions.ToCeometricCADDataTriangleList(objectId_0);
                if (coordinateSystem_0 != coordinateSystem)
                {
                    Triangle.TransformCoordinates(list, coordinateSystem, coordinateSystem_0);
                }
                else
                {
                    coordinateSystem_0 = null;
                }
                int limit = (int)(Math.Abs(ContourLineComputation.endElevation - ContourLineComputation.startElevation) / ContourLineComputation.spacing);
                progressMeter.SetLimit(limit);
                progressMeter.Start("Computing contours");
                int    num3      = 0;
                int    num4      = 0;
                int    num5      = 0;
                int    num6      = 0;
                int    num7      = 0;
                double maxZ      = cmd.mydb.TEDicList[cmd.mydb.Resolution].maxMaxZ;
                double elevation = ContourLineComputation.startElevation;
                Plane  plane     = new Plane(new ngeometry.VectorGeometry.Point(0.0, 0.0, elevation), new Vector3d(0.0, 0.0, 1.0));
                cmd.mydb.assistContourDics[cmd.mydb.Resolution] = new AssistContourDic();
                while (elevation <= ContourLineComputation.endElevation)
                {
                    if (elevation >= maxZ)
                    {
                        break;
                    }
                    progressMeter.MeterProgress();
                    messageFilter.CheckMessageFilter();
                    List <Edge> interEdgeList = this.getInterSection2(list, plane, num3, ref num5, ref num4);
                    if (interEdgeList.Count <= 0)
                    {
                        editor.WriteMessage("\nNo contours at elevation : " + elevation.ToString());
                    }
                    else
                    {
                        Autodesk.AutoCAD.Geometry.Plane    plane1  = new Autodesk.AutoCAD.Geometry.Plane(new Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0), new Autodesk.AutoCAD.Geometry.Vector3d(0, 0, 1));
                        Autodesk.AutoCAD.Geometry.Matrix3d prjMat1 = Autodesk.AutoCAD.Geometry.Matrix3d.Projection(plane1, plane1.Normal);
                        TransformUtil.Transform(interEdgeList, prjMat1);
                        List <Polyline3d> pline3ds = new List <Polyline3d>();
                        List <PLine>      pllist   = DBManager.WritePlinesInDataBase2(interEdgeList, coordinateSystem_0, num, false, layerId, Color.White, pline3ds);
                        cmd.contColorize.addContour(pline3ds, elevation);
                        num6 += pllist.Count;

                        double assistElevation = elevation + spacing / 2;
                        if (assistElevation >= maxZ)
                        {
                            assistElevation = elevation + (maxZ - elevation) / 2;
                        }
                        genAssistContour(list, plane, coordinateSystem_0, assistLayerId, assistElevation, num, num3);
                        num7 += interEdgeList.Count;
                    }

                    elevation    += ContourLineComputation.spacing;
                    plane.Point.Z = elevation;
                    num3++;
                }
                editor.WriteMessage("\nFailed intersections     : " + num5);
                editor.WriteMessage("\nDegenerate intersections : " + num4);
                editor.WriteMessage("\nTotal number of segments : " + num7);
                editor.WriteMessage("\nTotal number of polylines: " + num6);
                progressMeter.Stop();
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
        }