{"action":"created","issue":{"url":"https://api.github.com/repos/brendankenny/libtess.js/issues/13","labels_url":"https://api.github.com/repos/brendankenny/libtess.js/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/brendankenny/libtess.js/issues/13/comments","events_url":"https://api.github.com/repos/brendankenny/libtess.js/issues/13/events","html_url":"https://github.com/brendankenny/libtess.js/issues/13","id":86646886,"number":13,"title":"Excluding contour triangles","user":{"login":"iominh","id":1434477,"avatar_url":"https://avatars.githubusercontent.com/u/1434477?v=3","gravatar_id":"","url":"https://api.github.com/users/iominh","html_url":"https://github.com/iominh","followers_url":"https://api.github.com/users/iominh/followers","following_url":"https://api.github.com/users/iominh/following{/other_user}","gists_url":"https://api.github.com/users/iominh/gists{/gist_id}","starred_url":"https://api.github.com/users/iominh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iominh/subscriptions","organizations_url":"https://api.github.com/users/iominh/orgs","repos_url":"https://api.github.com/users/iominh/repos","events_url":"https://api.github.com/users/iominh/events{/privacy}","received_events_url":"https://api.github.com/users/iominh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-09T15:55:37Z","updated_at":"2015-06-10T18:25:55Z","closed_at":null,"body":"Hi Brendan,\r\n\r\nThanks so much for creating this awesome library! I've learned a lot from using it. I've tried other JS libraries like earcut and several point-in-polygon libraries, but libtess.js gives the best results across many different inputs.\r\n\r\nThis is a long shot and I'm not sure where to post this but maybe you might have some insights (or alternatively this could be rubber duck debugging for me). Anyway, I'm using a mapping library called CesiumJS to render arbitrary polygons on a globe. However, I want to exclude certain polygons from being rendered, so this is where libtess.js comes in.\r\n\r\nUsing libtess.js, I've implemented code very similarly to the [simple triangulation example you've provided](https://github.com/brendankenny/libtess.js/tree/gh-pages/examples/simple_triangulation), so initially I created a single contour of 2 triangles, as seen here (the blue and brown triangles):\r\n\r\n![screen shot 2015-06-09 at 11 29 59 am](https://cloud.githubusercontent.com/assets/1434477/8062339/24baad9a-0e9d-11e5-883b-ea136a6bb482.png)\r\n\r\nNext, I added another contour for an arbitrary polygon I want to not render (it's actually a \"circle\" polygon with 100 points that are radius-distanced from a center point). This produced the following results, where I render every triangle returned from the array passed into gluTessBeginPolygon: \r\n\r\n![screen shot 2015-06-09 at 11 30 46 am](https://cloud.githubusercontent.com/assets/1434477/8062403/7a6854a4-0e9d-11e5-9fab-69a0cb5ae960.png)\r\n\r\nThis worked better than every other library/algorithm I've tried (many others had issues triangulating the contours) but my goal is to exclude the center circle.\r\n\r\nI tried setting the winding rule to every possible rule to no avail. However, the \"GLU_TESS_WINDING_ABS_GEQ_TWO\" rule seems to produce the interior contour/polygon that I'm trying to exclude, so that seemed interesting:\r\n\r\n![glu_tess_winding_abs_geq_two](https://cloud.githubusercontent.com/assets/1434477/8062472/e2eb281c-0e9d-11e5-835e-832cfa522ff0.jpg)\r\n\r\nHere are the other rules I tried\r\n```js\r\ntessy.gluTessProperty(libtess.gluEnum.GLU_TESS_WINDING_RULE, libtess.windingRule.GLU_TESS_WINDING_NEGATIVE);\r\ntessy.gluTessProperty(libtess.gluEnum.GLU_TESS_WINDING_RULE, libtess.windingRule.GLU_TESS_WINDING_ODD);\r\ntessy.gluTessProperty(libtess.gluEnum.GLU_TESS_WINDING_RULE, libtess.windingRule.GLU_TESS_WINDING_NONZERO);\r\n```\r\n\r\nGLU_TESS_WINDING_NEGATIVE:\r\n![glu_tess_winding_negative2](https://cloud.githubusercontent.com/assets/1434477/8065256/568a82bc-0eae-11e5-85a0-8aac7b9d02e1.png)\r\n\r\nGLU_TESS_WINDING_POSITIVE:\r\n![glu_tess_winding_positive](https://cloud.githubusercontent.com/assets/1434477/8065188/eb96a0f8-0ead-11e5-8012-eb20d960336b.png)\r\n\r\nGLU_TESS_WINDING_NONZERO:\r\n![glu_tess_winding_nonzero](https://cloud.githubusercontent.com/assets/1434477/8065203/fb9c705e-0ead-11e5-9f1e-71581c8d6a7e.png)\r\n\r\nSo overall, my question is: when I run gluTessBeginPolygon and pass in an array, how can I make it so the array I get back excludes the triangles generated for a particular contour?"},"comment":{"url":"https://api.github.com/repos/brendankenny/libtess.js/issues/comments/110864141","html_url":"https://github.com/brendankenny/libtess.js/issues/13#issuecomment-110864141","issue_url":"https://api.github.com/repos/brendankenny/libtess.js/issues/13","id":110864141,"user":{"login":"brendankenny","id":316891,"avatar_url":"https://avatars.githubusercontent.com/u/316891?v=3","gravatar_id":"","url":"https://api.github.com/users/brendankenny","html_url":"https://github.com/brendankenny","followers_url":"https://api.github.com/users/brendankenny/followers","following_url":"https://api.github.com/users/brendankenny/following{/other_user}","gists_url":"https://api.github.com/users/brendankenny/gists{/gist_id}","starred_url":"https://api.github.com/users/brendankenny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendankenny/subscriptions","organizations_url":"https://api.github.com/users/brendankenny/orgs","repos_url":"https://api.github.com/users/brendankenny/repos","events_url":"https://api.github.com/users/brendankenny/events{/privacy}","received_events_url":"https://api.github.com/users/brendankenny/received_events","type":"User","site_admin":false},"created_at":"2015-06-10T18:25:55Z","updated_at":"2015-06-10T18:25:55Z","body":"Yeah, that's interesting. Geometry outside the original contours should never be generated, so something weird is going on. You can see that somewhat in the fact that the lower part of new mexico in the circle that shouldn't be covered at all appears to be covered by something new (though it's not clear from the screenshot by what exactly...doesn't look like a triangle). A codepen would be really helpful! That way I could play with it and see what's going on.\r\n\r\nFeel free to use representative data (as long as it shows the same problem) if you don't want to share your current work publicly."}}