CPLofPolygon

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.4, Creation date: 2018-12-26, Last change: 2025-09-14

returns the CPL of a graphics object type polygon

Description

Auxiliary function to convert the polygon graphics object handle into a CPL. Used in interactive functions such as uipolygoncontextmenu.

See Also: CPLofpolyshape , uipolygoncontextmenu

Example Illustration

 missing image of CPLofPolygon(h,ascell);

Syntax

CPL=CPLofPolygon(h,[ascell]);

Input Parameter

h: handle to polygon
ascell: if return as cell list or as array

Output Parameter

CPL: Closed Polygon line

Examples


h=plot(polyshape(PLcircle(4)))
CPLofPolygon(h)
h=plot(polyshape([PLcircle(4);nan nan; PLcircle(4)+[5 5]])); shg
CPLofPolygon(h)




Copyright 2018-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, CPLofPolygon, is designed to convert a polygon graphics object handle into a Closed Polygon Line (CPL). It is part of the SolidGeometry library and is used in interactive functions like uipolygoncontextmenu.

Input Parameters

Output

Algorithm Steps

  1. Retrieve the ascell parameter using getfuncparams, defaulting to false if not provided.
  2. Determine the number of polygon handles, n, using numel(h).
  3. If n is 1 or ascell is false:
    • Initialize nv to count the total number of vertices across all polygons.
    • Iterate over each polygon handle to accumulate the number of vertices.
    • Create a CPL array with nan separators between polygons.
    • Fill the CPL array with vertices from each polygon.
  4. If ascell is true:
    • Initialize CPL as a cell array with n elements.
    • For each polygon handle, store its vertices in the corresponding cell.
  5. If no output is requested (nargout==0):
    • Open a new figure and plot the polygons using CVLplot.
    • Annotate the plot with vertex labels using textCVL.
Algorithm explaination created using ChatGPT on 2025-08-19 08:26. (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