svghmi/gen_index_xhtml.ysl2
branchsvghmi
changeset 2872 83adf8859c55
parent 2870 634b43d69897
child 2873 022db76c3bff
equal deleted inserted replaced
2871:ed9b16b33628 2872:83adf8859c55
    83             otherwise
    83             otherwise
    84                 result "$descend";
    84                 result "$descend";
    85         }
    85         }
    86     }
    86     }
    87 
    87 
    88     def "func:intersect_1d" {
    88     include bbox_intersect.ysl2
    89         // it is assumed that a1 > a0 and b1 > b0
       
    90         param "a0";
       
    91         param "a1";
       
    92         param "b0";
       
    93         param "b1";
       
    94 
       
    95         const "d0", "$a0 >= $b0";
       
    96         const "d1", "$a1 >= $b1";
       
    97         choose {
       
    98             when "not($d0) and $d1"
       
    99                 // b contained in a
       
   100                 //   a0<b0 b1<a1
       
   101                 // a +--------+
       
   102                 // b    +--+
       
   103                 result "3";
       
   104             when "$d0 and not($d1)"
       
   105                 // a contained in b
       
   106                 //   b0<a0 a1<b1
       
   107                 // a    +--+
       
   108                 // b +--------+
       
   109                 result "2";
       
   110             when "$d0 and $d1 and $a0 < $b1"
       
   111                 // a and b are overlapped 
       
   112                 //   b0<a0<b1<a1
       
   113                 // a    +-----+
       
   114                 // b +-----+
       
   115                 result "1";
       
   116             when "not($d0) and not($d1) and $b0 < $a1"
       
   117                 // a and b are overlapped
       
   118                 //   a0<b0<a1<b1
       
   119                 // a +-----+
       
   120                 // b    +-----+
       
   121                 result "1";
       
   122             otherwise
       
   123                 result "0"; /* no intersection*/
       
   124         }
       
   125     }
       
   126 
       
   127     // returns :
       
   128     // 0 - no intersection
       
   129     //            .-----.
       
   130     //    .-----. |    b|
       
   131     //    |     | |     |
       
   132     //    |     | '-----'
       
   133     //    |a    |
       
   134     //    '-----'
       
   135     //
       
   136     // 1 - overlapping
       
   137     //        .-----.
       
   138     //    .---|--. b|
       
   139     //    |   |  |  |
       
   140     //    |   '-----'
       
   141     //    |a     |
       
   142     //    '------'
       
   143     //
       
   144     // 2 - overlapping
       
   145     //        .-----.
       
   146     //        |  a  |
       
   147     //    .---|-----|---.
       
   148     //    |   '-----'   |
       
   149     //    | b           |
       
   150     //    '-------------'
       
   151     //
       
   152     // 3 - overlapping
       
   153     //        .-----.
       
   154     //        |  b  |
       
   155     //    .---|-----|---.
       
   156     //    |   '-----'   |
       
   157     //    | a           |
       
   158     //    '-------------'
       
   159     //
       
   160     // 4 - a contained in b
       
   161     //    .-------------.
       
   162     //    |   .-----.   |
       
   163     //    |   |  a  |   |
       
   164     //    |b  '-----'   |
       
   165     //    '-------------'
       
   166     //
       
   167     // 6 - overlapping
       
   168     //        .----.
       
   169     //        |   b|
       
   170     //    .---|----|---.
       
   171     //    |a  |    |   |
       
   172     //    '---|----|---'
       
   173     //        '----'
       
   174     //
       
   175     // 9 - b contained in a
       
   176     //    .-------------.
       
   177     //    |   .-----.   |
       
   178     //    |   |  b  |   |
       
   179     //    |a  '-----'   |
       
   180     //    '-------------'
       
   181     //
       
   182     def "func:intersect" {
       
   183         param "a";
       
   184         param "b";
       
   185 
       
   186         const "x_intersect", "func:intersect_1d($a/@x, $a/@x+$a/@w, $b/@x, $b/@x+$b/@w)";
       
   187 
       
   188         choose{
       
   189             when "$x_intersect != 0"{
       
   190                 const "y_intersect", "func:intersect_1d($a/@y, $a/@y+$a/@h, $b/@y, $b/@y+$b/@h)";
       
   191                 result "$x_intersect * $y_intersect";
       
   192             }
       
   193             otherwise result "0";
       
   194         }
       
   195     }
       
   196 
    89 
   197     // return overlapping geometry for a given element
    90     // return overlapping geometry for a given element
   198     // all intersercting element are returned
    91     // all intersercting element are returned
   199     // except groups, that must be contained to be counted in
    92     // except groups, that must be contained to be counted in
   200     def "func:overlapping_geometry" {
    93     def "func:overlapping_geometry" {