Skip to content

Commit

Permalink
Merge pull request #88 from Ipuch/master
Browse files Browse the repository at this point in the history
small fixing with local  variable
  • Loading branch information
pariterre authored Feb 9, 2023
2 parents 9bce9ec + b24a5e7 commit b074abe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 13 additions & 11 deletions bioviz/biorbd_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import numpy as np
from PyQt5 import QtWidgets
from PyQt5.QtGui import QPalette, QColor
import threading

from vtk import (
vtkActor,
Expand Down Expand Up @@ -41,10 +42,11 @@
from pyomeca import Markers, Rototrans
from .mesh import Mesh

first = True
if first:
first = threading.local()
first.value = True
if first.value:
app = QtWidgets.QApplication(sys.argv)
first = False
first.value = False


class VtkWindow(QtWidgets.QMainWindow):
Expand Down Expand Up @@ -861,7 +863,7 @@ def new_mesh_set(self, all_meshes):
self.mesh_actors = list()

# Create the geometry of a point (the coordinate) points = vtkPoints()
for (i, mesh) in enumerate(self.all_meshes):
for i, mesh in enumerate(self.all_meshes):
if mesh.time.size != 1:
raise IndexError("Mesh should be from one frame only")

Expand Down Expand Up @@ -940,7 +942,7 @@ def update_mesh(self, all_meshes):

self.all_meshes = all_meshes

for (i, mesh) in enumerate(self.all_meshes):
for i, mesh in enumerate(self.all_meshes):
points = vtkPoints()
n_vertex = mesh.channel.size
mesh = np.array(mesh)
Expand Down Expand Up @@ -1000,7 +1002,7 @@ def new_muscle_set(self, all_muscles):
self.muscle_actors = list()

# Create the geometry of a point (the coordinate) points = vtkPoints()
for (i, mesh) in enumerate(self.all_muscles):
for i, mesh in enumerate(self.all_muscles):
if mesh.time.size != 1:
raise IndexError("Muscles should be from one frame only")

Expand Down Expand Up @@ -1064,7 +1066,7 @@ def update_muscle(self, all_muscles):

self.all_muscles = all_muscles

for (i, mesh) in enumerate(self.all_muscles):
for i, mesh in enumerate(self.all_muscles):
points = vtkPoints()
n_vertex = mesh.channel.size
mesh = np.array(mesh)
Expand Down Expand Up @@ -1123,7 +1125,7 @@ def new_ligament_set(self, all_ligaments):
self.ligament_actors = list()

# Create the geometry of a point (the coordinate) points = vtkPoints()
for (i, mesh) in enumerate(self.all_ligaments):
for i, mesh in enumerate(self.all_ligaments):
if mesh.time.size != 1:
raise IndexError("ligaments should be from one frame only")

Expand Down Expand Up @@ -1187,7 +1189,7 @@ def update_ligament(self, all_ligaments):

self.all_ligaments = all_ligaments

for (i, mesh) in enumerate(self.all_ligaments):
for i, mesh in enumerate(self.all_ligaments):
points = vtkPoints()
n_vertex = mesh.channel.size
mesh = np.array(mesh)
Expand Down Expand Up @@ -1246,7 +1248,7 @@ def new_wrapping_set(self, all_wrappings, seg):
self.wrapping_actors[seg] = list()

# Create the geometry of a point (the coordinate) points = vtkPoints()
for (i, wrapping) in enumerate(self.all_wrappings[seg]):
for i, wrapping in enumerate(self.all_wrappings[seg]):
if wrapping.time.size != 1:
raise IndexError("Mesh should be from one frame only")

Expand Down Expand Up @@ -1312,7 +1314,7 @@ def update_wrapping(self, all_wrappings):

self.all_wrappings[seg] = wrappings

for (i, wrapping) in enumerate(self.all_wrappings[seg]):
for i, wrapping in enumerate(self.all_wrappings[seg]):
points = vtkPoints()
n_vertex = wrapping.channel.size
wrapping = np.array(wrapping)
Expand Down
1 change: 0 additions & 1 deletion tests/test_Gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def get_test_folder():


def test_model_load():

model_path = f"{get_test_folder()}/../examples/pyomecaman.bioMod"

# From path
Expand Down

0 comments on commit b074abe

Please sign in to comment.