Syntax
SG=SGCpack(SG,B,[n])
Input Parameter
SG : | | solid geometry collector, could be empty |
B : | | solid (VL,FL) |
n : | | number of added parts |
Output Parameter
SG : | | solid geometry collector |
Examples
Generate 10 Boxes in a row for 3D print
A=SGbox ([10 10 20]); B=SGbox ([10 10 10]);
C=SGCpack ([],A,3); C=SGCpack (C,B,2);
SGplot (C), show
SGCpack([],SGsample(17),5)
Copyright 2013-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 algorithm is designed to arrange multiple solid geometries side by side, preparing them for a joint 3D print job. The function SGCpack
takes in a solid geometry collector, a solid, and an optional number of parts to add.
Input Parameters
- SG: A solid geometry collector, which can be empty initially.
- B: A solid, represented by vertex list (VL) and face list (FL).
- n: An optional parameter specifying the number of parts to add. Defaults to 1 if not provided.
Output
- SG: The updated solid geometry collector with the new solids packed.
Algorithm Steps
- Check if
B
is not a cell array. If it is not, proceed with the following steps:
- Initialize
maxs
as [150, 30, 150] and sx
as 1.
- Calculate the bounding box of
B
using BBofVL
.
- Determine the number of parts
n
to add, defaulting to 1 if not specified.
- For each part to be added (from 1 to
n
):
- If
SG
is empty, initialize its vertex list, face list, and bounding list. Otherwise, calculate the bounding box of SG
.
- Calculate the new x, y, and z positions for the solid based on the bounding boxes and spacing
sx
.
- If the new x position exceeds the maximum size, reset x and adjust y position.
- Transform the vertex list of
B
to the new position and concatenate it with SG
's vertex and face lists using VLFLcat
.
- Update the bounding list of
SG
with the new bounding box dimensions.
- If
B
is a cell array, iterate over each element and recursively call SGCpack
for each solid.
- If no output is expected, plot the solid geometry using
SGplot
and display the bounding list.
Algorithm explaination created using ChatGPT on 2025-08-19 07:48. (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