diff --git a/PyNutil/read_and_write.py b/PyNutil/read_and_write.py index 92c59656baef4c652c2e4f88a2553ac3f72de5aa..a2abf1274769b32dad7f231273479936159e328e 100644 --- a/PyNutil/read_and_write.py +++ b/PyNutil/read_and_write.py @@ -32,8 +32,15 @@ def load_visualign_json(filename): # save with .json extension need to see if i can remove this with open(filename.replace(".waln", ".json").replace(".wwrp", ".json"), "w") as f: json.dump(lz_compat_file, f, indent=4) + for slice in slices: + if "markers" in slice: + slice["markers"] = [ + [marker["x"], marker["y"], marker["nx"], marker["ny"] + ] for marker in slice["markers"] + ] else: slices = vafile["slices"] + slices = propagate(slices) return slices diff --git a/PyNutil/visualign_deformations.py b/PyNutil/visualign_deformations.py index 72086233a0ca7ccdd47d8f6ff96fcfdeb5361e82..16973f18b9df542438c710ceb2dbb0fceedbc9dd 100644 --- a/PyNutil/visualign_deformations.py +++ b/PyNutil/visualign_deformations.py @@ -1,7 +1,6 @@ """This code was written by Gergely Csucs and Rembrandt Bakker""" - import numpy as np - +from scipy.spatial import Delaunay def triangulate(w, h, markers): vertices = [ @@ -10,6 +9,7 @@ def triangulate(w, h, markers): [-0.1 * w, 1.1 * h, -0.1 * w, 1.1 * h], [ 1.1 * w, 1.1 * h, 1.1 * w, 1.1 * h], ] + edges = [0] * ((len(markers) + 4) * (len(markers) + 4 - 1) // 2) triangles = [Triangle(0, 1, 2, vertices, edges), Triangle(1, 2, 3, vertices, edges)] edges[0] = edges[1] = edges[4] = edges[5] = 2 @@ -233,3 +233,22 @@ class Triangle: + (self.B[1] - self.A[1]) * uv1[ok, 0] + (self.C[1] - self.A[1]) * uv1[ok, 1] ) + + +##below this is a test + + +vertices = [[0, 0,43.54623148539514, 26.174656909777603], + [0, 0,90.8065913697207, 46.20231798893295], + [0, 0,56.29635559428633, 51.23696264352707], + [0, 0,90.87928419178107, 15.497996125973435], + [0, 0,33.966820908745454, 11.999395004637503], + [0, 0,37.29543353675751, 79.4420010252766]] +triangulation = triangulate(100,100,vertices) +new_coords = transform(triangulation, new_coords[0], new_coords[1]) + + +from scipy.spatial import Delaunay + +# assuming you have a list of points called "points" +tri = Delaunay(points)