svgpolylineofCPL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - File handling
Introduced first in SolidGeometry 2.5.1, Creation date: 2015-09-13, Last change: 2025-09-14

writes CPLs as polygons or polyeder lines for a laser cutter



See Also: CPLsortinout , selectNaN , CPLwriteSVG

Example Illustration

 missing image of svgpolylineofCPL (fid,CPL,stroke,width,fill)

Syntax

svgpolylineofCPL(fid,CPL,[stroke,width,fill])

Input Parameter

fid: File Identifyer
CPL: Close Contour List
stroke: red, blue, etc.
width: 1, 3
fill: none, or red, blue, etc.

Examples


CPLwriteSVG(CPLsample(10))




Copyright 2015-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, svgpolylineofCPL, is designed to write closed contour lists (CPLs) as polygons or polyline elements in SVG format, typically for use with a laser cutter. The function is part of the SG-Library and was created by Tim Lueth.

Input Parameters

Algorithm Steps

  1. Initialize default values for stroke, width, and fill if they are not provided in varargin.
  2. Convert the input CPL to a format suitable for processing using CPLofPL.
  3. Determine the number of separate contours in CPL using separateNaN.
  4. Iterate over each contour:
    • Extract the current contour using separateNaN.
    • Check if the contour is closed by comparing the first and last points.
    • If closed, write a <polygon> element to the file. If not, write a <polyline> and issue a warning.
    • For each point in the contour, write its coordinates to the file in the format x,y.
    • Complete the SVG element with the specified stroke, stroke-width, and fill attributes.
Algorithm explaination created using ChatGPT on 2025-08-19 07:33. (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