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
Syntax
CPL=replaceNaN(CPL,ci,[CPLi])
Input Parameter
CPL: | | CPL |
ci: | | index of contour |
CPLi: | | new contour for contour ci |
Output Parameter
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
- CPL: The Closed Polyline structure that contains the contours.
- ci: The index or indices of the contour(s) to be replaced or removed.
- CPLi: The new contour to replace the existing contour at index
ci. If empty, the contour is removed.
Output
- CPL: The resulting Closed Polyline structure after the specified operations.
Algorithm Steps
- Retrieve the new contour
CPLi from the input parameters using getfuncparams.
- Check if
ci is a scalar. If not, sort ci and iterate over each index to perform the replacement or removal.
- For each index in
ci:
- Call
replaceNaN recursively for each index.
- If
CPLi is empty, adjust ci to account for the removal of contours.
- 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.
- 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