CPLinsideCPL
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 2.5.1, Creation date: 2015-09-11, Last change: 2025-09-14
returns the contours of a CPL that inside another CPL
Description
Written on SY Bontekoning at Marina Panacea Palma de Mallorca
See Also: , insideCPS
, selectNaN
Example Illustration
Syntax
[ind,CPLN]=CPLinsideCPL(CPL,CPLs)
Input Parameter
CPL: | | One outer CPL that defines the border line |
CPLs: | | CPL with several contours separated by NAN |
Output Parameter
ind: | | index which contour is inside of CPLO |
CPLN: | | CPL of all internal CPLs |
Examples
CPLinsideCPL(PLcircle(9),CPLcopypattern(PLcircle(2),[5 5],[2 2]))
Copyright 2015-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)
This function, CPLinsideCPL, determines which contours from a set of contours (CPLs) are inside a given outer contour (CPL). It returns the indices of these internal contours and the contours themselves.
Input Parameters
- CPL: A single closed polygon list that defines the outer boundary.
- CPLs: A closed polygon list containing multiple contours, separated by
NaN values.
Output Results
- ind: An index array indicating which contours from
CPLs are inside CPL.
- CPLN: A closed polygon list of all contours from
CPLs that are inside CPL.
Algorithm Steps
- Convert the outer contour
CPL into point list (PL) and edge list (EL) using PLELofCPL.
- Determine the number of separate contours in
CPLs using separateNaN.
- Initialize an index array
ind to store which contours are inside.
- Loop through each contour in
CPLs:
- Extract the current contour using
separateNaN.
- Check if the contour is inside
CPL using insidePLEL.
- Update the index array
ind based on the result.
- Find the indices of contours that are inside using
find(ind).
- Initialize
CPLN to store the internal contours.
- Loop through the indices of internal contours:
- Extract each internal contour and append it to
CPLN.
- Trim
CPLN to remove unused rows.
- If no output arguments are specified, plot the outer contour, all contours, and internal contours using
CPLplot.
Algorithm explaination created using ChatGPT on 2025-08-19 01:27. (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