コード例 #1
0
        private void RemoveCloseIntersects()
        {
            //compare to each other and keep those within min spacing
            List <Point3d> cleaned = new List <Point3d>();

            cleaned.Add(interpts[0]);
            for (int i = 1; i < interpts.Count; i++)
            {
                Point3d closest = CaveTools.ClosestPoint(interpts[i], cleaned);
                if (closest.DistanceTo(interpts[i]) > parameters.cellGap / 4)
                {
                    cleaned.Add(interpts[i]);
                }
            }
            interpts = cleaned;
        }
コード例 #2
0
        private Point3d FindConnectionPoint(Point3d refPoint)
        {
            Point3d connection = new Point3d();

            if (orientation == Orientation.Ceiling)
            {
                connection = CaveTools.ClosestProjected(breps, refPoint, orientationPlane.Normal * -1);
            }
            else
            {
                connection = CaveTools.ClosestPoint(centreLines, refPoint, orientationPlane);
                //Plane testPlane = new Plane(connection, orientationPlane.Normal);
                //double dist1 = refPoint.DistanceTo(testPlane.ClosestPoint(refPoint));
                //connection = refPoint - orientationPlane.Normal * dist1;
            }
            return(connection);
        }
コード例 #3
0
        private void FindIntersectsToKeep()
        {
            //compare to point grid to remove if too close

            for (int i = 0; i < interpts.Count; i++)
            {
                Point3d closest = CaveTools.ClosestPoint(interpts[i], planarPointGrid.SelectMany(x => x).ToList());
                if (closest.DistanceTo(interpts[i]) > parameters.cellGap / 4)
                {
                    Ray3d  ray = new Ray3d(interpts[i], panelFrame.localPlane.ZAxis);
                    double t   = Rhino.Geometry.Intersect.Intersection.MeshRay(panelFrame.CavePanels, ray);
                    if (t >= 0)
                    {
                        meshpts.Add(ray.PointAt(t));
                    }
                }
            }
        }
コード例 #4
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;
        }
コード例 #5
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);
        }