replaceNaN

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 3.9, Creation date: 2017-05-27, Last change: 2025-09-14

replaces or removes/ deletes a contour within a CPL

Description

In SG-Lib 5.0 deleting a contour is possible

See Also: selectNaN , lengthNaN , cellofNaN , separateNaN , uniqueNaN , unsortNaN

Example Illustration

 missing image of replaceNaN(CPL,ci,CPLi)

Syntax

CPL=replaceNaN(CPL,ci,[CPLi])

Input Parameter

CPL: CPL
ci: index of contour
CPLi: new contour for contour ci

Output Parameter

CPL: Resulting CPL

Examples


replaceNaN(CPLsample(12),3,flipud(separateNaN(CPLsample(12),3)));
replaceNaN(CPLsample(12),3,'');




Copyright 2017-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, replaceNaN, is designed to replace or remove a contour within a CPL (Closed Polyline) structure. It is part of the SG-Library and was introduced in SolidGeometry 3.9.

Input Parameters

Output

Algorithm Steps

  1. Retrieve the new contour CPLi from the input parameters using getfuncparams.
  2. Check if ci is a scalar. If not, sort ci and iterate over each index to perform the replacement or removal.
  3. For each index in ci:
    • Call replaceNaN recursively for each index.
    • If CPLi is empty, adjust ci to account for the removal of contours.
  4. If ci is a scalar:
    • Use separateNaN to find the boundaries of the contour within CPL.
    • If CPLi is not empty, replace the contour at index ci with CPLi using flexible sizing.
    • If CPLi is empty, remove the contour at index ci.
    • Ensure the last element of CPL is not NaN; if it is, remove it.
  5. If no output is requested, call CPLisccw to check the orientation of the resulting CPL.
Algorithm explaination created using ChatGPT on 2025-08-19 07:23. (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