Changeset 241 for XMLIO_V2/dev
- Timestamp:
- 07/04/11 07:48:20 (12 years ago)
- 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 125 125 const std::vector<std::size_t> * _count) 126 126 { 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); 128 129 std::vector<std::size_t>::const_iterator 129 130 it = sizes.begin(), end = sizes.end(); 130 131 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 } 131 141 132 142 for (;it != end; it++) 133 { 134 std::size_t s = *it; 143 { 135 144 if ((_start != NULL) && (_count != NULL)) 136 145 { 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++; 149 150 } 150 151 else 151 152 { 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]; 163 156 i++; 164 157 } … … 279 272 std::size_t CINetCDF4::getNbOfTimestep(void) 280 273 { 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()]); 282 277 } 283 278 … … 287 282 int grpid = this->getGroup(path); 288 283 int dimid = this->getUnlimitedDimension(); 284 285 if (dimid == -1) return (std::string()); 289 286 CheckError(nc_inq_dimname(grpid, dimid, full_name_in)); 290 287 -
XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_adv.cpp
r229 r241 425 425 return (*(++(++clist.rbegin()))); 426 426 } 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 } 427 451 428 452 -
XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_adv.hpp
r229 r241 68 68 std::string getLatCoordName (const std::string & _varname); 69 69 std::string getVertCoordName(const std::string & _varname); 70 std::string getTimeCoordName(const std::string & _varname); 70 71 71 72 std::set<std::string> getCoordVariables(void); -
XMLIO_V2/dev/dev_rv/src4/xmlio/netcdf/inetcdf4_impl.hpp
r229 r241 35 35 this->getReadDataInfos 36 36 (_varname, _record, _array_size, _sstart, _scount, _start, _count); 37 37 38 _data.resize(boost::extents[_array_size]); 38 39 this->readData_(grpid, varid, _sstart, _scount, _data.data()); -
XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.cpp
r239 r241 62 62 vtkLSCEReader::vtkLSCEReader(void) 63 63 : FileName(), CurGridType(RECTILINEAR), VarNames() 64 , A3D(true), ATemporal(true), ACell(true) 64 , A3D(true), ATemporal(true), ACell(true), AGridDef(false) 65 65 , Reader() 66 66 { … … 187 187 vtkInformationVector * outputVector) 188 188 { 189 try 190 { 189 191 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 } 210 217 return (1); 211 218 } … … 484 491 } 485 492 } 493 494 //---------------------------------------------------------------- 486 495 487 496 void vtkLSCEReader::GetDimensions(const vtkStdString & xcoordinate, … … 548 557 } 549 558 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); 552 561 553 562 if (Reader->hasBounds(xcoordinate)) … … 616 625 vtkIntArray * dimensions) 617 626 { 618 float value[3] , range[2];627 float value[3]; 619 628 double h = 1.0; 620 double cartesianCoord[3], vbounds[6] ;629 double cartesianCoord[3], vbounds[6], range[2]; 621 630 vtkIdType pts[nbvertex] ; 622 631 bool is2D = true; … … 634 643 zspacing->InsertNextValue(0); 635 644 636 zspacing->Get ValueRange (range);645 zspacing->GetRange (range); 637 646 638 647 std::size_t size = (*Reader->getDimensions(&xcoordinate).begin()).second; … … 724 733 data->SetName(varname.c_str()); 725 734 ARRAY_CREATE(data_arr, double, 1, [1]); 726 Reader->readData(*data_arr, varname );735 Reader->readData(*data_arr, varname, record); 727 736 Reader->replaceMissingValue(varname, *data_arr, vtkMath::Nan()); 728 737 … … 775 784 vtkRectilinearGrid * routput = vtkRectilinearGrid::SafeDownCast(output); 776 785 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 778 791 if (routput && !this->VarNames.empty()) 779 792 { // Grille rectiliniéaire … … 793 806 dims->InsertNextValue(yspacing->GetNumberOfTuples()); 794 807 dims->InsertNextValue(zspacing->GetNumberOfTuples()); 795 808 809 CreateRectilinearGrid(routput, outInfo, xspacing, yspacing, zspacing, dims); 796 810 AddScalarData(routput, *VarNames.begin(), 0, true); 797 CreateRectilinearGrid(routput, outInfo, xspacing, yspacing, zspacing, dims); 811 812 this->AGridDef = true; 798 813 } 799 814 … … 809 824 Reader->getVertCoordName(*VarNames.begin()), true, true, pts, dims); 810 825 826 CreateStructuredGrid(soutput, outInfo, pts, dims); 811 827 AddScalarData(soutput, *VarNames.begin(), 0, true); 812 CreateStructuredGrid(soutput, outInfo, pts, dims); 828 829 this->AGridDef = true; 813 830 } 814 831 815 832 if (uoutput && !this->VarNames.empty()) 816 833 { // Grille non-structurée 817 818 834 vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); 819 835 vtkSmartPointer<vtkIntArray> dims = vtkSmartPointer<vtkIntArray>::New(); … … 822 838 //CreateSimpleGrid (0, 12, 0, 12, 0, 12, pts, cells, dims); 823 839 //std::cout << Reader->getVertCoordName(*VarNames.begin()) << std::endl; 824 840 825 841 GetCellsAndPoints(Reader->getLonCoordName(*VarNames.begin()), 826 842 Reader->getLatCoordName(*VarNames.begin()), 827 Reader->getVertCoordName(*VarNames.begin()), true, false, true,843 Reader->getVertCoordName(*VarNames.begin()), true, true, true, 828 844 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); 829 849 830 AddScalarData(uoutput, *VarNames.begin(), 0, true); 831 CreateUnstructuredGrid(uoutput, outInfo, pts, cells, VTK_POLYGON); 832 833 850 this->AGridDef = true; 834 851 } 835 852 return (1); 836 853 } 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 //---------------------------------------------------------------- 837 897 838 898 int vtkLSCEReader::RequestInformation … … 844 904 vtkDataSet * output = vtkDataSet::GetData(outInfo); 845 905 846 if (true) 906 this->AGridDef = false; 907 908 if (!this->VarNames.empty()) 847 909 { 848 910 switch (this->CurGridType) … … 864 926 vtkRectilinearGrid * routput = vtkRectilinearGrid::SafeDownCast(output); 865 927 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 } 866 949 867 950 if (routput && !this->VarNames.empty()) -
XMLIO_V2/dev/dev_rv/src4/xmlio/vtk/lscereader.hpp
r239 r241 170 170 const vtkStdString & zcoordinate, 171 171 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); 172 177 173 178 //ETX … … 200 205 GridType CurGridType; 201 206 std::set<vtkStdString> VarNames; 202 bool A3D, ATemporal, ACell ;207 bool A3D, ATemporal, ACell, AGridDef; 203 208 204 209 int ReplaceFillValueWithNan;
Note: See TracChangeset
for help on using the changeset viewer.