コード例 #1
0
        private Mesh FindPanelByArea(Plane start, ref Plane end, double xdim, ref double area)
        {
            Mesh panel             = SelectClosestPanel(CaveTools.splitTwoPlanes(start, end, mesh), orientationPlane);
            AreaMassProperties amp = AreaMassProperties.Compute(panel);

            if (amp.Area < 9e6)
            {
                return(panel);
            }
            int    attempt = 10;
            double dist    = xdim / 2;

            while (attempt > 0)
            {
                //adjust plane
                if (amp.Area > 9e6)
                {
                    end.Origin = end.Origin + end.Normal * dist;
                }
                else
                {
                    end.Origin = end.Origin - end.Normal * dist;
                }
                panel = SelectClosestPanel(CaveTools.splitTwoPlanes(start, end, mesh), orientationPlane);
                amp   = AreaMassProperties.Compute(panel);
                attempt--;
                dist = dist / 2;
            }
            area = amp.Area;
            return(panel);
        }
コード例 #2
0
        private Mesh midSection()
        {
            Plane plane1 = OrientedBox.FaceOffsetPlane(bayBoundary.SideXmax, 2500);

            plane1.Flip();
            Plane plane2 = OrientedBox.FaceOffsetPlane(bayBoundary.SideXmin, 2000);

            plane2.Flip();
            Mesh ceiling = CaveTools.splitTwoPlanes(plane1, plane2, slice);

            //RhinoDoc.ActiveDoc.Objects.AddMesh(ceiling);
            return(ceiling);
        }
コード例 #3
0
        private List <Mesh> WallSplit3(OrientedBox orientedBox, Mesh mesh, List <Mesh> meshes)
        {
            Plane orientationPlane = orientedBox.SideZmaxPlane;

            List <Mesh> parts = new List <Mesh>();

            foreach (Mesh refmesh in meshes)
            {
                OrientedBox refBox = CaveTools.FindRefOrientedBox(orientationPlane, refmesh);
                //OrientedBox.CheckPlane(refBox.SideXmaxPlane);
                Mesh panel = CaveTools.splitTwoPlanes(refBox.SideXmaxPlane, refBox.SideXminPlane, mesh);
                parts.Add(panel);
            }
            foreach (Mesh m in parts)
            {
                RhinoDoc.ActiveDoc.Objects.AddMesh(m);
            }
            return(parts);
        }
コード例 #4
0
        private void Slice()
        {
            Plane p1 = new Plane(gridPlane.Origin, gridPlane.YAxis);
            Plane p2 = new Plane(gridPlane.Origin + gridPlane.YAxis * parameters.yCell, gridPlane.YAxis * -1);

            //try and slice the mesh
            Mesh  slice   = CaveTools.splitTwoPlanes(p1, p2, meshToVoxelise);
            bool  normals = slice.FaceNormals.ComputeFaceNormals();
            Plane boxPln  = new Plane(gridPlane.Origin, gridPlane.XAxis, gridPlane.YAxis);

            if (slice != null && slice.Faces.Count > 0)
            {
                //Brep minVol = CaveTools.findBBoxGivenPlane(boxPln, slice);
                //OrientedBox oBox = CaveTools.FindOrientedBox(boxPln, slice);
                //brepBBoxes.Add(oBox.BoundingBox);
                //caveSlices.Add(slice);
                //bayControllers.Add(new BayController(gridPlane, parameters));
            }
        }
コード例 #5
0
        private void MeshToPanels()
        {
            double cellSize = parameters.zCell;
            double boxDim   = orientedBox.zDim;

            if (orientation == Orientation.Ceiling)
            {
                cellSize = parameters.xCell;
                boxDim   = orientedBox.xDim;
            }


            int     panelNum      = 0;
            double  cumulativeDim = 0;
            Point3d p1            = orientationPlane.Origin;
            Point3d p2            = orientationPlane.Origin + orientationPlane.XAxis * cellSize;
            double  xPanel        = cellSize;
            double  yPanel        = parameters.yCell;

            if (orientation == Orientation.SideWest || orientation == Orientation.SideEast)
            {
                yPanel = orientedBox.xDim;
            }
            bool lastPanel = false;

            Mesh panel = new Mesh();

            while (cumulativeDim < boxDim)
            {
                Plane cut1 = new Plane(p1, orientationPlane.XAxis);
                Plane cut2 = new Plane(p2, orientationPlane.XAxis * -1);


                Plane local = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis);
                //area check
                double panelArea = 0;

                panel = FindPanelByArea(cut1, ref cut2, xPanel, ref panelArea);
                //RhinoDoc.ActiveDoc.Objects.AddMesh(panel);
                if (lastPanel)
                {
                    AreaMassProperties amp = AreaMassProperties.Compute(panel);
                    panelArea = amp.Area;
                    xPanel    = boxDim - orientationPlane.Origin.DistanceTo(p1);
                    if (xPanel < parameters.cellMin)
                    {
                        //try and combine with previous
                        if (panelFrames[panelNum - 1].panelArea + panelArea < 9e6 && xPanel + panelFrames[panelNum - 1].xdim < parameters.xCell + parameters.cellMin)
                        {
                            p1    = panelFrames[panelNum - 1].refPlane.Origin;
                            local = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis);
                            cut1  = new Plane(p1, orientationPlane.XAxis);
                            cut2  = new Plane(p2, orientationPlane.XAxis * -1);

                            panel = FindPanelByArea(cut1, ref cut2, xPanel, ref panelArea);
                            OrientedBox panelBox = CaveTools.FindOrientedBox(BayXY, panel, parameters.yCell);
                            xPanel = panelBox.zDim;
                            if (orientation == Orientation.Ceiling)
                            {
                                xPanel = panelBox.xDim;
                            }
                            //
                            panelFrames.RemoveAt(panelNum - 1);
                        }
                        else
                        {
                            //split last two panels equally
                            xPanel = (panelFrames[panelNum - 1].xdim + xPanel) / 2;

                            p1             = panelFrames[panelNum - 1].refPlane.Origin;
                            local          = new Plane(p1, orientationPlane.XAxis, orientationPlane.YAxis);
                            cut1           = new Plane(p1, orientationPlane.XAxis);
                            p2             = p1 + orientationPlane.XAxis * xPanel;
                            cut2           = new Plane(p2, orientationPlane.XAxis * -1);
                            panel          = SelectClosestPanel(CaveTools.splitTwoPlanes(cut1, cut2, mesh), orientationPlane);
                            cumulativeDim -= panelFrames[panelNum - 1].xdim;
                            panelFrames.RemoveAt(panelNum - 1);
                            lastPanel = false;
                        }
                    }
                }
                else
                {
                    xPanel = cut1.Origin.DistanceTo(cut2.Origin);
                }


                cumulativeDim += xPanel;

                panelFrames.Add(new PanelFrame(local, xPanel, parameters, panel, panelNum, yPanel));
                if (lastPanel)
                {
                    break;
                }
                //set p1 and p2 for next panel
                p1 = cut2.Origin;
                p2 = p1 + orientationPlane.XAxis * cellSize;
                if (orientationPlane.Origin.DistanceTo(p2) >= boxDim)
                {
                    lastPanel = true;
                }

                panelNum++;
            }
        }