src/gsim/se_lct_tests.cpp
// This method is the one called for clearance tests during the entrance tests (arrival or departure).
// The method has worked well in all tests performed so far, but it can probably be better optimized
// and understood.
// Note: there is no particular reason for the parameters in double - they could be converted to GsVecs
This method is the one called for clearance tests during the entrance tests (arrival or departure).
The method has worked well in all tests performed so far, but it can probably be better optimized
and understood.
Note: there is no particular reason for the parameters in double - they could be converted to GsVecs
This method is the one called for clearance tests during the entrance tests ( arrival or departure ) . The method has worked well in all tests performed so far but it can probably be better optimized and understood . Note : there is no particular reason for the parameters in double - they could be converted to GsVecs
bool SeLct::_entsector_clear ( const Sector& sc, SeBase* s, 
                               double x1, double y1, double x2, double y2, SeVertex* v )
 {
   double x3, y3, t;
   if ( v!=s->vtx() && v!=s->nxt()->vtx() )
    {
      if ( gs_point_segment_dist2(sc.cx,sc.cy,x1,y1,x2,y2,t)>=sc.r2 ) return true; 
      if ( _man->is_constrained(s->edg()) ) 
       { 
         GS_CLIP(t,0.0,1.0);
         x3 = x1*(1.0-t)+x2*t;
         y3 = y1*(1.0-t)+y2*t;
         bool insideb = gs_ccw(sc.cx,sc.cy,x3,y3,sc.bx,sc.by)>0? true:false; 
         bool insidea = gs_ccw(sc.cx,sc.cy,sc.ax,sc.ay,x3,y3)>0? true:false; 
         if ( insideb && insidea ) return false; 
         if ( !insideb )
          { if ( !gs_segment_line_intersect ( x1,y1,x2,y2,sc.cx,sc.cy,sc.bx,sc.by,x3,y3 ) ) return true; 
            if ( gs_dist2(sc.bx,sc.by,x3,y3)<=_epsilon2 ) return true; 
          }
         else 
          { if ( !gs_segment_line_intersect ( x1,y1,x2,y2,sc.cx,sc.cy,sc.ax,sc.ay,x3,y3 ) ) return true; 
            if ( gs_dist2(sc.ax,sc.ay,x3,y3)<=_epsilon2 ) return true; 
          }
         if ( gs_dist2(sc.cx,sc.cy,x3,y3)<sc.r2 ) return false; 
         return true;  in respect to sector
       }
    }
   s=s->ret();
   _man->get_vertex_coordinates ( s->nvtx(), x3, y3 );
   if ( gs_ccw(sc.cx,sc.cy,x3,y3,sc.bx,sc.by)>0 ) 
    { 
      if ( !_entsector_clear(sc,s->nxt(),x3,y3,x2,y2,v) ) return false;
    }
   if ( gs_ccw(sc.cx,sc.cy,sc.ax,sc.ay,x3,y3)>0 ) 
    { 
      if ( !_entsector_clear(sc,s,x1,y1,x3,y3,v) ) return false;
    }
   return true;
 }
bool SeLct :: _entsector_clear ( const Sector & sc , SeBase * s , double x1 , double y1 , double x2 , double y2 , SeVertex * v ) { double x3 , y3 , t ; if ( v != s -> vtx ( ) && v != s -> nxt ( ) -> vtx ( ) ) { if ( gs_point_segment_dist2 ( sc . cx , sc . cy , x1 , y1 , x2 , y2 , t ) >= sc . r2 ) return true ; if ( _man -> is_constrained ( s -> edg ( ) ) ) { GS_CLIP ( t , 0.0 , 1.0 ) ; x3 = x1 * ( 1.0 - t ) + x2 * t ; y3 = y1 * ( 1.0 - t ) + y2 * t ; bool insideb = gs_ccw ( sc . cx , sc . cy , x3 , y3 , sc . bx , sc . by ) > 0 ? true : false ; bool insidea = gs_ccw ( sc . cx , sc . cy , sc . ax , sc . ay , x3 , y3 ) > 0 ? true : false ; if ( insideb && insidea ) return false ; if ( ! insideb ) { if ( ! gs_segment_line_intersect ( x1 , y1 , x2 , y2 , sc . cx , sc . cy , sc . bx , sc . by , x3 , y3 ) ) return true ; if ( gs_dist2 ( sc . bx , sc . by , x3 , y3 ) <= _epsilon2 ) return true ; } else { if ( ! gs_segment_line_intersect ( x1 , y1 , x2 , y2 , sc . cx , sc . cy , sc . ax , sc . ay , x3 , y3 ) ) return true ; if ( gs_dist2 ( sc . ax , sc . ay , x3 , y3 ) <= _epsilon2 ) return true ; } if ( gs_dist2 ( sc . cx , sc . cy , x3 , y3 ) < sc . r2 ) return false ; return true ; } } s = s -> ret ( ) ; _man -> get_vertex_coordinates ( s -> nvtx ( ) , x3 , y3 ) ; if ( gs_ccw ( sc . cx , sc . cy , x3 , y3 , sc . bx , sc . by ) > 0 ) { if ( ! _entsector_clear ( sc , s -> nxt ( ) , x3 , y3 , x2 , y2 , v ) ) return false ; } if ( gs_ccw ( sc . cx , sc . cy , sc . ax , sc . ay , x3 , y3 ) > 0 ) { if ( ! _entsector_clear ( sc , s , x1 , y1 , x3 , y3 , v ) ) return false ; } return true ; }
This method is the one called for clearance tests during the entrance tests (arrival or departure).
This method is the one called for clearance tests during the entrance tests ( arrival or departure ) .
// entrance vertices are not to be confused with disturbances: // check if the current edge is "far enought": // passable // test if the sector is trying to cross an obstacle: //c-p3-b //c-a-p3 // closest point is inside sector, thus not passable // no need so far for testing endpoint cases here, not even entrance vertex endpoints. // protection case // incident point not inside // if ( !insidea ) // protection case // incident point not inside // not passable // passable in respect to sector //recurse: // c-p3-b // c-a-p3