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

Method GetOperandNumber

Common/Misc/vtkFunctionParser.cxx:1774–1860  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1772
1773//------------------------------------------------------------------------------
1774unsigned int vtkFunctionParser::GetOperandNumber(int currentIndex)
1775{
1776 int variableIndex = -1;
1777
1778 if (isdigit(this->Function[currentIndex]) || this->Function[currentIndex] == '.') // Number
1779 {
1780 double* tempImmediates = new double[this->ImmediatesSize];
1781 for (int i = 0; i < this->ImmediatesSize; i++)
1782 { // Copy current immediates to a temporary array
1783 tempImmediates[i] = this->Immediates[i];
1784 }
1785 delete[] this->Immediates;
1786
1787 // Allocate space for new immediate value.
1788 this->Immediates = new double[this->ImmediatesSize + 1];
1789
1790 // Copy contents of temporary array back to Immediates.
1791 for (int i = 0; i < this->ImmediatesSize; i++)
1792 {
1793 this->Immediates[i] = tempImmediates[i];
1794 }
1795
1796 VTK_FROM_CHARS_IF_ERROR_BREAK(
1797 &this->Function[currentIndex], this->Immediates[this->ImmediatesSize]);
1798 this->ImmediatesSize++;
1799 delete[] tempImmediates;
1800 return VTK_PARSER_IMMEDIATE;
1801 }
1802
1803 if (!strncmp(&this->Function[currentIndex], "iHat", 4))
1804 {
1805 return VTK_PARSER_IHAT;
1806 }
1807 if (!strncmp(&this->Function[currentIndex], "jHat", 4))
1808 {
1809 return VTK_PARSER_JHAT;
1810 }
1811 if (!strncmp(&this->Function[currentIndex], "kHat", 4))
1812 {
1813 return VTK_PARSER_KHAT;
1814 }
1815
1816 bool scalarVar = false;
1817 size_t currentLen = 0;
1818 // Bug 7396. If a scalar variable name is a subset of a vector var name it will
1819 // cause the scripting to crash. So instead of ending once we find a var name that matches in
1820 // scalars we will also check vectors
1821 for (int i = 0, max = this->GetNumberOfScalarVariables(); i < max; i++)
1822 { // Variable
1823 if (strncmp(&this->Function[currentIndex], this->ScalarVariableNames[i].c_str(),
1824 this->ScalarVariableNames[i].size()) == 0)
1825 {
1826 if (variableIndex == -1 || this->ScalarVariableNames[i].size() > currentLen)
1827 {
1828 currentLen = this->ScalarVariableNames[i].size();
1829 variableIndex = i;
1830 }
1831 }

Callers 2

CheckExpressionMethod · 0.95

Calls 2

c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected