FUNCTION REFERENCE

decsg

Decompose constructive solid geometry into minimal regions.

Decompose constructive solid geometry into minimal regions.

Syntax

dl = decsg(gd,sf,ns); [dl,bt] = decsg(gd,sf,ns); [dl,bt] = decsg(gd)

Each column of gd is one shape, zero padded: circle [1;xc;yc;r], polygon [2;n;x1..xn;y1..yn], rectangle [3;4;x1..x4;y1..y4], ellipse [4;xc;yc;a;b;phi] with phi in radians. ns is a char matrix with one name per column, for example ['R1';'C1']'. The set formula sf combines the names with + (union), * (intersection), - (difference) and parentheses. Precedence, highest first: - (difference), * (intersection), + (union); equal operators associate left to right; parentheses override. Without sf every region inside any shape is kept. Each column of dl is one boundary segment: row 1 type (1 circle arc, 2 line, 4 ellipse arc), rows 2-3 start and end x, rows 4-5 start and end y, rows 6-7 the region to the left and right (0 outside), rows 8-10 centre and radius of circle arcs, rows 8-12 centre, semi-axes and angle of ellipse arcs. Arcs run counter-clockwise; every circle and ellipse is first split into four quarter arcs. bt(i,j) is true when region i lies inside shape j. Borders between two kept regions stay; csgdel removes them.

Example

R1=[3;4;-1;1;1;-1;-1;-1;1;1]; C1=[1;0;0;0.5;0;0;0;0;0;0]; gd=[R1 C1]; ns=['R1';'C1']'; [dl,bt]=decsg(gd,'R1-C1',ns); size(dl)

Differences from MATLAB: region numbering and segment order may differ. Tangent curves meet at one touch point. Up to 512 shapes and 4096 boundary pieces. The third to fifth outputs are not supported.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.