{"id":18008031,"url":"https://github.com/luizzak/libtessswift","last_synced_at":"2025-08-05T06:17:30.508Z","repository":{"id":56919742,"uuid":"83447618","full_name":"LuizZak/LibTessSwift","owner":"LuizZak","description":"Libtess2 tesselation/triangulation library wrapper for Swift","archived":false,"fork":false,"pushed_at":"2020-03-24T10:43:37.000Z","size":701,"stargazers_count":16,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-18T19:41:12.355Z","etag":null,"topics":["cocoapod","swift","tesselation","triangulation"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LuizZak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-28T15:20:42.000Z","updated_at":"2025-03-19T09:14:46.000Z","dependencies_parsed_at":"2022-08-20T21:50:16.506Z","dependency_job_id":null,"html_url":"https://github.com/LuizZak/LibTessSwift","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/LuizZak/LibTessSwift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizZak%2FLibTessSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizZak%2FLibTessSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizZak%2FLibTessSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizZak%2FLibTessSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LuizZak","download_url":"https://codeload.github.com/LuizZak/LibTessSwift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LuizZak%2FLibTessSwift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266780344,"owners_count":23983039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapod","swift","tesselation","triangulation"],"created_at":"2024-10-30T01:16:52.070Z","updated_at":"2025-07-24T01:37:56.466Z","avatar_url":"https://github.com/LuizZak.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LibTessSwift\n\n[![Build Status](https://dev.azure.com/luiz-fs/LibTessSwift/_apis/build/status/LuizZak.LibTessSwift?branchName=master)](https://dev.azure.com/luiz-fs/LibTessSwift/_build/latest?definitionId=1\u0026branchName=master)\n\nA Swift wrapper on top of [Libtess2](https://github.com/memononen/Libtess2) for polygon triangulation.\n\nTests where derived from [LibTessDotNet](https://github.com/speps/LibTessDotNet) library, which is also a port of the library above.\n\nAlso, a fix for an issue of 0-area polygons from libtess2 that was fixed by LibTessDotNet is also merged in. \n\nSupports self-intersecting polygons and polygons with holes.\n\n## Sample Usage\n\nThis is a sample wrapper over TessC to process polygons and return resultin vertices/indices pairs.\n\n```swift\nfunc process(polygon: [MyVector]) throws -\u003e (vertices: [MyVector], indices: [Int])? {\n    let polygon: [MyVector] = ... // This should be an array of vertices - must have at least an `x` and `y` coordinate pairs!\n\n    guard let tess = TessC() else {\n        print(\"Something went wrong while initializing TessC! :c\")\n        return nil\n    }\n\n    // Size of polygon (number of points per face)\n    let polySize = 3\n\n    // Map from MyVector to CVector3 (LibTessSwift's vector representation)\n    let contour = polygon.map {\n        CVector3(x: TESSreal($0.x), y: TESSreal($0.y), z: 0.0)\n    }\n\n    // Add the contour to LibTess\n    tess.addContour(contour)\n\n    // Tesselate - if no errors are thrown, we're good!\n    try tess.tessellate(windingRule: .evenOdd, elementType: .polygons, polySize: polySize)\n\n    // Collect resulting vector\n    var result: [MyVector] = []\n    var indices: [Int] = []\n    \n    // Extract vertices\n    for vertex in tess.vertices! {\n        result.append(MyVector(x: vertex.x, y: vertex.y))\n    }\n    \n    // Extract each index for each polygon triangle found\n    for i in 0..\u003ctess.elementCount\n    {\n        for j in 0..\u003cpolySize\n        {\n            let index = tess.elements![i * polySize + j]\n            if (index == -1) {\n                continue\n            }\n            indices.append(index)\n        }\n    }\n\n    return (result, indices)\n}\n\n// Use away!\nguard let (verts, indices) = try process(myVerts) else {\n    return\n}\n\nMyRenderer.drawPolygon(verts: verts, indices: indices)\n```\n\n## Requirements\n\n## Installation\n\nLibTessSwift is available as a [Swift Package Manager](https://swift.org/package-manager/):\n\n```ruby\n.package(url: \"https://github.com/LuizZak/LibTessSwift.git\", .exact(\"0.8.0\"))\n```\n\n## Author\n\nLuizZak\n\n## License\n\nLibTessSwift is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizzak%2Flibtessswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizzak%2Flibtessswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizzak%2Flibtessswift/lists"}