Browse Source

Fix for clockwise figure-8 loops, anticlockwise still buggy

tags/1.6.1
Trevor Irons 3 years ago
parent
commit
999a700f9f
2 changed files with 24 additions and 5 deletions
  1. 22
    3
      akvo/gui/akvoGUI.py
  2. 2
    2
      setup.py

+ 22
- 3
akvo/gui/akvoGUI.py View File

626
                                 iclosest = iseg
626
                                 iclosest = iseg
627
 
627
 
628
                     points = np.concatenate([points[iclosest::],points[0:iclosest]])
628
                     points = np.concatenate([points[iclosest::],points[0:iclosest]])
629
+
630
+                    # Fill first loop
629
                     point1 = False
631
                     point1 = False
630
                     for iseg, ipt in enumerate(points):
632
                     for iseg, ipt in enumerate(points):
631
                         if cwise == 0:
633
                         if cwise == 0:
632
                             self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) )
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
                             if not point1:
636
                             if not point1:
634
                                 point1 = ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
637
                                 point1 = ( cn1+rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
635
                         else:
638
                         else:
636
                             self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) )
639
                             self.loops[self.ui.loopLabel.text()].SetPoint(iseg, ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) )
637
                             if not point1:
640
                             if not point1:
638
                                 point1 = ( cn1-rad*np.sin(ipt), ce1+rad*np.cos(ipt), ht) 
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
                     lenP = len(points)
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
                     for iseg, ipt in enumerate(points):
662
                     for iseg, ipt in enumerate(points):
644
                         if cwise == 0:
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
                         else:
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
                     # close loop        
668
                     # close loop        
650
                     self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg+1, point1) 
669
                     self.loops[self.ui.loopLabel.text()].SetPoint(lenP+iseg+1, point1) 

+ 2
- 2
setup.py View File

17
         build_py.run(self)
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
     long_description = fh.read()
21
     long_description = fh.read()
22
 
22
 
23
 setup(name='Akvo',
23
 setup(name='Akvo',
24
-      version='1.5.0',
24
+      version='1.5.1',
25
       python_requires='>3.7.0', # due to pyLemma
25
       python_requires='>3.7.0', # due to pyLemma
26
       description='Surface nuclear magnetic resonance workbench',
26
       description='Surface nuclear magnetic resonance workbench',
27
       long_description=long_description,
27
       long_description=long_description,

Loading…
Cancel
Save