Skip to content

Commit b69dabe

Browse files
committed
Add addObject as reusable method and use it in Collision to enable kwargs
1 parent a903e01 commit b69dabe

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

stlib/geometry/__geometry__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def __init__(self, params: GeometryParameters):
4949
params.data.generateAttribute(self)
5050
if(params.dynamicTopology):
5151
if(params.elementType is not None):
52-
addDynamicTopology(self, container = dataclasses.asdict(params.data))
52+
addDynamicTopology(self, container = dataclasses.asdict(params.data), **params.kwargs)
5353
else:
5454
raise ValueError
5555
else:
56-
addStaticTopology(self, container = dataclasses.asdict(params.data))
56+
addStaticTopology(self, container = dataclasses.asdict(params.data),**params.kwargs)

stlib/geometry/cube.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from stlib.geometry import GeometryParameters
22

3+
#TODO this is outdated an need to be updated with the InternalDataProvider
4+
35
class CubeParameters(GeometryParameters):
46
def __init__(self, center, edgeLength, pointPerEdge, dynamicTopology = False):
57

stlib/geometry/extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from Sofa.Core import Node
88

9-
9+
#TODO enable passing kwargs to this to use addObject instead and again get the benefit from splib
1010
class ExtractInternalDataProvider(InternalDataProvider):
1111
destElemType : ElementType
1212
fromElemType : ElementType

stlib/geometry/sphere.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from stlib.geometry import GeometryParameters
22

3+
#TODO this is outdated an need to be updated with the InternalDataProvider
4+
35
class SphereParameters(GeometryParameters):
46
def __init__(self, center, radius, pointPerRad, dynamicTopology = False):
57

stlib/prefabs/visual.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
from stlib.core.baseParameters import BaseParameters, Callable, Optional, dataclasses, Any
33
from stlib.geometry import Geometry, GeometryParameters
44
from stlib.geometry.file import FileParameters
5+
from splib.core.utils import DEFAULT_VALUE, addObject
6+
57
from Sofa.Core import Object
68

79
@dataclasses.dataclass
810
class VisualParameters(BaseParameters):
9-
color : Optional[list[float]] = None
10-
texture : Optional[str] = None
11+
color : Optional[list[float]] = DEFAULT_VALUE
12+
texture : Optional[str] = DEFAULT_VALUE
1113

1214
geometry : GeometryParameters = dataclasses.field(default_factory = lambda : GeometryParameters())
1315
addMapping : Optional[Callable] = None
@@ -18,8 +20,7 @@ def __init__(self, params: VisualParameters):
1820
BasePrefab.__init__(self, params)
1921

2022
geom = self.add(Geometry, params.geometry)
21-
# TODO : handle optional color, texture using DEFAULT_VALUE mechanism (as implemented by Paul)
22-
self.addObject("OglModel", color=params.color, src=geom.container.linkpath)
23+
addObject(self,"OglModel", "MechanicalState", color=params.color, src=geom.container.linkpath, **params.kwargs)
2324

2425
if params.addMapping is not None:
2526
params.addMapping(self)

0 commit comments

Comments
 (0)