From 7a61f23d335884bc9a17744001670c0149f53e84 Mon Sep 17 00:00:00 2001
From: Djalim Simaila <DjalimS.pro@outlook.fr>
Date: Mon, 24 Apr 2023 09:54:28 +0200
Subject: [PATCH] Docstrings, translations and other metadata fixes

---
 main.py                             | 12 ++++++------
 utils/files/input.py                | 11 +++++++++--
 utils/graph2D/mpl_render.py         |  9 +++++----
 utils/graph2D/visplot_render.py     | 13 +++++++++++--
 utils/graph3D/mpl_render.py         |  4 ++--
 utils/graph3D/visplot_render.py     |  4 ++++
 utils/math/position_manipulation.py | 14 +++++++++++---
 7 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/main.py b/main.py
index f2b288a..68097d3 100644
--- a/main.py
+++ b/main.py
@@ -20,10 +20,10 @@ def get_raw_data(obj:ScannedObject, ndigits:int, delta_z:int = 1)->dict:
         - Xi-Xmoy       : list of Xi-Xmoy values
         - Yi-Ymoy       : list of Yi-Ymoy values
     """
-    colones = ["X (en mm)", "Y (en mm)", "Z (en mm)", "teta (en rad)", "rayon (en mm)","Xi-Xmoy","Yi-Ymoy"]
+    columns = ["X (en mm)", "Y (en mm)", "Z (en mm)", "teta (en rad)", "rayon (en mm)","Xi-Xmoy","Yi-Ymoy"]
     data = {}
-    for colone in colones:
-        data[colone] = []
+    for column in columns:
+        data[column] = []
     for discrete_values in obj.get_discrete_vertices(delta_z):
         mean_x ,mean_y, mean_z = data_extraction.get_x_y_z_mean(discrete_values)
         for x,y,z in discrete_values:
@@ -49,10 +49,10 @@ def get_discrete_data(obj:ScannedObject, ndigits:int,delta_z:int= 1)->dict:
         - Rayon moyen (en mm)       : list of mean radius values
         - Rayon ecart type (en mm)  : list of radius standard deviation values
     """
-    colones = ["X moy (en mm)", "Y moy (en mm)", "Z moy (en mm)","Delta z(en mm)","Rayon moyen (en mm)","Rayon ecart type (en mm)"]
+    columns = ["X moy (en mm)", "Y moy (en mm)", "Z moy (en mm)","Delta z(en mm)","Rayon moyen (en mm)","Rayon ecart type (en mm)"]
     data = {}
-    for colone in colones:
-        data[colone] = []
+    for column in columns:
+        data[column] = []
     for discrete_values in obj.get_discrete_vertices(delta_z):
         x,y,z = data_extraction.get_x_y_z_mean(discrete_values)
         data["X moy (en mm)"].append(round(x, ndigits))
diff --git a/utils/files/input.py b/utils/files/input.py
index 94412c8..bc6fd24 100644
--- a/utils/files/input.py
+++ b/utils/files/input.py
@@ -19,9 +19,16 @@ class ScannedObject:
     """
     This class is used to manage the data of the 3D object.
 
-    :param vertices: List of vertices
-    :param faces: List of faces
+    :param vertices: List of verticesm Ndarray of shape (n,2)
+    :param faces: List of faces, Ndarray of shape (n,2)
     :param result_file_path: Path to the result file (deprecated, used for the bruteforce discretization)
+    
+    :ivar vertices: List of vertices, Ndarray of shape (n,2)
+    :ivar faces: List of faces, Ndarray of shape (n,2)
+    :ivar result_file_path: Path to the result file (deprecated, used for the bruteforce discretization)
+    :ivar x: List of x values of the vertices
+    :ivar y: List of y values of the vertices
+    :ivar z: List of z values of the vertices
 
     :static method from_xyz_file(): Creates a ScannedObject from a .xyz file
     :static method from_obj_file(): Creates a ScannedObject from a .obj file
diff --git a/utils/graph2D/mpl_render.py b/utils/graph2D/mpl_render.py
index dd6450f..9f78215 100644
--- a/utils/graph2D/mpl_render.py
+++ b/utils/graph2D/mpl_render.py
@@ -10,12 +10,13 @@ def render2D(values:list):
     ax.plot(values)
     plt.show()
 
-def cross_section(x:list,y:list):
+def cross_section(x_values:list, y_values:list):
     """
