ns-allinone-2.35/nam-1.15/netgraph.cc
void FeatureNetGraph::BoundingBox(BBox& bb)
{
  int i;
  minx_=int(bb.xmin);
  maxx_=int(bb.xmax);
  int newtix=int(time_*(maxx_-minx_)/(maxtime_-mintime_));
  if (newtix!=tix_) {
    tix_=newtix;
  }
  for(i=0;i<maxx_-minx_;i++)
    {
      scaleddata_[i]=0.0;
    }
  maxy_=1.0;
  /*Note: storing the data in an array like this is quick, but introduces
    some aliasing effects in the scaling process.  I think they're 
    negligable for this purpose but if we really want to remove them
    we must store the unscaled data in a list instead*/
  for(i=0;i<MAX_GRAPH;i++)
    {
      int ix = int(((float)(i*(maxx_-minx_)))/MAX_GRAPH);
      scaleddata_[ix]=graphdata_[i];
      if (scaleddata_[ix]>maxy_)
	maxy_=scaleddata_[ix];
    }
  if (miny_!=maxy_)
    {
      bb.ymin=miny_;
      bb.ymax=maxy_;
    }
  else 
    {
      bb.ymin=0.0;
      bb.ymax=1.0;
    }
}
/* following is a hack to get around the aliasing effects referred to
 * in the comments in NetGraph::BoundingBox.  It works for those data
 * sets I've tested it with, but it could produce undesired results
 * in some cases.
 */
following is a hack to get around the aliasing effects referred to
in the comments in NetGraph::BoundingBox.  It works for those data
sets I've tested it with, but it could produce undesired results
in some cases.
following is a hack to get around the aliasing effects referred to in the comments in NetGraph :: BoundingBox . It works for those data sets I ' ve tested it with but it could produce undesired results in some cases .
void FeatureNetGraph::BoundingBox(BBox& bb)
{
  int i;
  minx_=int(bb.xmin);
  maxx_=int(bb.xmax);
  int newtix=int(time_*(maxx_-minx_)/(maxtime_-mintime_));
  if (newtix!=tix_) {
    tix_=newtix;
  }
  for(i=0;i<maxx_-minx_;i++)
    {
      scaleddata_[i]=0.0;
    }
  maxy_=1.0;
  for(i=0;i<MAX_GRAPH;i++)
    {
      int ix = int(((float)(i*(maxx_-minx_)))/MAX_GRAPH);
      scaleddata_[ix]=graphdata_[i];
      if (scaleddata_[ix]>maxy_)
	maxy_=scaleddata_[ix];
    }
  if (miny_!=maxy_)
    {
      bb.ymin=miny_;
      bb.ymax=maxy_;
    }
  else 
    {
      bb.ymin=0.0;
      bb.ymax=1.0;
    }
}
void FeatureNetGraph :: BoundingBox ( BBox & bb ) { int i ; minx_ = int ( bb . xmin ) ; maxx_ = int ( bb . xmax ) ; int newtix = int ( time_ * ( maxx_ - minx_ ) / ( maxtime_ - mintime_ ) ) ; if ( newtix != tix_ ) { tix_ = newtix ; } for ( i = 0 ; i < maxx_ - minx_ ; i ++ ) { scaleddata_ [ i ] = 0.0 ; } maxy_ = 1.0 ; for ( i = 0 ; i < MAX_GRAPH ; i ++ ) { int ix = int ( ( ( float ) ( i * ( maxx_ - minx_ ) ) ) / MAX_GRAPH ) ; scaleddata_ [ ix ] = graphdata_ [ i ] ; if ( scaleddata_ [ ix ] > maxy_ ) maxy_ = scaleddata_ [ ix ] ; } if ( miny_ != maxy_ ) { bb . ymin = miny_ ; bb . ymax = maxy_ ; } else { bb . ymin = 0.0 ; bb . ymax = 1.0 ; } }
following is a hack to get around the aliasing effects referred to
 in the comments in NetGraph::BoundingBox.
following is a hack to get around the aliasing effects referred to in the comments in NetGraph :: BoundingBox .
/*Note: storing the data in an array like this is quick, but introduces
    some aliasing effects in the scaling process.  I think they're 
    negligable for this purpose but if we really want to remove them
    we must store the unscaled data in a list instead*/