Syntax
CPLN=CPLfillgap(CPL,[d])
Input Parameter
CPL : | | Closed Polygon List |
d : | | gap distance to bridge; by default 1% of maximum size length |
Output Parameter
Examples
CPLfillgap(CPLsample(14),3);
CPLfillgap(CPLsample(19),3);
CPLfillgap(CPLsample(21),3);
Copyright 2019-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, CPLfillgap
, is designed to create a new contour that fills gaps between existing contours in a Closed Polygon List (CPL). It is part of the SolidGeometry library and was introduced in version 4.6.
Input Parameters
- CPL: A Closed Polygon List, which is a set of 2D points representing one or more closed polygons.
- d: The gap distance to bridge between contours. If not provided, it defaults to 1% of the maximum size length of the bounding box of the CPL.
Output
- CPLN: The new polygon that fills the gaps between the contours in the input CPL.
Algorithm Steps
- The function starts by ensuring the CPL only contains the first two columns, which represent the x and y coordinates of the points.
- The gap distance
d
is determined. If not provided, it is calculated as 1% of the maximum size length of the bounding box of the CPL using the function sofBB
and BBofCPL
.
- The function
CPLbuffer
is called twice. First, it expands the CPL by the distance d
, and then it contracts it by the same distance d
. This process is intended to fill small gaps between contours.
- The
ftyp
parameter, which defaults to 'square', determines the type of buffering applied.
- If the
keep
parameter is true, the original CPL is inserted back into the result using CPLinsertPL
to ensure no data is lost due to a bug in polyspace.
- If no output is requested, the function plots the original and new polygons using
SGfigure
, CPSplot
, and CPLplot
.
Example Usage
The function can be used with sample data as follows:
CPLfillgap(CPLsample(14),3);
CPLfillgap(CPLsample(19),3);
CPLfillgap(CPLsample(21),3);
Algorithm explaination created using ChatGPT on 2025-08-19 08:30. (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