-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathfixing_box.py
More file actions
31 lines (23 loc) · 1.17 KB
/
fixing_box.py
File metadata and controls
31 lines (23 loc) · 1.17 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
__authors__ = "tnavez, qpeyron"
__contact__ = "tanguy.navez@inria.fr, quentin.peyron@inria.fr"
__version__ = "1.0.0"
__copyright__ = "(c) 2020, Inria"
__date__ = "Feb 09 2023"
from splib3.objectmodel import SofaPrefab
from splib3.numerics import getOrientedBoxFromTransform
class FixingBox(SofaPrefab):
"""Fix a set of 'dofs' according to a translation & orientation"""
def __init__(self, parent, target, name='FixingBox',
translation=[0.0, 0.0, 0.0], eulerRotation=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0]):
ob = getOrientedBoxFromTransform(translation=translation, eulerRotation=eulerRotation, scale=scale)
self.node = parent.addChild(name)
self.node.addObject('BoxROI',
orientedBox=ob,
name='BoxROI',
position=target.dofs.getData('rest_position').getLinkPath(),
drawBoxes=False)
c = self.node.addChild('Constraint')
target.addChild(c)
c.addObject('FixedWeakConstraint',
indices=self.node.BoxROI.getData('indices').getLinkPath(),
stiffness=1e12)