forked from erizmr/SPH_Taichi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_builder.py
37 lines (31 loc) · 1.05 KB
/
config_builder.py
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
class SimConfig:
def __init__(self, scene_file_path) -> None:
self.config = None
with open(scene_file_path, "r") as f:
self.config = json.load(f)
print(self.config)
def get_cfg(self, name, enforce_exist=False):
if enforce_exist:
assert name in self.config["Configuration"]
if name not in self.config["Configuration"]:
if enforce_exist:
assert name in self.config["Configuration"]
else:
return None
return self.config["Configuration"][name]
def get_rigid_bodies(self):
if "RigidBodies" in self.config:
return self.config["RigidBodies"]
else:
return []
def get_rigid_blocks(self):
if "RigidBlocks" in self.config:
return self.config["RigidBlocks"]
else:
return []
def get_fluid_blocks(self):
if "FluidBlocks" in self.config:
return self.config["FluidBlocks"]
else:
return []