model_server/gedge/src/constr_finetuning.cxx
/*
 * Constraintfinetuning
 * the finetuning phase (phase 4) of the Constraint layout algorithm
 */
Constraintfinetuning
the finetuning phase (phase 4) of the Constraint layout algorithm
Constraintfinetuning the finetuning phase ( phase 4 ) of the Constraint layout algorithm
void 
graph::Constraintfinetuning(int PR, int START_LEVEL) {
  if (headlevel) {
    constraints->consistency();
    headlevel->constr_init_finetuning();
    reset_values(headlevel);
    level* l = headlevel;
    l->constr_2halfD();
    for (int count_PR=0; count_PR < PR; count_PR++) {
      while (l->getnextlevel()) {
	l = l->getnextlevel();
	l->constr_adjust_down();
	l->constr_2halfD();
      }
      reset_values(headlevel,l);
      while (l->getprevlevel()) {
	l = l->getprevlevel();
	l->constr_adjust_up();
	l->constr_2halfD();
      }
      reset_values(headlevel,l);
    };
    int wide = -1;
    level* widest_level = 0;
    while (l->getnextlevel()) {
      l = l->getnextlevel();
      l->constr_adjust_down(); 
      l->constr_2halfD();
      edge_vector* p = l->getposition();
      int b = (*p)[l->getcitems()-1] - (*p)[0];
      if (b > wide) {
	wide = b;
	widest_level = l;
      }
    };
    if (l = widest_level) {
      reset_values(headlevel,l);
      while (l->getprevlevel()) {
	l=l->getprevlevel();
	l->constr_adjust_careful_up();
	l->constr_2halfD();
	edge_vector* p = l->getposition();
	int b = (*p)[l->getcitems()-1] - (*p)[0];
	if (b >= wide) {
	  wide = b;
	  widest_level = l;
	  reset_values(headlevel,l);
	}
      };
      if (START_LEVEL != -1) {
	if (debug) printf("starting from specified level %d\n", START_LEVEL);
        for (l = headlevel; l->getclevel() != START_LEVEL; l=l->getnextlevel(
));
       } else {
	if (debug) printf("starting from widest level %d\n", widest_level->getclevel());
          l = widest_level;
       }
      if (l = widest_level) {
	while (l->getnextlevel()) {
	  l=l->getnextlevel();
	  l->constr_adjust_careful_down();
	  l->constr_2halfD();
	}
      }
    }
    headlevel->last_adjust();
    headlevel->constr_Z();
    reset_values(headlevel);
  };
  headlevel->set_display();
  for (node* p = headnode; p != 0; p = p->getnextnode())
    p->movenode(p->getx(), p->gety());
  for (edge* e = headedge; e != 0; e=e->getnextedge()) 
    e->layout();
  dirty = 0;
}
void graph :: Constraintfinetuning ( int PR , int START_LEVEL ) { if ( headlevel ) { constraints -> consistency ( ) ; headlevel -> constr_init_finetuning ( ) ; reset_values ( headlevel ) ; level * l = headlevel ; l -> constr_2halfD ( ) ; for ( int count_PR = 0 ; count_PR < PR ; count_PR ++ ) { while ( l -> getnextlevel ( ) ) { l = l -> getnextlevel ( ) ; l -> constr_adjust_down ( ) ; l -> constr_2halfD ( ) ; } reset_values ( headlevel , l ) ; while ( l -> getprevlevel ( ) ) { l = l -> getprevlevel ( ) ; l -> constr_adjust_up ( ) ; l -> constr_2halfD ( ) ; } reset_values ( headlevel , l ) ; } ; int wide = -1 ; level * widest_level = 0 ; while ( l -> getnextlevel ( ) ) { l = l -> getnextlevel ( ) ; l -> constr_adjust_down ( ) ; l -> constr_2halfD ( ) ; edge_vector * p = l -> getposition ( ) ; int b = ( * p ) [ l -> getcitems ( ) - 1 ] - ( * p ) [ 0 ] ; if ( b > wide ) { wide = b ; widest_level = l ; } } ; if ( l = widest_level ) { reset_values ( headlevel , l ) ; while ( l -> getprevlevel ( ) ) { l = l -> getprevlevel ( ) ; l -> constr_adjust_careful_up ( ) ; l -> constr_2halfD ( ) ; edge_vector * p = l -> getposition ( ) ; int b = ( * p ) [ l -> getcitems ( ) - 1 ] - ( * p ) [ 0 ] ; if ( b >= wide ) { wide = b ; widest_level = l ; reset_values ( headlevel , l ) ; } } ; if ( START_LEVEL != -1 ) { if ( debug ) printf ( " \n " , START_LEVEL ) ; for ( l = headlevel ; l -> getclevel ( ) != START_LEVEL ; l = l -> getnextlevel ( ) ) ; } else { if ( debug ) printf ( " \n " , widest_level -> getclevel ( ) ) ; l = widest_level ; } if ( l = widest_level ) { while ( l -> getnextlevel ( ) ) { l = l -> getnextlevel ( ) ; l -> constr_adjust_careful_down ( ) ; l -> constr_2halfD ( ) ; } } } headlevel -> last_adjust ( ) ; headlevel -> constr_Z ( ) ; reset_values ( headlevel ) ; } ; headlevel -> set_display ( ) ; for ( node * p = headnode ; p != 0 ; p = p -> getnextnode ( ) ) p -> movenode ( p -> getx ( ) , p -> gety ( ) ) ; for ( edge * e = headedge ; e != 0 ; e = e -> getnextedge ( ) ) e -> layout ( ) ; dirty = 0 ; }
Constraintfinetuning
 the finetuning phase (phase 4) of the Constraint layout algorithm
Constraintfinetuning the finetuning phase ( phase 4 ) of the Constraint layout algorithm
//////////////////////////////////////////// begin priority layout phase; // looking for widest level while going down; // found if widest_level != 0 , may happen when only one level exists; // again looking for widest level while going up; // going down from widest_level for the last time; //////////////////////////////////////////// end priority layout phase;