cdt2d icon indicating copy to clipboard operation
cdt2d copied to clipboard

Holes

Open mflux opened this issue 7 years ago • 1 comments

Hi I'm interested in using this lib. Can you please complete the example with holes? Is there an api specifying hole paths?

mflux avatar Apr 19 '17 23:04 mflux

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});

`

Hartha-aloufi avatar Apr 28 '17 19:04 Hartha-aloufi