add polygon segment intersection detection code

add polygon segment intersection detection code