public void Triangulate(Contours contours, MeshDraft draft) { this.contours = contours; this.draft = draft; draft.Clear(); for (int y = 0; y < contours.squaresLengthY; y++) { for (int x = 0; x < contours.squaresLengthX; x++) { byte square = contours.GetSquare(x, y); switch (square) { case 0: break; case 1: // ▖ AddBottomLeftTriangle(x, y); break; case 2: // ▘ AddTopLeftTriangle(x, y); break; case 4: // ▝ AddTopRightTriangle(x, y); break; case 8: // ▗ AddBottomRightTriangle(x, y); break; case 3: // ▌ AddLeftHalf(x, y); break; case 6: // ▀ AddTopHalf(x, y); break; case 12: // ▐ AddRightHalf(x, y); break; case 9: // ▄ AddBottomHalf(x, y); break; case 5: // ▞ AddBottomLeftTriangle(x, y); AddTopRightTriangle(x, y); break; case 21: // ▞ filled center AddBottomLeftHexagon(x, y); break; case 10: // ▚ AddTopLeftTriangle(x, y); AddBottomRightTriangle(x, y); break; case 26: // ▚ filled center AddTopLeftHexagon(x, y); break; case 7: // ▛ AddTopLeftPentagon(x, y); break; case 14: // ▜ AddTopRightPentagon(x, y); break; case 13: // ▟ AddBottomRightPentagon(x, y); break; case 11: // ▙ AddBottomLeftPentagon(x, y); break; case 15: // ⬛ int lastQuadIndex = x; for (int i = x + 1; i < contours.squaresLengthX; i++) { if (contours.GetSquare(i, y) == 15) { lastQuadIndex = i; } else { break; } } AddQuad(x, lastQuadIndex, y); x = lastQuadIndex; break; } } } }