Skip to content

Commit

Permalink
use viewer in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed May 14, 2024
1 parent ebe5b33 commit 3322116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions docs/examples/example_mesh_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from compas.geometry import Vector
from compas_dr.numdata import InputData
from compas_dr.solvers import dr_numpy
from compas_view2.app import App
from compas_viewer import Viewer

# =============================================================================
# Input
Expand Down Expand Up @@ -38,11 +38,11 @@

forcecolor = Color.green().darkened(50)

viewer = App()
viewer.view.camera.position = [5, -5, 20]
viewer.view.camera.look_at([5, 5, 0])
viewer = Viewer()
viewer.renderer.camera.target = [5, 5, 0]
viewer.renderer.camera.position = [5, 4, 20]

viewer.add(mesh)
viewer.scene.add(mesh, show_points=False)

for vertex in fixed:
point = Point(*mesh.vertex_coordinates(vertex))
Expand All @@ -51,7 +51,7 @@
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.scene.add(ball, surfacecolor=Color.red())
viewer.scene.add(line, linecolor=forcecolor, lineswidth=3, show_points=False)

viewer.run()
viewer.show()
20 changes: 10 additions & 10 deletions docs/examples/example_mesh_constrained_on-arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from compas_dr.constraints import Constraint
from compas_dr.numdata import InputData
from compas_dr.solvers import dr_constrained_numpy
from compas_view2.app import App
from compas_viewer import Viewer

# =============================================================================
# Input
Expand Down Expand Up @@ -54,22 +54,22 @@

forcecolor = Color.green().darkened(50)

viewer = App()
viewer.view.camera.position = [-7, -10, 5]
viewer.view.camera.look_at([5, 5, 2])
viewer = Viewer()
viewer.renderer.camera.target = [5, 5, 2]
viewer.renderer.camera.position = [-7, -10, 5]

viewer.add(mesh)
viewer.add(arch.to_polyline(), linecolor=Color.cyan(), linewidth=3)
viewer.scene.add(mesh, show_points=False)
viewer.scene.add(arch.to_polyline(), linecolor=Color.cyan(), lineswidth=3, show_points=False)

for vertex in fixed:
point = Point(*mesh.vertex_coordinates(vertex))
residual = Vector(*result.residuals[vertex]) * 0.1
residual = Vector(*result.residuals[vertex]) * 0.5

ball = Sphere(radius=0.1, point=point).to_brep()
line = Line(point, point - residual)
ballcolor = Color.blue() if constraints[vertex] else Color.red()

viewer.add(ball, facecolor=ballcolor)
viewer.add(line, linecolor=forcecolor, linewidth=3)
viewer.scene.add(ball, surfacecolor=ballcolor, show_points=False)
viewer.scene.add(line, linecolor=forcecolor, lineswidth=3, show_points=False)

viewer.run()
viewer.show()

0 comments on commit 3322116

Please sign in to comment.