Correct the algorithm in the function MergeEdges in ShapeUpgrade_UnifySameDomain.cxx so as to take into account the orientation of the next edge added to the chain. Test cases for issue CR27521