CPLfillgap

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.6, Creation date: 2019-05-21, Last change: 2025-09-14

creates a contour that fills a another or several contours

Description

The functions are based on the planar CPLfunctions
- CPLconvexhullfillgap - closes gaps and try to find a SINGLE OUTLINE contour
- CPLoutlinecontour - just returns ALL OUTLINE contours
- CPLfillgap -just fillgapsb etween contours

See Also: CPLconvexhull , CPLconvexhulldelaunay , delaunayofCPL , CPLharbour , CPLfillin , CPLfillinside , CPLoutlinecontour , CPLconvexhullfillgap

Example Illustration

 missing image of CPLfillgap(CPL,d)

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

CPLN: new polygon

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

Output

Algorithm Steps

  1. The function starts by ensuring the CPL only contains the first two columns, which represent the x and y coordinates of the points.
  2. 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.
  3. 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.
  4. The ftyp parameter, which defaults to 'square', determines the type of buffering applied.
  5. 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.
  6. 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:

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