int main(int argc, char * argv[]) {
    auto trees = get_trees(argc, argv);
    for (auto & tree : trees) {
        int postorder_count = 0;
        for (auto ndi = tree->postorder_begin(); ndi != tree->postorder_end(); ++ndi, ++postorder_count) {
            std::cout << ndi->get_label() << "\t" << std::setprecision(8) << ndi->get_edge_length() << std::endl;
        }
    }
}
Esempio n. 2
0
void diffuse()
{
  edge_id e_id;
  facet_id f_id;
  facetedge_id fe_id;
  body_id b_id,bb_id;
  REAL pressure;
  REAL mass;
  REAL coeff;

  if ( web.representation == STRING )
  { edge_diffusion_attr = find_attribute(EDGE,DIFFUSE_EATTR_NAME);
    FOR_ALL_EDGES(e_id)
    { fe_id = get_edge_fe(e_id);
      if ( !valid_id(fe_id) ) return;
      b_id = get_facet_body(get_fe_facet(fe_id));
      if ( !valid_id(b_id) ) invert(fe_id);
      b_id = get_facet_body(get_fe_facet(fe_id));
      if ( !valid_id(b_id) ) continue;
      pressure = get_body_pressure(b_id);
       
      if ( !equal_id(fe_id,get_next_facet(fe_id)) )
      { fe_id = get_next_facet(fe_id);
        bb_id = get_facet_body(get_fe_facet(fe_id));
        if ( !valid_id(bb_id) ) invert(fe_id);
        bb_id = get_facet_body(get_fe_facet(fe_id));
        pressure -= get_body_pressure(bb_id);
      }
      else bb_id = NULLBODY;
      if ( edge_diffusion_attr >= 0 )
         coeff = *(REAL*)get_extra(e_id,edge_diffusion_attr);
      else coeff = web.diffusion_const; 
      mass = web.scale*coeff*pressure*get_edge_length(e_id);
      set_body_fixvol(b_id,get_body_fixvol(b_id)-mass);
      if ( valid_id(bb_id) )
        set_body_fixvol(bb_id,get_body_fixvol(bb_id)+mass);
    }
  } /* end STRING */