Changeset 241


Ignore:
Timestamp:
07/04/11 07:48:20 (13 years ago)
Author:
hozdoba
Message:
 
Location:
XMLIO_V2/dev/dev_rv/src4/xmlio
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4.cpp

    r229 r241  
    125125                                    const std::vector<std::size_t> * _count) 
    126126   { 
    127       std::vector<std::size_t> sizes = this->getDimensions(_varname);        
     127      std::vector<std::size_t> sizes  = this->getDimensions(_varname); 
     128      std::vector<std::string> iddims = this->getDimensionsIdList (&_varname);    
    128129      std::vector<std::size_t>::const_iterator 
    129130         it  = sizes.begin(), end = sizes.end(); 
    130131      int i = 0; 
     132       
     133      if (iddims.begin()->compare(this->getUnlimitedDimensionName()) == 0) 
     134      { 
     135         _sstart.push_back(_record); 
     136         _scount.push_back(1);  
     137         if ((_start == NULL) && 
     138             (_count == NULL)) i++; 
     139         it++; 
     140      } 
    131141 
    132142      for (;it != end; it++) 
    133       { 
    134          std::size_t  s = *it; 
     143      {       
    135144         if ((_start != NULL) && (_count != NULL)) 
    136145         { 
    137             if (s == UNLIMITED_DIM) 
    138             { 
    139                _sstart.push_back(_record); 
    140                _scount.push_back(1); 
    141             } 
    142             else 
    143             { 
    144                _sstart.push_back((*_start)[i]); 
    145                _scount.push_back((*_count)[i]); 
    146                _array_size *= (*_count)[i]; 
    147                i++; 
    148             } 
     146            _sstart.push_back((*_start)[i]); 
     147            _scount.push_back((*_count)[i]); 
     148            _array_size *= (*_count)[i]; 
     149            i++; 
    149150         } 
    150151         else 
    151152         { 
    152             if (s == UNLIMITED_DIM) 
    153             { 
    154                _sstart.push_back(_record); 
    155                _scount.push_back(1); 
    156             } 
    157             else 
    158             { 
    159                _sstart.push_back(0); 
    160                _scount.push_back(sizes[i]); 
    161                _array_size *= sizes[i]; 
    162             } 
     153            _sstart.push_back(0); 
     154            _scount.push_back(sizes[i]); 
     155            _array_size *= sizes[i]; 
    163156            i++; 
    164157         } 
     
    279272   std::size_t CINetCDF4::getNbOfTimestep(void) 
    280273   { 
    281        return (this->getDimensions(NULL)[this->getUnlimitedDimensionName()]); 
     274      int dimid = this->getUnlimitedDimension(); 
     275      if (dimid == -1) return (1); 
     276      return (this->getDimensions(NULL)[this->getUnlimitedDimensionName()]); 
    282277   } 
    283278             
     
    287282      int grpid = this->getGroup(path); 
    288283      int dimid = this->getUnlimitedDimension(); 
     284       
     285      if (dimid == -1) return (std::string()); 
    289286      CheckError(nc_inq_dimname(grpid, dimid, full_name_in)); 
    290287 
  • XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_adv.cpp

    r229 r241  
    425425          return (*(++(++clist.rbegin()))); 
    426426    } 
     427     
     428   std::string CINetCDF4Adv::getTimeCoordName(const std::string & _varname) 
     429   { 
     430      if (!this->isTemporal(_varname)) return (std::string()); 
     431       std::vector<std::string> clist = this->getCoordinatesIdList(_varname); 
     432       std::vector<std::string>::const_iterator it = clist.begin(), end = clist.end(); 
     433       if (this->hasCoordinates(_varname)) 
     434       { 
     435          for (; it != end; it++) 
     436          { 
     437              const std::string & var = *it; 
     438              if (this->hasVariable(var) && this->hasAttribute("standard_name", &var)) 
     439              { 
     440                  std::string time_name; 
     441                  this->readAttribute("standard_name", time_name, &var); 
     442                  if (time_name.compare("time") == 0) 
     443                      return (var); 
     444              } 
     445          } 
     446          return (this->getUnlimitedDimensionName()); 
     447       } 
     448       else 
     449          return (*(clist.begin())); 
     450   } 
    427451    
    428452    
  • XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_adv.hpp

    r229 r241  
    6868            std::string getLatCoordName (const std::string & _varname); 
    6969            std::string getVertCoordName(const std::string & _varname); 
     70            std::string getTimeCoordName(const std::string & _varname); 
    7071              
    7172            std::set<std::string> getCoordVariables(void); 
  • XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_impl.hpp

    r229 r241  
    3535      this->getReadDataInfos 
    3636         (_varname, _record, _array_size,  _sstart, _scount, _start, _count); 
     37       
    3738      _data.resize(boost::extents[_array_size]); 
    3839      this->readData_(grpid, varid, _sstart, _scount, _data.data()); 
  • XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.cpp

    r239 r241  
    6262      vtkLSCEReader::vtkLSCEReader(void) 
    6363         : FileName(), CurGridType(RECTILINEAR), VarNames() 
    64          , A3D(true), ATemporal(true), ACell(true) 
     64         , A3D(true), ATemporal(true), ACell(true), AGridDef(false) 
    6565         , Reader() 
    6666      { 
     
    187187                            vtkInformationVector *  outputVector) 
    188188      { 
     189         try 
     190         { 
    189191           
    190          if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) 
    191          { 
    192             return (this->RequestData(NULL, NULL, outputVector)); 
    193          } 
    194  
    195          if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_OBJECT())) 
    196          { 
    197          //   return (this->RequestDataObject(NULL, NULL, outputVector)); 
    198          } 
    199  
    200          if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) 
    201          { 
    202               return (this->RequestInformation(NULL, NULL, outputVector)); 
    203          } 
    204  
    205          if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) 
    206          { 
    207             return (this->RequestUpdateExtent(NULL, NULL, outputVector)); 
    208          } 
    209  
     192            if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) 
     193            { 
     194               return (this->RequestData(NULL, NULL, outputVector)); 
     195            } 
     196 
     197            if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_OBJECT())) 
     198            { 
     199            //   return (this->RequestDataObject(NULL, NULL, outputVector)); 
     200            } 
     201 
     202            if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) 
     203            { 
     204                 return (this->RequestInformation(NULL, NULL, outputVector)); 
     205            } 
     206 
     207            if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT())) 
     208            { 
     209               return (this->RequestUpdateExtent(NULL, NULL, outputVector)); 
     210            } 
     211         } 
     212         catch (xmlioserver::CException & _exception) 
     213         { 
     214            std::cerr << _exception.getMessage() << std::endl; 
     215            return (-1); 
     216         } 
    210217         return (1); 
    211218      } 
     
    484491         } 
    485492      } 
     493 
     494      //---------------------------------------------------------------- 
    486495       
    487496      void vtkLSCEReader::GetDimensions(const vtkStdString & xcoordinate, 
     
    548557         } 
    549558 
    550          dimensions->SetValue(0, dimensions->GetValue(0)+1); 
    551          dimensions->SetValue(1, dimensions->GetValue(1)+1); 
     559         dimensions->SetValue(0, dimensions->GetValue(0) + 1); 
     560         dimensions->SetValue(1, dimensions->GetValue(1) + 1); 
    552561 
    553562         if (Reader->hasBounds(xcoordinate)) 
     
    616625                                            vtkIntArray * dimensions) 
    617626      { 
    618          float  value[3], range[2]; 
     627         float  value[3]; 
    619628         double h = 1.0; 
    620          double cartesianCoord[3], vbounds[6]; 
     629         double cartesianCoord[3], vbounds[6], range[2]; 
    621630         vtkIdType pts[nbvertex] ; 
    622631         bool is2D = true; 
     
    634643            zspacing->InsertNextValue(0); 
    635644          
    636          zspacing->GetValueRange (range); 
     645         zspacing->GetRange (range); 
    637646 
    638647         std::size_t size = (*Reader->getDimensions(&xcoordinate).begin()).second; 
     
    724733         data->SetName(varname.c_str()); 
    725734         ARRAY_CREATE(data_arr, double, 1, [1]); 
    726          Reader->readData(*data_arr, varname); 
     735         Reader->readData(*data_arr, varname, record); 
    727736         Reader->replaceMissingValue(varname, *data_arr, vtkMath::Nan()); 
    728737          
     
    775784         vtkRectilinearGrid  * routput  = vtkRectilinearGrid::SafeDownCast(output); 
    776785         vtkStructuredGrid   * soutput  = vtkStructuredGrid::SafeDownCast(output); 
    777  
     786          
     787        double time = 0.0; 
     788        if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) 
     789           time = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())[0]; 
     790         
    778791         if (routput && !this->VarNames.empty()) 
    779792         { // Grille rectiliniéaire 
     
    793806            dims->InsertNextValue(yspacing->GetNumberOfTuples()); 
    794807            dims->InsertNextValue(zspacing->GetNumberOfTuples()); 
    795  
     808             
     809            CreateRectilinearGrid(routput, outInfo, xspacing, yspacing, zspacing, dims); 
    796810            AddScalarData(routput, *VarNames.begin(), 0, true); 
    797             CreateRectilinearGrid(routput, outInfo, xspacing, yspacing, zspacing, dims); 
     811 
     812            this->AGridDef = true; 
    798813         } 
    799814 
     
    809824                      Reader->getVertCoordName(*VarNames.begin()), true, true, pts, dims); 
    810825 
     826            CreateStructuredGrid(soutput, outInfo, pts, dims); 
    811827            AddScalarData(soutput, *VarNames.begin(), 0, true); 
    812             CreateStructuredGrid(soutput, outInfo, pts, dims); 
     828 
     829            this->AGridDef = true; 
    813830         } 
    814831 
    815832         if (uoutput  && !this->VarNames.empty()) 
    816833         { // Grille non-structurée 
    817  
    818834            vtkSmartPointer<vtkPoints>    pts   = vtkSmartPointer<vtkPoints>::New(); 
    819835            vtkSmartPointer<vtkIntArray>  dims  = vtkSmartPointer<vtkIntArray>::New(); 
     
    822838            //CreateSimpleGrid (0, 12, 0, 12, 0, 12, pts, cells, dims); 
    823839            //std::cout << Reader->getVertCoordName(*VarNames.begin()) << std::endl; 
    824              
     840 
    825841            GetCellsAndPoints(Reader->getLonCoordName(*VarNames.begin()), 
    826842                              Reader->getLatCoordName(*VarNames.begin()), 
    827                               Reader->getVertCoordName(*VarNames.begin()), true, false, true, 
     843                              Reader->getVertCoordName(*VarNames.begin()), true, true, true, 
    828844                              Reader->getNbVertex(*VarNames.begin()), cells, pts, dims); 
     845 
     846            CreateUnstructuredGrid(uoutput, outInfo, pts, cells, VTK_POLYGON); 
     847          
     848            AddScalarData(uoutput, *VarNames.begin(), this->GetRecord(*VarNames.begin(), time), true); 
    829849             
    830             AddScalarData(uoutput, *VarNames.begin(), 0, true); 
    831             CreateUnstructuredGrid(uoutput, outInfo, pts, cells, VTK_POLYGON); 
    832  
    833  
     850            this->AGridDef = true; 
    834851         } 
    835852         return (1); 
    836853      } 
     854 
     855      //---------------------------------------------------------------- 
     856       
     857      void vtkLSCEReader::GetTimeInformation 
     858               (const vtkStdString & variable, vtkDoubleArray * values, double * timeRange) 
     859      { 
     860         std::string timename = this->Reader->getTimeCoordName(variable); 
     861         if (this->Reader->hasVariable(timename)) 
     862         { 
     863            ARRAY_CREATE(data_arr, double, 1, [1]); 
     864            Reader->readData(*data_arr, timename); 
     865             
     866            values->SetNumberOfValues (data_arr->size()); 
     867            for (std::size_t i = 0; i < data_arr->size(); i++) 
     868               values->SetValue (i, (*data_arr)[i]); 
     869         } 
     870         else 
     871         { 
     872            std::size_t nbtimestep = this->Reader->getNbOfTimestep(); 
     873            values->SetNumberOfValues (nbtimestep); 
     874            for (std::size_t i = 0; i < nbtimestep; i++) 
     875               values->SetValue (i, i); 
     876         } 
     877         timeRange[0] = values->GetValue(0); 
     878         timeRange[1] = values->GetValue(values->GetNumberOfTuples()-1); 
     879      } 
     880       
     881      std::size_t vtkLSCEReader::GetRecord(const vtkStdString & variable, const double & value) 
     882      { 
     883         std::string timename = this->Reader->getTimeCoordName(variable); 
     884         if (this->Reader->hasVariable(timename)) 
     885         { 
     886            ARRAY_CREATE(data_arr, double, 1, [1]); 
     887            Reader->readData(*data_arr, timename); 
     888            return (std::find(data_arr->begin(), data_arr->end(), value) - data_arr->begin()); 
     889         } 
     890         else 
     891         { 
     892            return (value); 
     893         } 
     894      } 
     895 
     896      //---------------------------------------------------------------- 
    837897       
    838898      int vtkLSCEReader::RequestInformation 
     
    844904         vtkDataSet     *  output  = vtkDataSet::GetData(outInfo); 
    845905 
    846          if (true) 
     906         this->AGridDef = false; 
     907          
     908         if (!this->VarNames.empty()) 
    847909         { 
    848910            switch (this->CurGridType) 
     
    864926         vtkRectilinearGrid  * routput  = vtkRectilinearGrid::SafeDownCast(output); 
    865927         vtkStructuredGrid   * soutput  = vtkStructuredGrid::SafeDownCast(output); 
     928          
     929         if (!this->VarNames.empty()) 
     930         { // Informations temporelles 
     931            if (this->Reader->hasTemporalDim() && this->Reader->isTemporal(*VarNames.begin())) 
     932            { 
     933               vtkSmartPointer<vtkDoubleArray> timeStepValues = vtkSmartPointer<vtkDoubleArray>::New(); 
     934               double timeRange[2]; 
     935               this->GetTimeInformation(*VarNames.begin(), timeStepValues, timeRange); 
     936 
     937               outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), 
     938                            timeStepValues->GetPointer(0), 
     939                            timeStepValues->GetNumberOfTuples()); 
     940               outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); 
     941            } 
     942            else 
     943            { 
     944               outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); 
     945               outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE()); 
     946            } 
     947             
     948         } 
    866949          
    867950         if (routput && !this->VarNames.empty()) 
  • XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.hpp

    r239 r241  
    170170                               const vtkStdString & zcoordinate, 
    171171                               vtkIntArray * dimensions, bool bounds); 
     172             
     173            void GetTimeInformation 
     174               (const vtkStdString & variable, vtkDoubleArray * values, double * timeRange); 
     175             
     176            std::size_t GetRecord(const vtkStdString & variable, const double & value); 
    172177              
    173178            //ETX 
     
    200205            GridType CurGridType; 
    201206            std::set<vtkStdString> VarNames; 
    202             bool A3D, ATemporal, ACell; 
     207            bool A3D, ATemporal, ACell, AGridDef; 
    203208             
    204209            int ReplaceFillValueWithNan; 
Note: See TracChangeset for help on using the changeset viewer.