Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. const int y = 100;
  2. const int x = 100;
  3. const int offset = 20;
  4.  
  5. IList<PolygonPoint> bounds = new List<PolygonPoint>
  6. {
  7. new PolygonPoint(0,0),
  8. new PolygonPoint(0, y),
  9. new PolygonPoint(x, y),
  10. new PolygonPoint(x, 0),
  11. };
  12.  
  13. IList<PolygonPoint> hole = new List<PolygonPoint>
  14. {
  15. new PolygonPoint(offset, offset),
  16. new PolygonPoint(x - offset, offset),
  17. new PolygonPoint(offset, y - offset),
  18. new PolygonPoint(x - offset, y - offset),
  19. };
  20.  
  21. Polygon polygon = new Polygon(bounds); // here polygon contains four dots
  22. polygon.AddHole(new Polygon(hole)); // and here - eight
  23.  
  24. P2T.Triangulate(polygon); // here I get ten triangles
  25.  
  26. foreach (var triangle in polygon.Triangles.Where(tr => tr.IsInterior)) // <-- problem
  27. {
  28. // draw
  29. }
  30.  
  31. IList<PolygonPoint> hole = new List<PolygonPoint>
  32. {
  33. new PolygonPoint(offset, offset),
  34. new PolygonPoint(offset, y - offset),
  35. new PolygonPoint(x - offset, y - offset),
  36. new PolygonPoint(x - offset, offset),
  37. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement