| 2801 | if( (-EPS < t) && (t < 1+EPS) ) |
| 2802 | return i; |
| 2803 | } |
| 2804 | } |
| 2805 | |
| 2806 | return -1; |
| 2807 | } |
| 2808 | |
| 2809 | void splitByBorder( std::vector< std::vector<double> > &partition_x, std::vector< std::vector<double> > &partition_y, |
| 2810 | const std::vector< std::vector<double> > &cxs, const std::vector< std::vector<double> > &cys ) |
| 2811 | { |
| 2812 | assert( partition_x.size() == partition_y.size() ); |
| 2813 | assert( cxs.size() == cys.size() ); |
| 2814 | |
| 2815 | for(size_t i = 0; i < cxs.size(); i++){ |
| 2816 | |
| 2817 | std::vector<double> cx = cxs[i]; |
| 2818 | std::vector<double> cy = cys[i]; |
| 2819 | |
| 2820 | assert( cx.size() == cy.size() ); |
| 2821 | |
| 2822 | const double &beg_x = cx[0]; |
| 2823 | const double &beg_y = cy[0]; |
| 2824 | |
| 2825 | const double &end_x = cx.back(); // cx[ cx.size()-1 ] |
| 2826 | const double &end_y = cy.back(); // cy[ cy.size()-1 ] |
| 2827 | |
| 2828 | for(size_t j = 0; j < partition_x.size(); j++){ |
| 2829 | |
| 2830 | const std::vector<double> &px = partition_x[j]; |
| 2831 | const std::vector<double> &py = partition_y[j]; |
| 2832 | |
| 2833 | assert( px.size() == py.size() ); |
| 2834 | |
| 2835 | int beg_id = findSegment( beg_x, beg_y, px, py ); |
| 2836 | |
| 2837 | if( beg_id < 0 ) continue; |
| 2838 | |
| 2839 | int end_id = findSegment( end_x, end_y, px, py ); |
| 2840 | |
| 2841 | if( end_id < 0 ) continue; |
| 2842 | |
| 2843 | // findSegment returns 3n ( multiple of 3 ) |
| 2844 | |
| 2845 | if( end_id < beg_id ){ |
| 2846 | int tmp_id = beg_id; |
| 2847 | beg_id = end_id; |
| 2848 | end_id = tmp_id; |
| 2849 | std::reverse(cx.begin(), cx.end()); |
| 2850 | std::reverse(cy.begin(), cy.end()); |
| 2851 | } |
| 2852 | |
| 2853 | if( beg_id == end_id ){ |
| 2854 | |
| 2855 | if( (px[beg_id]-beg_x)*(px[beg_id]-beg_x) + (py[beg_id]-beg_y)*(py[beg_id]-beg_y) |
| 2856 | > (px[beg_id]-end_x)*(px[beg_id]-end_x) + (py[beg_id]-end_y)*(py[beg_id]-end_y) ){ |
| 2857 | |
| 2858 | std::reverse(cx.begin(), cx.end()); |
| 2859 | std::reverse(cy.begin(), cy.end()); |
| 2860 | } |
no test coverage detected