Пример #1
0
        /**
         * Copy
         *
         * @param original
         */
        public void Copy(OctNode original)
        {
            int i;

            for (i = 0; i < 6; i++)
            {
                Adjacent [i] = original.GetAdjacent(i);
                OctFaces [i] = original.GetFace(i);
            }
            for (i = 0; i < 8; i++)
            {
                Child [i] = original.GetChild(i);
            }
            ObjList = original.GetList();
            NumObj  = original.GetNumObj();
        }
Пример #2
0
        /**
         * CreateChildren
         *
         * @param objects
         * @param depth
         */
        private void CreateChildren(ObjNode objects, int depth)
        {
            double  maxX  = OctFaces [MAXX].GetVert(0).GetX();
            double  minX  = OctFaces [MINX].GetVert(0).GetX();
            double  maxY  = OctFaces [MAXY].GetVert(0).GetY();
            double  minY  = OctFaces [MINY].GetVert(0).GetY();
            double  maxZ  = OctFaces [MAXZ].GetVert(0).GetZ();
            double  minZ  = OctFaces [MINZ].GetVert(0).GetZ();
            Point   midpt = new Point((maxX + minX) / 2.0f, (maxY + minY) / 2.0f, (maxZ + minZ) / 2.0f);
            Point   max   = new Point();
            Point   min   = new Point();
            ObjNode currentnode;
            int     i;

            max.Set(maxX, maxY, maxZ);
            min.Set(midpt.GetX(), midpt.GetY(), midpt.GetZ());
            Child [0] = new OctNode(max, min);
            max.Set(maxX, midpt.GetY(), maxZ);
            min.Set(midpt.GetX(), minY, midpt.GetZ());
            Child [1] = new OctNode(max, min);
            max.Set(maxX, midpt.GetY(), midpt.GetZ());
            min.Set(midpt.GetX(), minY, minZ);
            Child [2] = new OctNode(max, min);
            max.Set(maxX, maxY, midpt.GetZ());
            min.Set(midpt.GetX(), midpt.GetY(), minZ);
            Child [3] = new OctNode(max, min);
            max.Set(midpt.GetX(), maxY, maxZ);
            min.Set(minX, midpt.GetY(), midpt.GetZ());
            Child [4] = new OctNode(max, min);
            max.Set(midpt.GetX(), midpt.GetY(), maxZ);
            min.Set(minX, minY, midpt.GetZ());
            Child [5] = new OctNode(max, min);
            max.Set(midpt.GetX(), midpt.GetY(), midpt.GetZ());
            min.Set(minX, minY, minZ);
            Child [6] = new OctNode(max, min);
            max.Set(midpt.GetX(), maxY, midpt.GetZ());
            min.Set(minX, midpt.GetY(), minZ);
            Child [7] = new OctNode(max, min);

            OctNode[] adj  = this.Adjacent;
            OctNode[] chld = this.Child;

            OctNode adj0 = adj [0];
            OctNode adj1 = adj [1];
            OctNode adj2 = adj [2];
            OctNode adj3 = adj [3];
            OctNode adj4 = adj [4];
            OctNode adj5 = adj [5];

            OctNode chld0 = chld [0];
            OctNode chld1 = chld [1];
            OctNode chld2 = chld [2];
            OctNode chld3 = chld [3];
            OctNode chld4 = chld [4];
            OctNode chld5 = chld [5];
            OctNode chld6 = chld [6];
            OctNode chld7 = chld [7];

            Child [0].FormAdjacent(adj0, adj1, adj2, chld4, chld1, chld3);
            Child [1].FormAdjacent(adj0, chld0, adj2, chld5, adj4, chld2);
            Child [2].FormAdjacent(adj0, chld3, chld1, chld6, adj4, adj5);
            Child [3].FormAdjacent(adj0, adj1, chld0, chld7, chld2, adj5);
            Child [4].FormAdjacent(chld0, adj1, adj2, adj3, chld5, chld7);
            Child [5].FormAdjacent(chld1, chld4, adj2, adj3, adj4, chld6);
            Child [6].FormAdjacent(chld2, chld7, chld5, adj3, adj4, adj5);
            Child [7].FormAdjacent(chld3, adj1, chld4, adj3, chld6, adj5);
            if (objects != null)
            {
                currentnode = objects;
            }
            else
            {
                currentnode = ObjList;
            }
            while (currentnode != null)
            {
                ObjectType currentobj = currentnode.GetObj();
                for (i = 0; i < 8; i++)
                {
                    OctNode cc = chld [i];
                    max = cc.GetFace(0).GetVert(0);
                    min = cc.GetFace(5).GetVert(3);
                    if (!((currentobj.GetMin().GetX() > max.GetX()) ||
                          (currentobj.GetMax().GetX() < min.GetX())))
                    {
                        if (!((currentobj.GetMin().GetY() > max.GetY()) ||
                              (currentobj.GetMax().GetY() < min.GetY())))
                        {
                            if (!((currentobj.GetMin().GetZ() > max.GetZ()) ||
                                  (currentobj.GetMax().GetZ() < min.GetZ())))
                            {
                                ObjNode newnode = new ObjNode(currentobj, Child [i].GetList());
                                cc.SetList(newnode);
                                cc.IncNumObj();
                            }
                        }
                    }
                }
                currentnode = currentnode.Next();
            }
            if (objects == null)
            {
                NumObj  = 0;
                ObjList = null;
            }
            if (depth < MaxDepth)
            {
                for (i = 0; i < 8; i++)
                {
                    if (Child [i].GetNumObj() > MaxObj)
                    {
                        Child [i].CreateChildren(null, depth + 1);
                    }
                }
            }
        }
Пример #3
0
	/**
	 * Copy
	 *
	 * @param original
	 */
	public void Copy(OctNode original)
	{
		int i;

		for(i = 0; i < 6; i++)
		{
			Adjacent[i] = original.GetAdjacent(i);
			OctFaces[i] = original.GetFace(i);
		}
		for(i = 0; i < 8; i++)
		{
			Child[i] = original.GetChild(i);
		}
		ObjList = original.GetList();
		NumObj = original.GetNumObj();
	}