PLofCPL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 3.4, Creation date: 2017-02-01, Last change: 2025-09-14

converts a nested CPL into a nested PL


Will be removed (2025-09-21): Use 'openCPL' instead

Description

This function is useful if CPLS are extruded to solids. CPLs are contours that are separted by NaN NaN. Nevertheless; sometimes the first point is doubled at the end, somethimes not. This function returns CPLs that are separated by NaN NaN but the point lists are open
Works with PL and VL

See Also: , CPLofPL , CPLofPLcontour

Example Illustration

 missing image of PLofCPL(CPL)

Syntax

NPL=PLofCPL(CPL)

Input Parameter

CPL: Closed polygon list with unclear closing condition

Output Parameter

NPL: Closed polygon list with open polygons

Examples

Try
PLofCPL([PLcircle(5);NaN NaN;PLcircle(3)]) % There are no changes
PLofCPL(CPLsample(7)) % remove the closing lines
PLofCPL(VLaddz(CPLsample(7))) % Now try with VL




Copyright 2017-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, PLofCPL, is designed to convert a closed polygon list (CPL) into a nested polygon list (NPL) with open polygons. It is particularly useful when CPLs are extruded to solids. The function handles contours separated by NaN NaN, ensuring that the resulting polygons are open.

Input Parameters

Output Results

Algorithm Steps

  1. Identify the indices where NaN NaN separates the polygons in the CPL using find(isnan(CPL(:,1))).
  2. Initialize an index array a to mark the start and end of each polygon, including the beginning and end of the CPL.
  3. Initialize NPL as a zero matrix with the same size as CPL.
  4. Iterate over each polygon segment defined by a:
  5. Trim NPL to remove any unused preallocated space.
  6. If no output argument is specified, plot the resulting NPL and the original CPL for visual comparison.

Example Usage

Algorithm explaination created using ChatGPT on 2025-08-19 07:42. (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