Skip to content

Commit

Permalink
Merge pull request #28 from pariterre/master
Browse files Browse the repository at this point in the history
Updated for 1.2.5 API
  • Loading branch information
pariterre authored May 4, 2020
2 parents 696ed11 + 0258787 commit 577d7e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions BiorbdViz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def __init__(self, model_path=None, loaded_model=None,
self.show_global_center_of_mass = show_global_center_of_mass
self.show_segments_center_of_mass = show_segments_center_of_mass
self.show_local_ref_frame = show_local_ref_frame
if self.model.nbMuscleTotal() > 0:
if self.model.nbMuscles() > 0:
self.show_muscles = show_muscles
else:
self.show_muscles = False
Expand Down Expand Up @@ -561,7 +561,7 @@ def add_options_panel(self):
if biorbd.currentLinearAlgebraBackend() == 1:
radio_muscle.setEnabled(False)
else:
if self.model.nbMuscleTotal() == 0:
if self.model.nbMuscles() == 0:
radio_muscle.setEnabled(False)
self.__select_analyses_panel(radio_muscle, 1)

Expand Down
14 changes: 7 additions & 7 deletions BiorbdViz/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, parent, main_window, background_color=(.5, .5, .5)):
# Get some aliases
self.main_window = main_window
self.model = self.main_window.model
self.n_mus = self.model.nbMuscleTotal()
self.n_mus = self.model.nbMuscles()
self.n_q = self.model.nbQ()

# Add dof selector
Expand Down Expand Up @@ -173,15 +173,15 @@ def __update_graph_size(self):
def __compute_all_values(self):
q_idx = self.dof_mapping[self.current_dof]
x_axis, all_q = self.__generate_x_axis(q_idx)
length = np.ndarray((self.n_point_for_q, self.model.nbMuscleTotal()))
moment_arm = np.ndarray((self.n_point_for_q, self.model.nbMuscleTotal()))
passive_forces = np.ndarray((self.n_point_for_q, self.model.nbMuscleTotal()))
active_forces = np.ndarray((self.n_point_for_q, self.model.nbMuscleTotal()))
length = np.ndarray((self.n_point_for_q, self.n_mus))
moment_arm = np.ndarray((self.n_point_for_q, self.n_mus))
passive_forces = np.ndarray((self.n_point_for_q, self.n_mus))
active_forces = np.ndarray((self.n_point_for_q, self.n_mus))
emg = biorbd.StateDynamics(0, self.active_forces_slider.value() / 100)
for i, q_mod in enumerate(all_q):
self.model.UpdateKinematicsCustom(biorbd.GeneralizedCoordinates(q_mod))
muscles_length_jacobian = self.model.musclesLengthJacobian().to_array()
for m in range(self.model.nbMuscleTotal()):
for m in range(self.n_mus):
if self.checkboxes_muscle[m].isChecked():
mus_group_idx, mus_idx, _ = self.muscle_mapping[self.checkboxes_muscle[m].text()]
mus = self.model.muscleGroup(mus_group_idx).muscle(mus_idx)
Expand All @@ -203,7 +203,7 @@ def __compute_all_values(self):
def __update_specific_plot(self, canvas, ax, x, y, skip=False):
# Plot all active muscles
number_of_active = 0
for m in range(self.model.nbMuscleTotal()):
for m in range(self.n_mus):
if self.checkboxes_muscle[m].isChecked():
if not skip:
ax.get_lines()[m].set_data(x, y[:, m])
Expand Down
34 changes: 17 additions & 17 deletions BiorbdViz/biorbd_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def new_marker_set(self, markers):
One frame of markers
"""
if markers.get_num_frames() is not 1:
if markers.get_num_frames() != 1:
raise IndexError("Markers should be from one frame only")
self.markers = markers

Expand Down Expand Up @@ -292,9 +292,9 @@ def update_markers(self, markers):
"""

if markers.get_num_frames() is not 1:
if markers.get_num_frames() != 1:
raise IndexError("Markers should be from one frame only")
if markers.get_num_markers() is not self.markers.get_num_markers():
if markers.get_num_markers() != self.markers.get_num_markers():
self.new_marker_set(markers)
return # Prevent calling update_markers recursively
self.markers = markers
Expand Down Expand Up @@ -356,7 +356,7 @@ def new_global_center_of_mass_set(self, global_center_of_mass):
One frame of segment center of mas
"""
if global_center_of_mass.get_num_frames() is not 1:
if global_center_of_mass.get_num_frames() != 1:
raise IndexError("Global center of mass should be from one frame only")
self.global_center_of_mass = global_center_of_mass

Expand Down Expand Up @@ -390,9 +390,9 @@ def update_global_center_of_mass(self, global_center_of_mass):
"""

