Skip to content

Commit cca8bf2

Browse files
jenholmbergmvdoc
andauthored
FIX pass expand_head_model value to all functions (#18)
* added --expand-head-model arg + argparser * fixed PR * DOC minor doc fixes * Minor ordering of things * Add 0 in front of .1 --------- Co-authored-by: Matteo Visconti di Oleggio Castello <[email protected]>
1 parent 865939d commit cca8bf2

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ __pycache__/
55
*.obj
66
*.ply
77
*.mlx
8+
*.stl
89

910
# temp folder
1011
temp/

make_headcase.py

+31-23
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,8 @@ def gen_case(
224224
workdir=None,
225225
casetype="s32",
226226
nparts=4,
227-
expand_head_model=0.1,
228227
customizations=DEFAULT_CUSTOMIZATIONS,
229-
):
228+
expand_head_model=0.1):
230229
"""
231230
Generate a headcase.
232231
@@ -246,11 +245,11 @@ def gen_case(
246245
nparts : int, optional
247246
Number of parts to divide the head case into. Possible values are 2 or 4.
248247
Default is 4.
249-
expand_head_model : float, optional
250-
Factor (in mm) to expand the head model by. Default is 0.1.
251248
customizations : str, optional
252249
Path to the customizations file to remove additional parts from the headcase.
253250
Default is `default_customizations.stl` in the `stls` folder.
251+
expand_head_model : float, optional
252+
Factor (in mm) to expand the head model by. Default is 0.1.
254253
255254
Examples
256255
--------
@@ -313,6 +312,7 @@ def pipeline(
313312
nparts=4,
314313
workdir=None,
315314
customizations=DEFAULT_CUSTOMIZATIONS,
315+
expand_head_model=0.1,
316316
):
317317
"""
318318
Run the pipeline to generate a head case from a head model.
@@ -333,6 +333,8 @@ def pipeline(
333333
Path to the working directory, default is None.
334334
customizations : dict, optional
335335
Customizations for the head case, default is `default_customizations.stl`.
336+
expand_head_model : float, optional
337+
Factor (in mm) to expand the head model by, default is 0.1.
336338
337339
Notes
338340
-----
@@ -368,6 +370,7 @@ def pipeline(
368370
casetype=casetype,
369371
nparts=nparts,
370372
customizations=customizations,
373+
expand_head_model=expand_head_model
371374
)
372375

373376
if workdir is None:
@@ -388,15 +391,6 @@ def pipeline(
388391
type=str,
389392
help="output headcase model (*.zip)",
390393
)
391-
parser.add_argument(
392-
"--expand-head-model",
393-
type=float,
394-
default="0.1",
395-
help="Expand the head model by this amount (in mm) before generating the "
396-
"headcase. The default (0.1 mm) should work for most cases. If the resulting "
397-
"headcase is too tight, one can try increasing this value. It is not "
398-
"recommended to pass a value greater than 1 mm.",
399-
)
400394
parser.add_argument(
401395
"--headcoil",
402396
"-c",
@@ -416,6 +410,18 @@ def pipeline(
416410
help="Split the headcase model into 4 (default) or 2 parts. Four parts require "
417411
"less support material when 3d printing the headcase.",
418412
)
413+
parser.add_argument(
414+
"--workdir",
415+
type=str,
416+
required=False,
417+
default=None,
418+
help="Working directory to use. If this flag is not used, "
419+
"then a temporary directory is created and deleted at the end. "
420+
"If this flag is used, the intermediate models are stored "
421+
"in the working directory and not deleted. "
422+
"This option is useful for manual tuning of the alignment, "
423+
"in combination with the flag --generated-headcase-only",
424+
)
419425
parser.add_argument(
420426
"--generate-headcase-only",
421427
action="store_true",
@@ -432,16 +438,15 @@ def pipeline(
432438
f"to fine-tune the headcase. The default file is {DEFAULT_CUSTOMIZATIONS}",
433439
)
434440
parser.add_argument(
435-
"--workdir",
436-
type=str,
437-
required=False,
438-
default=None,
439-
help="Working directory to use. If this flag is not used, "
440-
"then a temporary directory is created and deleted at the end. "
441-
"If this flag is used, the intermediate models are stored "
442-
"in the working directory and not deleted. "
443-
"This option is useful for manual tuning of the alignment, "
444-
"in combination with the flag --generated-headcase-only",
441+
"--expand-head-model",
442+
type=float,
443+
default=0.1,
444+
help="Expand the head model by this amount (in mm) before generating the "
445+
"headcase. The default (0.1 mm) should work for most cases. If the resulting "
446+
"headcase is too tight, one can try increasing this value. If the resulting "
447+
"headcase is too loose, one can try passing a negative value to shrink the head"
448+
"model. It is not recommended to pass a value greater than 1 mm or less than "
449+
"-1 mm.",
445450
)
446451
args = parser.parse_args()
447452
infile = os.path.abspath(args.infile)
@@ -451,6 +456,7 @@ def pipeline(
451456
workdir = args.workdir
452457
customizations = args.customizations_file
453458
generate_headcase_only = args.generate_headcase_only
459+
expand_head_model = args.expand_head_model
454460

455461
if generate_headcase_only:
456462
print("Making head case")
@@ -461,6 +467,7 @@ def pipeline(
461467
nparts=nparts,
462468
workdir=workdir,
463469
customizations=customizations,
470+
expand_head_model=expand_head_model,
464471
)
465472
else:
466473
pipeline(
@@ -470,4 +477,5 @@ def pipeline(
470477
nparts=nparts,
471478
workdir=workdir,
472479
customizations=customizations,
480+
expand_head_model=expand_head_model,
473481
)

0 commit comments

Comments
 (0)