Ich möchte Abbildung mit Loch zeichnen.(Behoben) Poly2tri - Dreieck IsInterior-Eigenschaft - richtig konfigurieren
Um dies zu tun, ich habe Figur Dreiecke schneiden und sie eins nach dem anderen zu ziehen.
Hier habe ich acht Außendreiecke und zwei Innen. Ich dachte, dass ich Äußere nur nehmen werde und sie wie
const int y = 100;
const int x = 100;
const int offset = 20;
IList<PolygonPoint> bounds = new List<PolygonPoint>
{
new PolygonPoint(0,0),
new PolygonPoint(0, y),
new PolygonPoint(x, y),
new PolygonPoint(x, 0),
};
IList<PolygonPoint> hole = new List<PolygonPoint>
{
new PolygonPoint(offset, offset),
new PolygonPoint(x - offset, offset),
new PolygonPoint(offset, y - offset),
new PolygonPoint(x - offset, y - offset),
};
Polygon polygon = new Polygon(bounds); // here polygon contains four dots
polygon.AddHole(new Polygon(hole)); // and here - eight
P2T.Triangulate(polygon); // here I get ten triangles
foreach (var triangle in polygon.Triangles.Where(tr => tr.IsInterior)) // <-- problem
{
// draw
}
ziehen aber jedes Dreieck im Polygon hat IsInterior == true. Was mache ich falsch?
P.S. Und für PointSet ist diese Eigenschaft im selben Fall immer falsch.
Jedes Dreieck ist innerhalb des Rechtecks ABCD, so dass sie alle innen sind. Sie wollen nur Dreiecke innerhalb/außerhalb des Loches. – jdweng
@ Jdweng, es ist ein Problem, wenn ja. Ich habe keinen Zugang zu Löchern: Sie sind privat. – homk
Nehmen Sie folgende Änderung vor: polygon.AddHole (neues Polygon (Loch)); An: Polygonloch = neues Polygon (Loch); polygon.AddHole (Loch); – jdweng