{"id":15292961,"url":"https://github.com/stla/polygonsoup","last_synced_at":"2025-05-07T05:11:46.931Z","repository":{"id":61650543,"uuid":"551935713","full_name":"stla/PolygonSoup","owner":"stla","description":"Make a consistent mesh from a polygon soup.","archived":false,"fork":false,"pushed_at":"2022-11-04T10:44:21.000Z","size":1383,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T05:11:40.634Z","etag":null,"topics":["cgal","mesh","r","rcpp"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-15T12:37:11.000Z","updated_at":"2024-08-24T14:33:59.000Z","dependencies_parsed_at":"2023-01-21T01:15:54.250Z","dependency_job_id":null,"html_url":"https://github.com/stla/PolygonSoup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stla%2FPolygonSoup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stla%2FPolygonSoup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stla%2FPolygonSoup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stla%2FPolygonSoup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stla","download_url":"https://codeload.github.com/stla/PolygonSoup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252817647,"owners_count":21808707,"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","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":["cgal","mesh","r","rcpp"],"created_at":"2024-09-30T16:36:42.950Z","updated_at":"2025-05-07T05:11:46.902Z","avatar_url":"https://github.com/stla.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PolygonSoup\n\nMake a consistent mesh from a polygon soup.\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/stla/PolygonSoup/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/stla/PolygonSoup/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nA polygon soup is a set of unorganized polygons. For example, define a \ntetrahedron as follows:\n\n```r\nvertices \u003c- rbind(\n  c(-1, -1, -1),\n  c( 1,  1, -1),\n  c( 1, -1,  1),\n  c(-1,  1,  1)\n)\nfaces \u003c- rbind(\n  c(1, 2, 3),\n  c(3, 4, 2),\n  c(4, 2, 1),\n  c(4, 3, 1)\n)\n```\n\nNow plot it by painting the front of its faces in blue and the back of its \nfaces in red; then both colors appear:\n\n```r\nlibrary(rgl)\ntmesh \u003c- tmesh3d(\n  vertices    = t(vertices),\n  indices     = t(faces),\n  homogeneous = FALSE\n)\nshade3d(tmesh, color = \"blue\", back = \"cull\")\nshade3d(tmesh, color = \"red\", front = \"cull\")\n```\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/tetrahedron1.gif)\n\nTo get a mesh with coherently oriented faces, use the `Mesh` function:\n\n```r\nlibrary(PolygonSoup)\nmesh  \u003c- Mesh(vertices, faces, normals = FALSE)\ntmesh \u003c- toRGL(mesh)\nshade3d(tmesh, color = \"blue\", back = \"cull\")\n```\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/tetrahedron2.gif)\n\nThe **PolygonSoup** package can deal with polygon soups whose polygons have \nany number of sides. For example, consider a pentagrammic prism:\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/PentagrammicPrism.jpg)\n\nThe vertices and the faces of a pentagrammic prism are given in the package, \nin a list named `PentagrammicPrism`. Two faces, at the center of the two \npentagramms, are pentagonal. Therefore one cannot directly plot the prism with \n**rgl**. The `Mesh` function allows to triangulate the faces:\n\n```r\nmesh \u003c- Mesh(\n  mesh = pentagrammicPrism,\n  triangulate = TRUE, normals = FALSE\n)\n```\n\nNow we can plot the pentagrammic prism. We can also plot its edges with the \nhelp of the `plotEdges` function:\n\n```r\ntmesh \u003c- toRGL(mesh)\nshade3d(tmesh, color = \"maroon\")\nplotEdges(\n  mesh[[\"vertices\"]], mesh[[\"edges\"]], color = \"darkred\",\n  tubesRadius = 0.02, spheresRadius = 0.02\n)\n```\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/pentagrammicPrism1.png)\n\nThe triangulation introduces additional edges, and you probably don't want to \nsee them. In `mesh[[\"edges0\"]]`, one has the edges before the triangulation:\n\n```r\nshade3d(tmesh, color = \"maroon\")\nplotEdges(\n  mesh[[\"vertices\"]], mesh[[\"edges0\"]], color = \"darkred\",\n  tubesRadius = 0.02, spheresRadius = 0.02\n)\n```\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/pentagrammicPrism2.png)\n\nOne can also plot only the exterior edges, that is to say the edges which are \nnot between two coplanar faces:\n\n```r\nshade3d(tmesh, color = \"maroon\")\nplotEdges(\n  mesh[[\"vertices\"]], mesh[[\"exteriorEdges\"]], color = \"darkred\",\n  tubesRadius = 0.02, spheresRadius = 0.02\n)\n```\n\n![](https://raw.githubusercontent.com/stla/PolygonSoup/main/inst/gifs/pentagrammicPrism3.png)\n\n\n## License\n\nThis package is provided under the GPL-3 license but it uses the C++ library \nCGAL. If you wish to use CGAL for commercial purposes, you must obtain a license\nfrom the [GeometryFactory](https://geometryfactory.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstla%2Fpolygonsoup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstla%2Fpolygonsoup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstla%2Fpolygonsoup/lists"}