CPLbufferCPLlines

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 5.1, Creation date: 2021-11-18, Last change: 2025-09-15

converts a set of lines into a closed polygon concept



See Also:

Example Illustration

 missing image of CPLbufferCPLlines(CPL,d)

Syntax

CPLN=CPLbufferCPLlines(CPL,d)

Input Parameter

CPL: CPL consisting of open lines without meshes
d: buffer width

Output Parameter

CPLN: New CPL or CPS

Examples


CPLofmeshgridrods([0 15 25 35 45 55 65],[0 10]); x=ans;
CPLbufferCPLlines(x,1);
CPLbufferCPLlines(PLcircle(10),1);
CPLbufferCPLlines(CPLofPL(PLcircle(10)),1);




Copyright 2021-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, CPLbufferCPLlines, is designed to convert a set of lines into a closed polygon concept. It is part of the SolidGeometry library and was introduced in version 5.1. The function takes two input parameters and produces one output.

Input Parameters

Output

Algorithm Steps

  1. Check if the buffer width d is not zero and if CPL is not empty. If either condition is not met, the function returns the original CPL.
  2. Initialize an empty array CCC to store processed lines.
  3. Use separateNaN(CPL) to determine the number of separate line segments in CPL.
  4. Iterate over each line segment:
    • Select the i-th line segment using selectNaN(CPL, i).
    • Grow the line segment by half the buffer width using PLgrowline with parameters (selectNaN(CPL, i), d/2, false, true).
    • Append the grown line segment to CCC, separated by nan nan to maintain segment separation.
  5. Remove the initial nan nan from CCC.
  6. Use CPLmeltbool to merge overlapping or adjacent line segments in CCC.
  7. Apply CPLradialEdges to refine the edges of the merged lines, using a quarter of the buffer width d/4.
  8. Assign the processed lines to CPLN.
  9. If no output argument is specified, plot the original and processed lines using SGfigure, CPLplot, and CPSplot.
Algorithm explaination created using ChatGPT on 2025-08-19 00:16. (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