@@ -2617,6 +2617,62 @@ void Geocode<T>::_runBlock(
2617
2617
isce3::geometry::areaProjIntegrateSegment (y10_cut, y00_cut, x10_cut,
2618
2618
x00_cut, size_y, size_x, w_arr, w_total, plane_orientation);
2619
2619
2620
+ bool flag_self_intersecting_area_element = false ;
2621
+
2622
+ // test for self-intersection
2623
+ for (int yy = 0 ; yy < size_y; ++yy) {
2624
+ for (int xx = 0 ; xx < size_x; ++xx) {
2625
+ double w = w_arr (yy, xx);
2626
+ if (w * w_total < 0 && abs (w) > 0.00001 ) {
2627
+ flag_self_intersecting_area_element = true ;
2628
+ break ;
2629
+ }
2630
+ }
2631
+ if (flag_self_intersecting_area_element) {
2632
+ break ;
2633
+ }
2634
+ }
2635
+
2636
+ if (flag_self_intersecting_area_element) {
2637
+ /*
2638
+ If self-intersecting, divide area element (geogrid pixel) into
2639
+ two triangles and integrate them separately.
2640
+ */
2641
+ isce3::core::Matrix<double > w_arr_1 (size_y, size_x);
2642
+ w_arr_1.fill (0 );
2643
+ double w_total_1 = 0 ;
2644
+ isce3::geometry::areaProjIntegrateSegment (y00_cut, y01_cut, x00_cut,
2645
+ x01_cut, size_y, size_x, w_arr_1, w_total_1, plane_orientation);
2646
+ isce3::geometry::areaProjIntegrateSegment (y01_cut, y11_cut, x01_cut,
2647
+ x11_cut, size_y, size_x, w_arr_1, w_total_1, plane_orientation);
2648
+ isce3::geometry::areaProjIntegrateSegment (y11_cut, y00_cut, x11_cut,
2649
+ x00_cut, size_y, size_x, w_arr_1, w_total_1, plane_orientation);
2650
+
2651
+ isce3::core::Matrix<double > w_arr_2 (size_y, size_x);
2652
+ w_arr_2.fill (0 );
2653
+ double w_total_2 = 0 ;
2654
+ isce3::geometry::areaProjIntegrateSegment (y00_cut, y11_cut, x00_cut,
2655
+ x11_cut, size_y, size_x, w_arr_2, w_total_2, plane_orientation);
2656
+ isce3::geometry::areaProjIntegrateSegment (y11_cut, y10_cut, x11_cut,
2657
+ x10_cut, size_y, size_x, w_arr_2, w_total_2, plane_orientation);
2658
+ isce3::geometry::areaProjIntegrateSegment (y10_cut, y00_cut, x10_cut,
2659
+ x00_cut, size_y, size_x, w_arr_2, w_total_2, plane_orientation);
2660
+
2661
+ w_total = 0 ;
2662
+ /*
2663
+ The new weight array `w_arr` is the sum of the absolute values of both
2664
+ triangles weighted arrays `w_arr_1` and `w_arr_2`. The integrated
2665
+ total `w_total` is updated accordingly.
2666
+ */
2667
+ for (int yy = 0 ; yy < size_y; ++yy) {
2668
+ for (int xx = 0 ; xx < size_x; ++xx) {
2669
+ w_arr (yy, xx) = std::min (
2670
+ abs (w_arr_1 (yy, xx)) + abs (w_arr_2 (yy, xx)), 1.0 );
2671
+ w_total += w_arr (yy, xx);
2672
+ }
2673
+ }
2674
+ }
2675
+
2620
2676
double nlooks = 0 ;
2621
2677
float area_total = 0 ;
2622
2678
std::vector<T_out> cumulative_sum (nbands, 0 );
@@ -2630,7 +2686,7 @@ void Geocode<T>::_runBlock(
2630
2686
double w = w_arr (yy, xx);
2631
2687
int y = yy + y_min;
2632
2688
int x = xx + x_min;
2633
- if (w == 0 || w * w_total < 0 )
2689
+ if (w == 0 )
2634
2690
continue ;
2635
2691
else if (y - offset_y < 0 || x - offset_x < 0 ||
2636
2692
y >= ybound || x >= xbound) {
0 commit comments