53 lines
2.2 KiB
Python
53 lines
2.2 KiB
Python
from utils.files.parsers import parse_obj_file, parse_xyz_file
|
|
import numpy as np
|
|
|
|
def parse_result_file(file_path):
|
|
lines = []
|
|
x,y,z = [],[],[]
|
|
with open(file_path, "r") as f:
|
|
lines = f.readlines()[1:]
|
|
for line in lines:
|
|
line = line.replace(",", ".")
|
|
values = line.split("\t")
|
|
x.append(float(values[0]))
|
|
y.append(float(values[1]))
|
|
z.append(float(values[2]))
|
|
return x,y,z
|
|
|
|
def verifier_coherance():
|
|
obj = parse_obj_file("datasets/Barette/3 - BARETTE v1.obj",normalised='z')
|
|
obj.export("verification.txt")
|
|
#obj = parse_xyz_file("datasets/Barette/4 - BARETTE v1.xyz",normalised='')
|
|
cpt = 0
|
|
L = []
|
|
moyx, moyy, moyz = parse_result_file("datasets/Barette/BARETTE_Delta 1,0_analyse rayon.txt")
|
|
print(len(moyx),len(moyy),len(moyz))
|
|
moy = moyx
|
|
verticies = obj.get_vertices(sort=True)
|
|
position = 0
|
|
while position < len(verticies) and len(moy) > 0:
|
|
x = verticies[position][0]
|
|
y = verticies[position][1]
|
|
z = verticies[position][2]
|
|
L.append(x)
|
|
m = np.mean(L)
|
|
print(f"searching for {moy[0]}, currently at {position}",end="\r")
|
|
if abs(m - moy[0]) < 0.000001:
|
|
moy.pop(0)
|
|
L = []
|
|
copyposition = position
|
|
if int(verticies[copyposition][2]) >= int(verticies[copyposition+1][2]):
|
|
while int(verticies[copyposition][2]) == int(verticies[copyposition-1][2]):
|
|
copyposition -= 1
|
|
"""
|
|
if verticies[position][2] - verticies[copyposition][2] > 1:
|
|
copyposition = position + 1
|
|
break
|
|
"""
|
|
# Position +1 pour l'allignement des indices avec le numero de ligne
|
|
# Position - copyposition + 1 car on se deplace seulement si, la condition est fasse aka, on bouge pas si on est aussi de la ou on doit etre
|
|
print("index :",position,"|should have stoped :",position - copyposition + 1,"position higher| Z difference :",verticies[position][2] - verticies[copyposition-1][2])
|
|
position += 1
|
|
|
|
if __name__ == "__main__":
|
|
verifier_coherance() |