示例#1
0
/// Callback to output PlacedVolume information of an single Placement
int VisMaterialProcessor::operator()(PlacedVolume pv, int /* level */)   {
  Volume vol = pv.volume();
  double frac_active = 0.0;
  VisAttr attr;

  for ( Atom atom : activeElements )   {
    frac_active += vol.material().fraction(atom);
  }
  //if ( frac_active >= fraction )
  printout(DEBUG,name,
           "++ Volume:%s [%s] active:%s fraction:%.3f active-vis:%s inactive-vis:%s",
           pv.name(), vol.name(), yes_no(frac_active >= fraction), frac_active,
           yes_no(activeVis.isValid()), yes_no(inactiveVis.isValid()));
  if ( activeVis.isValid() )   {
    if ( frac_active >= fraction )  {
      attr = activeVis;
      ++numActive;
    }
    if ( !attr.isValid() )  {
      for ( Material mat : activeMaterials )  {
        if ( mat.ptr() == vol.material().ptr() )   {
          attr = activeVis;
          ++numActive;
          break;
        }
      }
    }
  }
  // If we get here, the material is definitely inactive
  if ( inactiveVis.isValid() )  {
    if ( !attr.isValid() && setAllInactive )   {
      attr = inactiveVis;
      ++numInactive;
    }
    else if ( frac_active<fraction )   {
      attr = inactiveVis;
      ++numInactive;
    }
    if ( !attr.isValid() && inactiveVis.isValid() )  {
      for ( Material imat : inactiveMaterials )   {
        if ( imat.ptr() == vol.material().ptr() )   {
          attr = inactiveVis;
          ++numInactive;
          break;
        }
      }
    }
  }
  if ( attr.isValid() )  {
    set_attr(vol,attr);
  }
  return 1;
}