|
36 | 36 | #include <string.h> |
37 | 37 |
|
38 | 38 | #include "cvOneDUtility.h" |
39 | | -#include "cvOneDGlobal.h" |
40 | 39 |
|
41 | 40 | namespace cvOneD{ |
42 | 41 |
|
@@ -126,10 +125,25 @@ void readOptionsLegacyFormat(string inputFile, options* opts){ |
126 | 125 | try{ |
127 | 126 | // Get Joint Name |
128 | 127 | opts->jointName.push_back(tokenizedString[1]); |
129 | | -// opts->jointNode.push_back(atof(tokenizedString[2].c_str())); |
130 | | - opts->jointNode.push_back(tokenizedString[2]); |
| 128 | + |
| 129 | + // The legacy input files included a "joint node", but it is |
| 130 | + // never utilized in simulation. The legacy behavior was, instead |
| 131 | + // to simply associate each joint with the sequentially listed |
| 132 | + // nodeXcoord, nodeYcoord, and nodeZcoord. |
| 133 | + // |
| 134 | + // To preserve this legacy behavior, we're not going to deserialize |
| 135 | + // the jointNode. Instead, we're going to replace "jointNode" with |
| 136 | + // the sequential node item name. That's **wrong** -- we should be |
| 137 | + // using "jointNode"! |
| 138 | + // But! it preserves the legacy behavior of the existing legacy |
| 139 | + // options files when we refactor the actual utilization of the |
| 140 | + // options to use the jointNode. |
| 141 | + // |
| 142 | + // The actual population of the jointNode option is done in a |
| 143 | + // post-processing step after we finish processing the file. |
131 | 144 | opts->jointInletName.push_back(tokenizedString[3]); |
132 | 145 | opts->jointOutletName.push_back(tokenizedString[4]); |
| 146 | + |
133 | 147 | }catch(...){ |
134 | 148 | throw cvException(string("ERROR: Invalid JOINT Format. Line " + to_string(lineCount) + "\n").c_str()); |
135 | 149 | } |
@@ -258,22 +272,13 @@ void readOptionsLegacyFormat(string inputFile, options* opts){ |
258 | 272 | }else if(tokenizedString.size() < 2){ |
259 | 273 | throw cvException(string("ERROR: Not enough parameters for OUTPUT token. Line " + to_string(lineCount) + "\n").c_str()); |
260 | 274 | } |
261 | | - // Output Type |
262 | | - if(upper_string(tokenizedString[1]) == "TEXT"){ |
263 | | - cvOneDGlobal::outputType = OutputTypeScope::OUTPUT_TEXT; |
264 | | - }else if(upper_string(tokenizedString[1]) == "VTK"){ |
265 | | - cvOneDGlobal::outputType = OutputTypeScope::OUTPUT_VTK; |
266 | | - }else if(upper_string(tokenizedString[1]) == "BOTH"){ |
267 | | - cvOneDGlobal::outputType = OutputTypeScope::OUTPUT_BOTH; |
268 | | - }else{ |
269 | | - throw cvException("ERROR: Invalid OUTPUT Type.\n"); |
270 | | - } |
| 275 | + |
| 276 | + // Collect and store the output type data |
| 277 | + opts->outputType = tokenizedString[1]; |
271 | 278 | if(tokenizedString.size() > 2){ |
272 | | - cvOneDGlobal::vtkOutputType = atoi(tokenizedString[2].c_str()); |
273 | | - if(cvOneDGlobal::vtkOutputType > 1){ |
274 | | - throw cvException("ERROR: Invalid OUTPUT VTK Type.\n"); |
275 | | - } |
| 279 | + opts->vtkOutputType = atoi(tokenizedString[2].c_str()); |
276 | 280 | } |
| 281 | + |
277 | 282 | }else if(upper_string(tokenizedString[0]) == std::string("DATATABLE")){ |
278 | 283 | // printf("Found Data Table.\n"); |
279 | 284 | try{ |
@@ -361,6 +366,17 @@ void readOptionsLegacyFormat(string inputFile, options* opts){ |
361 | 366 | // Increment Line Count |
362 | 367 | lineCount++; |
363 | 368 | } |
| 369 | + |
| 370 | + // Post-process: to preserve legacy behavior, we're |
| 371 | + // making each joint node the corresponding sequential |
| 372 | + // node from the node array. See comment above for additional details. |
| 373 | + if(opts->jointName.size() > opts->nodeName.size()){ |
| 374 | + throw cvException("ERROR: there must be at least as many nodes as there are joints.\n"); |
| 375 | + } |
| 376 | + for(size_t k = 0; k < opts->jointName.size(); ++k){ |
| 377 | + opts->jointNode.push_back(opts->nodeName.at(k)); |
| 378 | + } |
| 379 | + |
364 | 380 | // Close File |
365 | 381 | infile.close(); |
366 | 382 | } |
|
0 commit comments