CPLadd

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Boolean
Introduced first in SolidGeometry 4.7, Creation date: 2019-06-23, Last change: 2025-09-14

adds the outer contours and subtacts the holes of two CPLs

Description

Overlaps filled and open contours; Helpful for mechanical design
different from CPLunion

See Also: CPLbool , CPLregionsholes

Example Illustration

 missing image of CPLadd(CPLA,CPLB,ibool)

Syntax

CPL=CPLadd(CPLA,CPLB,[ibool])

Input Parameter

CPLA: CPLA A
CPLB: CPLA B
ibool: '+' drills the holes through all, 'x' finds contour that fits trough all holes

Output Parameter

CPL: Final Contour

Examples


CPLadd(CPLsample(27),PLcircleoval(6,'',40,4));
CPLadd(PLcircleoval(6,'',40,4),CPLsample(27));
CPLadd(CPLsample(10),CPLsample(27));
CPLadd(CPLsample(27),CPLsample(10));




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, CPLadd, is designed to manipulate closed polygon lists (CPLs) by adding outer contours and subtracting holes. It is particularly useful in mechanical design for handling overlaps of filled and open contours.

Input Parameters

Output

Algorithm Steps

  1. Check if CPLA is empty. If it is, return CPLB as the result.
  2. Use CPLregionsholes to separate outer contours and holes for both CPLA and CPLB:
    • [CPLAo, CPLAi] = CPLregionsholes(CPLA)
    • [CPLBo, CPLBi] = CPLregionsholes(CPLB)
  3. Combine the outer contours of CPLA and CPLB using CPLbool with the '+' operation:
    • CPLO = CPLbool('+', CPLAo, CPLBo)
  4. Combine the holes of CPLA and CPLB using CPLbool with the operation specified by ibool:
    • CPLI = CPLbool(ibool, CPLAi, CPLBi)
  5. Subtract the combined holes from the combined outer contours using CPLbool with the '-' operation:
    • CPL = CPLbool('-', CPLO, CPLI)
  6. If no output is requested, plot the results using various plotting functions to visualize the contours and holes.
Algorithm explaination created using ChatGPT on 2025-08-19 07:03. (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