Example #1
0
        //public void SendEnterKey()
        //{
        //    System.Windows.Forms.SendKeys.SendWait("{ENTER}");
        //    Rhino.RhinoApp.Write("Enter");
        //}
        //public void SendEnterKey(object sender, System.EventArgs e)
        //{
        //    System.Windows.Forms.SendKeys.SendWait("{ENTER}");
        //    Rhino.RhinoApp.Write("Enter");
        //}
        public void LoDDDDd_Click(object sender, RoutedEventArgs e)
        {
            var yorn = MessageBox.Show("지적도를 다시 불러옵니다. 작업 내용은 저장되지 않습니다. 계속 하시겠습니까?", "지적도 재 설정", MessageBoxButton.YesNo);

            if (yorn == MessageBoxResult.No)
            {
                return;
            }

            LoadManager.getInstance().
            importFileWithAdress();

            //GetWindow();

            UIManager.getInstance().HideWindow(this, UIManager.WindowType.Menu);
        }
Example #2
0
        private void Button_Simple_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();

            int index = TuringAndCorbusierPlugIn.InstanceClass.turing.tempIndex;


            try
            {
                if (TuringAndCorbusierPlugIn.InstanceClass.turing.MainPanel_building3DPreview[index] != null)
                {
                    TuringAndCorbusierPlugIn.InstanceClass.turing.MainPanel_building3DPreview.RemoveAt(index);
                }
            }
            catch (System.ArgumentOutOfRangeException)
            {
            }

            //Rhino.RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(Rhino.RhinoDoc.ActiveDoc.Layers.Find("ZC304", true), true);

            List <Brep> tempBreps = TuringAndCorbusier.MakeBuildings.makeBuildings(tempOutput);
            List <Guid> tempGuid  = new List <Guid>();

            foreach (Brep i in tempBreps)
            {
                tempGuid.Add(LoadManager.getInstance().DrawObjectWithSpecificLayer(i, LoadManager.NamedLayer.Model));

                //foreach (Brep j in i)
                //{
                //    var guid = RhinoDoc.ActiveDoc.Objects.AddBrep(j);
                //    tempGuid.Add(guid);
                //    RhinoApp.Wait();
                //}
            }

            //Rhino.RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(Rhino.RhinoDoc.ActiveDoc.Layers.Find("Default", true), true);



            TuringAndCorbusierPlugIn.InstanceClass.turing.MainPanel_building3DPreview.Insert(index, tempGuid);
            //MessageBox.Show(index + " 번 결과에 모델링 저장");

            RhinoDoc.ActiveDoc.Views.Redraw();

            CloseWindow();
        }
        private void SetCurve2(Curve boundary, double scalefactor)
        {
            KDGinfo tempKDGinfo = new KDGinfo(boundary, scalefactor, false);

            TuringAndCorbusierPlugIn.InstanceClass.kdgInfoSet = tempKDGinfo;

            Curve scaledBoundary = tempKDGinfo.boundary;

            var objectsToHide = Rhino.RhinoDoc.ActiveDoc.Objects.FindByObjectType(Rhino.DocObjects.ObjectType.AnyObject);

            foreach (var objectToHide in objectsToHide)
            {
                Rhino.RhinoDoc.ActiveDoc.Objects.Hide(objectToHide.Id, true);
            }


            var guid = LoadManager.getInstance().DrawObjectWithSpecificLayer(scaledBoundary, LoadManager.NamedLayer.Guide);

            //Rhino.RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(Rhino.RhinoDoc.ActiveDoc.Layers.Find("ZC304", true), true);
            //var guid = RhinoDoc.ActiveDoc.Objects.AddCurve(scaledBoundary);
            LoadManager.getInstance().DrawObjectWithSpecificLayer(tempKDGinfo.outrect, LoadManager.NamedLayer.Model);
            //var rectguid = RhinoDoc.ActiveDoc.Objects.AddCurve(tempKDGinfo.outrect);
            int index = TuringAndCorbusierPlugIn.InstanceClass.turing.stackPanel.Children.Count;


            /// checkpoint 테스트용
            ///

            LoadManager.getInstance().DrawObjectWithSpecificLayer(tempKDGinfo.surrbuildings, LoadManager.NamedLayer.Model);

            //foreach (var surrcurve in TuringAndCorbusierPlugIn.InstanceClass.kdgInfoSet.surrbuildings)
            //{

            //    RhinoDoc.ActiveDoc.Objects.AddCurve(surrcurve);
            //}
            ///
            RhinoDoc.ActiveDoc.Objects.Select(guid);
            RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ZoomExtentsSelected();

            RhinoDoc.ActiveDoc.Views.Redraw();
            //RhinoDoc.ActiveDoc.Layers.SetCurrentLayerIndex(Rhino.RhinoDoc.ActiveDoc.Layers.Find("Default", true), true);
            TuringAndCorbusierPlugIn.InstanceClass.plot          = new TuringAndCorbusier.Plot(scaledBoundary);
            TuringAndCorbusierPlugIn.InstanceClass.plot.PlotType = this.plotType2;
        }
        public void initEvent()
        {
            if (isAdministrator())
            {
                Rhino.RhinoApp.WriteLine("Admin");
            }
            else
            {
                Rhino.RhinoApp.WriteLine("NotAdmin");
            }

            try
            {
                UIManager.getInstance().init();
            }
            catch (System.TypeInitializationException e1e)
            {
                System.Windows.Forms.MessageBox.Show(e1e.Message);
            }

            Rhino.ApplicationSettings.GeneralSettings.NewObjectIsoparmCount = -1;

            InstanceClass.turing.ProjectAddress.Text = CommonFunc.getAddressFromServer(InstanceClass.turing.CurrentDataIdName.ToList(), InstanceClass.turing.CurrentDataId.ToList());

            Rhino.RhinoApp.Wait();

            Rhino.RhinoApp.Wait();

            LoadManager.getInstance().importFileWithAdress();
            LoadManager.getInstance().LayerSetting();


            ///6.3
            RhinoWindowSetUp.SetUIForTC(Rhino.RhinoDoc.ActiveDoc);
            ///~6.3
            Rhino.RhinoApp.WriteLine("InitComplete");
        }
