by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.7, Creation date: 2019-06-23, Last change: 2025-09-14
CPLS=CPLselectinout(CPL,si,[in1st])
CPL: | CPL | |
si: | 0 = outside! surrounded by 1, 2 = surrounded by 2 etc. | |
in1st: | true = insode start, false = outside start |
CPLS: | Selected CPLs |
CPL=CPLsample(14); SGfigure; CPLplotcolors(CPL,'',16);
CPLselectinout(CPL,[0 2]);
CPLselectinout(CPL,[1 2]);
CPLselectinout(CPLsample(26),[0 1],false); % Main contour Level 1
CPLselectinout(CPLsample(26),[2 3],false); % Main contour Level 2
CPLselectinout(CPLsample(14),[1 2],true); % Main Hole Level 1
The function CPLselectinout is designed to select closed polygon lists (CPLs) based on their enclosure index. It is part of the SolidGeometry library and was introduced in version 4.7. The function takes in a CPL and returns selected CPLs based on specified criteria.
si parameter using getfuncparams with a default empty string.in1st parameter using getfuncparams with a default value of true.CPLsortinout with the CPL and in1st to get the enclosure index ci.si is empty, return the maximum value of ci as CPLS.fi where ci matches any value in si using ismember.fi using selectNaN and assign to CPLS.SGfigure, CPLplot, and plotannotation.Here are some example calls to the function:
CPLselectinout(CPL, [0 2]);CPLselectinout(CPL, [1 2]);CPLselectinout(CPLsample(26), [0 1], false); - Main contour Level 1CPLselectinout(CPLsample(26), [2 3], false); - Main contour Level 2CPLselectinout(CPLsample(14), [1 2], true); - Main Hole Level 1