Exemplo n.º 1
0
        /// <summary>
        /// 生成指定地面网格单元格投影到TriFace上的体素Box
        /// </summary>
        /// <param name="cellx"></param>
        /// <param name="cellz"></param>
        void CreateFloorGridCellProjTriFaceVoxBox(int cellx, int cellz)
        {
            Vector3d[]      rect     = voxSpace.GetFloorGridCellRect(cellx, cellz);
            OverlapRelation relation = geoAlgo.GetOverlapRelation(polyProjectionFloor, rect);

            if (relation == OverlapRelation.NotOverlay)
            {
                return;
            }

            Vector3d[] projectionPts;

            if (relation == OverlapRelation.PartOverlay)
            {
                int count = geoAlgo.InRect2DCount(rect[0].x, rect[2].x, rect[0].z, rect[1].z, vertexsProjectionFloor, ref inRectIdx);
                if (count == vertexsProjectionFloor.Length)
                {
                    projectionPts = vertexs;
                }
                else
                {
                    edgePloyPts.Clear();

                    if (faceDirType != DirCmpInfo.Vertical)
                    {
                        for (int i = 0; i < rect.Length; i++)
                        {
                            if (geoAlgo.IsInsidePoly2D(polyProjectionFloor, rect[i]))
                            {
                                edgePloyPts.Add(rect[i]);
                            }
                        }
                    }

                    for (int i = 0; i < count; i++)
                    {
                        edgePloyPts.Add(vertexsProjectionFloor[inRectIdx[i]]);
                    }

                    for (int i = 0; i < preCellRectSides.Length; i++)
                    {
                        preCellRectSides[i].startpos = rect[i];
                    }

                    Vector3d[] pts = geoAlgo.SolvePolySidesCrossPoints2D(preCellRectSides, polyProjectionFloor.sidesList[0]);

                    for (int i = 0; i < pts.Length; i++)
                    {
                        edgePloyPts.Add(pts[i]);
                    }

                    projectionPts = CreateProjectionToTriFacePts(edgePloyPts.ToArray());
                }
            }
            else
            {
                projectionPts = CreateProjectionToTriFacePts(rect);
            }

            CreateVoxBoxToList(projectionPts, cellx, cellz);
        }