Example #5
0
        // use
        public List <Brep> KDGmaker(List <Curve> segs, Curve boundary, List <Point3d> roadPoints, Brep ground)
        {
            double depth = 3000;

            var groundMesh = Mesh.CreateFromBrep(ground);


            //long mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("init : {0}", mem1);
            //split surface
            List <Point3d> bboxPts = new List <Point3d>();

            foreach (Curve c in segs)
            {
                bboxPts.Add(c.PointAtStart);
                bboxPts.Add(c.PointAtEnd);
            }
            var          bbox = new BoundingBox(bboxPts);
            Rectangle3d  rect = new Rectangle3d(Plane.WorldXY, bbox.Min, bbox.Max);
            List <Curve> crvs = new List <Curve>();

            crvs.Add(rect.ToNurbsCurve());

            Brep brep = Brep.CreatePlanarBreps(rect.ToNurbsCurve())[0];


            // mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("BeforeSplit : {0}", mem1);


            var temp1 = brep.Faces[0].Split(segs, 0.1).Faces;
            //mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("AfterSplit : {0}", mem1);
            List <Brep> temp2 = new List <Brep>();

            foreach (BrepFace bf in temp1)
            {
                temp2.Add(bf.DuplicateFace(false));
            }


            List <Curve> groundsplitcurve = new List <Curve>();

            //get edge polylines
            List <Polyline>    edges     = new List <Polyline>();
            List <Polyline>    edgesRoad = new List <Polyline>();
            List <Polyline>    edgesPlot = new List <Polyline>();
            List <Rectangle3d> rects     = new List <Rectangle3d>();

            //mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("BeforeD : {0}", mem1);
            foreach (Brep b in temp2)
            {
                Polyline polyTemp;
                Curve.JoinCurves(b.DuplicateEdgeCurves().ToList(), 1)[0].TryGetPolyline(out polyTemp);

                bool isRoad = false;
                for (int i = 0; i < roadPoints.Count; i++)
                {
                    if (polyTemp.ToNurbsCurve().Contains(roadPoints[i]) != Rhino.Geometry.PointContainment.Outside)
                    {
                        isRoad = true;
                        break;
                    }
                }

                if (!isRoad && boundary.Contains(polyTemp.CenterPoint()) == Rhino.Geometry.PointContainment.Outside)
                {
                    edges.Add(polyTemp);
                }
                else if (isRoad)
                {
                    edgesRoad.Add(polyTemp);
                }
                else
                {
                    edgesPlot.Add(polyTemp);
                }
            }
            // mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("AfterD : {0}", mem1);


            //create plot ground
            List <double> groundHeight = new List <double>();
            List <Brep>   grounds      = new List <Brep>();

            foreach (Polyline c in edgesPlot)
            {
                List <Point3d> ptl = new List <Point3d>();
                List <Brep>    bl  = new List <Brep>();
                ptl.Add(c.CenterPoint());
                bl.Add(ground);

                //LoadManager.getInstance().DrawObjectWithSpecificLayer(bl, LoadManager.NamedLayer.Guide);
                //Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();

                Point3d projectedPoint = Rhino.Geometry.Intersect.Intersection.ProjectPointsToMeshes(groundMesh, ptl, Vector3d.ZAxis, 0)[0];
                groundHeight.Add(projectedPoint.Z);

                //Brep groundPiece = Brep.CreatePlanarBreps(c.ToNurbsCurve())[0];
                Brep groundPiece = Surface.CreateExtrusion(c.ToNurbsCurve(), Vector3d.ZAxis * (-depth)).ToBrep().CapPlanarHoles(1);
                grounds.Add(groundPiece);
            }
            double averageHeight = groundHeight.Sum() / groundHeight.Count;

            //create building mass and ground
            Random      rand      = new Random(segs.Count);
            List <Brep> buildings = new List <Brep>();

            double pil = Consts.PilotiHeight;
            double flr = Consts.FloorHeight;



            //mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("BeforeEdge : {0}", mem1);
            foreach (Polyline c in edges)
            {
                if (getArea(c) > 1)
                {
                    List <Point3d> ptl = new List <Point3d>();
                    List <Brep>    bl  = new List <Brep>();
                    ptl.Add(c.CenterPoint());
                    bl.Add(ground);
                    Point3d projectedPoint;

                    //LoadManager.getInstance().DrawObjectWithSpecificLayer(bl, LoadManager.NamedLayer.Guide);
                    //Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();

                    //dtsasdfasdf

                    projectedPoint = Rhino.Geometry.Intersect.Intersection.ProjectPointsToMeshes(groundMesh, ptl, Vector3d.ZAxis, 0)[0];

                    //~dtsasdfasdf
                    //Brep groundPiece = Brep.CreatePlanarBreps(c.ToNurbsCurve())[0];
                    Brep groundPiece = Surface.CreateExtrusion(c.ToNurbsCurve(), Vector3d.ZAxis * (-depth)).ToBrep().CapPlanarHoles(1);
                    if (groundPiece == null)
                    {
                        continue;
                    }
                    groundPiece.Translate(Vector3d.ZAxis * (projectedPoint.Z - averageHeight));
                    grounds.Add(groundPiece);

                    Curve   cTemp = c.ToNurbsCurve();
                    Curve[] temp  = cTemp.Offset(Plane.WorldXY, -3002, 1, CurveOffsetCornerStyle.Sharp);
                    if (temp != null && temp.Length != 0)
                    {
                        cTemp = temp[0];
                        Curve[] temptemp = cTemp.Offset(Plane.WorldXY, 2, 1, CurveOffsetCornerStyle.Sharp);
                        if (temptemp.Length != 0)
                        {
                            cTemp = temptemp[0];
                            Polyline pTemp;
                            cTemp.TryGetPolyline(out pTemp);

                            if (getArea(pTemp) < getArea(c) * 0.6)
                            {
                                Curve[] temptemptemp = cTemp.Offset(Plane.WorldXY, 1000, 1, CurveOffsetCornerStyle.Sharp);
                                if (temptemptemp != null)
                                {
                                    cTemp = temptemptemp[0];
                                }
                            }
                            if (cTemp.IsClosed == true && cTemp.GetBoundingBox(false).Diagonal.Length < bbox.Diagonal.Length)
                            {
                                Brep tempBrep = Surface.CreateExtrusion(cTemp, Vector3d.ZAxis * (pil + flr * rand.Next(3, 5))).ToBrep().CapPlanarHoles(1);
                                tempBrep.Translate(Vector3d.ZAxis * (projectedPoint.Z - averageHeight));
                                buildings.Add(tempBrep);
                            }
                        }
                    }
                }
            }

            //mem1 = GC.GetTotalMemory(false);
            // Rhino.RhinoApp.WriteLine("AfterEdge : {0}", mem1);

            List <Curve> projectedRoads = new List <Curve>();

            //mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("BeforeRoadEdge : {0}", mem1);

            foreach (Polyline c in edgesRoad)
            {
                Curve        road1 = Curve.ProjectToMesh(c.ToNurbsCurve(), groundMesh, Vector3d.ZAxis, 0.01)[0];
                List <Curve> roadl = new List <Curve>();
                roadl.Add(road1);

                //LoadManager.getInstance().DrawObjectWithSpecificLayer(ground, LoadManager.NamedLayer.Model);

                //Curve road2 = Curve.ProjectToMesh(c.ToNurbsCurve(), Mesh.CreateFromBrep(ground)[0], Vector3d.ZAxis, 0)[0];
                road1.Translate(Vector3d.ZAxis * (-averageHeight));
                Brep groundPiece = Surface.CreateExtrusion(road1.ToNurbsCurve(), Vector3d.ZAxis * (-depth)).ToBrep().CapPlanarHoles(1);
                Guid guid        = LoadManager.getInstance().DrawObjectWithSpecificLayer(road1, LoadManager.NamedLayer.ETC);

                //Rhino.RhinoDoc.ActiveDoc.Objects.Select(guid,true,true);
                //Rhino.RhinoApp.RunScript("_-Patch '_Enter", true);

                //Rhino.RhinoDoc.ActiveDoc.Objects.Delete(guid, true);

                //LoadManager.getInstance().DrawObjectWithSpecificLayer(temp, LoadManager.NamedLayer.Guide);
                grounds.Add(groundPiece);

                projectedRoads.Add(road1);
            }

            //mem1 = GC.GetTotalMemory(false);
            //Rhino.RhinoApp.WriteLine("AfterRoadEdge : {0}", mem1);


            List <Mesh> projectedRoadMesh = GetRoadPatch(projectedRoads, groundMesh[0]);

            for (int i = 0; i < projectedRoadMesh.Count; i++)
            {
                if (projectedRoadMesh[i] != null)
                {
                    LoadManager.getInstance().DrawObjectWithSpecificLayer(projectedRoadMesh[i], LoadManager.NamedLayer.ETC);
                }
            }


            Point3d test = new Point3d(1, 1, 1);



            //test
            buildings.AddRange(grounds);

            return(buildings);
        }