Changeset 747 for XIOS/trunk/src


Ignore:
Timestamp:
10/21/15 11:50:11 (9 years ago)
Author:
rlacroix
Message:

Fix the inherited name for axis/domains with reference in some cases.

Correctly account for transformations and non default ids.

Location:
XIOS/trunk/src/node
Files:
3 edited

Legend:

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

    r742 r747  
    872872  } 
    873873 
     874  /*! 
     875   * Go through the hierarchy to find the axis from which the transformations must be inherited 
     876   */ 
    874877  void CAxis::solveInheritanceTransformation() 
    875878  { 
    876     if (this->hasTransformation()) return; 
    877  
     879    if (hasTransformation() || !hasDirectAxisReference()) 
     880      return; 
     881 
     882    CAxis* axis = this; 
    878883    std::vector<CAxis*> refAxis; 
    879     CAxis* refer_sptr; 
    880     CAxis* refer_ptr = this; 
    881     while (refer_ptr->hasDirectAxisReference()) 
    882     { 
    883       refAxis.push_back(refer_ptr); 
    884       refer_sptr = refer_ptr->getDirectAxisReference(); 
    885       refer_ptr  = refer_sptr; 
    886       if (refer_ptr->hasTransformation()) break; 
    887     } 
    888  
    889     if (refer_ptr->hasTransformation()) 
    890       for (int idx = 0; idx < refAxis.size(); ++idx) 
    891         refAxis[idx]->setTransformations(refer_ptr->getAllTransformations()); 
     884    while (!axis->hasTransformation() && axis->hasDirectAxisReference()) 
     885    { 
     886      refAxis.push_back(axis); 
     887      axis = axis->getDirectAxisReference(); 
     888    } 
     889 
     890    if (axis->hasTransformation()) 
     891      for (size_t i = 0; i < refAxis.size(); ++i) 
     892        refAxis[i]->setTransformations(axis->getAllTransformations()); 
     893 
     894    // Try to inherit the id of the referenced object as the axis name 
     895    // when no name was been defined and a defaut id is used. 
     896    if (name.isEmpty()) 
     897    { 
     898      static const std::string defId("__axis_undef_id_"); 
     899      const std::string& id = getId(); 
     900      if (id.size() > defId.size() && id.compare(0, defId.size(), defId) == 0) 
     901        name = axis->getId(); 
     902    } 
    892903  } 
    893904 
  • XIOS/trunk/src/node/domain.cpp

    r743 r747  
    18441844 
    18451845  /*! 
    1846     A current domain will go up the hierarchy to find out the domain from which it has transformation 
    1847   */ 
     1846   * Go through the hierarchy to find the domain from which the transformations must be inherited 
     1847   */ 
    18481848  void CDomain::solveInheritanceTransformation() 
    18491849  { 
    1850     if (this->hasTransformation()) return; 
    1851  
    1852     std::vector<CDomain*> refDomain; 
    1853     CDomain* refer_sptr; 
    1854     CDomain* refer_ptr = this; 
    1855     while (refer_ptr->hasDirectDomainReference()) 
    1856     { 
    1857       refDomain.push_back(refer_ptr); 
    1858       refer_sptr = refer_ptr->getDirectDomainReference(); 
    1859       refer_ptr  = refer_sptr; 
    1860       if (refer_ptr->hasTransformation()) break; 
    1861     } 
    1862  
    1863     if (refer_ptr->hasTransformation()) 
    1864       for (int idx = 0; idx < refDomain.size(); ++idx) 
    1865         refDomain[idx]->setTransformations(refer_ptr->getAllTransformations()); 
     1850    if (hasTransformation() || !hasDirectDomainReference()) 
     1851      return; 
     1852 
     1853    CDomain* domain = this; 
     1854    std::vector<CDomain*> refDomains; 
     1855    while (!domain->hasTransformation() && domain->hasDirectDomainReference()) 
     1856    { 
     1857      refDomains.push_back(domain); 
     1858      domain = domain->getDirectDomainReference(); 
     1859    } 
     1860 
     1861    if (domain->hasTransformation()) 
     1862      for (size_t i = 0; i < refDomains.size(); ++i) 
     1863        refDomains[i]->setTransformations(domain->getAllTransformations()); 
     1864 
     1865    // Try to inherit the id of the referenced object as the domain name 
     1866    // when no name was been defined and a defaut id is used. 
     1867    if (name.isEmpty()) 
     1868    { 
     1869      static const std::string defId("__domain_undef_id_"); 
     1870      const std::string& id = getId(); 
     1871      if (id.size() > defId.size() && id.compare(0, defId.size(), defId) == 0) 
     1872        name = domain->getId(); 
     1873    } 
    18661874  } 
    18671875 
  • XIOS/trunk/src/node/grid.cpp

    r746 r747  
    12241224        pDom->solveSrcInheritance(); 
    12251225        pDom->solveInheritanceTransformation(); 
    1226         if ((!pDom->domain_ref.isEmpty()) && (pDom->name.isEmpty())) 
    1227           pDom->name.setValue(pDom->getBaseDomainReference()->getId()); 
    12281226      } 
    12291227    } 
     
    12391237        pAxis->solveBaseReference(); 
    12401238        pAxis->solveInheritanceTransformation(); 
    1241         if ((!pAxis->axis_ref.isEmpty()) && (pAxis->name.isEmpty())) 
    1242           pAxis->name.setValue(pAxis->getBaseAxisReference()->getId()); 
    12431239      } 
    12441240    } 
Note: See TracChangeset for help on using the changeset viewer.