public ExpandDestinationDistance(ExpandCostFactor[] p_trace_costs,boolean[] p_layer_active,double p_min_normal_via_cost,double p_min_cheap_via_cost){
  trace_costs=p_trace_costs;
  layer_active=p_layer_active;
  layer_count=p_layer_active.length;
  min_normal_via_cost=p_min_normal_via_cost;
  min_cheap_via_cost=p_min_cheap_via_cost;
  int curr_active_layer_count=0;
  for (int ind=0; ind < layer_count; ++ind) {
    if (layer_active[ind])     curr_active_layer_count++;
  }
  active_layer_count=curr_active_layer_count;
  if (layer_active[0]) {
    if (trace_costs[0].horizontal < trace_costs[0].vertical) {
      min_component_side_trace_cost=trace_costs[0].horizontal;
      max_component_side_trace_cost=trace_costs[0].vertical;
    }
 else {
      min_component_side_trace_cost=trace_costs[0].vertical;
      max_component_side_trace_cost=trace_costs[0].horizontal;
    }
  }
  if (layer_active[layer_count - 1]) {
    ExpandCostFactor curr_trace_cost=trace_costs[layer_count - 1];
    if (curr_trace_cost.horizontal < curr_trace_cost.vertical) {
      min_solder_side_trace_cost=curr_trace_cost.horizontal;
      max_solder_side_trace_cost=curr_trace_cost.vertical;
    }
 else {
      min_solder_side_trace_cost=curr_trace_cost.vertical;
      max_solder_side_trace_cost=curr_trace_cost.horizontal;
    }
  }
  max_inner_side_trace_cost=Math.min(max_component_side_trace_cost,max_solder_side_trace_cost);
  for (int ind2=1; ind2 < layer_count - 1; ++ind2) {
    if (!layer_active[ind2]) {
      continue;
    }
    double curr_max_cost=Math.max(trace_costs[ind2].horizontal,trace_costs[ind2].vertical);
    max_inner_side_trace_cost=Math.min(max_inner_side_trace_cost,curr_max_cost);
  }
  min_component_inner_trace_cost=Math.min(min_component_side_trace_cost,max_inner_side_trace_cost);
  min_solder_inner_trace_cost=Math.min(min_solder_side_trace_cost,max_inner_side_trace_cost);
  min_component_solder_inner_trace_cost=Math.min(min_component_inner_trace_cost,min_solder_inner_trace_cost);
}

public ExpandDestinationDistance ( ExpandCostFactor [ ] p_trace_costs , boolean [ ] p_layer_active , double p_min_normal_via_cost , double p_min_cheap_via_cost ) { trace_costs = p_trace_costs ; layer_active = p_layer_active ; layer_count = p_layer_active . length ; min_normal_via_cost = p_min_normal_via_cost ; min_cheap_via_cost = p_min_cheap_via_cost ; int curr_active_layer_count = 0 ; for ( int ind = 0 ; ind < layer_count ; ++ ind ) { if ( layer_active [ ind ] ) curr_active_layer_count ++ ; } active_layer_count = curr_active_layer_count ; if ( layer_active [ 0 ] ) { if ( trace_costs [ 0 ] . horizontal < trace_costs [ 0 ] . vertical ) { min_component_side_trace_cost = trace_costs [ 0 ] . horizontal ; max_component_side_trace_cost = trace_costs [ 0 ] . vertical ; } else { min_component_side_trace_cost = trace_costs [ 0 ] . vertical ; max_component_side_trace_cost = trace_costs [ 0 ] . horizontal ; } } if ( layer_active [ layer_count - 1 ] ) { ExpandCostFactor curr_trace_cost = trace_costs [ layer_count - 1 ] ; if ( curr_trace_cost . horizontal < curr_trace_cost . vertical ) { min_solder_side_trace_cost = curr_trace_cost . horizontal ; max_solder_side_trace_cost = curr_trace_cost . vertical ; } else { min_solder_side_trace_cost = curr_trace_cost . vertical ; max_solder_side_trace_cost = curr_trace_cost . horizontal ; } } max_inner_side_trace_cost = Math . min ( max_component_side_trace_cost , max_solder_side_trace_cost ) ; for ( int ind2 = 1 ; ind2 < layer_count - 1 ; ++ ind2 ) { if ( ! layer_active [ ind2 ] ) { continue ; } double curr_max_cost = Math . max ( trace_costs [ ind2 ] . horizontal , trace_costs [ ind2 ] . vertical ) ; max_inner_side_trace_cost = Math . min ( max_inner_side_trace_cost , curr_max_cost ) ; } min_component_inner_trace_cost = Math . min ( min_component_side_trace_cost , max_inner_side_trace_cost ) ; min_solder_inner_trace_cost = Math . min ( min_solder_side_trace_cost , max_inner_side_trace_cost ) ; min_component_solder_inner_trace_cost = Math . min ( min_component_inner_trace_cost , min_solder_inner_trace_cost ) ; }
p_trace_costs and p_layer_active are arrays of dimension layer_count .