-    Render a 2D model using matplotlib
-    :param values: A list with the values
+    Render a 2D cross section using matplotlib
+    :param x: A list with the x values
+    :param y: A list with the y values
     """
     fig = plt.figure()
     ax = fig.add_subplot()
-    ax.scatter(x,y)
+    ax.scatter(x_values,y_values)
     plt.show()
\ No newline at end of file
diff --git a/utils/graph2D/visplot_render.py b/utils/graph2D/visplot_render.py
index 81e2c22..31925ab 100644
--- a/utils/graph2D/visplot_render.py
+++ b/utils/graph2D/visplot_render.py
@@ -2,6 +2,10 @@ import vispy.plot as vp
 import numpy as np
 
 def render2D(values:list):
+    """
+    Render a 2D plot using vispy
+    :param values: A list with the values
+    """
     fig = vp.Fig(size=(600, 500), show=False)
     plotwidget = fig[0, 0]
     fig.title = "bollu"
@@ -9,10 +13,15 @@ def render2D(values:list):
     plotwidget.colorbar(position="top", cmap="autumn")
     fig.show(run=True)
 
-def cross_section(x:list,y:list):
+def cross_section(x_values:list, y_values:list):
+    """
+    Render a 2D cross section using vispy
+    :param x: A list with the x values
+    :param y: A list with the y values
+    """
     color = (0.3, 0.5, 0.8)
     fig = vp.Fig(show=False)
-    line = fig[0:4, 0:4].plot(np.column_stack((x,y)), symbol='o', width=0,
+    line = fig[0:4, 0:4].plot(np.column_stack((x_values,y_values)), symbol='o', width=0,
                             face_color=color + (0.02,), edge_color=None,
                             marker_size=8)
     line.set_gl_state(depth_test=False)
diff --git a/utils/graph3D/mpl_render.py b/utils/graph3D/mpl_render.py
index c4757fe..1e2e32f 100644
--- a/utils/graph3D/mpl_render.py
+++ b/utils/graph3D/mpl_render.py
@@ -5,8 +5,8 @@ from utils.files.input import ScannedObject
 
 def render3D(obj:ScannedObject):
     """
-    Render a 3D model using matplotlib poly3dcollection
-    :param data: A dict with the vertices and faces
+    Render a 3D model using matplotlib's Poly3dcollection
+    :param obj: A ScannedObject to be rendered
     """
     fig = plt.figure()
     ax = fig.add_subplot(projection='3d')
diff --git a/utils/graph3D/visplot_render.py b/utils/graph3D/visplot_render.py
index 9392ee9..2dccf7f 100644
--- a/utils/graph3D/visplot_render.py
+++ b/utils/graph3D/visplot_render.py
@@ -6,6 +6,10 @@ from utils.files.input import ScannedObject
 
 
 def render3D(obj:ScannedObject):
+    """
+    Render a 3D model using vispy
+    :param obj: A ScannedObject to be rendered
+    """
     vertices = np.asarray(obj.get_vertices())
     faces = np.asarray(obj.get_faces())
     canvas = scene.SceneCanvas(keys='interactive', bgcolor='white')
diff --git a/utils/math/position_manipulation.py b/utils/math/position_manipulation.py
index 53af77c..94055f3 100644
--- a/utils/math/position_manipulation.py
+++ b/utils/math/position_manipulation.py
@@ -3,15 +3,19 @@ from utils.files.input import ScannedObject
 from utils.math.data_extraction import get_mean
 
 
-def get_mass_properties(obj:ScannedObject):
+def get_mass_properties(obj:ScannedObject)->tuple:
     '''
     Evaluate and return a tuple with the following elements:
         - the volume
         - the position of the center of gravity (COG)
         - the inertia matrix expressed at the COG
+    :param obj: Object to analyse
+    :return: tuple(float, numpy.array, numpy.array)
+
+    From numpy-stl:(https://pypi.org/project/numpy-stl/)
+        Documentation can be found here:
+        http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf
 
-    Documentation can be found here:
-    http://www.geometrictools.com/Documentation/PolyhedralMassProperties.pdf
     '''
 
     verts = np.asarray(obj.get_vertices())
@@ -66,6 +70,10 @@ def get_mass_properties(obj:ScannedObject):
     return volume, cog, inertia
 
 def verticalise(obj:ScannedObject):
+    """
+    Rotate the object so that the principal axis of inertia is vertical
+    :param obj: Object to analyse
+    """
     cog = get_mass_properties(obj)
     cog, inertia = get_mass_properties(obj)[1:]
     [val,vect] = np.linalg.eig(inertia)
-- 
GitLab