int compareTwoSegments_ ( Segment seg_1 , Segment seg_2 ) { int res = seg_1 . _isIntersecting ( seg_2 , m_tolerance , true ) ; if ( res != 0 ) { if ( res == 2 ) return errorCoincident ( ) ; else return errorCracking ( ) ; } Point2D start_1 = seg_1 . getStartXY ( ) ; Point2D end1 = seg_1 . getEndXY ( ) ; Point2D start2 = seg_2 . getStartXY ( ) ; Point2D end2 = seg_2 . getEndXY ( ) ; Point2D ptSweep = new Point2D ( ) ; ptSweep . setCoords ( m_sweep_x , m_sweep_y ) ; if ( start_1 . isEqual ( start2 ) && m_sweep_y == start_1 . y ) { assert ( start_1 . compare ( end1 ) < 0 && start2 . compare ( end2 ) < 0 ) ; if ( end1 . compare ( end2 ) < 0 ) ptSweep . setCoords ( end1 ) ; else ptSweep . setCoords ( end2 ) ; } else if ( start_1 . isEqual ( end2 ) && m_sweep_y == start_1 . y ) { assert ( start_1 . compare ( end1 ) < 0 && start2 . compare ( end2 ) > 0 ) ; if ( end1 . compare ( start2 ) < 0 ) ptSweep . setCoords ( end1 ) ; else ptSweep . setCoords ( start2 ) ; } else if ( start2 . isEqual ( end1 ) && m_sweep_y == start2 . y ) { assert ( end1 . compare ( start_1 ) < 0 && start2 . compare ( end2 ) < 0 ) ; if ( start_1 . compare ( end2 ) < 0 ) ptSweep . setCoords ( start_1 ) ; else ptSweep . setCoords ( end2 ) ; } else if ( end1 . isEqual ( end2 ) && m_sweep_y == end1 . y ) { assert ( start_1 . compare ( end1 ) > 0 && start2 . compare ( end2 ) > 0 ) ; if ( start_1 . compare ( start2 ) < 0 ) ptSweep . setCoords ( start_1 ) ; else ptSweep . setCoords ( start2 ) ; } double xleft = seg_1 . intersectionOfYMonotonicWithAxisX ( ptSweep . y , ptSweep . x ) ; double xright = seg_2 . intersectionOfYMonotonicWithAxisX ( ptSweep . y , ptSweep . x ) ; assert ( xleft != xright ) ; return xleft < xright ? - 1 : 1 ; }
is set .