public void Add(TopoVertex vertex,int level)
 {
     //  if (level == 20)
     //    Console.WriteLine("Level 20");
     count++;
     if (left == null && leaf == null)
     {
         leaf = new TopoVertexStorageLeaf();
     }
     if (IsLeaf)
     {
         if (leaf.vertices.Count < maxVerticesPerNode || level == 20)
         {
             leaf.Add(vertex);
             return;
         }
         // Split into 2 container
         left = new TopoVertexStorage();
         right = new TopoVertexStorage();
         splitDimension = leaf.LargestDimension();
         splitPosition = 0.5 * (leaf.box.minPoint[splitDimension] + leaf.box.maxPoint[splitDimension]);
         foreach (TopoVertex moveVertex in leaf.vertices)
         {
             if (moveVertex.pos[splitDimension] < splitPosition)
                 left.Add(moveVertex,level+1);
             else
                 right.Add(moveVertex,level+1);
         }
         leaf = null;
     }
     if (vertex.pos[splitDimension] < splitPosition)
         left.Add(vertex,level+1);
     else
         right.Add(vertex,level+1);
 }
예제 #2
0
 public void Add(TopoVertex vertex, int level)
 {
     //  if (level == 20)
     //    Console.WriteLine("Level 20");
     count++;
     if (left == null && leaf == null)
     {
         leaf = new TopoVertexStorageLeaf();
     }
     if (IsLeaf)
     {
         if (leaf.vertices.Count < maxVerticesPerNode || level == 20)
         {
             leaf.Add(vertex);
             return;
         }
         // Split into 2 container
         left           = new TopoVertexStorage();
         right          = new TopoVertexStorage();
         splitDimension = leaf.LargestDimension();
         splitPosition  = 0.5 * (leaf.box.minPoint[splitDimension] + leaf.box.maxPoint[splitDimension]);
         foreach (TopoVertex moveVertex in leaf.vertices)
         {
             if (moveVertex.pos[splitDimension] < splitPosition)
             {
                 left.Add(moveVertex, level + 1);
             }
             else
             {
                 right.Add(moveVertex, level + 1);
             }
         }
         leaf = null;
     }
     if (vertex.pos[splitDimension] < splitPosition)
     {
         left.Add(vertex, level + 1);
     }
     else
     {
         right.Add(vertex, level + 1);
     }
 }
 public void Clear()
 {
     left = right = null;
     leaf = null;
     count = 0;
 }
예제 #4
0
 public void Clear()
 {
     left  = right = null;
     leaf  = null;
     count = 0;
 }