(simModel)
| 58 | |
| 59 | # Create a particle model mesh |
| 60 | def 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 |
| 99 | def render(): |
no test coverage detected