Beispiel #1
0
int Scanner::getNextToken(token_type& t, location_type& l)
{
  int tokid;
  bool done = false;

  do {
    tokid = next(t);
    if (tokid != 0) { // not EOF
      for (const char *s = t.rawText.c_str(); *s; s++) {
        if (*s == '\n') {
          m_line++;
          m_column = 0;
        } else {
          m_column++;
        }
      }
    }
    switch (tokid) {
    case T_COMMENT:
    case T_DOC_COMMENT:
    case T_OPEN_TAG:
    case T_WHITESPACE:
      break;
    default:
      done = true;
      break;
    }
  } while (!done);

  l.last_line(m_line);
  l.last_column(m_column);
  return tokid;
}
GsTLInt Reduced_grid::closest_node( const location_type& P ) const {
/*
  int node_id = Cartesian_grid::closest_node(P);
  if(node_id < 0 || !is_inside_mask(node_id) ) {
    return -1;
  }
  else {
    return node_id;
  }
*/

  location_type origin = geometry_->origin();
  location_type P0;
  P0.x() = P.x() - origin.x();
  P0.y() = P.y() - origin.y();
  P0.z() = P.z() - origin.z();

  GsTLCoordVector cell_sizes = geometry_->cell_dims();
  int spacing = grid_cursor_->multigrid_spacing();

  // Account for the multi-grid spacing
  cell_sizes.x() = cell_sizes.x() * spacing;
  cell_sizes.y() = cell_sizes.y() * spacing;
  cell_sizes.z() = cell_sizes.z() * spacing;


  GsTLInt i = std::max( GsTL::floor( P0.x()/cell_sizes.x() + 0.5 ), 0 );
  GsTLInt j = std::max( GsTL::floor( P0.y()/cell_sizes.y() + 0.5 ), 0 );
  GsTLInt k = std::max( GsTL::floor( P0.z()/cell_sizes.z() + 0.5 ), 0 );

  // The function will return a valid node even if P is outside the
  // grid's bounding box
  if( i >= grid_cursor_->max_iter( SGrid_cursor::X ) )
    i = grid_cursor_->max_iter( SGrid_cursor::X ) - 1;
  if( j >= grid_cursor_->max_iter( SGrid_cursor::Y ) )
    j = grid_cursor_->max_iter( SGrid_cursor::Y ) - 1;
  if( k >= grid_cursor_->max_iter( SGrid_cursor::Z ) )
    k = grid_cursor_->max_iter( SGrid_cursor::Z ) - 1;

  // Need to check if the i,j,k is within the active_region of the grid

//  SGrid_cursor* cursor = dynamic_cast<SGrid_cursor*>(mgrid_cursor_);
//  int id = cursor->node_id(i,j,k);
//  return id;
  return mgrid_cursor_->node_id( i, j, k );
}
Beispiel #3
0
int Scanner::getNextToken(token_type& t, location_type& l) {
  int tokid;
  bool done = false;

  do {
    tokid = next(t);
    switch (tokid) {
    case T_COMMENT:
    case T_DOC_COMMENT:
    case T_OPEN_TAG:
    case T_WHITESPACE:
      break;
    default:
      done = true;
      break;
    }
  } while (!done && !m_full);

  l.first_line(m_firstLine);
  l.first_column(m_firstColumn);
  l.last_line(m_line);
  l.last_column(m_column);
  return tokid;
}