forked from Bonifatius94/PySocialForce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
41 lines (29 loc) · 1017 Bytes
/
app.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
from flask import Flask
import ghhops_server as hs
import simulateHops
import rhino3dm as rg
app = Flask(__name__)
hops = hs.Hops(app)
@hops.component(
"/simulate",
name = "Simulate Pedestrian Movement",
nickname = "Simulate",
description ="Simulate Pedestrian Movement according to the Social Force Model by Helbing and Molnar",
inputs=[
hs.HopsInteger("Step", "No", "Number of Simulation Steps"),
hs.HopsBoolean("Simulate", "Sim", "Simulate Pedestrian Movement", hs.HopsParamAccess.ITEM, False),
hs.HopsInteger("margin", "M", "Boundary Margin", hs.HopsParamAccess.ITEM)
],
outputs=[
hs.HopsPoint("Positions", "Pos", "Positions of Pedestrians per Step", hs.HopsParamAccess.TREE)
]
)
def simulate(steps, toggle, margin):
positions=[]
if(toggle==True):
positions= simulateHops.simulate(steps, margin)
else:
positions.append(rg.Point3d(0,0,0))
return positions
if __name__== "__main__":
app.run(debug=True)