if global_center_of_mass.get_num_frames() is not 1:
if global_center_of_mass.get_num_frames() != 1:
raise IndexError("Segment center of mass should be from one frame only")
if global_center_of_mass.get_num_markers() is not self.global_center_of_mass.get_num_markers():
if global_center_of_mass.get_num_markers() != self.global_center_of_mass.get_num_markers():
self.new_global_center_of_mass_set(global_center_of_mass)
return # Prevent calling update_center_of_mass recursively
self.global_center_of_mass = global_center_of_mass
Expand Down Expand Up @@ -453,7 +453,7 @@ def new_segments_center_of_mass_set(self, segments_center_of_mass):
One frame of segment center of mas
"""
if segments_center_of_mass.get_num_frames() is not 1:
if segments_center_of_mass.get_num_frames() != 1:
raise IndexError("Segments center of mass should be from one frame only")
self.segments_center_of_mass = segments_center_of_mass

Expand Down Expand Up @@ -487,9 +487,9 @@ def update_segments_center_of_mass(self, segments_center_of_mass):
"""

if segments_center_of_mass.get_num_frames() is not 1:
if segments_center_of_mass.get_num_frames() != 1:
raise IndexError("Segment center of mass should be from one frame only")
if segments_center_of_mass.get_num_markers() is not self.segments_center_of_mass.get_num_markers():
if segments_center_of_mass.get_num_markers() != self.segments_center_of_mass.get_num_markers():
self.new_segments_center_of_mass_set(segments_center_of_mass)
return # Prevent calling update_center_of_mass recursively
self.segments_center_of_mass = segments_center_of_mass
Expand Down Expand Up @@ -543,7 +543,7 @@ def new_mesh_set(self, all_meshes):
mesh_tp.append(all_meshes)
all_meshes = mesh_tp

if all_meshes.get_num_frames() is not 1:
if all_meshes.get_num_frames() != 1:
raise IndexError("Mesh should be from one frame only")

if not isinstance(all_meshes, MeshCollection):
Expand Down Expand Up @@ -604,7 +604,7 @@ def update_mesh(self, all_meshes):
mesh_tp.append(all_meshes)
all_meshes = mesh_tp

if all_meshes.get_num_frames() is not 1:
if all_meshes.get_num_frames() != 1:
raise IndexError("Mesh should be from one frame only")

for i in range(len(all_meshes)):
Expand Down Expand Up @@ -666,7 +666,7 @@ def new_muscle_set(self, all_muscles):
musc_tp.append(all_muscles)
all_muscles = musc_tp

if all_muscles.get_num_frames() is not 1:
if all_muscles.get_num_frames() != 1:
raise IndexError("Muscles should be from one frame only")

if not isinstance(all_muscles, MeshCollection):
Expand Down Expand Up @@ -728,13 +728,13 @@ def update_muscle(self, all_muscles):
musc_tp.append(all_muscles)
all_muscles = musc_tp

if all_muscles.get_num_frames() is not 1:
if all_muscles.get_num_frames() != 1:
raise IndexError("Muscle should be from one frame only")

for i in range(len(all_muscles)):
if (
all_muscles.get_mesh(i).get_num_vertex()
is not self.all_muscles.get_mesh(i).get_num_vertex()
!= self.all_muscles.get_mesh(i).get_num_vertex()
):
self.new_muscle_set(all_muscles)
return # Prevent calling update_markers recursively
Expand Down Expand Up @@ -777,7 +777,7 @@ def new_rt_set(self, all_rt):
self.rt_actors = list()

for i, rt in enumerate(all_rt):
if rt.get_num_frames() is not 1:
if rt.get_num_frames() != 1:
raise IndexError("RT should be from one frame only")

# Create the polyline which will hold the actors
Expand Down Expand Up @@ -853,7 +853,7 @@ def update_rt(self, all_rt):
rt_tp.append(all_rt[:, :])
all_rt = rt_tp

if all_rt.get_num_rt() is not self.n_rt:
if all_rt.get_num_rt() != self.n_rt:
self.new_rt_set(all_rt)
return # Prevent calling update_rt recursively

Expand All @@ -863,7 +863,7 @@ def update_rt(self, all_rt):
self.all_rt = all_rt

for i, rt in enumerate(self.all_rt):
if rt.get_num_frames() is not 1:
if rt.get_num_frames() != 1:
raise IndexError("RT should be from one frame only")

# Update the end points of the axes and the origin
Expand Down

0 comments on commit 577d7e6

Please sign in to comment.