cgma
|
00001 /******************************************************************************* 00002 COPYRIGHT 2002 CATERPILLAR INC. ALL RIGHTS RESERVED 00003 00004 This program is the property of Caterpillar Inc., includes Caterpillar's 00005 confidential and trade secret information, and is maintained as an 00006 unpublished copyrighted work. It is not to be copied or used by others 00007 except under license from Caterpillar. This program is also protected as an 00008 unpublished work in accordance with the copyright act of 1976. In the event 00009 of either inadvertent or deliberate publication, Caterpillar Inc. intends to 00010 maintain copyright protection for this work under the relevant copyright 00011 laws pertaining to published works. The inclusion of a copyright notice 00012 hereon is precautionary only, and does not imply publication or disclosure. 00013 00014 00015 Filename : CCubitFile.cpp 00016 00017 Purpose : Implements reading and writing data in the Cubit file format. 00018 00019 Special Notes : 00020 00021 Creator : Will A. Helden 00022 00023 Creation Date : 02/15/02 00024 00025 Owner : Will A. Helden 00026 00027 *******************************************************************************/ 00028 00029 #include "CCubitFile.hpp" 00030 #include "CubitDefines.h" 00031 #include "CubitFileIOWrapper.hpp" 00032 #include "CubitFileMetaData.hpp" 00033 #include "CubitFileFEModel.hpp" 00034 #include "CubitFileSimModel.hpp" 00035 #include <cstring> 00036 #include "CubitFileUtil.hpp" 00037 00038 using namespace NCubitFile; 00039 00041 // Construction/Destruction 00043 00044 /* Note: some platforms define both BIG_ENDIAN and LITTLE_ENDIAN 00045 so don't do if defined(LITTLE_ENDIAN) here. Compare to BYTE_ORDER instead. */ 00046 #if defined(_WIN32) || defined(__LITTLE_ENDIAN__) || defined(CUBIT_LINUX) || (defined(LITTLE_ENDIAN) && (BYTE_ORDER==LITTLE_ENDIAN)) /* should be little endian platforms */ 00047 const UnsignedInt32 CCubitFile::mintNativeEndian = 0; 00048 #else // big endian platforms 00049 const UnsignedInt32 CCubitFile::mintNativeEndian = 0xFFFFFFFF; 00050 #endif 00051 const UnsignedInt32 CCubitFile::mintSizeOfContents = 00052 sizeof(SCubitFileContentsHeader) / sizeof(UnsignedInt32); 00053 const UnsignedInt32 CCubitFile::mintSizeOfModel = 00054 sizeof(SCubitFileModelEntry) / sizeof(UnsignedInt32); 00055 00056 CCubitFile::CCubitFile() 00057 { 00058 meErrorState = eSuccess; 00059 mintNextModelID = 1; 00060 00061 mpaReadModels = mpaWriteModels = NULL; 00062 mpaReadModelStat = NULL; 00063 mpMetaData = NULL; 00064 mstrReadFileName = mstrWriteFileName = mstrBackupFileName = NULL; 00065 mpReadFEModel = mpWriteFEModel = NULL; 00066 mpReadSimModel = mpWriteSimModel = NULL; 00067 00068 mModelBuff.mintNumModels = 0; 00069 mModelBuff.mpaModelData = NULL; 00070 } 00071 00072 CCubitFile::~CCubitFile() 00073 { 00074 // auto-save? 00075 // delete incomplete temp files 00076 FreeAll(); 00077 00078 // Assume if any FE models are still around now (i.e. EndRead/Write hasn't 00079 // been called) there was an error, so free their memory. 00080 if(mpReadFEModel) 00081 delete mpReadFEModel; 00082 if(mpWriteFEModel) 00083 delete mpWriteFEModel; 00084 if(mpReadSimModel) 00085 delete mpReadSimModel; 00086 if(mpWriteSimModel) 00087 delete mpWriteSimModel; 00088 00089 if(mModelBuff.mpaModelData) 00090 delete [] mModelBuff.mpaModelData; 00091 } 00092 00093 void CCubitFile::FreeAll() 00094 // Frees all allocated memory, closes open files, and resets class members to 00095 // their constructed state. 00096 { 00097 // Free all allocated memory. 00098 if(mstrReadFileName) 00099 delete [] mstrReadFileName; 00100 if(mstrWriteFileName) 00101 delete [] mstrWriteFileName; 00102 if(mstrBackupFileName) 00103 delete [] mstrBackupFileName; 00104 mstrReadFileName = mstrWriteFileName = mstrBackupFileName = NULL; 00105 if(mpaReadModels) 00106 delete [] mpaReadModels; 00107 if(mpaWriteModels) 00108 delete [] mpaWriteModels; 00109 mpaReadModels = mpaWriteModels = NULL; 00110 if(mpaReadModelStat) 00111 delete [] mpaReadModelStat; 00112 mpaReadModelStat = NULL; 00113 if(mpMetaData) 00114 delete mpMetaData; 00115 mpMetaData = NULL; 00116 00117 // Close any open files. 00118 try { 00119 if(mpReadFile) 00120 mpReadFile.close(); 00121 if(mpWriteFile) 00122 mpWriteFile.close(); 00123 } 00124 catch(...) { } 00125 } 00126 00127 CCubitFile::EErrorCode CCubitFile::Open(const char* xstrReadFileName, 00128 const char* xstrWriteFileName, 00129 const char* xstrBackupFileName) 00130 // Open a file for reading or writing. 00131 // === NOTES === 00132 // * The read file is a file to be read only. The file must exist and be 00133 // accessable or this function will fail. 00134 // * The write file is an output file. The file must be creatable or this 00135 // function will fail. If the file already exists, it will be overwritten. 00136 // If the write file name is the same as the read file name, a temporary 00137 // write file name will be generated to be written to until the completion 00138 // of the write operation at which time the read file will be deleted and 00139 // the write file renamed to take its place. 00140 // * The backup file name is used for preventing the loss of old read files. 00141 // If the read file was to be deleted automatically by a write operation, 00142 // specification of a backup name, will cause the read file to be renamed 00143 // instead. 00144 // * Any of these three filenames may be NULL, but at least one name, read or 00145 // write, must be specified. 00146 { 00147 try { 00148 if(!xstrReadFileName && !xstrWriteFileName) 00149 throw ePassedNullPointer; 00150 00151 mpMetaData = new CMetaData; 00152 00153 // If a file has been designated for reading, copy its name and try to 00154 // open it. 00155 if(xstrReadFileName ) { 00156 UnsignedInt32 lintFileName = std::strlen(xstrReadFileName); 00157 mstrReadFileName = new char[lintFileName + 1]; 00158 std::strcpy(mstrReadFileName, xstrReadFileName); 00159 00160 if( !xstrWriteFileName ) 00161 { 00162 mpReadFile.open(mstrReadFileName, "rb"); 00163 if(!mpReadFile) 00164 throw eFileReadError; 00165 00166 // Test to see if the file is a cubit file... it should begin with 00167 // the string 'CUBE'. 00168 unsigned char lachrMagic[4]; 00169 if(fread(lachrMagic, 1, 4, mpReadFile.file()) != 4) 00170 throw eFileUnrecognizedFormat; 00171 if((lachrMagic[0] != 'C') || (lachrMagic[1] != 'U') || 00172 (lachrMagic[2] != 'B') || (lachrMagic[3] != 'E')) 00173 throw eFileUnrecognizedFormat; 00174 00175 // Load the file's "table of contents". 00176 CIOWrapper lIO(mpReadFile.file(), 4, 0); 00177 lIO.BeginReadBlock(4); 00178 lIO.Read((UnsignedInt32*)&mReadContents, mintSizeOfContents); 00179 lIO.EndReadBlock(); 00180 00181 if(mReadContents.mintHeaderSchema > 0) 00182 throw eFileUnrecognizedFormat; 00183 00184 if(mReadContents.mintNumModels) { 00185 mpaReadModels = 00186 new SCubitFileModelEntry[mReadContents.mintNumModels]; 00187 mpaReadModelStat = new EModelStat[mReadContents.mintNumModels]; 00188 if(!mpaReadModels || !mpaReadModelStat) throw eMemoryError; 00189 00190 lIO.BeginReadBlock(mReadContents.mintModelTableOffset); 00191 lIO.Read((UnsignedInt32*)mpaReadModels, 00192 mReadContents.mintNumModels * mintSizeOfModel); 00193 lIO.EndReadBlock(); 00194 00195 UnsignedInt32 lintMod; 00196 for(lintMod = 0; lintMod < mReadContents.mintNumModels; lintMod++) { 00197 mpaReadModelStat[lintMod] = eStatNotWritten; 00198 if(mpaReadModels[lintMod].mintModelHandle >= mintNextModelID) 00199 mintNextModelID = mpaReadModels[lintMod].mintModelHandle + 1; 00200 } 00201 } 00202 00203 // Read the file-scoped (model) meta-data. 00204 mpMetaData->ReadMetaData(mpReadFile.file(), 00205 mReadContents.mintModelMetaDataOffset, 0, 00206 mReadContents.mintHeaderSourceEndian); 00207 } 00208 else 00209 { 00210 mReadContents.mintHeaderSourceEndian = mintNativeEndian; 00211 mReadContents.mintHeaderSchema = 0; 00212 mReadContents.mintNumModels = 0; 00213 mReadContents.mintModelTableOffset = 0; 00214 mReadContents.mintModelMetaDataOffset = 0; 00215 mReadContents.mintActiveFEModel = 0; 00216 00217 // Copy the backup file name, if specified. 00218 if(xstrBackupFileName) { 00219 UnsignedInt32 lintFileName = std::strlen(xstrBackupFileName); 00220 mstrBackupFileName = new char[lintFileName + 1]; 00221 std::strcpy(mstrBackupFileName, xstrBackupFileName); 00222 } 00223 } 00224 } 00225 else { 00226 // If there wasn't a file to read, initialize the read contents to 00227 // nothing. 00228 mReadContents.mintHeaderSourceEndian = mintNativeEndian; 00229 mReadContents.mintHeaderSchema = 0; 00230 mReadContents.mintNumModels = 0; 00231 mReadContents.mintModelTableOffset = 0; 00232 mReadContents.mintModelMetaDataOffset = 0; 00233 mReadContents.mintActiveFEModel = 0; 00234 } 00235 00236 // If a file has been designated for writing 00237 if(xstrWriteFileName) { 00238 UnsignedInt32 lintFileName = std::strlen(xstrWriteFileName); 00239 mstrWriteFileName = new char[lintFileName + 10]; 00240 00241 // If the read and write file names don't match, then the write 00242 // file can be opened by name. 00243 if(!mstrReadFileName || std::strcmp(mstrReadFileName, xstrWriteFileName)) { 00244 mintWriteTempFile = 0; 00245 std::strcpy(mstrWriteFileName, xstrWriteFileName); 00246 mpWriteFile.open(mstrWriteFileName, "wb"); 00247 } 00248 // Otherwise, generate a temporary file name to write to so that 00249 // the read file's contents will not be destroyed until it is 00250 // verifiable that any new writes are successful. 00251 else { 00252 mintWriteTempFile = 1; 00253 UnsignedInt32 lintTempFile = 0; 00254 while(!mpWriteFile && (lintTempFile < 0xFF)) { 00255 sprintf(mstrWriteFileName, "%s~%.2x.tmp", 00256 mstrReadFileName, lintTempFile); 00257 mpWriteFile.open(mstrWriteFileName, "wb"); 00258 lintTempFile++; 00259 } 00260 } 00261 if(!mpWriteFile) 00262 throw eFileWriteError; 00263 00264 // Initialize the write file contents - copy the model inventory 00265 // (but not actual contents yet) from the read file. 00266 mWriteContents.mintHeaderSourceEndian = mintNativeEndian; 00267 mWriteContents.mintHeaderSchema = 0; 00268 mWriteContents.mintNumModels = mReadContents.mintNumModels; 00269 mWriteContents.mintModelTableOffset = 0; 00270 mWriteContents.mintModelMetaDataOffset = 0; 00271 mWriteContents.mintActiveFEModel = mReadContents.mintActiveFEModel; 00272 mintWriteBuffNumModels = 0; 00273 00274 if(mWriteContents.mintNumModels) { 00275 mpaWriteModels = 00276 new SCubitFileModelEntry[mWriteContents.mintNumModels]; 00277 if(!mpaWriteModels) throw eMemoryError; 00278 00279 UnsignedInt32 lintMod; 00280 for(lintMod = 0; lintMod < mWriteContents.mintNumModels; lintMod++) { 00281 mpaWriteModels[lintMod].mintModelHandle = 00282 mpaReadModels[lintMod].mintModelHandle; 00283 mpaWriteModels[lintMod].mintModelOffset = 0; 00284 mpaWriteModels[lintMod].mintModelLength = 0; 00285 mpaWriteModels[lintMod].mintModelType = 00286 mpaReadModels[lintMod].mintModelType; 00287 mpaWriteModels[lintMod].mintModelOwner = 00288 mpaReadModels[lintMod].mintModelOwner; 00289 } 00290 } 00291 00292 // Initialize the write file by writing its identity and an initial 00293 // table of contents. 00294 CIOWrapper lIO(mpWriteFile.file()); 00295 lIO.BeginWriteBlock(0); 00296 lIO.Write("CUBE", 4); 00297 lIO.Write((UnsignedInt32*)&mWriteContents, mintSizeOfContents); 00298 lIO.EndWriteBlock(); 00299 00300 WriteModelTable(); 00301 } 00302 else { 00303 // If there wasn't a file to written, initialize the write contents 00304 // to nothing. 00305 mWriteContents.mintHeaderSourceEndian = mintNativeEndian; 00306 mWriteContents.mintHeaderSchema = 0; 00307 mWriteContents.mintNumModels = 0; 00308 mWriteContents.mintModelTableOffset = 0; 00309 mWriteContents.mintModelMetaDataOffset = 0; 00310 mWriteContents.mintActiveFEModel = 0; 00311 } 00312 00313 return eSuccess; 00314 } 00315 00316 // Handle all open errors by reseting the file object. 00317 catch(EErrorCode xeErrorCode) { 00318 FreeAll(); 00319 return xeErrorCode; 00320 } 00321 catch(...) { 00322 FreeAll(); 00323 return eUnknownError; 00324 } 00325 } 00326 00327 CCubitFile::EErrorCode CCubitFile::Close() 00328 // Close any open files, completing any pending write operations, and free any 00329 // allocated resources. See Open() comments for more info. 00330 { 00331 try { 00332 00333 if(mpWriteFile) { 00334 // Write file scoped (model) metadata and update the file's table 00335 // of contents one last time. 00336 UnsignedInt32 lintMetaDataLength; 00337 mpMetaData->WriteMetaData(mpWriteFile.file(), 00338 mWriteContents.mintModelMetaDataOffset, lintMetaDataLength); 00339 WriteModelTable(); 00340 00341 // throw away erroneously written files?!? 00342 00343 // If the written file was a temporary file, delete the original 00344 // file and replace it with the temporary file. 00345 if(mintWriteTempFile) { 00346 // Close any open files. 00347 mpReadFile.close(); 00348 mpWriteFile.close(); 00349 00350 // If there was a backup name specified for the old read file 00351 // rename it instead of deleting it. 00352 if(mstrBackupFileName) 00353 CubitFileUtil::rename_file(mstrReadFileName, mstrBackupFileName); 00354 else 00355 CubitFileUtil::remove_file(mstrReadFileName); 00356 if(CUBIT_SUCCESS != CubitFileUtil::rename_file(mstrWriteFileName, mstrReadFileName)) 00357 throw eUnknownError; 00358 } 00359 } 00360 00361 // Close any open files and clean up allocated memory. 00362 FreeAll(); 00363 return eSuccess; 00364 } 00365 catch(EErrorCode xeErrorCode) { 00366 FreeAll(); 00367 return xeErrorCode; 00368 } 00369 catch(...) { 00370 FreeAll(); 00371 return eUnknownError; 00372 } 00373 } 00374 00375 /*UnsignedInt32 CCubitFile::GetModelList(UnsignedInt32& xintNumModels, 00376 const SModelData*& xpaModels) 00377 // Returns a list of all models contained in the file. 00378 { 00379 SCubitFileModelEntry* lpaModels = NULL; 00380 if(mpaWriteModels) { 00381 lpaModels = mpaWriteModels; 00382 xintNumModels = mWriteContents.mintNumModels; 00383 } 00384 else if(mpaReadModels) { 00385 lpaModels = mpaReadModels; 00386 xintNumModels = mReadContents.mintNumModels; 00387 } 00388 00389 if(!lpaModels || !xintNumModels) { 00390 xpaModels = NULL; 00391 return eNotFound; 00392 } 00393 00394 if(mModelBuff.mintNumModels < xintNumModels) { 00395 mModelBuff.mintNumModels = xintNumModels; 00396 if(mModelBuff.mpaModelData) 00397 delete [] mModelBuff.mpaModelData; 00398 mModelBuff.mpaModelData = new SModelData[xintNumModels]; 00399 } 00400 xpaModels = mModelBuff.mpaModelData; 00401 00402 for(UnsignedInt32 lintModel = 0; lintModel < xintNumModels; lintModel++) { 00403 mModelBuff.mpaModelData[lintModel].mintModelHandle = 00404 lpaModels[lintModel].mintModelHandle; 00405 mModelBuff.mpaModelData[lintModel].mintModelType = 00406 lpaModels[lintModel].mintModelType; 00407 mModelBuff.mpaModelData[lintModel].mintModelOwner = 00408 lpaModels[lintModel].mintModelOwner; 00409 } 00410 return eSuccess; 00411 }*/ 00412 00413 UnsignedInt32 CCubitFile::IsModel(HModel xintModel) 00414 { 00415 UnsignedInt32 lintIndex; 00416 if(mWriteContents.mintNumModels) 00417 return FindModel(xintModel, mpaWriteModels, mWriteContents.mintNumModels, lintIndex); 00418 else if(mReadContents.mintNumModels) 00419 return FindModel(xintModel, mpaReadModels, mReadContents.mintNumModels, lintIndex); 00420 return 0; // failure 00421 } 00422 00423 UnsignedInt32 CCubitFile::GetReadModelLength(HModel xintModel, 00424 UnsignedInt32& xintLength) 00425 // Looks up the length of the data block in the cubit filr for the requested 00426 // model. Returns success if the model is found, otherwise an error is returned. 00427 { 00428 UnsignedInt32 lintIndex; 00429 if(FindModel(xintModel, mpaReadModels, mReadContents.mintNumModels, lintIndex)) { 00430 xintLength = mpaReadModels[lintIndex].mintModelLength; 00431 return eSuccess; 00432 } 00433 else { 00434 xintLength = 0; 00435 return eNotFound; 00436 } 00437 } 00438 00439 UnsignedInt32 CCubitFile::CreateModel(EModelType xeModelType, HModel& xintModel) 00440 // Define a new model in the temp file. 00441 { 00442 if(!mpWriteFile) return eFileWriteError; 00443 00444 // Allocate a new bigger model table, copy the existing table (if any) 00445 // into the new one and then replace the old one. 00446 SCubitFileModelEntry* lpaModels = 00447 new SCubitFileModelEntry[mWriteContents.mintNumModels + 1]; 00448 if(!lpaModels) return eMemoryError; 00449 if(mpaWriteModels) { 00450 memcpy(lpaModels, mpaWriteModels, 00451 sizeof(SCubitFileModelEntry) * mWriteContents.mintNumModels); 00452 delete [] mpaWriteModels; 00453 } 00454 mpaWriteModels = lpaModels; 00455 00456 // Initialize the new model's table entry. 00457 mpaWriteModels[mWriteContents.mintNumModels].mintModelHandle = 00458 xintModel;// = mintNextModelID++; 00459 mpaWriteModels[mWriteContents.mintNumModels].mintModelOffset = 0; 00460 mpaWriteModels[mWriteContents.mintNumModels].mintModelLength = 0; 00461 mpaWriteModels[mWriteContents.mintNumModels].mintModelType = xeModelType; 00462 mpaWriteModels[mWriteContents.mintNumModels].mintModelOwner = 0; 00463 mpaWriteModels[mWriteContents.mintNumModels].mintModel64bitOSPad = 0; 00464 mWriteContents.mintNumModels++; 00465 00466 return eSuccess; 00467 } 00468 00469 UnsignedInt32 CCubitFile::DeleteModel(HModel xintModel) 00470 // Flag an model that exists in the read file not to be copied into the write file. 00471 { 00472 if(!mpWriteFile) return eFileWriteError; 00473 00474 // Flag the model in the old file as marked for deletion. 00475 UnsignedInt32 lintIndex; 00476 if(!FindModel(xintModel, mpaReadModels, mReadContents.mintNumModels, lintIndex)) 00477 return eNotFound; 00478 if(mpaReadModelStat[lintIndex] == eStatWritten) 00479 return eOrderError; 00480 mpaReadModelStat[lintIndex] = eStatDelete; 00481 00482 // Remove the model from the write file's table and close up the position in 00483 // the model table (if applicable). 00484 if(FindModel(xintModel, mpaWriteModels, mWriteContents.mintNumModels, lintIndex)) { 00485 mWriteContents.mintNumModels--; 00486 if(mWriteContents.mintNumModels && 00487 (lintIndex < mWriteContents.mintNumModels)) { 00488 for(UnsignedInt32 lintCopyTo = lintIndex; lintCopyTo < 00489 mWriteContents.mintNumModels; lintCopyTo++) { 00490 memcpy(&mpaWriteModels[lintCopyTo], 00491 &mpaWriteModels[lintCopyTo + 1], 00492 sizeof(SCubitFileModelEntry)); 00493 } 00494 } 00495 } 00496 00497 // Find any models that have the deleted model as their owner and reset 00498 // the owner to no owner (0). 00499 if(mWriteContents.mintNumModels) { 00500 for(UnsignedInt32 lintModel = 0; lintModel < 00501 mWriteContents.mintNumModels; lintModel++) { 00502 if(mpaWriteModels[lintModel].mintModelOwner == xintModel) 00503 mpaWriteModels[lintModel].mintModelOwner = 0; 00504 } 00505 } 00506 00507 // Delete any meta-data that belonged with the deleted model. 00508 mpMetaData->ClearMetaDataForID(xintModel); 00509 00510 return eSuccess; 00511 } 00512 00513 UnsignedInt32 CCubitFile::GetModelOwner(HModel xintModel, HModel& xintOwner) 00514 // Return the owning model of the passed model. 00515 { 00516 // Flag the model in the old file as marked for deletion. 00517 UnsignedInt32 lintIndex; 00518 if(!FindModel(xintModel, mpaWriteModels, mWriteContents.mintNumModels, lintIndex)) 00519 return eNotFound; 00520 xintOwner = mpaWriteModels[lintIndex].mintModelOwner; 00521 return eSuccess; 00522 } 00523 00524 UnsignedInt32 CCubitFile::SetModelOwner(HModel xintModel, HModel xintOwner) 00525 // Set the owning model for the passed model. 00526 { 00527 // Flag the model in the old file as marked for deletion. 00528 UnsignedInt32 lintIndex; 00529 if(xintOwner && // don't allow the model to have a non-existant owner. 00530 !FindModel(xintOwner, mpaWriteModels, mWriteContents.mintNumModels, lintIndex)) 00531 return eNotFound; 00532 if(!FindModel(xintModel, mpaWriteModels, mWriteContents.mintNumModels, lintIndex)) 00533 return eNotFound; 00534 mpaWriteModels[lintIndex].mintModelOwner = xintOwner; 00535 return eSuccess; 00536 } 00537 00538 UnsignedInt32 CCubitFile::FindModel(HModel xintModel, 00539 SCubitFileModelEntry* xpaModels, 00540 UnsignedInt32 xintNumModels, 00541 UnsignedInt32& xintIndex) 00542 // Determine the index of the passed model handle in the passed model table. 00543 // Private function, return true/false, no exceptions thrown. 00544 { 00545 if(xintNumModels) { 00546 for(UnsignedInt32 lintMod = 0; lintMod < xintNumModels; lintMod++) { 00547 if(xpaModels[lintMod].mintModelHandle == xintModel) { 00548 xintIndex = lintMod; 00549 return 1; // success 00550 } 00551 } 00552 } 00553 return 0; // failure 00554 } 00555 00556 void CCubitFile::WriteModelTable() 00557 // Write (or rewrite) the model table to the write file. 00558 { 00559 if(!mpWriteFile) throw eFileWriteError; 00560 00561 if(!mWriteContents.mintNumModels) return; // no models... nothing to do! 00562 00563 CIOWrapper lIO(mpWriteFile.file()); 00564 00565 // Write the model table, if the number of models has increased, write the 00566 // table to a new location in the file, otherwise reuse the previous 00567 // table's file space. 00568 if(mWriteContents.mintNumModels > mintWriteBuffNumModels) { 00569 mintWriteBuffNumModels = mWriteContents.mintNumModels; 00570 mWriteContents.mintModelTableOffset = lIO.BeginWriteBlock(); 00571 } 00572 else 00573 lIO.BeginRewriteBlock(mWriteContents.mintModelTableOffset, 0); 00574 lIO.Write((UnsignedInt32*)mpaWriteModels, 00575 mWriteContents.mintNumModels * mintSizeOfModel); 00576 lIO.EndWriteBlock(); 00577 00578 // Rewrite the contents header to reflect any model table changes. 00579 lIO.BeginRewriteBlock(4, 0); 00580 lIO.Write((UnsignedInt32*)&mWriteContents, mintSizeOfContents); 00581 lIO.EndWriteBlock(); 00582 } 00583 00584 void CCubitFile::CopyModel(UnsignedInt32 xintReadOffset, 00585 UnsignedInt32& xintWriteOffset, 00586 UnsignedInt32 xintLength, 00587 FILE* xpReadFile, FILE* xpWriteFile) 00588 // Copy a model from one file to another. The copied model is byte identical 00589 // to the original. 00590 { 00591 // Create a 16 kilobyte memory buffer to try to improve copy IO efficiency 00592 // over a byte-per-byte copy. 00593 char* lpachrCopyBuffer = new char[0x4000]; //16KB 00594 if(!lpachrCopyBuffer) 00595 throw eMemoryError; 00596 00597 // Position the files pointers for the copy. 00598 CIOWrapper lReadIO(xpReadFile); 00599 CIOWrapper lWriteIO(xpWriteFile); 00600 lReadIO.BeginReadBlock(xintReadOffset); 00601 xintWriteOffset = lWriteIO.BeginWriteBlock(); 00602 00603 // Copy the models 16K at a time. 00604 UnsignedInt32 lintRemaining = xintLength; 00605 UnsignedInt32 lintCopyBytes = 0x4000; 00606 while(lintRemaining) { 00607 if(lintRemaining > 0x4000) // More than 16K left, copy 16K. 00608 lintRemaining -= 0x4000; 00609 else { // 16K or less left, copy all of what's left. 00610 lintCopyBytes = lintRemaining; 00611 lintRemaining = 0; 00612 } 00613 lReadIO.Read(lpachrCopyBuffer, lintCopyBytes); 00614 lWriteIO.Write(lpachrCopyBuffer, lintCopyBytes); 00615 } 00616 00617 // Make sure the copy was complete and free the buffer. 00618 lReadIO.EndReadBlock(); 00619 if(lWriteIO.EndWriteBlock() != xintLength) 00620 throw eCorruptBlock; 00621 delete [] lpachrCopyBuffer; 00622 } 00623 00624 00626 // Geometry Model Read/Write 00628 00629 UnsignedInt32 CCubitFile::BeginWriteGeomModel(HModel xintGeomModel, 00630 const char* xstrGeomFile) 00631 // Copy an external geometry file into the cubit file as a geometry model. 00632 { 00633 if(!mpWriteFile) return eFileWriteError; 00634 00635 // Try to open the geometry model file for reading. 00636 CubitFile lpGeomFile(xstrGeomFile, "rb"); 00637 if(!lpGeomFile) 00638 return eFileReadError; 00639 00640 // Determine the size of the geometry file and then copy it into the 00641 // cubit file. 00642 EErrorCode leReturn = eSuccess; 00643 try { 00644 UnsignedInt32 lintReadIndex, lintWriteIndex; 00645 // Locate the model's index in the write contents and make sure it is 00646 // not an FEA model. 00647 if(!FindModel(xintGeomModel, mpaWriteModels, 00648 mWriteContents.mintNumModels, lintWriteIndex)) 00649 throw eNotFound; 00650 if(mpaWriteModels[lintWriteIndex].mintModelType == eFEModel) 00651 throw eNotFound; 00652 // Locate the model's index in the read contents, if possible, and 00653 // make sure the model has not already been written or deleted, and 00654 // then mark it written. 00655 if(FindModel(xintGeomModel, mpaReadModels, 00656 mReadContents.mintNumModels, lintReadIndex)) { 00657 if(mpaReadModelStat[lintReadIndex] != eStatNotWritten) 00658 throw eOrderError; 00659 mpaReadModelStat[lintReadIndex] = eStatWritten; 00660 } 00661 00662 // Measure the length of the geometry model file and then copy it into 00663 // to cubit file. 00664 if(NCubitFile::SetLocation(lpGeomFile.file(), 0, SEEK_END)) 00665 throw CCubitFile::eFileSeekError; 00666 UnsignedInt32 lintGeomLength = GetLocation(lpGeomFile.file()); 00667 CopyModel(0, mpaWriteModels[lintWriteIndex].mintModelOffset, 00668 lintGeomLength, lpGeomFile.file(), mpWriteFile.file()); 00669 mpaWriteModels[lintWriteIndex].mintModelLength = lintGeomLength; 00670 } 00671 catch(EErrorCode xeErrorCode) { leReturn = xeErrorCode; } 00672 catch(...) { leReturn = eUnknownError; } 00673 00674 return leReturn; 00675 } 00676 00677 UnsignedInt32 CCubitFile::EndWriteGeomModel() 00678 // The formal end to a geometry model write. 00679 { 00680 return eSuccess; 00681 } 00682 00683 UnsignedInt32 CCubitFile::BeginReadGeomModel(HModel xintGeomModel, 00684 FILE* xpGeomFile) 00685 // Copy an geometry model out of the cubit file into an external geometry file. 00686 { 00687 if(!mpReadFile) return eFileReadError; 00688 if(!xpGeomFile) return eFileWriteError; 00689 00690 UnsignedInt32 lintStartFilePos = GetLocation(xpGeomFile); 00691 00692 // Determine the size of the geometry file and then copy it into the 00693 // cubit file. 00694 EErrorCode leReturn = eSuccess; 00695 try { 00696 UnsignedInt32 lintReadIndex, lintWriteOffset; 00697 // Locate the model's index in the read contents and make sure it is 00698 // not an FEA model. 00699 if(!FindModel(xintGeomModel, mpaReadModels, 00700 mReadContents.mintNumModels, lintReadIndex)) 00701 throw eNotFound; 00702 if(mpaReadModels[lintReadIndex].mintModelType == eFEModel) 00703 throw eNotFound; 00704 00705 // Copy the geometry model file out of the cubit file. 00706 CopyModel(mpaReadModels[lintReadIndex].mintModelOffset, 00707 lintWriteOffset, mpaReadModels[lintReadIndex].mintModelLength, 00708 mpReadFile.file(), xpGeomFile); 00709 } 00710 catch(EErrorCode xeErrorCode) { leReturn = xeErrorCode; } 00711 catch(...) { leReturn = eUnknownError; } 00712 00713 NCubitFile::SetLocation(xpGeomFile, lintStartFilePos, SEEK_SET); 00714 return leReturn; 00715 } 00716 00717 UnsignedInt32 CCubitFile::EndReadGeomModel() 00718 // The formal end to a geometry model read. 00719 { 00720 return eSuccess; 00721 } 00722 00723 00724 UnsignedInt32 CCubitFile::BeginWriteModel(HModel xintModelId, EModelType type, 00725 FILE*& writeable_file) 00726 { 00727 // Let's not return a FILE* until we know it's going to be OK to write to. 00728 writeable_file = NULL; 00729 00730 if(!mpWriteFile) 00731 return eFileWriteError; 00732 00733 EErrorCode leReturn = eSuccess; 00734 try 00735 { 00736 UnsignedInt32 lintReadIndex, lintWriteIndex; 00737 // Locate the model's index in the write contents and make sure it is 00738 // the right kind of model. 00739 if(!FindModel(xintModelId, 00740 mpaWriteModels, 00741 mWriteContents.mintNumModels, 00742 lintWriteIndex)) 00743 throw eNotFound; 00744 00745 if(mpaWriteModels[lintWriteIndex].mintModelType != type) 00746 throw eNotFound; 00747 00748 // Locate the model's index in the read contents, if possible, and 00749 // make sure the model has not already been written or deleted, and 00750 // then mark it as being written. 00751 if(FindModel(xintModelId, mpaReadModels, 00752 mReadContents.mintNumModels, lintReadIndex)) 00753 { 00754 if(mpaReadModelStat[lintReadIndex] != eStatNotWritten) 00755 throw eOrderError; 00756 mpaReadModelStat[lintReadIndex] = eStatWriting; 00757 } 00758 00759 // Move the FILE* to the correct write position so the FILE* 00760 // can be written to directly. From CopyFile, it looks like the 00761 // correct location is the end of the file. 00762 if (NCubitFile::SetLocation(mpWriteFile.file(), 0, SEEK_END)) 00763 throw eFileSeekError; 00764 00765 // Save our current FILE* position so we can detect the size of 00766 // data written to the model. 00767 mpaWriteModels[lintWriteIndex].mintModelOffset = GetLocation(mpWriteFile.file()); 00768 00769 // set the FILE* 00770 writeable_file = mpWriteFile.file(); 00771 } 00772 catch(EErrorCode xeErrorCode) 00773 { leReturn = xeErrorCode; } 00774 catch(...) 00775 { leReturn = eUnknownError; } 00776 00777 return leReturn; 00778 } 00779 00780 UnsignedInt32 CCubitFile::EndWriteModel(HModel xintModelId) 00781 { 00782 if (!mpWriteFile) 00783 return eFileWriteError; 00784 00785 // Find the model's write record 00786 UnsignedInt32 lintWriteIndex; 00787 if(!FindModel(xintModelId, 00788 mpaWriteModels, 00789 mWriteContents.mintNumModels, 00790 lintWriteIndex)) 00791 return eNotFound; 00792 00793 // Make sure we saved the start position 00794 if (mpaWriteModels[lintWriteIndex].mintModelOffset == 0) 00795 return eOrderError; 00796 00797 // Get the end of the FILE. 00798 if (NCubitFile::SetLocation(mpWriteFile.file(), 0, SEEK_END)) 00799 return eFileSeekError; 00800 UnsignedInt32 cur_pos = GetLocation(mpWriteFile.file()); 00801 00802 // See how many bytes that is past our saved position. 00803 UnsignedInt32 size_in_bytes = cur_pos - mpaWriteModels[lintWriteIndex].mintModelOffset; 00804 00805 // Locate the model's index in the read contents, if possible, and 00806 // make sure the model has not already been written or deleted, and 00807 // then mark it as written. 00808 UnsignedInt32 lintReadIndex; 00809 if(FindModel(xintModelId, mpaReadModels, 00810 mReadContents.mintNumModels, lintReadIndex)) 00811 { 00812 if(mpaReadModelStat[lintReadIndex] != eStatWriting) 00813 throw eOrderError; 00814 mpaReadModelStat[lintReadIndex] = eStatWritten; 00815 } 00816 00817 // Save the size to the model header. 00818 mpaWriteModels[lintWriteIndex].mintModelLength = size_in_bytes; 00819 00820 return eSuccess; 00821 } 00822 00823 // Returns a FILE* that can be read from. The FILE* will NOT return EOF 00824 // at the end of the data...the reader should not go GetReadModelLength() 00825 // bytes beyond the current FILE* position. You should copy the contents 00826 // to another FILE if this is an issue for the reader. 00827 UnsignedInt32 CCubitFile::BeginReadModel(HModel xintModelId, EModelType type, 00828 FILE*& f) 00829 { 00830 f = NULL; 00831 00832 if(!mpReadFile) 00833 return eFileReadError; 00834 00835 // Determine the size of the geometry file and then copy it into the 00836 // cubit file. 00837 EErrorCode leReturn = eSuccess; 00838 try 00839 { 00840 UnsignedInt32 lintReadIndex; 00841 // Locate the model's index in the read contents and make sure it is 00842 // an assembly model. 00843 if(!FindModel(xintModelId, mpaReadModels, 00844 mReadContents.mintNumModels, lintReadIndex)) 00845 throw eNotFound; 00846 if(mpaReadModels[lintReadIndex].mintModelType != type) 00847 throw eNotFound; 00848 00849 // Set the read pointer to the correct location 00850 NCubitFile::SetLocation(mpReadFile.file(), mpaReadModels[lintReadIndex].mintModelOffset, SEEK_SET); 00851 00852 // Set the FILE* 00853 f = mpReadFile.file(); 00854 } 00855 catch(EErrorCode xeErrorCode) 00856 { leReturn = xeErrorCode; } 00857 catch(...) 00858 { leReturn = eUnknownError; } 00859 00860 return leReturn; 00861 } 00862 00863 UnsignedInt32 CCubitFile::EndReadModel() 00864 { 00865 return eSuccess; 00866 } 00867 00868 00870 // FEA Model Read/Write 00872 00873 UnsignedInt32 CCubitFile::BeginWriteFEModel(HModel xintFEModel, 00874 UnsignedInt32 xintGeomCount, 00875 UnsignedInt32 xintGroupCount, 00876 UnsignedInt32 xintBlockCount, 00877 UnsignedInt32 xintNodeSetCount, 00878 UnsignedInt32 xintSideSetCount) 00879 // Prepares the file for the writing of a FEA model. After this call there 00880 // should be no other write oprations on the file not associated with the 00881 // writing of the FEA model until a matching call is made to EndWriteFEModel. 00882 // RETURNS: 0 on success, other values indicate error code. 00883 { 00884 try { 00885 if(!mpWriteFile) throw eFileWriteError; 00886 if(mpWriteFEModel) throw eOrderError; 00887 00888 // Write the model table first to try to guarentee that it will be 00889 // at the beginning of the file. 00890 WriteModelTable(); 00891 00892 // Lookup the requested model in the model table and make sure it is 00893 // an FEA model. 00894 if(!FindModel(xintFEModel, mpaWriteModels, mWriteContents.mintNumModels, 00895 mintFEModelIndex)) 00896 throw eNotFound; 00897 if(mpaWriteModels[mintFEModelIndex].mintModelType != eFEModel) 00898 throw eNotFound; 00899 00900 // Create the object that manages FEA model file transactions and have 00901 // it begin its model write. 00902 mpWriteFEModel = new CFEModel(); 00903 if(!mpWriteFEModel) 00904 throw eMemoryError; 00905 00906 mpaWriteModels[mintFEModelIndex].mintModelOffset = 00907 mpWriteFEModel->InitWrite(mpWriteFile.file(), xintGeomCount, xintGroupCount, 00908 xintBlockCount, xintNodeSetCount, xintSideSetCount); 00909 return eSuccess; 00910 } 00911 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 00912 catch(...) { return eUnknownError; } 00913 } 00914 00915 // Try to write the nodes for the passed geometry index/ID to the writable file 00916 UnsignedInt32 CCubitFile::WriteNodes(UnsignedInt32 xintIndex, 00917 UnsignedInt32 xintGeomID, 00918 UnsignedInt32 xintNodeCount, 00919 UnsignedInt32 *xpaintNodeIDs, 00920 double *xpadblX, 00921 double *xpadblY, 00922 double *xpadblZ) 00923 { 00924 try 00925 { 00926 if(!mpWriteFEModel) 00927 throw eOrderError; 00928 mpWriteFEModel->WriteNodes(xintIndex, xintGeomID, 00929 xintNodeCount, xpaintNodeIDs, 00930 xpadblX, xpadblY, xpadblZ); 00931 } 00932 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 00933 catch(...) { return eUnknownError; } 00934 return eSuccess; 00935 } 00936 00937 UnsignedInt32 CCubitFile::WriteElems(UnsignedInt32 xintIndex, 00938 UnsignedInt32 xintNumTypes, 00939 SElemData* xpaElemData) 00940 // Try to write the element connectivity for the passed geometry index/ID 00941 // to the writable file. 00942 { 00943 try { 00944 if(!mpWriteFEModel) 00945 throw eOrderError; 00946 mpWriteFEModel->WriteElems(xintIndex, xintNumTypes, xpaElemData); 00947 return eSuccess; 00948 } 00949 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 00950 catch(...) { return eUnknownError; } 00951 } 00952 00953 UnsignedInt32 CCubitFile::WriteGroup(UnsignedInt32 xintIndex, 00954 UnsignedInt32 xintGroupID, 00955 UnsignedInt32 xintGroupType, 00956 ConstCharPtr xpachrGroupName, 00957 UnsignedInt32 xintNumTypes, 00958 SGroupData* xpaGroupData) 00959 // Try to write the membership of the passed group index to the writable file. 00960 // RETURNS: 0 on success, other values indicate error code. 00961 { 00962 try { 00963 if(!mpWriteFEModel) 00964 throw eOrderError; 00965 mpWriteFEModel->WriteGroup(xintIndex, xintGroupID, 00966 xintGroupType, xpachrGroupName, xintNumTypes, xpaGroupData); 00967 return eSuccess; 00968 } 00969 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 00970 catch(...) { return eUnknownError; } 00971 } 00972 00973 UnsignedInt32 CCubitFile::WriteBlock(UnsignedInt32 xintIndex, 00974 UnsignedInt32 xintBlockID, 00975 int unique_id, 00976 UnsignedInt32 xintBlockType, 00977 UnsignedInt32 xintBlockColor, 00978 UnsignedInt32 xintMixedElemType, 00979 UnsignedInt32 xintDefPyramidType, 00980 UnsignedInt32 xintMaterialID, 00981 UnsignedInt32 xintBlockDimension, 00982 UnsignedInt32 xintNumTypes, 00983 SBlockData* xpaBlockData, 00984 UnsignedInt32 xintAttributeOrder, 00985 double* xpadblAttributes) 00986 // Try to write the membership of the passed group index to the writable file. 00987 // RETURNS: 0 on success, other values indicate error code. 00988 { 00989 try { 00990 if(!mpWriteFEModel) 00991 throw eOrderError; 00992 mpWriteFEModel->WriteBlock(xintIndex, xintBlockID, unique_id, xintBlockType, 00993 xintBlockColor, xintMixedElemType, xintDefPyramidType, 00994 xintMaterialID, xintBlockDimension, xintNumTypes, xpaBlockData, 00995 xintAttributeOrder, xpadblAttributes); 00996 return eSuccess; 00997 } 00998 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 00999 catch(...) { return eUnknownError; } 01000 } 01001 01002 UnsignedInt32 CCubitFile::WriteNodeSet(UnsignedInt32 xintIndex, 01003 UnsignedInt32 xintNodeSetID, 01004 int unique_id, 01005 UnsignedInt32 xintColor, 01006 UnsignedInt32 xintPointSymbol, 01007 UnsignedInt32 xintNumTypes, 01008 SNodeSetData* xpaNodeSetData, 01009 const std::vector<char>& bcdata) 01010 // Try to write the membership of the passed group index to the writable file. 01011 // RETURNS: 0 on success, other values indicate error code. 01012 { 01013 try { 01014 if(!mpWriteFEModel) 01015 throw eOrderError; 01016 mpWriteFEModel->WriteNodeSet(xintIndex, xintNodeSetID, unique_id, xintColor, 01017 xintPointSymbol, xintNumTypes, xpaNodeSetData, bcdata); 01018 return eSuccess; 01019 } 01020 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01021 catch(...) { return eUnknownError; } 01022 } 01023 01024 UnsignedInt32 CCubitFile::WriteSideSet_11(UnsignedInt32 xintIndex, 01025 UnsignedInt32 xintSideSetID, 01026 int unique_id, 01027 UnsignedInt32 xintColor, 01028 UnsignedInt32 xintUseShells, 01029 UnsignedInt32 xintNumTypes, 01030 SSideSetData_11* xpaSideSetData, 01031 UnsignedInt32 xintNumDistFact, 01032 double* xpadblDistribution, 01033 const std::vector<char>& bcdata) 01034 // Try to write the membership of the passed group index to the writable file. 01035 // RETURNS: 0 on success, other values indicate error code. 01036 { 01037 try { 01038 if(!mpWriteFEModel) 01039 throw eOrderError; 01040 mpWriteFEModel->WriteSideSet_11(xintIndex, xintSideSetID, unique_id, xintColor, 01041 xintUseShells, xintNumTypes, xpaSideSetData, xintNumDistFact, 01042 xpadblDistribution, bcdata); 01043 return eSuccess; 01044 } 01045 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01046 catch(...) { return eUnknownError; } 01047 } 01048 01049 UnsignedInt32 CCubitFile::EndWriteFEModel() 01050 // Designate the end of writing a FEA model and free any memory allocated for 01051 // the write operations and update the file contents header. 01052 // RETURNS: 0 on success, other values indicate error code. 01053 { 01054 try { 01055 if(!mpWriteFEModel) 01056 throw eOrderError; 01057 mpaWriteModels[mintFEModelIndex].mintModelLength = 01058 mpWriteFEModel->EndWrite(); 01059 delete mpWriteFEModel; 01060 mpWriteFEModel = NULL; 01061 01062 UnsignedInt32 lintReadIndex; 01063 if(FindModel(mpaWriteModels[mintFEModelIndex].mintModelHandle, 01064 mpaReadModels, mReadContents.mintNumModels, lintReadIndex)) 01065 mpaReadModelStat[lintReadIndex] = eStatWritten; 01066 01067 return eSuccess; 01068 } 01069 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01070 catch(...) { return eUnknownError; } 01071 } 01072 01073 //----------------------------------------------------------------------------- 01074 01075 UnsignedInt32 CCubitFile::BeginReadFEModel(HModel xintFEModel, 01076 UnsignedInt32& xintGeomCount, 01077 UnsignedInt32& xintGroupCount, 01078 UnsignedInt32& xintBlockCount, 01079 UnsignedInt32& xintNodeSetCount, 01080 UnsignedInt32& xintSideSetCount) 01081 // Prepares the file for the reading of a FEA model. After this call there 01082 // should be no other read oprations on the file not associated with the 01083 // reading of the FEA model until a matching call is made to EndReadFEModel. 01084 // RETURNS: 0 on success, other values indicate error code. 01085 { 01086 try { 01087 if(!mpReadFile) throw eFileReadError; 01088 if(mpReadFEModel) throw eOrderError; 01089 01090 UnsignedInt32 lintIndex; 01091 if(!FindModel(xintFEModel, mpaReadModels, mReadContents.mintNumModels, 01092 lintIndex)) 01093 throw eNotFound; 01094 if(mpaReadModels[lintIndex].mintModelType != eFEModel) 01095 throw eNotFound; 01096 01097 mpReadFEModel = new CFEModel(); 01098 if(!mpReadFEModel) throw eMemoryError; 01099 01100 mpReadFEModel->InitRead(mpReadFile.file(), mpaReadModels[lintIndex].mintModelOffset, 01101 xintGeomCount, xintGroupCount, 01102 xintBlockCount, xintNodeSetCount, xintSideSetCount); 01103 return eSuccess; 01104 } 01105 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01106 catch(...) { return eUnknownError; } 01107 } 01108 01109 UnsignedInt32 CCubitFile::ReadNodes(UnsignedInt32 xintIndex, 01110 UnsignedInt32& xintGeomID, 01111 UnsignedInt32& xintNodeCount, 01112 UnsignedInt32*& xpaintNodeIDs, 01113 double*& xpadblX, 01114 double*& xpadblY, 01115 double*& xpadblZ) 01116 // Try to read the nodes for the passed geometry index/ID from the 01117 // read-only file. 01118 // RETURNS: 0 on success, other values indicate error code. 01119 { 01120 UnsignedInt32 lintErrorCode; 01121 try { 01122 if(!mpReadFEModel) 01123 throw eOrderError; 01124 mpReadFEModel->ReadNodes(xintIndex, xintGeomID, 01125 xintNodeCount, xpaintNodeIDs, xpadblX, xpadblY, xpadblZ); 01126 return eSuccess; 01127 } 01128 catch(EErrorCode xeErrorCode) { 01129 lintErrorCode = xeErrorCode; 01130 } 01131 catch(...) { 01132 lintErrorCode = eUnknownError; 01133 } 01134 xintNodeCount = 0; 01135 xpaintNodeIDs = NULL; 01136 xpadblX = xpadblY = xpadblZ = NULL; 01137 return lintErrorCode; 01138 } 01139 01140 UnsignedInt32 CCubitFile::ReadElems(HModel meshModelId, 01141 UnsignedInt32 xintIndex, 01142 UnsignedInt32& xintGeomID, 01143 UnsignedInt32& xintNumTypes, 01144 SElemData*& xpaElemData) 01145 // Try to read the element connectivity for the passed geometry index/ID 01146 // from the read-only file. 01147 // RETURNS: 0 on success, other values indicate error code. 01148 { 01149 UnsignedInt32 lintErrorCode; 01150 try { 01151 01152 CMetaData *mmd = NULL; 01153 this->GetReadMetaData(CCubitFile::eModelMetaData, mmd); 01154 if( !mmd ) 01155 { 01156 throw eFileReadError; 01157 } 01158 01159 // get the data version from the file. 01160 // Version 1.0 has an old element type enum 01161 double data_version = 0.0; 01162 mmd->GetValue(meshModelId, "DataVersion", data_version); 01163 01164 if(!mpReadFEModel) 01165 throw eOrderError; 01166 mpReadFEModel->ReadElems(data_version, xintIndex, xintGeomID, 01167 xintNumTypes, xpaElemData); 01168 return eSuccess; 01169 } 01170 catch(EErrorCode xeErrorCode) { 01171 lintErrorCode = xeErrorCode; 01172 } 01173 catch(...) { 01174 lintErrorCode = eUnknownError; 01175 } 01176 xintNumTypes = 0; 01177 xpaElemData = NULL; 01178 return lintErrorCode; 01179 } 01180 01181 UnsignedInt32 CCubitFile::ReadGroupIdentity(UnsignedInt32 xintIndex, 01182 UnsignedInt32& xintGroupID, 01183 UnsignedInt32& xintGroupType, 01184 ConstCharPtr& xpachrGroupName) 01185 // Try to read the identity (ID, name, type) of the passed group index from the 01186 // read-only file. 01187 // RETURNS: 0 on success, other values indicate error code. 01188 { 01189 UnsignedInt32 lintErrorCode; 01190 try { 01191 if(!mpReadFEModel) 01192 throw eOrderError; 01193 mpReadFEModel->ReadGroupIdentity(xintIndex, 01194 xintGroupID, xintGroupType, xpachrGroupName); 01195 return eSuccess; 01196 } 01197 catch(EErrorCode xeErrorCode) { 01198 lintErrorCode = xeErrorCode; 01199 } 01200 catch(...) { 01201 lintErrorCode = eUnknownError; 01202 } 01203 xintGroupID = xintGroupType = 0; 01204 xpachrGroupName = NULL; 01205 return lintErrorCode; 01206 } 01207 01208 UnsignedInt32 CCubitFile::ReadGroupMembers(UnsignedInt32 xintIndex, 01209 UnsignedInt32& xintNumTypes, 01210 SGroupData*& xpaGroupData) 01211 // Try to read the membership of the passed group index from the read-only file. 01212 // Note: The 01213 // RETURNS: 0 on success, other values indicate error code. 01214 { 01215 UnsignedInt32 lintErrorCode; 01216 try { 01217 if(!mpReadFEModel) 01218 throw eOrderError; 01219 mpReadFEModel->ReadGroupMembers(xintIndex, xintNumTypes, xpaGroupData); 01220 return eSuccess; 01221 } 01222 catch(EErrorCode xeErrorCode) { 01223 lintErrorCode = xeErrorCode; 01224 } 01225 catch(...) { 01226 lintErrorCode = eUnknownError; 01227 } 01228 xintNumTypes = 0; 01229 xpaGroupData = NULL; 01230 return lintErrorCode; 01231 } 01232 01233 UnsignedInt32 CCubitFile::ReadBlock(UnsignedInt32 xintIndex, 01234 UnsignedInt32& xintBlockID, 01235 int& unique_id, 01236 UnsignedInt32& xintBlockType, 01237 UnsignedInt32& xintBlockColor, 01238 UnsignedInt32& xintMixedElemType, 01239 UnsignedInt32& xintDefPyramidType, 01240 UnsignedInt32& xintMaterialID, 01241 UnsignedInt32& xintBlockDimension, 01242 UnsignedInt32& xintNumTypes, 01243 SBlockData*& xpaBlockData, 01244 UnsignedInt32& xintAttributeOrder, 01245 double*& xpadblAttributes) 01246 // Try to read the membership of the passed block index from the read-only file. 01247 // Note: The 01248 // RETURNS: 0 on success, other values indicate error code. 01249 { 01250 UnsignedInt32 lintErrorCode; 01251 try { 01252 if(!mpReadFEModel) 01253 throw eOrderError; 01254 mpReadFEModel->ReadBlock(xintIndex, xintBlockID, unique_id, 01255 xintBlockType, xintBlockColor, xintMixedElemType, 01256 xintDefPyramidType, xintMaterialID, xintBlockDimension, 01257 xintNumTypes, xpaBlockData, xintAttributeOrder, xpadblAttributes); 01258 return eSuccess; 01259 } 01260 catch(EErrorCode xeErrorCode) { 01261 lintErrorCode = xeErrorCode; 01262 } 01263 catch(...) { 01264 lintErrorCode = eUnknownError; 01265 } 01266 xintBlockID = xintBlockType = xintBlockColor = xintMixedElemType = 01267 xintDefPyramidType = xintMaterialID = xintNumTypes = 01268 xintAttributeOrder = 0; 01269 xpaBlockData = NULL; 01270 xpadblAttributes = NULL; 01271 return lintErrorCode; 01272 } 01273 01274 UnsignedInt32 CCubitFile::ReadNodeSet(UnsignedInt32 xintIndex, 01275 UnsignedInt32& xintNodeSetID, 01276 int& unique_id, 01277 UnsignedInt32& xintColor, 01278 UnsignedInt32& xintPointSymbol, 01279 UnsignedInt32& xintNumTypes, 01280 SNodeSetData*& xpaNodeSetData, 01281 std::vector<char>& bcdata) 01282 // Try to read the membership of the passed node set index from the read-only file. 01283 // Note: The 01284 // RETURNS: 0 on success, other values indicate error code. 01285 { 01286 UnsignedInt32 lintErrorCode; 01287 try { 01288 if(!mpReadFEModel) 01289 throw eOrderError; 01290 mpReadFEModel->ReadNodeSet(xintIndex, xintNodeSetID, unique_id, 01291 xintColor, xintPointSymbol, xintNumTypes, xpaNodeSetData, bcdata); 01292 return eSuccess; 01293 } 01294 catch(EErrorCode xeErrorCode) { 01295 lintErrorCode = xeErrorCode; 01296 } 01297 catch(...) { 01298 lintErrorCode = eUnknownError; 01299 } 01300 xintNodeSetID = xintColor = xintPointSymbol = xintNumTypes = 0; 01301 xpaNodeSetData = NULL; 01302 return lintErrorCode; 01303 } 01304 01305 UnsignedInt32 CCubitFile::ReadSideSet_10(UnsignedInt32 xintIndex, 01306 UnsignedInt32& xintSideSetID, 01307 UnsignedInt32& xintColor, 01308 UnsignedInt32& xintUseShells, 01309 UnsignedInt32& xintNumTypes, 01310 SSideSetData_10*& xpaSideSetData, 01311 UnsignedInt32& xintNumDistFact, 01312 double*& xpadblDistribution) 01313 // Try to read the membership of the passed side set index from the read-only file. 01314 // Note: The 01315 // RETURNS: 0 on success, other values indicate error code. 01316 { 01317 UnsignedInt32 lintErrorCode; 01318 try { 01319 if(!mpReadFEModel) 01320 throw eOrderError; 01321 mpReadFEModel->ReadSideSet_10(xintIndex, xintSideSetID, 01322 xintColor, xintUseShells, xintNumTypes, xpaSideSetData, 01323 xintNumDistFact, xpadblDistribution); 01324 return eSuccess; 01325 } 01326 catch(EErrorCode xeErrorCode) { 01327 lintErrorCode = xeErrorCode; 01328 } 01329 catch(...) { 01330 lintErrorCode = eUnknownError; 01331 } 01332 xintSideSetID = xintColor = xintNumTypes = xintNumDistFact = 0; 01333 xpaSideSetData = NULL; 01334 xpadblDistribution = NULL; 01335 return lintErrorCode; 01336 } 01337 01338 UnsignedInt32 CCubitFile::ReadSideSet_11(UnsignedInt32 xintIndex, 01339 UnsignedInt32& xintSideSetID, 01340 int& unique_id, 01341 UnsignedInt32& xintColor, 01342 UnsignedInt32& xintUseShells, 01343 UnsignedInt32& xintNumTypes, 01344 SSideSetData_11*& xpaSideSetData, 01345 UnsignedInt32& xintNumDistFact, 01346 double*& xpadblDistribution, 01347 std::vector<char>& bcdata) 01348 // Try to read the membership of the passed side set index from the read-only file. 01349 // Note: The 01350 // RETURNS: 0 on success, other values indicate error code. 01351 { 01352 UnsignedInt32 lintErrorCode; 01353 try { 01354 if(!mpReadFEModel) 01355 throw eOrderError; 01356 mpReadFEModel->ReadSideSet_11(xintIndex, xintSideSetID, unique_id, 01357 xintColor, xintUseShells, xintNumTypes, xpaSideSetData, 01358 xintNumDistFact, xpadblDistribution, bcdata); 01359 return eSuccess; 01360 } 01361 catch(EErrorCode xeErrorCode) { 01362 lintErrorCode = xeErrorCode; 01363 } 01364 catch(...) { 01365 lintErrorCode = eUnknownError; 01366 } 01367 xintSideSetID = xintColor = xintNumTypes = xintNumDistFact = 0; 01368 xpaSideSetData = NULL; 01369 xpadblDistribution = NULL; 01370 return lintErrorCode; 01371 } 01372 01373 UnsignedInt32 CCubitFile::EndReadFEModel() 01374 // Designate the end of reading a FEA model and free any memory allocated for 01375 // the read operations. 01376 // RETURNS: 0 on success, other values indicate error code. 01377 { 01378 try { 01379 if(!mpReadFEModel) 01380 return eOrderError; 01381 mpReadFEModel->EndRead(); 01382 delete mpReadFEModel; 01383 mpReadFEModel = NULL; 01384 return eSuccess; 01385 } 01386 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01387 catch(...) { return eUnknownError; } 01388 } 01389 01390 UnsignedInt32 CCubitFile::BeginWriteSimModel(HModel xintSimModel, 01391 UnsignedInt32 xintBCCount, 01392 UnsignedInt32 xintICCount, 01393 UnsignedInt32 xintBCSetCount, 01394 UnsignedInt32 xintMaterialCount, 01395 UnsignedInt32 xintAmplitudeCount, 01396 UnsignedInt32 xintConstraintCount) 01397 { 01398 try { 01399 if(!mpWriteFile) throw eFileWriteError; 01400 if(mpWriteSimModel) throw eOrderError; 01401 01402 // Write the model table first to try to guarentee that it will be 01403 // at the beginning of the file. 01404 WriteModelTable(); 01405 01406 // Lookup the requested model in the model table and make sure it is 01407 // an FEA model. 01408 if(!FindModel(xintSimModel, mpaWriteModels, mWriteContents.mintNumModels, 01409 mintSimModelIndex)) 01410 throw eNotFound; 01411 if(mpaWriteModels[mintSimModelIndex].mintModelType != eSimModel) 01412 throw eNotFound; 01413 01414 // Create the object that manages FEA model file transactions and have 01415 // it begin its model write. 01416 mpWriteSimModel = new CSimModel(); 01417 if(!mpWriteSimModel) 01418 throw eMemoryError; 01419 01420 mpaWriteModels[mintSimModelIndex].mintModelOffset = 01421 mpWriteSimModel->InitWrite(mpWriteFile.file(), xintBCCount, 01422 xintICCount, xintBCSetCount, 01423 xintMaterialCount, xintAmplitudeCount, 01424 xintConstraintCount); 01425 return eSuccess; 01426 } 01427 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01428 catch(...) { return eUnknownError; } 01429 } 01430 01431 UnsignedInt32 CCubitFile::WriteBCSet(UnsignedInt32 xintIndex, 01432 UnsignedInt32 xintBCSetID, 01433 UnsignedInt32 xintBCSetUniqueID, 01434 UnsignedInt32 xintBCSetAnalysisType, 01435 UnsignedInt32 xintRestraintTypesCount, 01436 UnsignedInt32 xintLoadTypesCount, 01437 UnsignedInt32 xintContactPairTypesCount, 01438 SBCSetData* xpaBCSetRestraintData, 01439 SBCSetData* xpaBCSetLoadData, 01440 SBCSetData* xpaBCSetContactPairData) 01441 // Try to write the membership of the passed group index to the writable file. 01442 // RETURNS: 0 on success, other values indicate error code. 01443 { 01444 try { 01445 if(!mpWriteSimModel) 01446 throw eOrderError; 01447 01448 mpWriteSimModel->WriteBCSet(xintIndex,xintBCSetID,xintBCSetUniqueID, 01449 xintBCSetAnalysisType,xintRestraintTypesCount,xintLoadTypesCount, 01450 xintContactPairTypesCount,xpaBCSetRestraintData, 01451 xpaBCSetLoadData,xpaBCSetContactPairData); 01452 01453 return eSuccess; 01454 } 01455 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01456 catch(...) { return eUnknownError; } 01457 } 01458 01459 UnsignedInt32 CCubitFile::WriteMaterial(UnsignedInt32 xintIndex, 01460 UnsignedInt32 xintMaterialID, 01461 UnsignedInt32 xintMaterialUniqueID, 01462 UnsignedInt32 xintPropertiesCount, 01463 SMaterialData* xpaMaterialData 01464 ) 01465 { 01466 try { 01467 if(!mpWriteSimModel) 01468 throw eOrderError; 01469 01470 mpWriteSimModel->WriteMaterial(xintIndex,xintMaterialID,xintMaterialUniqueID, 01471 xintPropertiesCount,xpaMaterialData); 01472 01473 return eSuccess; 01474 } 01475 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01476 catch(...) { return eUnknownError; } 01477 } 01478 01479 UnsignedInt32 CCubitFile::WriteConstraint(UnsignedInt32 xintIndex, 01480 UnsignedInt32 xintConstraintID, 01481 UnsignedInt32 xintConstraintUniqueID, 01482 UnsignedInt32 xintConstraintType, 01483 UnsignedInt32 xintIndependentTypeCount, 01484 SConstraintData* xpaIndependentData, 01485 UnsignedInt32 xintDependentTypeCount, 01486 SConstraintData* xpaDependentData 01487 ) 01488 { 01489 try { 01490 if(!mpWriteSimModel) 01491 throw eOrderError; 01492 01493 mpWriteSimModel->WriteConstraint(xintIndex,xintConstraintID,xintConstraintUniqueID, 01494 xintConstraintType,xintIndependentTypeCount,xpaIndependentData, 01495 xintDependentTypeCount,xpaDependentData); 01496 01497 return eSuccess; 01498 } 01499 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01500 catch(...) { return eUnknownError; } 01501 } 01502 01503 UnsignedInt32 CCubitFile::EndWriteSimModel() 01504 { 01505 try { 01506 if(!mpWriteSimModel) 01507 throw eOrderError; 01508 mpaWriteModels[mintSimModelIndex].mintModelLength = 01509 mpWriteSimModel->EndWrite(); 01510 delete mpWriteSimModel; 01511 mpWriteSimModel = NULL; 01512 01513 UnsignedInt32 lintReadIndex; 01514 if(FindModel(mpaWriteModels[mintSimModelIndex].mintModelHandle, 01515 mpaReadModels, mReadContents.mintNumModels, lintReadIndex)) 01516 mpaReadModelStat[lintReadIndex] = eStatWritten; 01517 01518 return eSuccess; 01519 } 01520 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01521 catch(...) { return eUnknownError; } 01522 } 01523 01524 UnsignedInt32 CCubitFile::BeginReadSimModel(HModel xintSimModel, 01525 UnsignedInt32& xintBCCount, 01526 UnsignedInt32& xintICCount, 01527 UnsignedInt32& xintBCSetCount, 01528 UnsignedInt32& xintMaterialCount, 01529 UnsignedInt32& xintAmplitudeCount, 01530 UnsignedInt32& xintConstraintCount) 01531 { 01532 try { 01533 if(!mpReadFile) throw eFileReadError; 01534 if(mpReadSimModel) throw eOrderError; 01535 01536 UnsignedInt32 lintIndex; 01537 if(!FindModel(xintSimModel, mpaReadModels, mReadContents.mintNumModels, 01538 lintIndex)) 01539 throw eNotFound; 01540 if(mpaReadModels[lintIndex].mintModelType != eSimModel) 01541 throw eNotFound; 01542 01543 mpReadSimModel = new CSimModel(); 01544 if(!mpReadSimModel) throw eMemoryError; 01545 01546 mpReadSimModel->InitRead(mpReadFile.file(), mpaReadModels[lintIndex].mintModelOffset, 01547 xintBCCount, xintICCount, xintBCSetCount, 01548 xintMaterialCount, xintAmplitudeCount, 01549 xintConstraintCount); 01550 return eSuccess; 01551 } 01552 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01553 catch(...) { return eUnknownError; } 01554 } 01555 01556 UnsignedInt32 CCubitFile::ReadBCSet(UnsignedInt32 xintIndex, 01557 UnsignedInt32& xintBCSetID, 01558 UnsignedInt32& xintBCSetUniqueID, 01559 UnsignedInt32& xintBCSetAnalysisType, 01560 UnsignedInt32& xintRestraintTypesCount, 01561 UnsignedInt32& xintLoadTypesCount, 01562 UnsignedInt32& xintContactPairTypesCount, 01563 SBCSetData*& xpaBCSetRestraintData, 01564 SBCSetData*& xpaBCSetLoadData, 01565 SBCSetData*& xpaBCSetContactPairData) 01566 // Try to read the membership of the passed node set index from the read-only file. 01567 // Note: The 01568 // RETURNS: 0 on success, other values indicate error code. 01569 { 01570 UnsignedInt32 lintErrorCode; 01571 try { 01572 if(!mpReadSimModel) 01573 throw eOrderError; 01574 01575 mpReadSimModel->ReadBCSet(xintIndex,xintBCSetID,xintBCSetUniqueID, 01576 xintBCSetAnalysisType,xintRestraintTypesCount, 01577 xintLoadTypesCount,xintContactPairTypesCount,xpaBCSetRestraintData, 01578 xpaBCSetLoadData,xpaBCSetContactPairData); 01579 01580 return eSuccess; 01581 } 01582 catch(EErrorCode xeErrorCode) { 01583 lintErrorCode = xeErrorCode; 01584 } 01585 catch(...) { 01586 lintErrorCode = eUnknownError; 01587 } 01588 xintBCSetID = xintBCSetUniqueID = xintBCSetAnalysisType = 0; 01589 xintRestraintTypesCount = xintLoadTypesCount = xintContactPairTypesCount = 0; 01590 xpaBCSetRestraintData = NULL; 01591 xpaBCSetLoadData = NULL; 01592 xpaBCSetContactPairData = NULL; 01593 return lintErrorCode; 01594 } 01595 01596 UnsignedInt32 CCubitFile::ReadMaterial(UnsignedInt32 xintIndex, 01597 UnsignedInt32& xintMaterialID, 01598 UnsignedInt32& xintMaterialUniqueID, 01599 UnsignedInt32& xintPropertiesCount, 01600 SMaterialData*& xpaMaterialData 01601 ) 01602 { 01603 UnsignedInt32 lintErrorCode; 01604 try { 01605 if(!mpReadSimModel) 01606 throw eOrderError; 01607 01608 mpReadSimModel->ReadMaterial(xintIndex,xintMaterialID,xintMaterialUniqueID, 01609 xintPropertiesCount,xpaMaterialData); 01610 01611 return eSuccess; 01612 } 01613 catch(EErrorCode xeErrorCode) { 01614 lintErrorCode = xeErrorCode; 01615 } 01616 catch(...) { 01617 lintErrorCode = eUnknownError; 01618 } 01619 xintMaterialID = xintMaterialUniqueID = xintPropertiesCount = 0; 01620 xpaMaterialData = NULL; 01621 return lintErrorCode; 01622 } 01623 01624 UnsignedInt32 CCubitFile::ReadConstraint(UnsignedInt32 xintIndex, 01625 UnsignedInt32& xintConstraintID, 01626 UnsignedInt32& xintConstraintUniqueID, 01627 UnsignedInt32& xintConstraintType, 01628 UnsignedInt32& xintIndependentTypeCount, 01629 SConstraintData*& xpaIndependentData, 01630 UnsignedInt32& xintDependentTypeCount, 01631 SConstraintData*& xpaDependentData 01632 ) 01633 { 01634 UnsignedInt32 lintErrorCode; 01635 try { 01636 if(!mpReadSimModel) 01637 throw eOrderError; 01638 01639 mpReadSimModel->ReadConstraint(xintIndex,xintConstraintID,xintConstraintUniqueID, 01640 xintConstraintType,xintIndependentTypeCount,xpaIndependentData, 01641 xintDependentTypeCount,xpaDependentData); 01642 01643 return eSuccess; 01644 } 01645 catch(EErrorCode xeErrorCode) { 01646 lintErrorCode = xeErrorCode; 01647 } 01648 catch(...) { 01649 lintErrorCode = eUnknownError; 01650 } 01651 xintConstraintID = xintConstraintUniqueID = xintConstraintType = 0; 01652 xpaIndependentData = xpaDependentData = NULL; 01653 return lintErrorCode; 01654 } 01655 01656 UnsignedInt32 CCubitFile::EndReadSimModel() 01657 { 01658 try { 01659 if(!mpReadSimModel) 01660 return eOrderError; 01661 mpReadSimModel->EndRead(); 01662 delete mpReadSimModel; 01663 mpReadSimModel = NULL; 01664 return eSuccess; 01665 } 01666 catch(EErrorCode xeErrorCode) { return xeErrorCode; } 01667 catch(...) { return eUnknownError; } 01668 } 01669 01671 // Meta-data accessors 01673 01674 UnsignedInt32 CCubitFile::GetReadMetaData(EMetaDataOwnerType xeType, 01675 CMetaData*& xpMetaData) 01676 // Return the requested meta-data object for the read file if possible. 01677 { 01678 xpMetaData = NULL; 01679 if(xeType == eModelMetaData) 01680 xpMetaData = mpMetaData; 01681 else if(mpReadFEModel) { 01682 switch(xeType) { 01683 case eGeomMetaData: 01684 xpMetaData = &mpReadFEModel->GetGeomMetaData(); 01685 break; 01686 case eNodeMetaData: 01687 xpMetaData = &mpReadFEModel->GetNodeMetaData(); 01688 break; 01689 case eElemMetaData: 01690 xpMetaData = &mpReadFEModel->GetElemMetaData(); 01691 break; 01692 case eGroupMetaData: 01693 xpMetaData = &mpReadFEModel->GetGroupMetaData(); 01694 break; 01695 case eBlockMetaData: 01696 xpMetaData = &mpReadFEModel->GetBlockMetaData(); 01697 break; 01698 case eNodeSetMetaData: 01699 xpMetaData = &mpReadFEModel->GetNodeSetMetaData(); 01700 break; 01701 case eSideSetMetaData: 01702 xpMetaData = &mpReadFEModel->GetSideSetMetaData(); 01703 break; 01704 default: 01705 break; 01706 } 01707 } 01708 else if (mpReadSimModel) { 01709 switch (xeType) { 01710 case eBCSetMetaData: 01711 xpMetaData = &mpReadSimModel->GetBCSetMetaData(); 01712 break; 01713 case eMaterialMetaData: 01714 xpMetaData = &mpReadSimModel->GetMaterialMetaData(); 01715 break; 01716 case eConstraintMetaData: 01717 xpMetaData = &mpReadSimModel->GetConstraintMetaData(); 01718 break; 01719 default: 01720 break; 01721 } 01722 } 01723 else 01724 return eOrderError; 01725 return xpMetaData ? eSuccess : eNotFound; 01726 } 01727 01728 UnsignedInt32 CCubitFile::GetWriteMetaData(EMetaDataOwnerType xeType, 01729 CMetaData*& xpMetaData) 01730 // Return the requested meta-data object for the write file if possible. 01731 { 01732 xpMetaData = NULL; 01733 if(xeType == eModelMetaData) 01734 xpMetaData = mpMetaData; 01735 else if(mpWriteFEModel) { 01736 switch(xeType) { 01737 case eGeomMetaData: 01738 xpMetaData = &mpWriteFEModel->GetGeomMetaData(); 01739 break; 01740 case eNodeMetaData: 01741 xpMetaData = &mpWriteFEModel->GetNodeMetaData(); 01742 break; 01743 case eElemMetaData: 01744 xpMetaData = &mpWriteFEModel->GetElemMetaData(); 01745 break; 01746 case eGroupMetaData: 01747 xpMetaData = &mpWriteFEModel->GetGroupMetaData(); 01748 break; 01749 case eBlockMetaData: 01750 xpMetaData = &mpWriteFEModel->GetBlockMetaData(); 01751 break; 01752 case eNodeSetMetaData: 01753 xpMetaData = &mpWriteFEModel->GetNodeSetMetaData(); 01754 break; 01755 case eSideSetMetaData: 01756 xpMetaData = &mpWriteFEModel->GetSideSetMetaData(); 01757 break; 01758 default: 01759 break; 01760 } 01761 } 01762 else if (mpWriteSimModel) { 01763 switch (xeType) { 01764 case eBCSetMetaData: 01765 xpMetaData = &mpWriteSimModel->GetBCSetMetaData(); 01766 break; 01767 case eMaterialMetaData: 01768 xpMetaData = &mpWriteSimModel->GetMaterialMetaData(); 01769 break; 01770 case eConstraintMetaData: 01771 xpMetaData = &mpWriteSimModel->GetConstraintMetaData(); 01772 break; 01773 default: 01774 break; 01775 } 01776 } 01777 else 01778 return eOrderError; 01779 return xpMetaData ? eSuccess : eNotFound; 01780 }