Home > PCB_MathPolygon > splitPolygon
PCB_MathPolygon.splitPolygon() method
Split single polygon
Signature
typescript
function splitPolygon(...complexPolygons: Array<IPCB_ComplexPolygon>): Array<IPCB_Polygon>;1
Parameters
Parameter | Type | Description |
|---|---|---|
complexPolygons | Array<IPCB_ComplexPolygon> | Complex polygon |
Returns
Array<IPCB_Polygon>
Single polygon array
Example
javascript
// 1. 构建一个两块的复杂多边形(矩形外框 + 圆形)
const complexPolygon = eda.pcb_MathPolygon.createComplexPolygon([
['R', 1000, 1000, 500, 300, 0, 0],
['CIRCLE', 3000, 1150, 100],
]);
// 2. 拆分为单多边形对象数组
const polygons = eda.pcb_MathPolygon.splitPolygon(complexPolygon);
// 3. 逐个读取单多边形的源数据
polygons.forEach((polygon, index) => {
console.log(`polygon${index + 1}:`, JSON.stringify(polygon.getSource()));
});
console.log('count:', polygons.length);1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14