CPLselectinout

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

returns selected CPLs based on their enclosure index

Description

You can use CPLoutlinecontour if you need just the outline contours

See Also: CPLsortinout , selectNaN , CPLoutlinecontour

Example Illustration

 missing image of CPLselectinout(CPL,si,in1st)

Syntax

CPLS=CPLselectinout(CPL,si,[in1st])

Input Parameter

CPL: CPL
si: 0 = outside! surrounded by 1, 2 = surrounded by 2 etc.
in1st: true = insode start, false = outside start

Output Parameter

CPLS: Selected CPLs

Examples


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




Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

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.

Input Parameters

Output Results

Algorithm Steps

  1. Retrieve the si parameter using getfuncparams with a default empty string.
  2. Retrieve the in1st parameter using getfuncparams with a default value of true.
  3. Call CPLsortinout with the CPL and in1st to get the enclosure index ci.
  4. If si is empty, return the maximum value of ci as CPLS.
  5. Find indices fi where ci matches any value in si using ismember.
  6. Select the CPLs at indices fi using selectNaN and assign to CPLS.
  7. If no output is requested, plot the original and selected CPLs using SGfigure, CPLplot, and plotannotation.

Example Usage

Here are some example calls to the function:

Algorithm explaination created using ChatGPT on 2025-08-19 07:38. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21