cdt2d
cdt2d copied to clipboard
Holes
Hi I'm interested in using this lib. Can you please complete the example with holes? Is there an api specifying hole paths?
You can add holes with the polygon points, but you need to define the edges of the polygon and the edges of the holes - the constraints edges - and set exterior flag to false
` let cnt = 0; for (let i = 0; i < holes.length; i++) { for (let j = 0; j < holes[i].length; j++) { pos.push([holes[i][j].x, holes[i][j].y]);
if(j)
edges.push([points.length + cnt -1, points.length + cnt]);
cnt++;
}
edges.push([points.length + cnt -1, points.length + cnt - holes[i].length]);
}
let cells = cdt2d(pos, edges, {exterior:false});
`