From 0258787636c8679d27e84b7e7d2facee87bb5341 Mon Sep 17 00:00:00 2001 From: pariterre Date: Sun, 3 May 2020 19:42:01 -0400 Subject: [PATCH] Updated for 1.2.5 API --- BiorbdViz/__init__.py | 4 ++-- BiorbdViz/analyses.py | 14 +++++++------- BiorbdViz/biorbd_vtk.py | 34 +++++++++++++++++----------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/BiorbdViz/__init__.py b/BiorbdViz/__init__.py index 7737b7c..06a8585 100644 --- a/BiorbdViz/__init__.py +++ b/BiorbdViz/__init__.py @@ -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 @@ -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) diff --git a/BiorbdViz/analyses.py b/BiorbdViz/analyses.py index e608c92..872b529 100644 --- a/BiorbdViz/analyses.py +++ b/BiorbdViz/analyses.py @@ -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 @@ -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) @@ -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]) diff --git a/BiorbdViz/biorbd_vtk.py b/BiorbdViz/biorbd_vtk.py index e6a1c5b..ca7d358 100644 --- a/BiorbdViz/biorbd_vtk.py +++ b/BiorbdViz/biorbd_vtk.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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): @@ -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)): @@ -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): @@ -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 @@ -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 @@ -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 @@ -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