SGN=SGaddfields(SG,FNN)
SG : | Solid Geometry | |
FNN : | cell list of all field names similar to fieldnames |
SGN : | New solid with all elements have the |
loadweb JACO_robot.mat; A=JACO
B=SGbox
loadweb ADAM_C.mat; C=ADAM_C
FN=SGfieldnames({A,B,C})
SGaddfields({A,B,C},FN)
This function, SGaddfields
, is designed to add fields to elements of a solid geometry structure. It takes two input parameters:
The output is:
The algorithm works as follows:
SG
is a cell array. If true, iterate over each element in SG
and recursively call SGaddfields
for each element, storing the result in SGN
.SG
is a structure, determine the number of elements n
in SG
.n
is greater than 1, iterate over each element and recursively call SGaddfields
for each element, storing the result in SGN
.n
is 1, perform the following steps:SG
using SGfieldnames
.FNN
that are not already present in SG
.SGN
as a copy of SG
.SGN
with an empty value.SG
is neither a cell array nor a structure, display the variable information using whos
and issue a warning indicating the input is unclear.This function is part of the SG-Library and was introduced in SolidGeometry 5.0. It is useful for ensuring that all elements of a solid geometry have a consistent set of fields, which can be important for subsequent processing or analysis.
Algorithm explaination created using ChatGPT on 2025-08-19 00:31. (Please note: No guarantee for the correctness of this explanation)