CPLbox

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 5.4, Creation date: 2023-12-23, Last change: 2025-09-15

create a CPL of a square including text

Description

Useful for the box world domain. Slow function because of CPLoftext


See Also: PLsquare , CPLoftext

Example Illustration

 missing image of CPLbox(sze,txt)

Syntax

CPL=CPLbox([sze,txt])

Input Parameter

sze: [x y]; default is 10
txt: chars for labeling

Output Parameter

CPL: CPL of Contour

Examples


CPL=CPLbox(10,'A'); SGfigure(0,90); CPSplot(CPL);
CPLbox([30 20],'test')
CPLbox([300 20],'Table');




Copyright 2023-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 algorithm is designed to create a closed polygon list (CPL) of a square with optional text labeling. It is part of the SolidGeometry library and is useful in the box world domain.

Input Parameters

Output

Algorithm Steps

  1. Retrieve the size parameter sze using getfuncparams, defaulting to 10 if not provided.
  2. Retrieve the text parameter txt using getfuncparams, defaulting to an empty string if not provided.
  3. Create a square CPL using the PLsquare function with the specified size sze.
  4. If the txt parameter is not empty:
    • Generate a CPL for the text using CPLoftext.
    • Buffer the square CPL by -1 using CPLbuffer to create a margin.
    • Fit the text CPL within the buffered square CPL using CPLfitsinCPL.
    • Subtract the text CPL from the square CPL using CPLsubtract.
  5. If no output argument is specified (nargout==0):
    • Open a new figure with SGfigure at position (0,90).
    • Plot the CPL using CPSplot.
Algorithm explaination created using ChatGPT on 2025-08-18 23:45. (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