MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / createMesh

Function createMesh

pyPBD/examples/armadillo.py:60–96  ·  view source on GitHub ↗
(simModel)

Source from the content-addressed store, hash-verified

58
59# Create a particle model mesh
60def createMesh(simModel):
61 sim = pbd.Simulation.getCurrent()
62 model = sim.getModel()
63
64 # Load TetGen model from file
65 fileNameNode = "../../data/models/armadillo_4k.node"
66 fileNameEle = "../../data/models/armadillo_4k.ele"
67 (positions, tets) = pbd.TetGenLoader.loadTetgenModel(fileNameNode, fileNameEle)
68
69 # move up and scale vertices
70 pos = np.array(positions)
71 for x in pos:
72 x[0] *= 1.5
73 x[1] = x[1]*1.5 + 6
74 x[2] *= 1.5
75 # Generata tetrahedra model
76 tetModel = model.addTetModel(pos, tets, testMesh=True)
77
78 # init constraints
79 stiffness = 1.0
80 if (simModel == 3):
81 stiffness = 1000000
82 if (simModel == 6):
83 stiffness = 100000
84 poissonRatio = 0.3
85
86 # Generate a default set of constraints for the tet model to simulate stretching and shearing resistance
87 # simModel:
88 # 1 = distance constraints (PBD)
89 # 2 = FEM tet constraints (PBD)
90 # 3 = strain tet constraints (PBD)
91 # 4 = shape matching
92 # 5 = distance constraints (XPBD)
93 model.addSolidConstraints(tetModel, simModel, stiffness, poissonRatio, stiffness, False, False)
94
95 print("Number of tets: " + str(tetModel.getParticleMesh().numTets()))
96 print("Number of vertices: " + str(len(pos)))
97
98# Render all bodies
99def render():

Callers 1

buildModelFunction · 0.70

Calls 10

strClass · 0.85
lenFunction · 0.85
getModelMethod · 0.80
loadTetgenModelMethod · 0.80
addTetModelMethod · 0.80
addSolidConstraintsMethod · 0.80
numTetsMethod · 0.80
printFunction · 0.50
getCurrentMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected