------------------------------------------------------------------------------
| 693 | } |
| 694 | //------------------------------------------------------------------------------ |
| 695 | int vtkHyperTreeGridSource::InitializeFromStringDescriptor() |
| 696 | { |
| 697 | std::string descNoProcess = this->Descriptor; |
| 698 | for (char c = '0'; c <= '9'; c++) |
| 699 | { |
| 700 | descNoProcess.erase( |
| 701 | std::remove(descNoProcess.begin(), descNoProcess.end(), c), descNoProcess.end()); |
| 702 | } |
| 703 | |
| 704 | // Verify that grid and material specifications are consistent |
| 705 | if (this->UseMask && strlen(this->Mask) != descNoProcess.size()) |
| 706 | { |
| 707 | vtkErrorMacro(<< "Material mask is used but has length " << strlen(this->Mask) |
| 708 | << " != " << descNoProcess.size() |
| 709 | << " which is the length of the grid descriptor, omitting process qualifiers."); |
| 710 | return 0; |
| 711 | } |
| 712 | |
| 713 | // Calculate total level 0 grid size |
| 714 | unsigned int nTotal = 1; |
| 715 | for (unsigned int idim = 0; idim < 3; ++idim) |
| 716 | { |
| 717 | if (this->Dimensions[idim] != 1) |
| 718 | { |
| 719 | nTotal *= (this->Dimensions[idim] - 1); |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | // Parse string descriptor and material mask if used |
| 724 | unsigned int nRefined = 0; |
| 725 | unsigned int nLeaves = 0; |
| 726 | unsigned int nNextLevel = nTotal; |
| 727 | unsigned int maskCounter = 0; |
| 728 | bool rootLevel = true; |
| 729 | std::ostringstream descriptor; |
| 730 | std::ostringstream mask; |
| 731 | |
| 732 | // Reset parsed level containers: |
| 733 | this->LevelDescriptors.clear(); |
| 734 | this->LevelMasks.clear(); |
| 735 | |
| 736 | // Iterate through descriptor strings |
| 737 | for (size_t i = 0; i < strlen(this->Descriptor); ++i) |
| 738 | { |
| 739 | char c = this->Descriptor[i]; |
| 740 | char m = 0; |
| 741 | if (!isdigit(c) && this->UseMask) |
| 742 | { |
| 743 | // Only read mask value when the current descriptor character is not a process number |
| 744 | m = this->Mask[maskCounter++]; |
| 745 | } |
| 746 | switch (c) |
| 747 | { |
| 748 | case ' ': |
| 749 | // Space is allowed as separator, verify mask consistency if needed |
| 750 | if (this->UseMask && m != ' ') |
| 751 | { |
| 752 | vtkErrorMacro(<< "Space separators do not match between " |