diff --git a/docs/examples/example_mesh_basic.py b/docs/examples/example_mesh_basic.py index 56572f0..e47b947 100644 --- a/docs/examples/example_mesh_basic.py +++ b/docs/examples/example_mesh_basic.py @@ -25,22 +25,19 @@ indata = InputData.from_mesh(mesh, fixed, loads, qpre) # ============================================================================= -# Solve +# Solve and Update # ============================================================================= result = dr_numpy(indata=indata) -# ============================================================================= -# Update -# ============================================================================= - -for vertex in mesh.vertices(): - mesh.vertex_attributes(vertex, "xyz", result.xyz[vertex]) +result.update_mesh(mesh) # ============================================================================= # Visualize # ============================================================================= +forcecolor = Color.green().darkened(50) + viewer = App() viewer.view.camera.position = [5, -5, 20] viewer.view.camera.look_at([5, 5, 0]) @@ -49,14 +46,12 @@ for vertex in fixed: point = Point(*mesh.vertex_coordinates(vertex)) - residual = Vector(*result.residuals[vertex]) - ball = Sphere(radius=0.1, point=point) - - viewer.add(ball.to_brep(), facecolor=Color.red()) - viewer.add( - Line(point, point - residual * 0.1), - linecolor=Color.green().darkened(50), - linewidth=3, - ) + residual = Vector(*result.residuals[vertex]) * 0.1 + + ball = Sphere(radius=0.1, point=point).to_brep() + line = Line(point, point - residual) + + viewer.add(ball, facecolor=Color.red()) + viewer.add(line, linecolor=forcecolor, linewidth=3) viewer.run()