------------------------------------------------------------------------------
| 653 | |
| 654 | //------------------------------------------------------------------------------ |
| 655 | int vtkNetCDFReader::ReadMetaData(int ncFD) |
| 656 | { |
| 657 | // Look at all variables and record them so that the user can select which |
| 658 | // ones he wants. This oddness of adding and removing from |
| 659 | // VariableArraySelection is to preserve any current settings for variables. |
| 660 | typedef std::set<std::string> stringSet; |
| 661 | stringSet variablesToAdd; |
| 662 | stringSet variablesToRemove; |
| 663 | |
| 664 | // Initialize variablesToRemove with all the variables. Then remove them from |
| 665 | // the list as we find them. |
| 666 | for (int i = 0; i < this->VariableArraySelection->GetNumberOfArrays(); i++) |
| 667 | { |
| 668 | variablesToRemove.insert(this->VariableArraySelection->GetArrayName(i)); |
| 669 | } |
| 670 | |
| 671 | int numVariables; |
| 672 | CALL_NETCDF_INT(this->Accessor->inq_nvars(ncFD, &numVariables)); |
| 673 | |
| 674 | for (int i = 0; i < numVariables; i++) |
| 675 | { |
| 676 | char name[NC_MAX_NAME + 1]; |
| 677 | CALL_NETCDF_INT(this->Accessor->inq_varname(ncFD, i, name)); |
| 678 | if (variablesToRemove.find(name) == variablesToRemove.end()) |
| 679 | { |
| 680 | // Variable not already here. Insert it in the variables to add. |
| 681 | variablesToAdd.insert(name); |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | // Variable already exists. Leave it be. Remove it from the |
| 686 | // variablesToRemove list. |
| 687 | variablesToRemove.erase(name); |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | // Add and remove variables. This will be a no-op if the variables have not |
| 692 | // changed. |
| 693 | for (stringSet::iterator removeItr = variablesToRemove.begin(); |
| 694 | removeItr != variablesToRemove.end(); ++removeItr) |
| 695 | { |
| 696 | this->VariableArraySelection->RemoveArrayByName(removeItr->c_str()); |
| 697 | } |
| 698 | for (stringSet::iterator addItr = variablesToAdd.begin(); addItr != variablesToAdd.end(); |
| 699 | ++addItr) |
| 700 | { |
| 701 | this->VariableArraySelection->AddArray(addItr->c_str()); |
| 702 | } |
| 703 | |
| 704 | return 1; |
| 705 | } |
| 706 | |
| 707 | //------------------------------------------------------------------------------ |
| 708 | int vtkNetCDFReader::FillVariableDimensions(int ncFD) |
no test coverage detected