Exemple #1
0
        public void SetExtraSupport(PanelFrame panelF, List <Line> grid, List <List <MeshNode> > meshnodes, List <Line> frame, Parameters p)
        {
            panelFrame = panelF;
            gridPlanar = grid;
            SetPlanarPoints(meshnodes);
            subFrame   = frame;
            parameters = p;
            offset     = CaveTools.OffsetBoundary(panelFrame, parameters.cellGap / 2.0 - 1);
            //RhinoDoc.ActiveDoc.Objects.AddCurve(offset);
            if (offset == null)
            {
                SetWarningGeometry();
                return;
            }


            GetIntersectionPts();

            if (interpts.Count == 0)
            {
                SetWarningGeometry();
                return;
            }

            RemoveCloseIntersects();
            FindIntersectsToKeep();
            setStubs();
            //CheckGeometry();
        }
Exemple #2
0
        private void FrameGridToLineCentre(PanelFrame panelFrame, Line frameline, int i, int j)
        {
            Point3d start     = panelFrame.localPlane.ClosestPoint(frameline.From);
            Point3d end       = panelFrame.localPlane.ClosestPoint(frameline.To);
            Point3d planePt   = panelFrame.localPlane.ClosestPoint(panelFrame.frameGrid[i][j]);
            Point3d endToMove = new Point3d(start);
            Point3d endFixed  = new Point3d(end);

            if (planePt.DistanceTo(end) < planePt.DistanceTo(start))
            {
                endToMove = new Point3d(end);
                endFixed  = new Point3d(start);
            }
            Point3d  ptOnLn = new Point3d();
            Vector3d move   = endToMove - endFixed;

            move.Unitize();
            //500 mm from fixed end
            endToMove = endFixed + move * 500;
            Line drop = new Line(endToMove, panelFrame.localPlane.ZAxis * 10000);

            double a = 0;
            double b = 0;

            Rhino.Geometry.Intersect.Intersection.LineLine(frameline, drop, out a, out b);
            ptOnLn = frameline.PointAt(a);

            UpdateStubs(panelFrame, panelFrame.frameGrid[i][j], ptOnLn, ptOnLn);
            panelFrame.frameGrid[i][j] = ptOnLn;
        }
Exemple #3
0
        private void CheckFixClash(PanelFrame wall, PanelFrame roof, bool adjustroof, Orientation wallOrientation)
        {
            Brep roofBrep = roof.subFrameBoundary();
            Brep wallBrep = wall.subFrameBoundary();

            Curve[]   curves     = null;
            Point3d[] points     = null;
            int       wallRow    = 0;
            int       ceilingRow = 0;

            if (wallOrientation == Orientation.SideEast)
            {
                wallRow = wall.frameGrid.Count - 1;
            }
            if (wallOrientation == Orientation.SideNorth)
            {
                ceilingRow = roof.frameGrid.Count - 1;
            }
            if (wallOrientation == Orientation.SideSouth)
            {
                wallRow = wall.frameGrid.Count - 1;
            }
            if (Rhino.Geometry.Intersect.Intersection.BrepBrep(roofBrep, wallBrep, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance, out curves, out points))
            {
                if (curves.Length > 0)
                {
                    TrySnapGhosts(wall, wallRow);
                    if (adjustroof)
                    {
                        TrySnapGhosts(roof, ceilingRow);
                    }
                }
            }
        }
Exemple #4
0
        public static Curve OffsetBoundary(PanelFrame panelFrame, double dist)
        {
            //panelFrame.parameters.cellGap / 2.0 - 1
            NurbsCurve         boundary = GetPlanarPanelBoundary(panelFrame);
            AreaMassProperties amp      = AreaMassProperties.Compute(boundary);

            if (amp == null)
            {
                return(null);
            }
            //RhinoDoc.ActiveDoc.Objects.AddCurve(boundary);
            Curve[] offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, dist, 5, CurveOffsetCornerStyle.Sharp);
            if (offsets == null)
            {
                offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }

            AreaMassProperties amp2 = AreaMassProperties.Compute(offsets[0]);

            if (amp2 == null || amp2.Area > amp.Area)
            {
                offsets = boundary.Offset(CaveTools.averagePoint(boundary.Points.Select(x => x.Location).ToList()), panelFrame.localPlane.Normal, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }
            amp2 = AreaMassProperties.Compute(offsets[0]);
            if (amp2 == null || amp2.Area < 10000)
            {
                offsets = boundary.Offset(panelFrame.localPlane, -(dist), 5, CurveOffsetCornerStyle.Sharp);
            }
            if (offsets == null)
            {
                return(null);
            }
            return(offsets[0]);
        }
Exemple #5
0
        private void RemoveExtraSupport(PanelFrame panelFrame, Point3d pt)
        {
            Line toRemove = new Line();

            foreach (Line line in panelFrame.meshExtraSupport.Stubs)
            {
                if (pt.DistanceTo(line.ClosestPoint(pt, true)) < 5)
                {
                    toRemove = line;
                }
            }
            panelFrame.meshExtraSupport.Stubs.Remove(toRemove);
        }
