FLofSGcolor

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - FL/Facet Lists
Introduced first in SolidGeometry 4.9, Creation date: 2020-08-10, Last change: 2025-09-14

finds the faced of a specified color



See Also: SGcolorfaces

Example Illustration

 missing image of FLofSGcolor(SG,col)

Syntax

fi=FLofSGcolor(SG,col)

Input Parameter

SG: Solid Geometry
col: search color

Output Parameter

fi: facet index in SG

Examples


SGfittingsample; A=ans; FSofSGT(A,'F',-1); fi=ans; SGcolorfaces(A,'dp',fi); SG=ans, % deep purple
FLofSGcolor(SG,'dp') % logical faces of SG.FL
FLofSGcolor(SG,'r');




Copyright 2020-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, FLofSGcolor, is designed to find the facets of a specified color within a solid geometry object. Below is a detailed explanation of the algorithm and its parameters.

Input Parameters

Output

Algorithm Steps

  1. The function begins by extracting the vertices list (VL), facets list (FL), and facet colors (FC) from the Solid Geometry object using the helper function VLFLofSG(SG).
  2. The input color col is converted to its RGB representation using the function rgbofall(nofcolmap(col,true)).
  3. The function calculates the Euclidean distance between each facet's color in FC and the specified color col. It uses vecnormr(FC-col) to compute this distance.
  4. Facets with a color distance less than 1e-2 are considered a match, and their indices are stored in fi.
  5. If no output is requested (nargout==0), the function will plot the solid geometry. It uses SGfigure to create a new figure and view(-30,30) to set the viewing angle.
  6. The function plots facets that do not match the color in white with 50% transparency using VLFLplotalpha(VL,FL(~fi,:),'w',0.5).
  7. Facets that match the color are plotted in the specified color using VLFLplotalpha(VL,FL(fi,:),col).
  8. If no facets match the specified color, a debug message is printed: dbprintf('Color not found in solid').

This function is part of the Solid Geometry library and is used to identify and visualize facets of a specific color within a 3D model.

Algorithm explaination created using ChatGPT on 2025-08-18 23:21. (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