How to detect a rectangle is closed or not

what is the source data of your drawing?