Parcourir la source

Fix for clockwise figure-8 loops, anticlockwise still buggy

tags/1.6.1
Trevor Irons il y a 4 ans
Parent
révision
999a700f9f
2 fichiers modifiés avec 24 ajouts et 5 suppressions
  1. 22
    3
      akvo/gui/akvoGUI.py
  2. 2
    2
      setup.py

+ 22
- 3
akvo/gui/akvoGUI.py Voir le fichier

@@ -626,25 +626,44 @@ class ApplicationWindow(QtWidgets.QMainWindow):
626 626
                                 iclosest = iseg
627 627
 
628 628
                     points = np.concatenate([points[iclosest::],points[0:iclosest]])
629
+
630
+                    # Fill first loop
629 631
                     point1 = False
630 632
                     for iseg, ipt in enumerate(points):
631 633
                         if cwise == 0:
632 634
                             self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) )
635
+                            pointlast = ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
633 636
                             if not point1:
634 637
                                 point1 = ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
635 638
                         else:
636 639
                             self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) )
637 640
                             if not point1:
638 641
                                 point1 = ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
642
+                            pointlast = ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
639 643
 
640 644
                     lenP = len(points)
641 645
 
642
-                    # fill 
646
+                    # reorder points again to find nearest point in second loop
647
+                    closest = 99999
648
+                    iclosest = -1 
649
+                    for iseg, ipt in enumerate(points):
650
+                        if cwise == 0:
651
+                            p2 = np.array([cn2-rad*np.sin(ipt), ce2+rad*np.cos(ipt)])
652
+                        else:
653
+                            p2 = np.array([cn2+rad*np.sin(ipt), ce2+rad*np.cos(ipt)])
654
+                        for p1 in ptsL:
655
+                            dist = np.linalg.norm(np.array(pointlast[0:2])-p2)
656
+                            if dist < closest:
657
+                                closest = dist
658
+                                iclosest = iseg
659
+                    points = np.concatenate([points[iclosest::],points[0:iclosest]])
660
+
661
+                    # fill second loop
643 662
                     for iseg, ipt in enumerate(points):
644 663
                         if cwise == 0:
645
-                            self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg, ( cn2-rad*np.cos(ipt), ce2-rad*np.sin(ipt), ht) )
664
+                            self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg, ( cn2-rad*np.sin(ipt), ce2+rad*np.cos(ipt), ht) )
646 665
                         else:
647
-                            self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg, ( cn2+rad*np.cos(ipt), ce2+rad*np.sin(ipt), ht) )
666
+                            self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg, ( cn2+rad*np.sin(ipt), ce2+rad*np.cos(ipt), ht) )
648 667
 
649 668
                     # close loop        
650 669
                     self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg+1, point1) 

+ 2
- 2
setup.py Voir le fichier

@@ -17,11 +17,11 @@ class custom_build_py(build_py):
17 17
         build_py.run(self)
18 18
 
19 19
 
20
-with open("../README.md", "r") as fh:
20
+with open("README.md", "r") as fh:
21 21
     long_description = fh.read()
22 22
 
23 23
 setup(name='Akvo',
24
-      version='1.5.0',
24
+      version='1.5.1',
25 25
       python_requires='>3.7.0', # due to pyLemma
26 26
       description='Surface nuclear magnetic resonance workbench',
27 27
       long_description=long_description,

Chargement…
Annuler
Enregistrer