CPLsetallcw
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CPL/Closed Polygon Lists
Introduced first in SolidGeometry 4.7, Creation date: 2019-07-05, Last change: 2025-09-14
sets all contours of a CPL to cw
Description
this function can be used to show the effect of polybuffer or polyshape
See Also: CPLisccwinout
, CPLsortinout
, CPLisccw
, CPLisccwcorrected
Example Illustration
Syntax
CPL=CPLsetallcw(CPL)
Input Parameter
Output Parameter
CPL: | | CPL with all polygons in cw |
Examples
CPL=CPLsample(13)
CPLisccw(CPL)
CPLsetallcw(CPL); X=ans;
CPLbuffer(X,.5)
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, CPLsetallcw, is designed to ensure that all contours in a Closed Polygon List (CPL) are oriented clockwise (cw).
Input Parameters
- CPL: A Closed Polygon List, which is a data structure representing a list of polygons.
Output
- CPL: The same Closed Polygon List with all polygons oriented clockwise.
Algorithm Steps
- Call the function
CPLisccw with the input CPL to determine the orientation of each polygon in the list. This function returns an array a where each element is a boolean indicating if the corresponding polygon is counter-clockwise (ccw).
- Determine the number of polygons in the list using
numel(a) and store it in n.
- Iterate over each polygon using a for-loop from 1 to
n:
- If the polygon is counter-clockwise (i.e.,
a(i) is true), perform the following steps:
- Select the polygon using
selectNaN(CPL, i), which extracts the i-th polygon from the list.
- Reverse the order of the vertices using
flipud to change its orientation to clockwise.
- Replace the original polygon in the list with the reversed one using
replaceNaN(CPL, i, ...).
- After processing all polygons, check if the function is called with an output argument. If not (i.e.,
nargout == 0), call CPLisccw(CPL) to display the orientation status of the polygons.
Example Usage
The example provided demonstrates how to use the function:
- Create a sample CPL using
CPLsample(13).
- Check the orientation of the polygons with
CPLisccw(CPL).
- Set all polygons to clockwise using
CPLsetallcw(CPL).
- Buffer the polygons with
CPLbuffer(X, 0.5) to visualize the effect.
Algorithm explaination created using ChatGPT on 2025-08-18 23:14. (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