SGN=SGcell2array([SGC])
SGC : | Cell of Solids |
SGN : | Array of Solids - requires the same struct fields for all structs |
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)
SGcell2array({{A,B,C}})
This function, SGcell2array
, is designed to convert a cell list of solids into a struct array of solids. It is part of the SolidGeometry library and was introduced to address the issue of whether a cell list or a struct array is more efficient for handling solids.
SG
.SGfieldnames
and stores them in FN
.SGaddfields
with the solids and the field names.na
.SGN
is initialized to store the resulting struct array of solids.SGN
.SGcell2array
on the contents of the cell and appends the result to SGN
.nargout==0
), the function visualizes the solids using SGfigure
and SGTplotalpha
.The function can be used as follows:
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) SGcell2array({{A,B,C}})
This example demonstrates loading solid objects, ensuring they have consistent fields, and converting them into a struct array.
Algorithm explaination created using ChatGPT on 2025-08-19 07:39. (Please note: No guarantee for the correctness of this explanation)