patchofSG

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 3.8, Creation date: 2017-04-19, Last change: 2025-09-14

creates a patch struct of a solid geometry

Description

Matlab has different data models for the handling of surface models:
patch, triangulation, delaunaytriangulation, poly2fv etc.
SUPPORTS also with cells of solids an returns a list
ATTENTION: A patch is only valid if the figure is not closed. So in case that you want to use a patch for surface reduction, copy it afterwards into a SG using 'SGofpatch'; It is similar to SGplot

See Also: SGofpatch , SGplot , SGreduceVLFL

Example Illustration

 missing image of patchofSG(SG,realp)

Syntax

h=patchofSG(SG,[realp])

Input Parameter

SG: Soldid Geometry;
realp: true=real patch; default is false

Output Parameter

h: handle to patch struct or patch class

Examples


a=patchofSG(SGsample(17))
a=patchofSG(SGsample(17),true)




Copyright 2017-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)

The function patchofSG is designed to create a patch structure from a solid geometry (SG). It is part of the SG-Library and was developed by Tim Lueth. The function can handle both individual solid geometries and cells of solids, returning a list of patches.

Input Parameters

Output

Algorithm Details

The function begins by setting the default value of realp to false. It checks if the number of input arguments is greater than or equal to 2 and if the second argument is not empty. If both conditions are met, it assigns the value of the second argument to realp.

The function then checks if SG is a cell array. If it is, it initializes an empty array h and iterates over each element in the cell array. For each element, it calls patchofSG recursively with the separated solid geometry and the visibility parameter vis. The results are concatenated into h.

If SG is not a cell array, the function assigns the face list SG.FL to h.Faces and the vertex list SG.VL to h.Vertices. If realp is true, it creates a patch using the structure h.

There is a commented-out section that, if enabled, would create a figure and set the visibility of the patch to 'on' if no output arguments are specified.

Algorithm explaination created using ChatGPT on 2025-08-19 01:04. (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