Beispiel #1
0
/** It returns the pointer to the new object that is created.  After
    reading which type of dimension this is, it reads the initial zone
    boundary, followed by a list of pairs: number of intervals in the
    zone and the zone boundary. */
Dimension* Dimension::getDimension(istream& input)
{
  char token[64];
  int dimType;
  double zoneBound;

  input >> token;
  switch(tolower(token[0]))
    {
    case 'x':
      dimType = DIM_X;
      break;
    case 'y':
      dimType = DIM_Y;
      break;
    case 'z':
      dimType = DIM_Z;
      break;
    case 'r':
      dimType = DIM_R;
      break;
    case 't':
      dimType = DIM_THETA;
      break;
    case 'p':
      dimType = DIM_PHI;
      break;
    default:
      error(130,"Invalid dimension type: %s",token);
    }

  next = new Dimension(dimType);
  memCheck(next,"Dimension::getDimension(...): next");

  Dimension *dimPtr = next;

  /* read first zone boundary */
  input >> dimPtr->start;

  /* read list of zone definitions until keyword "end" */
  Zone* zoneList = dimPtr->zoneListHead;

  verbose(2,"Reading zone boundaries for Dimension %s:",token);
  verbose(3,"Start: %g",dimPtr->start);

  clearComment(input);
  input >> token;
  while (strcmp(token,"end"))
    {
      input >> zoneBound;
      zoneList = zoneList->addZone(atoi(token),zoneBound);

      clearComment(input);
      input >> token;
    }

  if (zoneList->head())
    warning(131,"Dimension has no boundaries");

  return dimPtr;         
  

}