SGreadSTLreducedFL

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Import/Export
Introduced first in SolidGeometry 5.3, Creation date: 2023-05-31, Last change: 2025-09-15

Reads in a STL file and reduces immedeatly the number of faces

Description

This function is important if very large files of CAD design, natural landscapes, or medical data is processed

See Also: SGreadSTL

Example Illustration

 missing image of SGreadSTLreducedFL(PAR,

Syntax

SG=SGreadSTLreducedFL([PAR,"nFL"])

Input Parameter

PAR: same parameter set as SGreadSTL
"nFL": optional string parameter; default is 60000

Output Parameter

SG: Solid Geometry




Copyright 2023-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, SGreadSTLreducedFL, is designed to read an STL file and reduce the number of faces in the geometry. It is particularly useful for processing large CAD files, natural landscapes, or medical data.

Input Parameters

Output Results

Algorithm Steps

  1. The function begins by extracting the nFL parameter from the input arguments using getfuncparamStr. If not provided, it defaults to 60000.
  2. The STL file is read using the SGreadSTL function with the provided parameters.
  3. The size of the bounding box of the solid geometry is calculated using sofBB.
  4. The point cloud distance matrix is computed using VLpointclouddistance on the vertex list SG.VL.
  5. The minimum distance m is found from the distance matrix.
  6. The ratio k is calculated as the size of the bounding box divided by the minimum distance.
  7. If k is greater than 500, the vertex list is scaled by a factor of 256 (this part is commented out in the code).
  8. The function SGreduceVLFL is called to reduce the number of faces in the solid geometry to numFL.
  9. If the field alpha exists in the solid geometry and its value is not between 0 and 1, it is removed using rmfield.
  10. If no output is requested, the function plots the solid geometry using SGfigure and SGplotalpha with a white color.
Algorithm explaination created using ChatGPT on 2025-08-19 00:41. (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