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

Method WriteSOSCaseFile

IO/Parallel/vtkEnSightWriter.cxx:1083–1140  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1081
1082//------------------------------------------------------------------------------
1083void vtkEnSightWriter::WriteSOSCaseFile(int numProcs)
1084{
1085 this->ComputeNames();
1086
1087 if (!this->BaseName)
1088 {
1089 vtkErrorMacro("A FileName or Path/BaseName must be specified.");
1090 return;
1091 }
1092
1093 this->SanitizeFileName(this->BaseName);
1094
1095 char charBuffer[512];
1096 auto result = vtk::format_to_n(
1097 charBuffer, sizeof(charBuffer), "{:s}/{:s}.case.sos", this->Path, this->BaseName);
1098 *result.out = '\0';
1099
1100 FILE* fd = nullptr;
1101 if (!(fd = OpenFile(charBuffer)))
1102 return;
1103
1104 this->WriteTerminatedStringToFile("FORMAT\n", fd);
1105 this->WriteTerminatedStringToFile("type: master_server gold\n\n", fd);
1106
1107 this->WriteTerminatedStringToFile("SERVERS\n", fd);
1108 result =
1109 vtk::format_to_n(charBuffer, sizeof(charBuffer), "number of servers: {:d}\n\n", numProcs);
1110 *result.out = '\0';
1111 this->WriteTerminatedStringToFile(charBuffer, fd);
1112
1113 // write the servers section with placeholders for the ensight server
1114 // location and server name
1115 int i = 0;
1116 for (i = 0; i < numProcs; i++)
1117 {
1118 result = vtk::format_to_n(charBuffer, sizeof(charBuffer), "#Server {:d}\n", i);
1119 *result.out = '\0';
1120 this->WriteTerminatedStringToFile(charBuffer, fd);
1121 this->WriteTerminatedStringToFile("#-------\n", fd);
1122 result = vtk::format_to_n(charBuffer, sizeof(charBuffer), "machine id: MID{:05d}\n", i);
1123 *result.out = '\0';
1124 this->WriteTerminatedStringToFile(charBuffer, fd);
1125
1126 this->WriteTerminatedStringToFile("executable: MEX\n", fd);
1127 result = vtk::format_to_n(charBuffer, sizeof(charBuffer), "data_path: {:s}\n", this->Path);
1128 *result.out = '\0';
1129 this->WriteTerminatedStringToFile(charBuffer, fd);
1130 result = vtk::format_to_n(
1131 charBuffer, sizeof(charBuffer), "casefile: {:s}.{:d}.case\n\n", this->BaseName, i);
1132 *result.out = '\0';
1133 this->WriteTerminatedStringToFile(charBuffer, fd);
1134 }
1135
1136 if (fd)
1137 {
1138 fclose(fd);
1139 }
1140}

Callers 1

RequestDataMethod · 0.95

Calls 5

ComputeNamesMethod · 0.95
SanitizeFileNameMethod · 0.95
format_to_nFunction · 0.50
OpenFileFunction · 0.50

Tested by

no test coverage detected