-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunify.py
More file actions
37 lines (24 loc) · 896 Bytes
/
unify.py
File metadata and controls
37 lines (24 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
import os
import sys
import resource
from mesh_union.logger import logger
from mesh_union.tree import Node
from mesh_union.utils import union
from mesh_union.definitions import UNIFICATION_PROCESS_MEMORY_LIMIT_MB
args = sys.argv[1:]
if len(args) != 2:
logger.error('Script needs 2 args: metadata json file name and output file name')
sys.exit(1)
[metadataFileName, outputFileName] = args
metadata = None
with open(metadataFileName, 'r') as f:
metadata = json.load(f)
if UNIFICATION_PROCESS_MEMORY_LIMIT_MB is not None:
MAX_VIRTUAL_MEMORY = UNIFICATION_PROCESS_MEMORY_LIMIT_MB * 1024 * 1024
resource.setrlimit(resource.RLIMIT_AS, (MAX_VIRTUAL_MEMORY, resource.RLIM_INFINITY))
tree = Node.from_json(metadata)
meshes = tree.flatten()
final_mesh = union(meshes)
final_mesh.export(outputFileName, file_type='stl')
logger.info('Mesh generated successfully')