From: yu.dongliang <18588496441@163.com> Date: Wed, 1 Nov 2023 06:29:04 +0000 (+0800) Subject: ses_layout.c X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=4b179414c284f458eb1a9cdb4dbe080cb124e00f;p=ses.git ses_layout.c --- diff --git a/ses_core.h b/ses_core.h index 539c21b..39be787 100644 --- a/ses_core.h +++ b/ses_core.h @@ -124,6 +124,8 @@ ses_ctx_t* ses_ctx_alloc(); void ses_ctx_free (ses_ctx_t* ctx); +int ses_cross_graph_kcolor(scf_vector_t* graph, int k, scf_vector_t* colors); + int ses_layout_board (ScfEboard* b); int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count); diff --git a/ses_layout.c b/ses_layout.c index de5f9a0..1f311e5 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -1249,6 +1249,35 @@ static void __ses_mov_pos(ScfEfunction* f, int d) } } +int ses_cross(ScfEfunction* f, int d) +{ + scf_vector_t* graph = scf_vector_alloc(); + scf_vector_t* colors = scf_vector_alloc(); + ses_edge_t* edge; + + scf_loge("\n"); + __ses_get_crosses(f, d, graph); + + scf_vector_add(colors, (void*)1); + scf_vector_add(colors, (void*)2); + + int ret = ses_cross_graph_kcolor(graph, 2, colors); + if (ret < 0) { + scf_loge("\n"); + } + + int i; + for (i = 0; i < graph->size; i++) { + edge = graph->data[i]; + + scf_logi("i: %d, c%ld->color: %ld\n", i, edge->c->id, edge->color); + } + + scf_vector_clear(graph, ( void (*)(void*) )ses_edge_free); + scf_vector_free(graph); + scf_vector_free(colors); +} + int ses_layout_function(ScfEfunction* f, int d) { ScfEcomponent* c; @@ -1276,31 +1305,17 @@ int ses_layout_function(ScfEfunction* f, int d) qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id); - scf_vector_t* crosses0 = scf_vector_alloc(); - scf_vector_t* crosses1 = scf_vector_alloc(); - - scf_loge("\n"); - __ses_get_crosses(f, d, crosses0); - __ses_de_cross(f, d); __ses_setc_xy(f, d); __ses_xchg_cx(f, d); __ses_xchg_ce(f, d); - scf_loge("\n"); - __ses_get_crosses(f, d, crosses1); + ses_cross(f, d); __ses_mov_pos(f, d); __ses_layout_cx(f, d); - scf_vector_clear(crosses0, ( void (*)(void*) )ses_edge_free); - scf_vector_clear(crosses1, ( void (*)(void*) )ses_edge_free); - scf_vector_free(crosses0); - scf_vector_free(crosses1); - crosses0 = NULL; - crosses1 = NULL; - int tx0 = INT_MAX; int tx1 = 0;