void mergeEdges_ ( int edge1 , int edge2 ) { // dbg_check_edge_(edge1); int cluster_1 = getEdgeCluster ( edge1 , 0 ) ; int cluster2 = getEdgeCluster ( edge1 , 1 ) ; int cluster21 = getEdgeCluster ( edge2 , 0 ) ; int cluster22 = getEdgeCluster ( edge2 , 1 ) ; int originVertices1 = getEdgeOriginVertices ( edge1 ) ; int originVertices2 = getEdgeOriginVertices ( edge2 ) ; m_edge_vertices . concatenateLists ( originVertices1 , originVertices2 ) ; if ( edge2 == getClusterFirstEdge ( cluster_1 ) ) setClusterFirstEdge_ ( cluster_1 , edge1 ) ; if ( edge2 == getClusterFirstEdge ( cluster2 ) ) setClusterFirstEdge_ ( cluster2 , edge1 ) ; disconnectEdge_ ( edge2 ) ; // disconnects the edge2 from the clusters. deleteEdge_ ( edge2 ) ; if ( ! ( ( cluster_1 == cluster21 && cluster2 == cluster22 ) || ( cluster2 == cluster21 && cluster_1 == cluster22 ) ) ) { // Merged edges have different clusters (clusters have not yet been // merged) // merge clusters before merging the edges getClusterXY ( cluster_1 , pt_1 ) ; getClusterXY ( cluster21 , pt_2 ) ; if ( pt_1 . isEqual ( pt_2 ) ) { if ( cluster_1 != cluster21 ) { mergeClusters_ ( cluster_1 , cluster21 ) ; assert ( ! m_modified_clusters . hasElement ( cluster21 ) ) ; } if ( cluster2 != cluster22 ) { mergeClusters_ ( cluster2 , cluster22 ) ; assert ( ! m_modified_clusters . hasElement ( cluster22 ) ) ; } } else { if ( cluster2 != cluster21 ) { mergeClusters_ ( cluster2 , cluster21 ) ; assert ( ! m_modified_clusters . hasElement ( cluster21 ) ) ; } if ( cluster_1 != cluster22 ) { mergeClusters_ ( cluster_1 , cluster22 ) ; assert ( ! m_modified_clusters . hasElement ( cluster22 ) ) ; } } } else { // Merged edges have equal clusters. } // dbg_check_edge_(edge1); }
Merges two coincident edges into one . The edge2 becomes invalid .