Exemplo n.º 1
0
        private List <System.Windows.Point> CalcAsync(int i, double 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]);
            }


            //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++)
            {
                int maxfloor;
                var reg = Regulation.MergedRegulation_TopOnly(nc, plot, (double)r / 180 * Math.PI, out maxfloor);

                List <Curve> trash;
                List <Rhino.Geometry.Line> trash2;
                var length = Calculate.AngleMax_Simple(reg.Last(), maxfloor, width, (double)r / 180 * Math.PI, out trash, out trash2);

                valuesCollection.Add(length);
                points.Add(new System.Windows.Point(r, length * maxfloor / 10));
            }
            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("180회 소요시간 " + x.ToString() + "초, 회당 " + (x / 180).ToString() + "초");
            double lengthmax = points.Select(n => n.Y).Max();

            return(points);
        }
Exemplo n.º 2
0
        public Curve InnerLoop(Curve boundary)
        {
            CurveOrientation ot             = boundary.ClosedCurveOrientation(Plane.WorldXY);
            double           offsetDistance = 6;
            var segments = boundary.DuplicateSegments();


            for (int i = 0; i < segments.Length; i++)
            {
                Vector3d v = segments[i].TangentAtStart;
                v.Rotate(-Math.PI / 2, Vector3d.ZAxis);
                Curve temp = segments[i].DuplicateCurve();
                temp.Translate(v * offsetDistance);
                segments[i] = temp;
            }

            List <Point3d> toPoly = new List <Point3d>();

            for (int i = 0; i < segments.Length; i++)
            {
                int    j  = (i + 1) % segments.Length;
                Line   l1 = new Line(segments[i].PointAtStart, segments[i].PointAtEnd);
                Line   l2 = new Line(segments[j].PointAtStart, segments[j].PointAtEnd);
                double p1;
                double p2;
                Rhino.Geometry.Intersect.Intersection.LineLine(l1, l2, out p1, out p2);
                toPoly.Add(l1.PointAt(p1));
            }

            toPoly.Add(toPoly[0]);

            Curve merged = new Polyline(toPoly).ToNurbsCurve();

            var intersection = Rhino.Geometry.Intersect.Intersection.CurveSelf(merged, 0);

            var parameters = intersection.Select(n => n.ParameterA).ToList();

            parameters.AddRange(intersection.Select(n => n.ParameterB));

            var spltd  = merged.Split(parameters);
            var joined = Regulation.NewJoin(spltd);

            return(joined.Where(n => n.ClosedCurveOrientation(Plane.WorldXY) == ot).ToList()[0]);
        }
Exemplo n.º 3
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();
        }