void splitEdge_(int edge1, int edge2, int intersectionCluster,
			SegmentIntersector intersector) {

		disconnectEdge_(edge1);// disconnects the edge from the clusters. The
								// edge still remembers the clusters.
		if (edge2 != -1)
			disconnectEdge_(edge2);// disconnects the edge from the clusters.
									// The edge still remembers the clusters.

		// Collect all edges that are affected when the clusters change position
		// due to snapping
		// The edges are collected in m_edges_to_insert_in_sweep_structure.
		// Collect the modified clusters in m_modified_clusters.
		processSplitHelper1_(0, edge1, intersector);
		if (edge2 != -1)
			processSplitHelper1_(1, edge2, intersector);

		if (intersectionCluster != -1) {
			intersector.getResultPoint().getXY(pt_1);
			getClusterXY(intersectionCluster, pt_2);
			if (!pt_2.isEqual(pt_1))
				m_modified_clusters.add(intersectionCluster);
		}

		// remove modified clusters from the event queue. We'll reincert them
		// later
		for (int i = 0, n = m_modified_clusters.size(); i < n; i++) {
			int cluster = m_modified_clusters.get(i);
			int eventQnode = getClusterEventQNode(cluster);
			if (eventQnode != -1) {
				m_event_q.deleteNode(eventQnode, -1);
				setClusterEventQNode_(cluster, -1);
			}
		}

		int edgeOrigins1 = getEdgeOriginVertices(edge1);
		int edgeOrigins2 = (edge2 != -1) ? getEdgeOriginVertices(edge2) : -1;

		// Adjust the vertex coordinates and split the segments in the the edit
		// shape.
		applyIntersectorToEditShape_(edgeOrigins1, intersector, 0);
		if (edge2 != -1)
			applyIntersectorToEditShape_(edgeOrigins2, intersector, 1);

		// Produce clusters, and new edges. The new edges are added to
		// m_edges_to_insert_in_sweep_structure.
		createEdgesAndClustersFromSplitEdge_(edge1, intersector, 0);
		if (edge2 != -1)
			createEdgesAndClustersFromSplitEdge_(edge2, intersector, 1);

		m_edge_vertices.deleteList(edgeOrigins1);
		deleteEdge_(edge1);

		if (edge2 != -1) {
			m_edge_vertices.deleteList(edgeOrigins2);
			deleteEdge_(edge2);
		}

		// insert clusters into the event queue and the edges into the sweep
		// structure.
		for (int i = 0, n = m_modified_clusters.size(); i < n; i++) {
			int cluster = m_modified_clusters.get(i);
			if (cluster == m_sweep_point_cluster)
				m_b_sweep_point_cluster_was_modified = true;

			int eventQnode = getClusterEventQNode(cluster);
			if (eventQnode == -1) {
				int vertex = getClusterFirstVertex(cluster);
				assert (getClusterFromVertex(vertex) == cluster);

				eventQnode = m_event_q.addUniqueElement(vertex, -1);// O(logN)
																	// operation
				if (eventQnode == -1) {// the cluster is coinciding with another
										// one. merge.
					int existingNode = m_event_q.getDuplicateElement(-1);
					int v = m_event_q.getElement(existingNode);
					assert (m_shape.isEqualXY(vertex, v));
					int existingCluster = getClusterFromVertex(v);
					mergeClusters_(existingCluster, cluster);
				} else {
					setClusterEventQNode_(cluster, eventQnode);
				}
			} else {
				// if already inserted (probably impossible) case
			}
		}

		m_modified_clusters.clear(false);
	}
void splitEdge_ ( int edge1 , int edge2 , int intersectionCluster , SegmentIntersector intersector ) { disconnectEdge_ ( edge1 ) ; if ( edge2 != - 1 ) disconnectEdge_ ( edge2 ) ; processSplitHelper1_ ( 0 , edge1 , intersector ) ; if ( edge2 != - 1 ) processSplitHelper1_ ( 1 , edge2 , intersector ) ; if ( intersectionCluster != - 1 ) { intersector . getResultPoint ( ) . getXY ( pt_1 ) ; getClusterXY ( intersectionCluster , pt_2 ) ; if ( ! pt_2 . isEqual ( pt_1 ) ) m_modified_clusters . add ( intersectionCluster ) ; } for ( int i = 0 , n = m_modified_clusters . size ( ) ; i < n ; i ++ ) { int cluster = m_modified_clusters . get ( i ) ; int eventQnode = getClusterEventQNode ( cluster ) ; if ( eventQnode != - 1 ) { m_event_q . deleteNode ( eventQnode , - 1 ) ; setClusterEventQNode_ ( cluster , - 1 ) ; } } int edgeOrigins1 = getEdgeOriginVertices ( edge1 ) ; int edgeOrigins2 = ( edge2 != - 1 ) ? getEdgeOriginVertices ( edge2 ) : - 1 ; applyIntersectorToEditShape_ ( edgeOrigins1 , intersector , 0 ) ; if ( edge2 != - 1 ) applyIntersectorToEditShape_ ( edgeOrigins2 , intersector , 1 ) ; createEdgesAndClustersFromSplitEdge_ ( edge1 , intersector , 0 ) ; if ( edge2 != - 1 ) createEdgesAndClustersFromSplitEdge_ ( edge2 , intersector , 1 ) ; m_edge_vertices . deleteList ( edgeOrigins1 ) ; deleteEdge_ ( edge1 ) ; if ( edge2 != - 1 ) { m_edge_vertices . deleteList ( edgeOrigins2 ) ; deleteEdge_ ( edge2 ) ; } for ( int i = 0 , n = m_modified_clusters . size ( ) ; i < n ; i ++ ) { int cluster = m_modified_clusters . get ( i ) ; if ( cluster == m_sweep_point_cluster ) m_b_sweep_point_cluster_was_modified = true ; int eventQnode = getClusterEventQNode ( cluster ) ; if ( eventQnode == - 1 ) { int vertex = getClusterFirstVertex ( cluster ) ; assert ( getClusterFromVertex ( vertex ) == cluster ) ; eventQnode = m_event_q . addUniqueElement ( vertex , - 1 ) ; if ( eventQnode == - 1 ) { int existingNode = m_event_q . getDuplicateElement ( - 1 ) ; int v = m_event_q . getElement ( existingNode ) ; assert ( m_shape . isEqualXY ( vertex , v ) ) ; int existingCluster = getClusterFromVertex ( v ) ; mergeClusters_ ( existingCluster , cluster ) ; } else { setClusterEventQNode_ ( cluster , eventQnode ) ; } } else { } } m_modified_clusters . clear ( false ) ; }
m_edges_to_insert_in_sweep_structure.