Пример #1
0
        //private void GenerateOne_Click(object sender, RoutedEventArgs e)
        //{
        //    if (PlotTypeCombo.SelectedIndex == -1)
        //        return;

        //    if (tempSelectedBoundary == null)
        //        return;

        //    int i = PlotTypeCombo.SelectedIndex;

        //    Plot plot = new Plot() { Boundary = tempSelectedBoundary, BuildingType = BuildingTypes.다세대, LegalCVR = setting.LegalCVR[i], LegalFAR = setting.LegalFAR[i], LegalMaxF = setting.LegalMaxF[i], PlotType = (PlotTypes)i, RoadWidths = new List<double>() { 4 } };


        //    //test
        //    var roadCenter = Regulation.RoadCenterLines(plot);
        //    var north = Regulation.North(roadCenter, plot);
        //    var clearance = Regulation.Clearance(plot);
        //    int minimum = north.Count > clearance.Count ? clearance.Count : north.Count;
        //    List<Curve> nc = new List<Curve>();
        //    for (int j = 0; j < minimum; j++)
        //    {
        //        var a = Curve.CreateBooleanIntersection(north[j], clearance[j]);
        //        nc.Add(a[0]);
        //    }

        //    int r = (int)Angle.Value;

        //    var start = DateTime.Now;
        //    var reg = Regulation.MergedRegulation(nc, plot, (double)r / 180 * Math.PI);
        //    var end = DateTime.Now;
        //    //Rhino.RhinoApp.WriteLine("법규선계산 : " + (end.Second - start.Second) + "초" + (end.Millisecond - start.Millisecond) + "ms");
        //    start = DateTime.Now;
        //    List<Curve> temp1;
        //    List<Curve> temp2;
        //    var val1 = Calculate.AngleMax_Josh(reg.Last(), plot.LegalMaxF, 9, (double)r / 180 * Math.PI,out temp1);
        //    end = DateTime.Now;
        //    //Rhino.RhinoApp.WriteLine("최대길이계산 : " + (end.Second - start.Second) + "초" + (end.Millisecond - start.Millisecond) + "ms  yvalue = " + Math.Round(length, 1).ToString());
        //    var val2 = Calculate.AngleMax(reg.Last(), plot.LegalMaxF, 9, (double)r / 180 * Math.PI, out temp2);
        //    //points.Add(new System.Windows.Point(r, length));



        //    //double lengthmax = points.Select(n => n.Y).Max();

        //    preview.reg = reg;
        //    preview.model1 = temp1;
        //    preview.model2 = temp2;
        //    preview.value1 = val1;
        //    preview.value2 = val2;
        //    Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();
        //}

        /// <summary>
        /// asdfasfdfdassfdasfda
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Angle_Combo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (Angle_Combo.SelectedIndex == -1)
            {
                return;
            }

            if (PlotTypeCombo.SelectedIndex == -1)
            {
                return;
            }

            if (tempSelectedBoundary == null)
            {
                return;
            }

            if (Width_Combo.SelectedIndex == -1)
            {
                return;
            }

            int i = PlotTypeCombo.SelectedIndex;
            //폭
            double width   = (double)Width_Combo.SelectedItem;
            double canvasy = Graph.Height;
            double canvasx = Graph.Width;
            List <System.Windows.Point> points = new List <System.Windows.Point>();
            Plot plot = new Plot()
            {
                Boundary = tempSelectedBoundary, BuildingType = BuildingTypes.다세대, LegalCVR = setting.LegalCVR[i], LegalFAR = setting.LegalFAR[i], LegalMaxF = setting.LegalMaxF[i], PlotType = (PlotTypes)i, RoadWidths = new List <double>()
                {
                    4
                }
            };


            //test
            var          roadCenter = Regulation.RoadCenterLines(plot);
            var          north      = Regulation.North(roadCenter, plot);
            var          clearance  = Regulation.Clearance(plot);
            int          minimum    = north.Count > clearance.Count ? clearance.Count : north.Count;
            List <Curve> nc         = new List <Curve>();

            for (int j = 0; j < minimum; j++)
            {
                var a = Curve.CreateBooleanIntersection(north[j], clearance[j]);
                nc.Add(a[0]);
            }



            double r = (double)Angle_Combo.SelectedValue;

            var start = DateTime.Now;
            var reg   = Regulation.MergedRegulation(nc, plot, (double)r / 180 * Math.PI);
            var end   = DateTime.Now;

            //Rhino.RhinoApp.WriteLine("법규선계산 : " + (end.Second - start.Second) + "초" + (end.Millisecond - start.Millisecond) + "ms");
            start = DateTime.Now;
            //List<Curve> temp1;
            List <Curve> temp2;

            //var val1 = Calculate.AngleMax_Josh(reg.Last(), plot.LegalMaxF, 9, (double)r / 180 * Math.PI, out temp1);
            end = DateTime.Now;

            List <Rhino.Geometry.Line> parkingBaseLine;
            //Rhino.RhinoApp.WriteLine("최대길이계산 : " + (end.Second - start.Second) + "초" + (end.Millisecond - start.Millisecond) + "ms  yvalue = " + Math.Round(length, 1).ToString());
            var val2 = Calculate.AngleMax_Simple(reg.Last(), plot.LegalMaxF, width, (double)r / 180 * Math.PI, out temp2, out parkingBaseLine);

            double aptDistance  = (reg.Last().PointAtStart.Z - 3.3) * 0.8;
            double linedistance = width + aptDistance;

            var far = Math.Round(val2 * width * plot.LegalMaxF / plot.Area, 4) * 100;
            //points.Add(new System.Windows.Point(r, length));


            //유닛분배........................................................................................
            //유닛정보,라인..음..
            List <Point3d> aptSeparatePoints = new List <Point3d>();
            List <Point3d> balancedPoints    = new List <Point3d>();

            for (int j = 0; j < temp2.Count; j++)
            {
                var tempcurve  = temp2[j];
                var templength = tempcurve.GetLength();
                var unitset    = (UnitSetting)Units.Items[0];
                var unitlength = unitset.Area / width;
                var p1         = tempcurve.PointAtLength(templength);
                aptSeparatePoints.Add(p1);
                int aptcount = 0;
                while (templength > 2 * unitlength)
                {
                    var p2 = tempcurve.PointAtLength(templength - unitlength);
                    var p3 = tempcurve.PointAtLength(templength - unitlength * 2);
                    aptcount += 2;
                    aptSeparatePoints.Add(p2);
                    aptSeparatePoints.Add(p3);
                    templength -= 2 * unitlength;
                }

                double lengthleftperapt  = templength / aptcount;
                double balancedaptlength = unitlength + lengthleftperapt;
                for (int k = 0; k <= aptcount; k++)
                {
                    var temppoint = tempcurve.PointAtLength(k * balancedaptlength);
                    balancedPoints.Add(temppoint);
                }
            }

            preview.points         = aptSeparatePoints;
            preview.balancedpoints = balancedPoints;


            List <Curve>  parkingLinesCollection = new List <Curve>();
            List <Curve>  baseCurves             = parkingBaseLine.Select(n => n.ToNurbsCurve() as Curve).ToList();
            ParkingMaster master       = new ParkingMaster(tempSelectedBoundary, baseCurves, linedistance);
            int           parkingCount = master.CalculateParkingScore();

            parkingLinesCollection = master.parkingCells;
            //for (int p = 0; p < parkingBaseLine.Count; p++)
            //{
            //    bool addfirst = p == 0 ? true : false;
            //    List<Curve> parkingLines = ParkingPrediction.Calculate(linedistance, parkingBaseLine[p].ToNurbsCurve(), addfirst);
            //    parkingLinesCollection.AddRange(parkingLines);
            //}


            //주차는.?

            //for()

            //plot, aptline, width, distance

            //distance 와 set

            //double lengthmax = points.Select(n => n.Y).Max();

            preview.reg    = reg;
            preview.model1 = parkingLinesCollection;
            preview.model2 = temp2;
            preview.value1 = parkingCount;
            preview.value2 = far;
            Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw();
        }
Пример #2
0
        private List <List <System.Windows.Point> > CalcAsyncEachFloor(int i, double width)
        {
            List <List <System.Windows.Point> > result = new List <List <System.Windows.Point> >();
            Plot plot = new Plot()
            {
                Boundary = tempSelectedBoundary, BuildingType = BuildingTypes.다세대, LegalCVR = setting.LegalCVR[i], LegalFAR = setting.LegalFAR[i], LegalMaxF = setting.LegalMaxF[i], PlotType = (PlotTypes)i, RoadWidths = new List <double>()
                {
                    4
                }
            };

            //test
            var          roadCenter = Regulation.RoadCenterLines(plot);
            var          north      = Regulation.North(roadCenter, plot);
            var          clearance  = Regulation.Clearance(plot);
            int          minimum    = north.Count > clearance.Count ? clearance.Count : north.Count;
            List <Curve> nc         = new List <Curve>();

            for (int j = 0; j < minimum; j++)
            {
                var a = Curve.CreateBooleanIntersection(north[j], clearance[j]);
                nc.Add(a[0]);
            }


            //List<List<Curve>> curvesCollection = new List<List<Curve>>();
            //List<double> valuesCollection = new List<double>();
            var start = DateTime.Now;

            for (int r = 0; r < 180; r++)
            {
                List <System.Windows.Point> points = new List <System.Windows.Point>();

                var reg = Regulation.MergedRegulation(nc, plot, (double)r / 180 * Math.PI);

                List <Curve> trash;
                List <Rhino.Geometry.Line> trash2;
                for (int f = reg.Count - 4; f < reg.Count; f++)
                {
                    var length = Calculate.AngleMax_Simple(reg[f], f, width, (double)r / 180 * Math.PI, out trash, out trash2);

                    //valuesCollection.Add(length);
                    points.Add(new System.Windows.Point(r, length * f / 10));
                }

                result.Add(points);
            }
            var end      = DateTime.Now;
            int endsec   = end.Second;
            int startsec = start.Second;

            if (startsec > endsec)
            {
                endsec += 60;
            }
            double endtime   = endsec * 1000 + end.Millisecond;
            double starttime = startsec * 1000 + start.Millisecond;
            double x         = (endtime - starttime) / 1000;

            Rhino.RhinoApp.WriteLine("소요시간 " + x.ToString() + "초");
            //double lengthmax = points.Select(n => n.Y).Max();

            return(result);
        }