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

Method AddVariableFileName

IO/EnSight/vtkEnSightReader.cxx:2723–2799  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2721
2722//------------------------------------------------------------------------------
2723void vtkEnSightReader::AddVariableFileName(const char* fileName1, const char* fileName2)
2724{
2725 int size;
2726 int i;
2727 bool complexType = this->VariableMode == vtkEnSightReader::COMPLEX_SCALAR_PER_NODE ||
2728 this->VariableMode == vtkEnSightReader::COMPLEX_VECTOR_PER_NODE ||
2729 this->VariableMode == vtkEnSightReader::COMPLEX_SCALAR_PER_ELEMENT ||
2730 this->VariableMode == vtkEnSightReader::COMPLEX_VECTOR_PER_ELEMENT;
2731
2732 if (!complexType)
2733 {
2734 size = this->NumberOfVariables;
2735
2736 char** newFileNameList = new char*[size]; // temporary array
2737
2738 // copy file names to temporary array
2739 for (i = 0; i < size; i++)
2740 {
2741 newFileNameList[i] = new char[strlen(this->VariableFileNames[i]) + 1];
2742 strcpy(newFileNameList[i], this->VariableFileNames[i]);
2743 delete[] this->VariableFileNames[i];
2744 }
2745 delete[] this->VariableFileNames;
2746
2747 // make room for new file name
2748 this->VariableFileNames = new char*[size + 1];
2749
2750 // copy existing file names back to first array
2751 for (i = 0; i < size; i++)
2752 {
2753 this->VariableFileNames[i] = new char[strlen(newFileNameList[i]) + 1];
2754 strcpy(this->VariableFileNames[i], newFileNameList[i]);
2755 delete[] newFileNameList[i];
2756 }
2757 delete[] newFileNameList;
2758
2759 // add new file name at end of first array
2760 this->VariableFileNames[size] = new char[strlen(fileName1) + 1];
2761 strcpy(this->VariableFileNames[size], fileName1);
2762 vtkDebugMacro(<< "file name: " << this->VariableFileNames[size]);
2763 }
2764 else
2765 {
2766 size = this->NumberOfComplexVariables;
2767
2768 char** newFileNameList = new char*[2 * size]; // temporary array
2769
2770 // copy file names to temporary array
2771 for (i = 0; i < 2 * size; i++)
2772 {
2773 newFileNameList[i] = new char[strlen(this->ComplexVariableFileNames[i]) + 1];
2774 strcpy(newFileNameList[i], this->ComplexVariableFileNames[i]);
2775 delete[] this->ComplexVariableFileNames[i];
2776 }
2777 delete[] this->ComplexVariableFileNames;
2778
2779 // make room for new file name
2780 this->ComplexVariableFileNames = new char*[2 * (size + 1)];

Callers 1

ReadCaseFileVariableMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected