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

 missing image of CPLinsideCPL(CPL,CPLs)

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

Output Results

Algorithm Steps

  1. Convert the outer contour CPL into point list (PL) and edge list (EL) using PLELofCPL.
  2. Determine the number of separate contours in CPLs using separateNaN.
  3. Initialize an index array ind to store which contours are inside.
  4. Loop through each contour in CPLs:
  5. Find the indices of contours that are inside using find(ind).
  6. Initialize CPLN to store the internal contours.
  7. Loop through the indices of internal contours:
  8. Trim CPLN to remove unused rows.
  9. 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