-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathutils.py
More file actions
54 lines (41 loc) · 1.86 KB
/
utils.py
File metadata and controls
54 lines (41 loc) · 1.86 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
from typing import List, Callable, Tuple, Dict
from functools import wraps
import Sofa
import Sofa.Core
class defaultValueType():
def __init__(self):
pass
DEFAULT_VALUE = defaultValueType()
def isDefault(obj):
return isinstance(obj,defaultValueType)
def getParameterSet(name : str,parameterSet : Dict) -> Dict:
if name in parameterSet:
if isinstance(parameterSet[name], dict):
return parameterSet[name]
return {}
def MapKeywordArg(objectName,*argumentMaps):
def MapArg(method):
@wraps(method)
def wrapper(*args, **kwargs):
containerParams = getParameterSet(objectName,kwargs)
for argMap in argumentMaps:
if (argMap[0] in kwargs) and not(kwargs[argMap[0]] is None):
containerParams[argMap[1]] = kwargs[argMap[0]]
kwargs[objectName] = containerParams
return method(*args,**kwargs)
return wrapper
return MapArg
REQUIRES_COLLISIONPIPELINE = "requiresCollisionPipeline"
def setRequiresCollisionPipeline(rootnode):
if rootnode is not None:
if rootnode.findData(REQUIRES_COLLISIONPIPELINE) is None:
rootnode.addData(name=REQUIRES_COLLISIONPIPELINE, type="bool", default=False, help="Some prefabs in the scene requires a collision pipeline.")
else:
rootnode.requiresCollisionPipeline.value = True
REQUIRES_LAGRANGIANCONSTRAINTSOLVER = "requiresLagrangianConstraintSolver"
def setRequiresLagrangianConstraintSolver(rootnode):
if rootnode is not None:
if rootnode.findData(REQUIRES_LAGRANGIANCONSTRAINTSOLVER) is None:
rootnode.addData(name=REQUIRES_LAGRANGIANCONSTRAINTSOLVER, type="bool", default=False, help="Some prefabs in the scene requires a Lagrangian constraint solver.")
else:
rootnode.requiresLagrangianConstraintSolver.value = True