Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Decompose constructive solid geometry into minimal regions

`dl = decsg(gd,sf,ns)`

`dl = decsg(gd)`

```
[dl,bt]
= decsg(___)
```

decomposes
the geometry description matrix `dl`

= decsg(`gd`

,`sf`

,`ns`

)`gd`

into the geometry
matrix `dl`

and returns the minimal regions that
satisfy the set formula `sf`

. The name-space matrix `ns`

is
a text matrix that relates the columns in `gd`

to
variable names in `sf`

.

Typically, you draw a geometry in the PDE Modeler app, then export it to the MATLAB^{®} Command Window by selecting **Export Geometry
Description, Set Formula, Labels** from the
**Draw** menu in the app. The resulting geometry
description matrix `gd`

represents the CSG model.
`decsg`

analyzes the model and constructs a set of
disjointed minimal regions bounded by boundary segments and border segments.
This set of minimal regions constitutes the *decomposed
geometry* and allows other Partial Differential Equation Toolbox™ functions to work with the geometry.

Alternatively, you can use the `decsg`

function
when creating a geometry without using the app. See 2-D Geometry Creation at Command Line for details.

To return all minimal regions (`sf`

corresponds
to the union of all shapes in `gd`

), use the shorter
syntax

.`dl`

= decsg(`gd`

)

In rare cases

`decsg`

can error or create an invalid geometry because of the limitations of its algorithm. Such issues can occur when two or more edges of a geometry partially overlap, almost coincide, or are almost tangent.

`decsg`

does not check the input CSG model for correctness. It assumes that no circles or ellipses are identical or degenerated and that no lines have zero length. Polygons must not be self-intersecting. Use the function`csgchk`

to check the CSG model.`decsg`

returns`NaN`

if it cannot evaluate the set formula`sf`

.

PDE
Modeler | `csgchk`

| `csgdel`

| `geometryFromEdges`

| `pdecirc`

| `pdeellip`

| `pdepoly`

| `pderect`

| `wgeom`