예제 #1
0
        public static Elevation drawElevation(Curve baseCurve, List <List <Household> > houseHolds, List <Core> cores)
        {
            double storiesHeight = Consts.FloorHeight;
            double pilotiHeight  = Consts.PilotiHeight;

            double windowSide   = 300;
            double windowLow    = 300;
            double windowHeight = 2100;

            Curve groundCurve = new LineCurve(new Point3d(0, 0, 0), new Point3d(baseCurve.GetLength(), 0, 0));

            List <Curve> outlineCurve = new List <Curve>();
            List <Curve> windowDetail = new List <Curve>();
            List <Curve> banister     = new List <Curve>();
            List <Curve> core         = new List <Curve>();

            List <double> widthList = new List <double>();

            foreach (List <Household> i in houseHolds)
            {
                foreach (Household j in i)
                {
                    widthList.Add(j.YLengthA);
                }
            }

            List <double> uniqueWidthList = widthList.Distinct().ToList();

            uniqueWidthList.Sort();

            List <Brep>   tempElevationBase = new List <Brep>();
            List <Curve>  BalconyBase       = new List <Curve>();
            List <double> pilotiParameter   = new List <double>();
            List <Curve>  coreBase          = new List <Curve>();

            for (int h = 0; h < houseHolds.Count(); h++)
            {
                for (int i = 0; i < houseHolds[h].Count(); i++)
                {
                    Point3d start = houseHolds[h][i].Origin + houseHolds[h][i].XDirection * (-houseHolds[h][i].XLengthB);
                    Point3d end   = houseHolds[h][i].Origin + houseHolds[h][i].XDirection * (houseHolds[h][i].XLengthA - houseHolds[h][i].XLengthB);

                    double startDomain; double endDomain;

                    baseCurve.ClosestPoint(start, out startDomain);
                    baseCurve.ClosestPoint(end, out endDomain);

                    if (h == 0)
                    {
                        pilotiParameter.Add((endDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0);
                        pilotiParameter.Add((startDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0);
                    }

                    Curve tempHousingBase = new LineCurve(groundCurve.PointAt((startDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0), groundCurve.PointAt((endDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0));

                    tempHousingBase.Transform(Transform.Translation(new Vector3d(0, start.Z, 0)));
                    Curve tempHousingTop = tempHousingBase.DuplicateCurve();
                    tempHousingTop.Transform(Transform.Translation(new Vector3d(0, storiesHeight, 0)));

                    Curve[] tempLoftBase = { tempHousingBase, tempHousingTop };

                    Brep tempHousingBrep = Brep.CreateFromLoft(tempLoftBase, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0];

                    Curve tempBalconyBase = tempHousingBase.DuplicateCurve();
                    tempBalconyBase.Transform(Transform.Translation(new Vector3d(0, windowLow, 0)));

                    double balconyBaseStart; double balconyBaseEnd;

                    tempBalconyBase.LengthParameter(windowSide, out balconyBaseStart);
                    tempBalconyBase.LengthParameter(tempBalconyBase.GetLength() - windowSide, out balconyBaseEnd);

                    tempBalconyBase = new LineCurve(tempBalconyBase.PointAt(balconyBaseStart), tempBalconyBase.PointAt(balconyBaseEnd));

                    tempElevationBase.Add(tempHousingBrep);
                    BalconyBase.Add(tempBalconyBase);
                }
            }

            for (int i = 0; i < cores.Count(); i++)
            {
                Point3d tempCoreStart = cores[i].Origin;
                Point3d tempCoreEnd   = cores[i].Origin + cores[i].XDirection * cores[i].Width;

                double startDomain; double endDomain;

                baseCurve.ClosestPoint(tempCoreStart, out startDomain);
                baseCurve.ClosestPoint(tempCoreEnd, out endDomain);

                Curve tempCoreBase = new LineCurve(groundCurve.PointAt((startDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0), groundCurve.PointAt((endDomain - baseCurve.Domain.T0) * baseCurve.GetLength() + groundCurve.Domain.T0));

                coreBase.Add(tempCoreBase);
            }

            List <List <Brep> > elevationBrepSortedByWidth = new List <List <Brep> >();

            for (int i = 0; i < uniqueWidthList.Count(); i++)
            {
                elevationBrepSortedByWidth.Add(new List <Brep>());
            }

            for (int i = 0; i < widthList.Count; i++)
            {
                int tempWidthIndex = uniqueWidthList.IndexOf(widthList[i]);

                elevationBrepSortedByWidth[tempWidthIndex].Add(tempElevationBase[i]);
            }

            //elevationBrepSortedByWidth[elevationBrepSortedByWidth.Count() - 1].AddRange(DrawPiloti(groundCurve, pilotiParameter.Distinct().ToList(), pilotiHeight));

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

            foreach (List <Brep> i in elevationBrepSortedByWidth)
            {
                Brep[] joinedBreps = Brep.JoinBreps(i, 2);

                foreach (Brep j in joinedBreps)
                {
                    outlineCurve.AddRange(j.DuplicateNakedEdgeCurves(true, true).ToList());
                    joinedOutLineCurve.AddRange(Curve.JoinCurves(j.DuplicateNakedEdgeCurves(true, true).ToList()).ToList());
                }
            }

            for (int i = 0; i < coreBase.Count(); i++)
            {
                Curve coreBoundary = offsetOneSide(coreBase[i], (cores[i].Stories + 1) * Consts.FloorHeight + Consts.PilotiHeight);

                core.AddRange(getOuterCurve(coreBoundary, joinedOutLineCurve));
            }

            foreach (Curve h in BalconyBase)
            {
                double[]      target            = { double.MaxValue, 2, 2 };
                List <object> typeList          = new List <object>();
                List <Curve>  splittedBaseCurve = divideBaseCurve(h, target, out typeList);

                for (int i = 0; i < splittedBaseCurve.Count(); i++)
                {
                    List <string> windowTypeList = Enum.GetValues(typeof(WindowType)).Cast <WindowType>().Select(v => v.ToString()).ToList();

                    if (windowTypeList.IndexOf(typeList[i].ToString()) != -1)
                    {
                        int index = windowTypeList.IndexOf(typeList[i].ToString());

                        List <Curve> tempWindow = drawWindow((WindowType)index, splittedBaseCurve[i], windowHeight);

                        windowDetail.AddRange(tempWindow);

                        List <Curve> tempBanister = drawBanister(splittedBaseCurve[i], 25, 900);

                        banister.AddRange(tempBanister);
                    }
                }
            }

            return(new Elevation(outlineCurve, windowDetail, banister, core));
        }
예제 #2
0
        public static Section drawSection(List <Curve> baseCurve, List <List <List <Household> > > households, List <List <Core> > cores, Plot plot)
        {
            double storyHeight   = 2800;
            double floorLow      = 200;
            double wallThickness = 200;

            List <int> index = new List <int>();

            Curve perpCurve = new LineCurve(Point3d.Origin, Point3d.Origin);

            List <Curve>        Boundary = new List <Curve>();
            List <Curve>        Room     = new List <Curve>();
            List <Curve>        Core     = new List <Curve>();
            List <RoomNamecard> roomName = new List <RoomNamecard>();

            List <Curve> JoinedBoundaryCrv = new List <Curve>();
            List <Curve> CoreBase          = new List <Curve>();

            List <double> uniqueParameter = getUniqueParameter(baseCurve, plot, out perpCurve, out index);

            Curve groundCurve = new LineCurve(Point3d.Origin, new Point3d(perpCurve.GetLength(), 0, 0));

            for (int i = 0; i < index.Count(); i++)
            {
                Core tempCoreProperty = cores[index[i]][0];

                Point3d tempCoreStart = tempCoreProperty.Origin;
                Point3d tempCoreEnd   = tempCoreProperty.Origin + tempCoreProperty.YDirection * tempCoreProperty.Depth;

                double tempStartParam; double tempEndParam;

                perpCurve.ClosestPoint(tempCoreStart, out tempStartParam);
                perpCurve.ClosestPoint(tempCoreEnd, out tempEndParam);

                Curve tempCoreBase = new LineCurve(groundCurve.PointAt(tempStartParam), groundCurve.PointAt(tempEndParam));

                CoreBase.Add(offsetOneSide(tempCoreBase, Consts.PilotiHeight + Consts.FloorHeight * (tempCoreProperty.Stories + 1)));
            }


            for (int i = 0; i < uniqueParameter.Count(); i++)
            {
                List <Brep> boundary           = new List <Brep>();
                int         tempIntersectIndex = 0;

                for (int j = 0; j < households[i].Count(); j++)
                {
                    Household tempHousehold    = households[i][j][tempIntersectIndex];
                    double    widthAsParameter = tempHousehold.YLengthA * (groundCurve.Domain.T1 - groundCurve.Domain.T0) / groundCurve.GetLength();

                    Point3d tempStart = groundCurve.PointAt(uniqueParameter[i] - widthAsParameter / 2);
                    Point3d tempEnd   = groundCurve.PointAt(uniqueParameter[i] + widthAsParameter / 2);

                    Curve tempBase = new LineCurve(tempStart, tempEnd);
                    tempBase.Transform(Transform.Translation(new Vector3d(0, tempHousehold.Origin.Z, 0)));

                    Curve tempLoftBase = tempBase.DuplicateCurve();
                    tempLoftBase.Transform(Transform.Translation(new Vector3d(0, storyHeight, 0)));

                    Curve[] tempLoftBaseSet = { tempBase, tempLoftBase };
                    Brep    tempLoftedBrep  = Brep.CreateFromLoft(tempLoftBaseSet, Point3d.Unset, Point3d.Unset, LoftType.Straight, false)[0];
                    boundary.Add(tempLoftedBrep);

                    Curve roomBase = tempBase.DuplicateCurve();
                    roomBase.Transform(Transform.Translation(new Vector3d(0, floorLow, 0)));

                    double tempRoombaseStart; double tempRoombaseEnd;

                    roomBase.LengthParameter(wallThickness, out tempRoombaseStart);
                    roomBase.LengthParameter(roomBase.GetLength() - wallThickness, out tempRoombaseEnd);

                    roomBase = new LineCurve(roomBase.PointAt(tempRoombaseStart), roomBase.PointAt(tempRoombaseEnd));

                    Curve room = offsetOneSide(roomBase, storyHeight - floorLow * 2);

                    RoomNamecard tempNamecard = RoomNamecard.CreateRoomNamecard(roomBase.PointAt(roomBase.Domain.Mid) + new Point3d(0, (storyHeight - floorLow * 2) / 2, 0), tempHousehold.GetArea(), storyHeight - floorLow * 2);

                    Room.Add(room);
                    roomName.Add(tempNamecard);
                }

                Brep[] joinedBoundary = Brep.JoinBreps(boundary, 0.1);

                foreach (Brep j in joinedBoundary)
                {
                    Curve[] tempNakedEdge = j.DuplicateNakedEdgeCurves(true, true);

                    Boundary.AddRange(tempNakedEdge.ToList());

                    JoinedBoundaryCrv.AddRange(Curve.JoinCurves(tempNakedEdge).ToList());
                }
            }

            List <Surroundinginfo> surrounding = checkSurrounding(perpCurve, plot, groundCurve);

            return(new Section(Boundary, Room, Core, surrounding, roomName));
        }
예제 #3
0
        private static List <Brep> DrawPiloti(Curve baseCurve, IEnumerable <double> parameter, double pilotiHeight)
        {
            List <Brep> output = new List <Brep>();

            double pilotiWidth = 300;

            double convertedPilotiWidth;

            baseCurve.LengthParameter(pilotiWidth, out convertedPilotiWidth);
            convertedPilotiWidth = convertedPilotiWidth - baseCurve.Domain.T0;

            //첫부분 필로티 생성)

            Curve firstPilotiCurve = new LineCurve(baseCurve.PointAt(parameter.ToList()[0]), baseCurve.PointAt(parameter.ToList()[0] + convertedPilotiWidth));
            Curve firstLoftBase    = firstPilotiCurve.DuplicateCurve();

            firstLoftBase.Transform(Transform.Translation(new Vector3d(0, pilotiHeight, 0)));

            Curve[] firstLoftBaseSet = { firstPilotiCurve, firstLoftBase };

            Brep firstPilotiBrep = Brep.CreateFromLoft(firstLoftBaseSet, Point3d.Unset, Point3d.Unset, LoftType.Normal, false)[0];

            output.Add(firstPilotiBrep);

            //중간부분 필로티 생성)

            for (int i = 1; i < parameter.Count() - 1; i++)
            {
                Curve tempCurve    = new LineCurve(baseCurve.PointAt(parameter.ToList()[i] - convertedPilotiWidth / 2), baseCurve.PointAt(parameter.ToList()[i] + convertedPilotiWidth / 2));
                Curve tempLoftBase = tempCurve.DuplicateCurve();
                tempLoftBase.Transform(Transform.Translation(new Vector3d(0, pilotiHeight, 0)));

                Curve[] tempLoftBaseSet = { tempCurve, tempLoftBase };

                Brep tempPilotiBrep = Brep.CreateFromLoft(tempLoftBaseSet, Point3d.Unset, Point3d.Unset, LoftType.Normal, false)[0];

                output.Add(tempPilotiBrep);

                /*
                 *
                 * Curve tempCurve_2 = new LineCurve(baseCurve.PointAt(parameter.ToList()[i]), baseCurve.PointAt(parameter.ToList()[i] + convertedPilotiWidth / 2));
                 * Curve tempLoftBase_2 = tempCurve_2.DuplicateCurve();
                 * tempLoftBase_2.Transform(Transform.Translation(new Vector3d(0, pilotiHeight, 0)));
                 *
                 * Curve[] tempLoftBaseSet_2 = { tempCurve_2, tempLoftBase_2 };
                 *
                 * Brep tempPilotiBrep_2 = Brep.CreateFromLoft(tempLoftBaseSet_2, Point3d.Unset, Point3d.Unset, LoftType.Normal, false)[0];
                 *
                 * output.Add(tempPilotiBrep_2);
                 */
            }

            //마지막부분 필로티 생성)

            Curve lastPilotiCurve = new LineCurve(baseCurve.PointAt(parameter.ToList()[parameter.Count() - 1] - convertedPilotiWidth), baseCurve.PointAt(parameter.ToList()[parameter.Count() - 1]));
            Curve lastLoftBase    = lastPilotiCurve.DuplicateCurve();

            lastLoftBase.Transform(Transform.Translation(new Vector3d(0, pilotiHeight, 0)));

            Curve[] lastLoftBaseSet = { lastPilotiCurve, lastLoftBase };

            Brep lastPilotiBrep = Brep.CreateFromLoft(lastLoftBaseSet, Point3d.Unset, Point3d.Unset, LoftType.Normal, false)[0];

            output.Add(lastPilotiBrep);

            return(output);
        }
예제 #4
0
// ===============================================================================================
// splits curve at kinks (discontinuity)
// ===============================================================================================
        public static bool CurveDiscontinuity(List <Curve> L, Curve crv, int continuity, bool recursive)
        {
            if (crv == null)
            {
                return(false);
            }

            PolyCurve polycurve = crv as PolyCurve;

            if (polycurve != null)
            {
                if (recursive)
                {
                    polycurve.RemoveNesting();
                }

                Curve[] segments = polycurve.Explode();

                if (segments == null)
                {
                    return(false);
                }
                if (segments.Length == 0)
                {
                    return(false);
                }

                if (recursive)
                {
                    foreach (Curve S in segments)
                    {
                        return(CurveDiscontinuity(L, S, continuity, recursive));
                    }
                }
                else
                {
                    foreach (Curve S in segments)
                    {
                        L.Add(S.DuplicateShallow() as Curve);
                    }
                }

                return(true);
            }

            PolylineCurve polyline = crv as PolylineCurve;

            if (polyline != null)
            {
                if (recursive)
                {
                    for (int i = 0; i < (polyline.PointCount - 1); i++)
                    {
                        L.Add(new LineCurve(polyline.Point(i), polyline.Point(i + 1)));
                    }
                }
                else
                {
                    L.Add(polyline.DuplicateCurve());
                }
                return(true);
            }

            Polyline p;

            if (crv.TryGetPolyline(out p))
            {
                if (recursive)
                {
                    for (int i = 0; i < (p.Count - 1); i++)
                    {
                        L.Add(new LineCurve(p[i], p[i + 1]));
                    }
                }
                else
                {
                    L.Add(new PolylineCurve());
                }
                return(true);
            }

            //Maybe it’s a LineCurve?
            LineCurve line = crv as LineCurve;

            if (line != null)
            {
                L.Add(line.DuplicateCurve());
                return(true);
            }

            //It might still be an ArcCurve…
            ArcCurve arc = crv as ArcCurve;

            if (arc != null)
            {
                L.Add(arc.DuplicateCurve());
                return(true);
            }

            //Nothing else worked, lets assume it’s a nurbs curve and go from there…
            NurbsCurve nurbs = crv.ToNurbsCurve();

            if (nurbs == null)
            {
                return(false);
            }

            double t0 = nurbs.Domain.Min;
            double t1 = nurbs.Domain.Max;
            double t;

            int LN = L.Count;

            do
            {
                if (!nurbs.GetNextDiscontinuity((Continuity)continuity, t0, t1, out t))
                {
                    break;
                }

                Interval trim = new Interval(t0, t);
                if (trim.Length < 1e-10)
                {
                    t0 = t;
                    continue;
                }

                Curve M = nurbs.DuplicateCurve();
                M = M.Trim(trim);
                if (M.IsValid)
                {
                    L.Add(M);
                }

                t0 = t;
            } while (true);

            if (L.Count == LN)
            {
                L.Add(nurbs);
            }

            return(true);
        }