コード例 #1
0
ファイル: Triangulation.cs プロジェクト: cybergen/bri-lib
 /**
  * Determine the cavity caused by site.
  * @param site the site causing the cavity
  * @param triangle the triangle containing site
  * @return set of all triangles that have site in their circumcircle
  */
 private List<Triangle> getCavity(Pnt site, Triangle triangle)
 {
     List<Triangle> encroached = new List<Triangle>();
     Queue<Triangle> toBeChecked = new Queue<Triangle>();
     List<Triangle> marked = new List<Triangle>();
     toBeChecked.Enqueue(triangle);
     marked.AddIfNotContains(triangle);
     while (toBeChecked.Count != 0) {
         triangle = toBeChecked.Dequeue();
         if (site.vsCircumcircle(triangle.ToArray()) == 1)
             continue; // Site outside triangle => triangle not in cavity
         encroached.AddIfNotContains(triangle);
         // Check the neighbors
         foreach (var neighbor in triGraph.neighbors(triangle)){
             if (marked.Contains(neighbor)) continue;
             marked.AddIfNotContains(neighbor);
             toBeChecked.Enqueue(neighbor);
         }
     }
     return encroached;
 }