| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,7 +141,7 @@ def test_fft_peaks(): | |||
| 141 | 141 | ||
| 142 | 142 | print len(simplified) | |
| 143 | 143 | ||
| 144 | - assert len(simplified) == 17 | ||
| 144 | + assert len(simplified) == 20 | ||
| 145 | 145 | ||
| 146 | 146 | def test_start_with_moveto(): | |
| 147 | 147 | # Should be entirely clipped away to a single MOVETO | |
@@ -212,8 +212,8 @@ def test_clipper(): | |||
| 212 | 212 | ||
| 213 | 213 | @image_comparison(baseline_images=['para_equal_perp']) | |
| 214 | 214 | def test_para_equal_perp(): | |
| 215 | - x = np.array([0, 1, 2, 1, 0, -1, 0, 1]) | ||
| 216 | - y = np.array([1, 1, 2, 1, 0, -1, 0, 0]) | ||
| 215 | + x = np.array([0, 1, 2, 1, 0, -1, 0, 1] + [1] * 128) | ||
| 216 | + y = np.array([1, 1, 2, 1, 0, -1, 0, 0] + [0] * 128) | ||
| 217 | 217 | ||
| 218 | 218 | fig = plt.figure() | |
| 219 | 219 | ax = fig.add_subplot(111) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -520,7 +520,7 @@ class PathSimplifier : protected EmbeddedQueue<9> | |||
| 520 | 520 | m_moveto(true), m_after_moveto(false), | |
| 521 | 521 | m_lastx(0.0), m_lasty(0.0), m_clipped(false), | |
| 522 | 522 | m_origdx(0.0), m_origdy(0.0), | |
| 523 | - m_origdNorm2(0.0), m_dnorm2Max(0.0), m_dnorm2Min(0.0), | ||
| 523 | + m_origdNorm2(0.0), m_dnorm2Max(0.0), | ||
| 524 | 524 | m_lastMax(false), m_nextX(0.0), m_nextY(0.0), | |
| 525 | 525 | m_lastWrittenX(0.0), m_lastWrittenY(0.0) | |
| 526 | 526 | { | |
@@ -637,7 +637,6 @@ class PathSimplifier : protected EmbeddedQueue<9> | |||
| 637 | 637 | ||
| 638 | 638 | //set all the variables to reflect this new orig vector | |
| 639 | 639 | m_dnorm2Max = m_origdNorm2; | |
| 640 | - m_dnorm2Min = 0.0; | ||
| 641 | 640 | m_lastMax = true; | |
| 642 | 641 | ||
| 643 | 642 | m_nextX = m_lastWrittenX = m_lastx = *x; | |
@@ -677,36 +676,25 @@ class PathSimplifier : protected EmbeddedQueue<9> | |||
| 677 | 676 | /* check if the current vector is parallel or | |
| 678 | 677 | anti-parallel to the orig vector. If it is | |
| 679 | 678 | parallel, test if it is the longest of the vectors | |
| 680 | - we are merging in that direction. If anti-p, test | ||
| 681 | - if it is the longest in the opposite direction (the | ||
| 682 | - min of our final line) */ | ||
| 679 | + we are merging in that direction. */ | ||
| 683 | 680 | double paradNorm2 = paradx * paradx + parady * parady; | |
| 684 | 681 | ||
| 685 | - if (perpdNorm2 == paradNorm2) { | ||
| 682 | + m_lastMax = false; | ||
| 683 | + if (totdot > 0.0) | ||
| 684 | + { | ||
| 685 | + if (paradNorm2 > m_dnorm2Max) | ||
| 686 | + { | ||
| 687 | + m_lastMax = true; | ||
| 688 | + m_dnorm2Max = paradNorm2; | ||
| 689 | + m_nextX = *x; | ||
| 690 | + m_nextY = *y; | ||
| 691 | + } | ||
| 692 | + } | ||
| 693 | + else | ||
| 694 | + { | ||
| 686 | 695 | _push(&m_lastx, &m_lasty); | |
| 687 | 696 | _push(x, y); | |
| 688 | 697 | break; | |
| 689 | - } else { | ||
| 690 | - m_lastMax = false; | ||
| 691 | - if (totdot >= 0.0) | ||
| 692 | - { | ||
| 693 | - if (paradNorm2 > m_dnorm2Max) | ||
| 694 | - { | ||
| 695 | - m_lastMax = true; | ||
| 696 | - m_dnorm2Max = paradNorm2; | ||
| 697 | - m_nextX = *x; | ||
| 698 | - m_nextY = *y; | ||
| 699 | - } | ||
| 700 | - } | ||
| 701 | - else | ||
| 702 | - { | ||
| 703 | - if (paradNorm2 < m_dnorm2Min) | ||
| 704 | - { | ||
| 705 | - m_dnorm2Min = paradNorm2; | ||
| 706 | - m_nextX = *x; | ||
| 707 | - m_nextY = *y; | ||
| 708 | - } | ||
| 709 | - } | ||
| 710 | 698 | } | |
| 711 | 699 | ||
| 712 | 700 | m_lastx = *x; | |
@@ -770,7 +758,6 @@ class PathSimplifier : protected EmbeddedQueue<9> | |||
| 770 | 758 | double m_origdy; | |
| 771 | 759 | double m_origdNorm2; | |
| 772 | 760 | double m_dnorm2Max; | |
| 773 | - double m_dnorm2Min; | ||
| 774 | 761 | bool m_lastMax; | |
| 775 | 762 | double m_nextX; | |
| 776 | 763 | double m_nextY; | |
@@ -805,7 +792,6 @@ class PathSimplifier : protected EmbeddedQueue<9> | |||
| 805 | 792 | m_origdNorm2 = m_origdx * m_origdx + m_origdy * m_origdy; | |
| 806 | 793 | ||
| 807 | 794 | m_dnorm2Max = m_origdNorm2; | |
| 808 | - m_dnorm2Min = 0.0; | ||
| 809 | 795 | m_lastMax = true; | |
| 810 | 796 | m_lastWrittenX = m_queue[m_queue_write-1].x; | |
| 811 | 797 | m_lastWrittenY = m_queue[m_queue_write-1].y; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments