2014-10-19 48 views
1

我希望削減在多邊形孔:無法找到節點給定afront點 - Poly2Tri

|-----------------------| 
|      | 
|  |------|   | 
|  |  |   | 
|  |------|   | 
|      | 
|-----------------------|  

外有以下COORDS(雙):

-0,76 ; -1,5 
1,86 ; -1,5 
-0,76 ; 1,5 
1,86 ; 1,5 

內coords(double)是:

0,65 ; -0,66 
1,57 ; -0,66 
0,65 ; 0,75 
1,57 ; 0,75 

我想用這個Poly2Tri創建一個帶有前四個點的Polygon。

PolygonPoint[] pts = new PolygonPoint[shape.Length]; 
for (int i = 0; i < shape.Length; i++) 
{ 
    pts[i] = new PolygonPoint((shape[i].X), (shape[i].Y)); 
    points.Add(shape[i]); 
} 
Polygon p = new Polygon(pts); 

之後,我加了第二個四點的洞。

p.AddHole(new Polygon(ptsO)); 

現在我叫:

P2T.Triangulate(p); 

我得到以下異常:無法找到給定afront點節點

如何解決這個異常?

+2

什麼是完整的堆棧跟蹤和錯誤消息? – 2014-10-19 08:04:53

回答

2

我對這個圖書館並不熟悉,但外部4點並不按照您指定的順序逆時針順序。相反,他們交叉,其中,灰線連接POINT3回point0:

enter image description here

嘗試將它們按逆時針順序相反。您可能需要按順時針順序創建內部循環,具體取決於Poly2Tri的慣例。

更新

剛剛發現一些文檔here

enter image description here

  • 輸入/輸出
  • 簡單多邊形外bounary以計數器時鐘爲導向的頂點ise方向。

    [snip]

    下面是以順時針方向定向的孔的所有頂點;

    +1

    我會測試這個。今晚會寫信給你。謝謝! – user3252833 2014-10-20 10:31:58

    +0

    它的工作原理。謝謝! – user3252833 2014-10-30 12:59:29

    相關問題