Ignore:
Timestamp:
11/16/15 16:21:45 (9 years ago)
Author:
rlacroix
Message:

Add a new field attribute grid_path to allow chaining spatial transformations.

Intermediate grids must be separated by comma and the source/destination grids must not be listed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/field.cpp

    r775 r790  
    819819   { 
    820820     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) 
    821        grid->transformGrid(getDirectFieldReference()->grid); 
     821     { 
     822       std::vector<CGrid*> grids; 
     823       // Source grid 
     824       grids.push_back(getDirectFieldReference()->grid); 
     825       // Intermediate grids 
     826       if (!grid_path.isEmpty()) 
     827       { 
     828         std::string gridId; 
     829         size_t start = 0, end; 
     830 
     831         do 
     832         { 
     833           end = grid_path.getValue().find(',', start); 
     834           if (end != std::string::npos) 
     835           { 
     836             gridId = grid_path.getValue().substr(start, end - start); 
     837             start = end + 1; 
     838           } 
     839           else 
     840             gridId = grid_path.getValue().substr(start); 
     841 
     842           if (!CGrid::has(gridId)) 
     843             ERROR("void CField::solveTransformedGrid()", 
     844                   << "Invalid grid_path, the grid '" << gridId << "' does not exist."); 
     845 
     846           grids.push_back(CGrid::get(gridId)); 
     847         } 
     848         while (end != std::string::npos); 
     849       } 
     850       // Destination grid 
     851       grids.push_back(grid); 
     852 
     853       for (size_t i = 0, count = grids.size() - 1; i < count; ++i) 
     854       { 
     855         CGrid *gridSrc  = grids[i]; 
     856         CGrid *gridDest = grids[i + 1]; 
     857         if (!gridDest->isTransformed()) 
     858           gridDest->transformGrid(gridSrc); 
     859       } 
     860     } 
    822861   } 
    823862 
Note: See TracChangeset for help on using the changeset viewer.