CPLofSGsliceauto

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - CVLz/Slices
Introduced first in SolidGeometry 4.3, Creation date: 2018-10-29, Last change: 2025-09-14

returns the slive with a significant z distance



See Also: CPLofSGslice , CPLofSGslice2 , CPLofSGslice3 , CVLzofSGsliceauto

Example Illustration

 missing image of CPLofSGsliceauto(SG,dz);

Syntax

[CPL,CVL,zz]=CPLofSGsliceauto(SG,[dz]);

Input Parameter

SG: Solid Geometry
dz: minimal z change; default is soBB(SG)/50

Output Parameter

CPL: Closed Polygon Line
CVL: Closed Vertex List of all z values
zz:

Examples


SGreadSTL; A=ans; SGrotateservo(A); B=ans
CPLofSGsliceauto(B);




Copyright 2018-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, CPLofSGsliceauto, is designed to compute slices of a solid geometry (SG) at significant z distances. It returns a closed polygon line (CPL), a closed vertex list (CVL), and a list of z values (zz).

Input Parameters

Output Results

Algorithm Steps

  1. Remove surface edge points from the solid geometry using SGremsurfedgepoints.
  2. Calculate the bounding box size of the solid geometry using sofBB.
  3. Determine the dz value using getfuncparams. If dz is an integer, adjust it by dividing the bounding box size in the z-direction by dz.
  4. Extract unique z-values from the vertex list of the solid geometry.
  5. Identify significant z-values where the change is greater than or equal to dz using circshift to compare adjacent z-values.
  6. Adjust the identified z-values by a small shift (sh) to ensure precision.
  7. Round the z-values to the nearest division of dz/2 using rounddiv.
  8. Ensure uniqueness of the z-values.
  9. Compute the closed polygon line and vertex list for the identified z-values using CPLofSGslice3.
  10. If no output arguments are specified, display the number of slices and plot the solid geometry and slices using SGfigure, SGplot, CVLplot, and CVLzplotasCPS.
Algorithm explaination created using ChatGPT on 2025-08-19 08:15. (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