model_server/obj/src/objTree.h.cxx
// Find common root for two nodes
Find common root for two nodes
Find common root for two nodes
objTree *  obj_tree_common_root(objTree * node1, objTree * node2,
				objTree * *n1, objTree * *n2)
  {
  Initialize(obj_tree_common_root);
  int delta = node2->depth() - node1->depth();
  int i;
  if(delta > 0)
    for(i = 0; i < delta; i++)
      node2 = node2->get_parent();
  else 
    for(i = 0; i > delta; i--)
      node1 = node1->get_parent();
  objTree * x1 = 0, * x2 = 0;
  while(node1 != node2)
    {
    x1 = node1;
    x2 = node2;
    node1 = node1->get_parent();
    node2 = node2->get_parent();
    }
  if(n1) *n1 = x1;
  if(n2) *n2 = x2;
  ReturnValue(node1);
  }
objTree * obj_tree_common_root ( objTree * node1 , objTree * node2 , objTree * * n1 , objTree * * n2 ) { Initialize ( obj_tree_common_root ) ; int delta = node2 -> depth ( ) - node1 -> depth ( ) ; int i ; if ( delta > 0 ) for ( i = 0 ; i < delta ; i ++ ) node2 = node2 -> get_parent ( ) ; else for ( i = 0 ; i > delta ; i -- ) node1 = node1 -> get_parent ( ) ; objTree * x1 = 0 , * x2 = 0 ; while ( node1 != node2 ) { x1 = node1 ; x2 = node2 ; node1 = node1 -> get_parent ( ) ; node2 = node2 -> get_parent ( ) ; } if ( n1 ) * n1 = x1 ; if ( n2 ) * n2 = x2 ; ReturnValue ( node1 ) ; }
Find common root for two nodes
Find common root for two nodes