Exemple #6
0
        public static NurbsCurve GetPlanarPanelBoundary(PanelFrame panelFrame)
        {
            Polyline[] outlines = panelFrame.CavePanels.GetOutlines(panelFrame.localPlane);
            if (outlines == null || outlines.Length == 0)
            {
                return(null);
            }
            int reduct = outlines[0].ReduceSegments(4);

            NurbsCurve boundary = NurbsCurve.Create(false, 1, outlines[0]);

            return(boundary);
        }
Exemple #7
0
 private void UpdateStubs(PanelFrame panelFrame, Point3d oldframePt, Point3d meshpt, Point3d newframPt)
 {
     foreach (StubMember stubMember in panelFrame.cornerStub)
     {
         if (oldframePt.DistanceTo(stubMember.Stub.ClosestPoint(oldframePt, true)) < 5)
         {
             stubMember.Update(meshpt, newframPt);
         }
     }
     foreach (StubMember stubMember in panelFrame.internalStub)
     {
         if (oldframePt.DistanceTo(stubMember.Stub.ClosestPoint(oldframePt, true)) < 5)
         {
             stubMember.Update(meshpt, newframPt);
         }
     }
 }
Exemple #8
0
        private void FrameGridToExtraSupportPos(PanelFrame panelFrame, Line frameline, int i, int j, Point3d closestExtra)
        {
            Point3d start     = panelFrame.localPlane.ClosestPoint(frameline.From);
            Point3d end       = panelFrame.localPlane.ClosestPoint(frameline.To);
            Point3d endToMove = new Point3d(start);
            Point3d endFixed  = new Point3d(end);

            if (panelFrame.frameGrid[i][j].DistanceTo(end) < panelFrame.frameGrid[i][j].DistanceTo(start))
            {
                endToMove = new Point3d(end);
                endFixed  = new Point3d(start);
            }
            Point3d extra  = panelFrame.localPlane.ClosestPoint(closestExtra);
            Point3d ptOnLn = new Point3d();

            if (extra.DistanceTo(endFixed) < 500)
            {
                //move to frame 500mmm
                Vector3d move = endToMove - endFixed;
                move.Unitize();
                endToMove = endFixed + move * 500;
                Line   drop = new Line(endToMove, panelFrame.localPlane.ZAxis * 10000);
                double a    = 0;
                double b    = 0;
                Rhino.Geometry.Intersect.Intersection.LineLine(frameline, drop, out a, out b);
                ptOnLn = frameline.PointAt(a);
                UpdateStubs(panelFrame, panelFrame.frameGrid[i][j], ptOnLn, ptOnLn);
            }
            else
            {
                //move to closest extra
                ptOnLn = frameline.ClosestPoint(closestExtra, true);
                Point3d meshpt = CaveTools.ClosestPoint(panelFrame.frameGrid[i][j], panelFrame.meshExtraSupport.Stubs.Select(x => x.To).ToList());
                UpdateStubs(panelFrame, panelFrame.frameGrid[i][j], meshpt, ptOnLn);
                //remove extra support
                RemoveExtraSupport(panelFrame, closestExtra);
            }

            panelFrame.frameGrid[i][j] = ptOnLn;
        }
