Syntax
[SG,H,AbC,FName]=SGreadOBJ([FName,mag,check])
Input Parameter
FName : | | File Name |
mag : | | magnification; default is 1 |
check : | | checker; default is false |
Output Parameter
SG : | | Solid Geometry |
H : | | Colors, not used in SG-Lib 4.7 |
AbC : | | Colors, not used in SG-Lib 4.7 |
FName : | | File Name, added in SG-Lib 4.7 |
Copyright 2018-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 SGreadOBJ
is designed to read OBJ files and is part of the SG-Library. It primarily utilizes the VLFLreadOBJ
function to handle the reading process. The function supports specific OBJ file formats, including:
f v1 v2 v3
f v1/vn v2/vn v3/vn
f v1//vn v2//vn v3//vn
These formats represent different ways of defining faces in an OBJ file.
Input Parameters
- FName: The name of the file to be read. It is a string representing the file path.
- mag: The magnification factor applied to the geometry. The default value is 1, meaning no magnification.
- check: A boolean flag to enable or disable checking. The default value is
false
.
Output Results
- SG: The Solid Geometry data structure containing vertex and face information.
- H: Color information, although not used in SG-Lib version 4.7.
- AbC: Additional color information, also not used in SG-Lib version 4.7.
- FName: The file name, included in the output for reference.
Function Workflow
The function begins by extracting the input parameters using getfuncparams
, which assigns default values if parameters are not provided. It then calls VLFLreadOBJ
with the input arguments to read the OBJ file and obtain the vertex list (SG.VL
), face list (SG.FL
), and other outputs.
The function assigns the file name to SG.stampname
and records the current date and time in SG.stampdate
.
If no output arguments are specified, the function visualizes the geometry using SGfigure
and SGplotalpha
, setting a default view angle and title based on the file name.
Algorithm explaination created using ChatGPT on 2025-08-19 06:49. (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