-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.py
46 lines (34 loc) · 1.19 KB
/
Controller.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
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Sofa
import Sofa.Core
import Sofa.Simulation
import SofaRuntime
import os
import numpy as np
_runAsPythonScript = False
def get1DIdx(RowIdx,ColIdx):
Idx1D = RowIdx * 8 + ColIdx
return Idx1D
class Controller(Sofa.Core.Controller):
def __init__(self, *args, **kwargs):
Sofa.Core.Controller.__init__(self, *args, **kwargs)
self.RootNode = kwargs['RootNode']
self.Counter = 0
self.IterationCounter = 0
self.DistributionStride = 5
self.begun = False
self.ModelNode = self.RootNode.origami
self.SurfacePressurePressure = self.ModelNode.cavity.pressure
self.VolumeChange = 0
self.VolumeIncrement = 30
self.SideInflationSign = 1
def onKeypressedEvent(self, c):
increment=50
key = c['key']
if (key == "+"):
pressureValue=self.SurfacePressurePressure.value.value[0] + increment
self.SurfacePressurePressure.value = [pressureValue]
if (key == "-"):
pressureValue=self.SurfacePressurePressure.value.value[0] - increment
self.SurfacePressurePressure.value = [pressureValue]