Exemple #9
0
        private void SetHangers(PanelFrame panelFrame, List <Point3d> bayMinima)
        {
            foreach (Point3d p in bayMinima)
            {
                if (panelFrame.UnitBoundary.Contains(p, panelFrame.localPlane, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance) == PointContainment.Inside)
                {
                    Point3d planePt = panelFrame.localPlane.ClosestPoint(p);

                    List <Line> frameLinesX = new List <Line>();
                    List <Line> frameLinesY = new List <Line>();
                    Plane       pln         = new Plane(planePt, panelFrame.localPlane.YAxis);
                    panelFrame.SetFrameLines(ref panelFrame.nodeGrid, ref frameLinesX, ref frameLinesY);
                    Dictionary <Point3d, double> pointDist = new Dictionary <Point3d, double>();
                    double   t           = 0;
                    bool     shiftStalac = false;
                    Vector3d shift       = new Vector3d();
                    foreach (Line frame  in frameLinesY)
                    {
                        Rhino.Geometry.Intersect.Intersection.LinePlane(frame, pln, out t);
                        if (t >= 0 && t <= 1)
                        {
                            Point3d interPt = frame.PointAt(t);
                            if (interPt.DistanceTo(frame.To) < 300)
                            {
                                shift       = frame.To - interPt;
                                interPt     = frame.To;
                                shiftStalac = true;
                            }

                            if (interPt.DistanceTo(frame.From) < 300)
                            {
                                shift       = frame.From - interPt;
                                interPt     = frame.From;
                                shiftStalac = true;
                            }

                            pointDist.Add(interPt, interPt.DistanceTo(planePt));
                        }
                    }
                    if (shiftStalac)
                    {
                        //move the point
                        Transform xform = Transform.Translation(shift);
                        p.Transform(xform);
                    }

                    if (pointDist.Count < 2)
                    {
                        Line vertical = new Line(p, planePt);
                        panelFrame.stalactiteVertical.Add(vertical);
                        RhinoDoc.ActiveDoc.Objects.AddLine(vertical);
                        continue;
                    }
                    var myList = pointDist.ToList();

                    myList.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));
                    Point3d s         = myList[0].Key;
                    Point3d e         = myList[1].Key;
                    Line    startLine = new Line(s, panelFrame.localPlane.ZAxis * 100000);
                    Line    endLine   = new Line(e, panelFrame.localPlane.ZAxis * 100000);

                    Point3d Start = new Point3d();
                    Point3d End   = new Point3d();
                    double  p1    = 0;
                    double  p2    = 0;

                    foreach (Line frame in panelFrame.frameLinesY)
                    {
                        bool inter1 = Rhino.Geometry.Intersect.Intersection.LineLine(startLine, frame, out p1, out p2);
                        if (startLine.PointAt(p1).DistanceTo(frame.PointAt(p2)) < 5)
                        {
                            if (p2 >= 0 && p2 <= 1 && p1 >= 0 && p1 <= 1)
                            {
                                Start = frame.PointAt(p2);
                            }
                        }
                    }
                    foreach (Line frame in panelFrame.frameLinesY)
                    {
                        bool inter2 = Rhino.Geometry.Intersect.Intersection.LineLine(endLine, frame, out p1, out p2);
                        if (endLine.PointAt(p1).DistanceTo(frame.PointAt(p2)) < 5)
                        {
                            if (p2 >= 0 && p2 <= 1 && p1 >= 0 && p1 <= 1)
                            {
                                End = frame.PointAt(p2);
                            }
                        }
                    }
                    if (End.Z == 0 || Start.Z == 0)
                    {
                        Line vertical = new Line(p, planePt);
                        panelFrame.stalactiteVertical.Add(vertical);
                        RhinoDoc.ActiveDoc.Objects.AddLine(vertical);
                    }
                    else
                    {
                        Line sFrame   = new Line(Start, End);
                        Line vLine    = new Line(p, panelFrame.localPlane.ZAxis * 100000);
                        bool inter3   = Rhino.Geometry.Intersect.Intersection.LineLine(vLine, sFrame, out p1, out p2);
                        Line vertical = new Line(p, sFrame.PointAt(p2));
                        if (!shiftStalac)
                        {
                            panelFrame.stalactiteSubFrame.Add(sFrame);
                            RhinoDoc.ActiveDoc.Objects.AddLine(sFrame);
                        }
                        panelFrame.stalactiteVertical.Add(vertical);
                        RhinoDoc.ActiveDoc.Objects.AddLine(vertical);
                    }
                }
            }
        }
Exemple #10
0
        public void TrySnapGhosts(PanelFrame panelFrame, int rowToAdjust)
        {
            //only apply to edge near clash
            if (panelFrame.clashFixAttempted)
            {
                return;
            }
            panelFrame.clashFixAttempted = true;
            for (int i = 0; i < panelFrame.meshnodes.Count; i++)
            {
                //skip middle row
                if (panelFrame.meshnodes.Count == 3 && i == 1)
                {
                    continue;
                }
                if (i != rowToAdjust)
                {
                    continue;
                }
                for (int j = 0; j < panelFrame.meshnodes[i].Count; j++)
                {
                    if (panelFrame.meshnodes[i][j].isGhost)
                    {
                        bool     replaceSupport = false;
                        Point3d  closestExtra   = CaveTools.ClosestPoint(panelFrame.frameGrid[i][j], panelFrame.meshExtraSupport.Stubs.Select(x => x.From).ToList());
                        Line     frameline      = new Line();
                        Vector3d test           = panelFrame.frameGrid[i][j] - closestExtra;

                        foreach (Line line in panelFrame.frameLinesX)
                        {
                            if (panelFrame.frameGrid[i][j].DistanceTo(line.ClosestPoint(panelFrame.frameGrid[i][j], true)) < 5)
                            {
                                frameline = line;
                            }
                            // angle should be small a and dist on line
                            double angle = Vector3d.VectorAngle(test, line.Direction);
                            if (Math.Abs(angle - Math.PI) < 0.05 || angle < 0.05)
                            {
                                //the extra stub is on the same frame line
                                Point3d ptOnLn = line.ClosestPoint(closestExtra, true);

                                if (panelFrame.frameGrid[i][j].DistanceTo(ptOnLn) < line.Length && closestExtra.DistanceTo(ptOnLn) < 5)
                                {
                                    replaceSupport = true;
                                    break;
                                }
                            }
                        }
                        if (replaceSupport)
                        {
                            FrameGridToExtraSupportPos(panelFrame, frameline, i, j, closestExtra);
                        }
                        else
                        {
                            FrameGridToLineCentre(panelFrame, frameline, i, j);
                        }
                    }
                }
            }
            //now re set frame
            panelFrame.frameLinesX = new List <Line>();
            panelFrame.frameLinesY = new List <Line>();
            panelFrame.SetFrameLines(ref panelFrame.frameGrid, ref panelFrame.frameLinesX, ref panelFrame.frameLinesY);
        }