MCPcopy Create free account
hub / github.com/Kitware/VTK / InitializeFromStringDescriptor

Method InitializeFromStringDescriptor

Filters/Sources/vtkHyperTreeGridSource.cxx:695–900  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

693}
694//------------------------------------------------------------------------------
695int 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 "

Callers 2

RequestDataMethod · 0.95
RequestDataMethod · 0.80

Calls 14

backMethod · 0.80
removeFunction · 0.50
countFunction · 0.50
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
push_backMethod · 0.45
strMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected