cgma
CubitFileFEModel.cpp
Go to the documentation of this file.
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      : CubitFileFEModel.cpp
00016 
00017  Purpose       : Implements the reading and writing functionality for a FE
00018                  model section of a Cubit (*.cub) format file.
00019            
00020  Special Notes :
00021 
00022  Creator       : Will A. Helden
00023 
00024  Creation Date : 02/15/02
00025 
00026  Owner         : Will A. Helden
00027 
00028 *******************************************************************************/
00029 
00030 #include "CubitFileFEModel.hpp"
00031 #include "CubitFileIOWrapper.hpp"
00032 
00033 using namespace NCubitFile;
00034 
00036 // CFEModel
00038 
00039 // The number of 32 bit words contained int each of the stored structures.
00040 const UnsignedInt32 CFEModel::mintSizeOfFEModelHeader =
00041     sizeof(SCubitFileFEModelHeader) / sizeof(UnsignedInt32);
00042 const UnsignedInt32 CFEModel::mintSizeOfGeomEntry =
00043     sizeof(SCubitFileGeomEntry) / sizeof(UnsignedInt32);
00044 const UnsignedInt32 CFEModel::mintSizeOfGroupEntry =
00045     sizeof(SCubitFileGroupEntry) / sizeof(UnsignedInt32);
00046 const UnsignedInt32 CFEModel::mintSizeOfBlockEntry =
00047     sizeof(SCubitFileBlockEntry) / sizeof(UnsignedInt32);
00048 const UnsignedInt32 CFEModel::mintSizeOfNodeSetEntry =
00049     sizeof(SCubitFileNodeSetEntry) / sizeof(UnsignedInt32);
00050 const UnsignedInt32 CFEModel::mintSizeOfSideSetEntry =
00051     sizeof(SCubitFileSideSetEntry) / sizeof(UnsignedInt32);
00052 
00053 CFEModel::CFEModel()
00054 {
00055     mpReadFile = mpWriteFile = NULL;
00056     mpaGeoms = NULL;
00057     mpaGroups = NULL;
00058     mpaBlocks = NULL;
00059     mpaNodeSets = NULL;
00060     mpaSideSets = NULL;
00061 
00062     mintFEModelOffset = 0;
00063     memset(&mFEModel, 0, sizeof(SCubitFileFEModelHeader));
00064     mFEModel.mintFEModelEndian = CCubitFile::mintNativeEndian;
00065 
00066     // Initialize the return buffers for file data - all memory allocated by
00067     // this object should also be freed up by it.
00068     memset(&mNodeBuff, 0, sizeof(SNodeReturnBuffer));
00069     memset(&mElemBuff, 0, sizeof(SElemReturnBuffer));
00070     memset(&mGroupBuff, 0, sizeof(SGroupReturnBuffer));
00071     memset(&mBlockBuff, 0, sizeof(SBlockReturnBuffer));
00072     memset(&mNodeSetBuff, 0, sizeof(SNodeSetReturnBuffer));
00073     memset(&mSideSetBuff_10, 0, sizeof(SSideSetReturnBuffer_10));
00074     memset(&mSideSetBuff_11, 0, sizeof(SSideSetReturnBuffer_11));
00075 }
00076 
00077 CFEModel::~CFEModel()
00078 {
00079     if(mpaGeoms)
00080         delete [] mpaGeoms;
00081     if(mpaGroups)
00082         delete [] mpaGroups;
00083     if(mpaBlocks)
00084         delete [] mpaBlocks;
00085     if(mpaNodeSets)
00086         delete [] mpaNodeSets;
00087     if(mpaSideSets)
00088         delete [] mpaSideSets;
00089 
00090     if(mNodeBuff.mpaNodeIDs)
00091         delete [] mNodeBuff.mpaNodeIDs;
00092     if(mNodeBuff.mpadblX)
00093         delete [] mNodeBuff.mpadblX;
00094     if(mNodeBuff.mpadblY)
00095         delete [] mNodeBuff.mpadblY;
00096     if(mNodeBuff.mpadblZ)
00097         delete [] mNodeBuff.mpadblZ;
00098     if(mElemBuff.mpaElemData)
00099         delete [] mElemBuff.mpaElemData;
00100     if(mElemBuff.mpaElemIDs)
00101         delete [] mElemBuff.mpaElemIDs;
00102     if(mElemBuff.mpaElemGlobalIDs)
00103         delete [] mElemBuff.mpaElemGlobalIDs;
00104     if(mElemBuff.mpaElemConnect)
00105         delete [] mElemBuff.mpaElemConnect;
00106     if(mGroupBuff.mpaGroupData)
00107         delete [] mGroupBuff.mpaGroupData;
00108     if(mGroupBuff.mpaintMemberIDs)
00109         delete [] mGroupBuff.mpaintMemberIDs;
00110     if(mBlockBuff.mpaBlockData)
00111         delete [] mBlockBuff.mpaBlockData;
00112     if(mBlockBuff.mpaintMemberIDs)
00113         delete [] mBlockBuff.mpaintMemberIDs;
00114     if(mBlockBuff.mpadblAttributes)
00115         delete [] mBlockBuff.mpadblAttributes;
00116     if(mNodeSetBuff.mpaNodeSetData)
00117         delete [] mNodeSetBuff.mpaNodeSetData;
00118     if(mNodeSetBuff.mpaintMemberIDs)
00119         delete [] mNodeSetBuff.mpaintMemberIDs;
00120     
00121     if(mSideSetBuff_10.mpaSideSetData)
00122         delete [] mSideSetBuff_10.mpaSideSetData;
00123     if(mSideSetBuff_10.mpaintMemberIDs)
00124         delete [] mSideSetBuff_10.mpaintMemberIDs; 
00125     if(mSideSetBuff_10.mpachrMemberSense)
00126         delete [] mSideSetBuff_10.mpachrMemberSense;
00127     if(mSideSetBuff_10.mpaintMemberSense)
00128         delete [] mSideSetBuff_10.mpaintMemberSense;
00129     if(mSideSetBuff_10.mpachrMemberSideNum)
00130         delete [] mSideSetBuff_10.mpachrMemberSideNum;
00131     if(mSideSetBuff_10.mpadblDistribution)
00132         delete [] mSideSetBuff_10.mpadblDistribution;
00133     
00134     if(mSideSetBuff_11.mpaSideSetData)
00135         delete [] mSideSetBuff_11.mpaSideSetData;
00136     if(mSideSetBuff_11.mpaintMemberTypes)
00137         delete [] mSideSetBuff_11.mpaintMemberTypes; 
00138     if(mSideSetBuff_11.mpaintMemberIDs)
00139         delete [] mSideSetBuff_11.mpaintMemberIDs; 
00140     if(mSideSetBuff_11.mpachrMemberSense)
00141         delete [] mSideSetBuff_11.mpachrMemberSense;
00142     if(mSideSetBuff_11.mpaintMemberWRTEntities)
00143         delete [] mSideSetBuff_11.mpaintMemberWRTEntities;
00144     if(mSideSetBuff_11.mpadblDistribution)
00145         delete [] mSideSetBuff_11.mpadblDistribution;
00146 }
00147 
00148 
00150 // Write Functions
00152 
00153 UnsignedInt32 CFEModel::InitWrite(FILE* xpFile,
00154                                   UnsignedInt32 xintGeomCount,
00155                                   UnsignedInt32 xintGroupCount,
00156                                   UnsignedInt32 xintBlockCount,
00157                                   UnsignedInt32 xintNodeSetCount,
00158                                   UnsignedInt32 xintSideSetCount)
00159 {
00160     if(mpWriteFile)  throw CCubitFile::eFileWriteError;
00161 
00162     mpWriteFile = xpFile;
00163     CIOWrapper lIO(mpWriteFile);
00164 
00165     // Write out the FE model header to reserve its position and size in the
00166     // file.
00167     mintFEModelOffset = lIO.BeginWriteBlock();
00168     lIO.Write((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
00169     mFEModel.mintFEModelLength = lIO.EndWriteBlock();
00170 
00171     mFEModel.mintGeometryCount = xintGeomCount;
00172     if(xintGeomCount) {
00173         // Create a geometry entity array for storing ownership statistics and
00174         // initially blank it.
00175         mpaGeoms = new SCubitFileGeomEntry[xintGeomCount];
00176         memset(mpaGeoms, 0, sizeof(SCubitFileGeomEntry) * xintGeomCount);
00177 
00178         // Write the blank geometry table to the file to reserve its position
00179         // and size in the file.
00180         mFEModel.mintGeomTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
00181         lIO.Write((UnsignedInt32*)mpaGeoms,
00182             xintGeomCount * mintSizeOfGeomEntry);
00183         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
00184     }
00185 
00186     mFEModel.mintGroupCount = xintGroupCount;
00187     if(xintGroupCount) {
00188         // Create a group array for storing ownership statistics and
00189         // initially blank it.
00190         mpaGroups = new SCubitFileGroupEntry[xintGroupCount];
00191         memset(mpaGroups, 0, sizeof(SCubitFileGroupEntry) * xintGroupCount);
00192 
00193         // Write the blank group table to the file to reserve its position
00194         // and size in the file.
00195         mFEModel.mintGroupTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
00196         lIO.Write((UnsignedInt32*)mpaGroups,
00197             xintGroupCount * mintSizeOfGroupEntry);
00198         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
00199     }
00200 
00201     mFEModel.mintBlockCount = xintBlockCount;
00202     if(xintBlockCount) {
00203         // Create a block array for storing ownership statistics and
00204         // initially blank it.
00205         mpaBlocks = new SCubitFileBlockEntry[xintBlockCount];
00206         memset(mpaBlocks, 0, sizeof(SCubitFileBlockEntry) * xintBlockCount);
00207 
00208         // Write the blank block table to the file to reserve its position
00209         // and size in the file.
00210         mFEModel.mintBlockTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
00211         lIO.Write((UnsignedInt32*)mpaBlocks,
00212             xintBlockCount * mintSizeOfBlockEntry);
00213         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
00214     }
00215 
00216     mFEModel.mintNodeSetCount = xintNodeSetCount;
00217     if(xintNodeSetCount) {
00218         // Create a node set array for storing ownership statistics and
00219         // initially blank it.
00220         mpaNodeSets = new SCubitFileNodeSetEntry[xintNodeSetCount];
00221         memset(mpaNodeSets, 0, sizeof(SCubitFileNodeSetEntry) * xintNodeSetCount);
00222 
00223         // Write the blank geometry table to the file to reserve its position
00224         // and size in the file.
00225         mFEModel.mintNodeSetTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
00226         lIO.Write((UnsignedInt32*)mpaNodeSets,
00227             xintNodeSetCount * mintSizeOfNodeSetEntry);
00228         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
00229     }
00230 
00231     mFEModel.mintSideSetCount = xintSideSetCount;
00232     if(xintSideSetCount) {
00233         // Create a SideSet array for storing ownership statistics and
00234         // initially blank it.
00235         mpaSideSets = new SCubitFileSideSetEntry[xintSideSetCount];
00236         memset(mpaSideSets, 0, sizeof(SCubitFileSideSetEntry) * xintSideSetCount);
00237 
00238         // Write the blank geometry table to the file to reserve its position
00239         // and size in the file.
00240         mFEModel.mintSideSetTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
00241         lIO.Write((UnsignedInt32*)mpaSideSets,
00242             xintSideSetCount * mintSizeOfSideSetEntry);
00243         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
00244     }
00245 
00246     return mintFEModelOffset;
00247 }
00248 
00249 void CFEModel::WriteNodes(UnsignedInt32 xintIndex,
00250                           UnsignedInt32 xintGeomID,
00251                           UnsignedInt32 xintNodeCount,
00252                           UnsignedInt32 *xpaintNodeIDs,
00253                           double *xpadblX, double *xpadblY, double *xpadblZ)
00254 {
00255     if(!mpWriteFile)
00256         throw CCubitFile::eFileWriteError;
00257     if(xintIndex >= mFEModel.mintGeometryCount)
00258         throw CCubitFile::eNotFound;
00259     if(!mpaGeoms)
00260         throw CCubitFile::eOrderError;
00261     if(mpaGeoms[xintIndex].mintNodeCount)
00262         throw CCubitFile::eDuplicateWrite;
00263 
00264     mpaGeoms[xintIndex].mintGeomID = xintGeomID;
00265 
00266     if(xintNodeCount) {
00267         if(!xpaintNodeIDs || !xpadblX || !xpadblY || !xpadblZ)
00268             throw CCubitFile::ePassedNullPointer;
00269 
00270         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00271 
00272         mpaGeoms[xintIndex].mintNodeCount = xintNodeCount;
00273         mpaGeoms[xintIndex].mintNodeOffset =
00274             lpIO->BeginWriteBlock(mintFEModelOffset);
00275 
00276         lpIO->Write(xpaintNodeIDs, xintNodeCount);
00277         lpIO->Write(xpadblX, xintNodeCount);
00278         lpIO->Write(xpadblY, xintNodeCount);
00279         lpIO->Write(xpadblZ, xintNodeCount);
00280 
00281         mFEModel.mintFEModelLength += lpIO->EndWriteBlock();
00282 
00283         delete lpIO;
00284     }
00285 }
00286 
00287 void CFEModel::WriteElems(UnsignedInt32 xintIndex,
00288                           UnsignedInt32 xintNumTypes, SElemData* xpaElemData)
00289 {
00290     if(!mpWriteFile)
00291         throw CCubitFile::eFileWriteError;
00292     if(xintIndex >= mFEModel.mintGeometryCount)
00293         throw CCubitFile::eNotFound;
00294     if(!mpaGeoms)
00295         throw CCubitFile::eOrderError;
00296     if(mpaGeoms[xintIndex].mintElemTypeCount)
00297         throw CCubitFile::eDuplicateWrite;
00298 
00299     if(xintNumTypes) {
00300         if(!xpaElemData)
00301             throw CCubitFile::ePassedNullPointer;
00302         UnsignedInt32 lintElem;
00303         for(lintElem = 0; lintElem < xintNumTypes; lintElem++) {
00304             if(xpaElemData[lintElem].mintElemCount) {
00305                 if(!xpaElemData[lintElem].mpaElemIDs)
00306                     throw CCubitFile::ePassedNullPointer;
00307                 if(!xpaElemData[lintElem].mpaElemGlobalIDs)
00308                     throw CCubitFile::ePassedNullPointer;
00309                 if(xpaElemData[lintElem].mintElemOrder)
00310                     if(!xpaElemData[lintElem].mpaElemConnect)
00311                         throw CCubitFile::ePassedNullPointer;
00312             }
00313         }
00314 
00315         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00316         mpaGeoms[xintIndex].mintElemTypeCount = xintNumTypes;
00317         mpaGeoms[xintIndex].mintElemOffset =
00318             lpIO->BeginWriteBlock(mintFEModelOffset);
00319 
00320         for(lintElem = 0; lintElem < xintNumTypes; lintElem++) {
00321             if(!xpaElemData[lintElem].mintElemCount) {
00322                 mpaGeoms[xintIndex].mintElemTypeCount--;
00323                 continue;
00324             }
00325             mpaGeoms[xintIndex].mintElemCount +=
00326                 xpaElemData[lintElem].mintElemCount;
00327         
00328             lpIO->Write(&xpaElemData[lintElem].mintElemType, 1);
00329             lpIO->Write(&xpaElemData[lintElem].mintElemOrder, 1);
00330             lpIO->Write(&xpaElemData[lintElem].mintElemCount, 1);
00331             lpIO->Write(xpaElemData[lintElem].mpaElemIDs,
00332                 xpaElemData[lintElem].mintElemCount);
00333             lpIO->Write(xpaElemData[lintElem].mpaElemGlobalIDs,
00334                 xpaElemData[lintElem].mintElemCount);
00335             if(xpaElemData[lintElem].mintElemOrder) {
00336                 lpIO->Write(xpaElemData[lintElem].mpaElemConnect,
00337                     xpaElemData[lintElem].mintElemCount *
00338                     xpaElemData[lintElem].mintElemOrder);
00339             }
00340         }
00341 
00342         mpaGeoms[xintIndex].mintElemLength = lpIO->EndWriteBlock();
00343         mFEModel.mintFEModelLength += mpaGeoms[xintIndex].mintElemLength;
00344         delete lpIO;
00345     }
00346 }
00347 
00348 void CFEModel::WriteGroup(UnsignedInt32 xintIndex,
00349                           UnsignedInt32 xintGroupID,
00350                           UnsignedInt32 xintGroupType,
00351                           const char* xpachrGroupName,
00352                           UnsignedInt32 xintNumTypes,
00353                           SGroupData* xpaGroupData)
00354 {
00355     if(!mpWriteFile)
00356         throw CCubitFile::eFileWriteError;
00357     if(xintIndex >= mFEModel.mintGroupCount)
00358         throw CCubitFile::eNotFound;
00359     if(!mpaGroups)
00360         throw CCubitFile::eOrderError;
00361     if(mpaGroups[xintIndex].mintMemberTypeCount)
00362         throw CCubitFile::eDuplicateWrite;
00363 
00364     if(xintNumTypes) {  
00365         // An empty group is valid, but an incompletely defined one is not.
00366         if(!xpaGroupData)
00367             throw CCubitFile::ePassedNullPointer;
00368         for(UnsignedInt32 lintGroup = 0; lintGroup < xintNumTypes; lintGroup++) {
00369             if(xpaGroupData[lintGroup].mintMemberCount &&
00370                 !xpaGroupData[lintGroup].mpaMemberIDs)
00371                 throw CCubitFile::ePassedNullPointer;
00372         }
00373     }
00374 
00375     mpaGroups[xintIndex].mintGroupID = xintGroupID;
00376     mpaGroups[xintIndex].mintGroupType = xintGroupType;
00377     mpaGroups[xintIndex].mintMemberTypeCount = xintNumTypes;
00378     if(mGroupMetaData.SetValue(xintGroupID, "NAME", xpachrGroupName) !=
00379         CCubitFile::eSuccess)
00380         throw CCubitFile::eFileWriteError;
00381     
00382     if(xintNumTypes) {
00383         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00384         mpaGroups[xintIndex].mintMemberOffset =
00385             lpIO->BeginWriteBlock(mintFEModelOffset);
00386 
00387         for(UnsignedInt32 lintGroup = 0; lintGroup < xintNumTypes; lintGroup++) {
00388             if(!xpaGroupData[lintGroup].mintMemberCount) {
00389                 mpaGroups[xintIndex].mintMemberTypeCount--;
00390                 continue;
00391             }
00392             mpaGroups[xintIndex].mintMemberCount +=
00393                 xpaGroupData[lintGroup].mintMemberCount;
00394             
00395             lpIO->Write(&xpaGroupData[lintGroup].mintMemberType, 1);
00396             lpIO->Write(&xpaGroupData[lintGroup].mintMemberCount, 1);
00397             lpIO->Write(xpaGroupData[lintGroup].mpaMemberIDs,
00398                 xpaGroupData[lintGroup].mintMemberCount);
00399         }
00400         
00401         mpaGroups[xintIndex].mintGroupLength = lpIO->EndWriteBlock();
00402         mFEModel.mintFEModelLength += mpaGroups[xintIndex].mintGroupLength;
00403         delete lpIO;
00404     }
00405     else {
00406         // An empty group does not have a data block in the file.
00407         mpaGroups[xintIndex].mintMemberOffset = 0;
00408         mpaGroups[xintIndex].mintGroupLength = 0;
00409     }
00410 }
00411 
00412 void CFEModel::WriteBlock(UnsignedInt32 xintIndex,
00413                           UnsignedInt32 xintBlockID,
00414                           int unique_id,
00415                           UnsignedInt32 xintBlockType,
00416                           UnsignedInt32 xintBlockColor,
00417                           UnsignedInt32 xintMixedElemType,
00418                           UnsignedInt32 xintDefPyramidType,
00419                           UnsignedInt32 xintMaterialID,
00420                           UnsignedInt32 xintBlockDimension,
00421                           UnsignedInt32 xintNumTypes,
00422                           SBlockData* xpaBlockData,
00423                           UnsignedInt32 xintAttributeOrder,
00424                           double* xpadblAttributes)
00425 {
00426     if(!mpWriteFile)
00427         throw CCubitFile::eFileWriteError;
00428     if(xintIndex >= mFEModel.mintBlockCount)
00429         throw CCubitFile::eNotFound;
00430     if(!mpaBlocks)
00431         throw CCubitFile::eOrderError;
00432     if(mpaBlocks[xintIndex].mintMemberTypeCount)
00433         throw CCubitFile::eDuplicateWrite;
00434 
00435     UnsignedInt32 lintBlock;
00436     if(xintNumTypes) {  
00437         // An empty block is valid, but an incompletely defined one is not.
00438         if(!xpaBlockData)
00439             throw CCubitFile::ePassedNullPointer;
00440         for(lintBlock = 0; lintBlock < xintNumTypes; lintBlock++) {
00441             if(xpaBlockData[lintBlock].mintMemberCount &&
00442                 !xpaBlockData[lintBlock].mpaMemberIDs)
00443                 throw CCubitFile::ePassedNullPointer;
00444         }
00445     }
00446 
00447     if(xintAttributeOrder) {
00448         if(!xpadblAttributes)
00449             throw CCubitFile::ePassedNullPointer;
00450     }
00451 
00452     mpaBlocks[xintIndex].mintBlockID = xintBlockID;
00453     mpaBlocks[xintIndex].mintBlockElementType = xintBlockType;
00454     mpaBlocks[xintIndex].mintMemberTypeCount = xintNumTypes;
00455     mpaBlocks[xintIndex].mintBlockColor = xintBlockColor;
00456     mpaBlocks[xintIndex].mintBlockMixedElemType = xintMixedElemType;
00457     mpaBlocks[xintIndex].mintBlockDefPyramidType = xintDefPyramidType;
00458     mpaBlocks[xintIndex].mintBlockMaterial = xintMaterialID;
00459     mpaBlocks[xintIndex].mintBlockDimension = xintBlockDimension;
00460     mpaBlocks[xintIndex].mintAttributeOrder = xintAttributeOrder;
00461     
00462     
00463     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00464     mpaBlocks[xintIndex].mintMemberOffset =
00465         lpIO->BeginWriteBlock(mintFEModelOffset);
00466 
00467     for(lintBlock = 0; lintBlock < xintNumTypes; lintBlock++) {
00468         if(!xpaBlockData[lintBlock].mintMemberCount) {
00469             mpaBlocks[xintIndex].mintMemberTypeCount--;
00470             continue;
00471         }
00472         mpaBlocks[xintIndex].mintMemberCount +=
00473             xpaBlockData[lintBlock].mintMemberCount;
00474 
00475         lpIO->Write(&xpaBlockData[lintBlock].mintMemberType, 1);
00476         lpIO->Write(&xpaBlockData[lintBlock].mintMemberCount, 1);
00477         lpIO->Write(xpaBlockData[lintBlock].mpaMemberIDs,
00478             xpaBlockData[lintBlock].mintMemberCount);
00479     }
00480     if(xintAttributeOrder)
00481         lpIO->Write(xpadblAttributes, xintAttributeOrder);
00482 
00483     lpIO->Write("id", 2);
00484     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
00485 
00486     mpaBlocks[xintIndex].mintBlockLength = lpIO->EndWriteBlock();
00487     mFEModel.mintFEModelLength += mpaBlocks[xintIndex].mintBlockLength;
00488     delete lpIO;
00489 }
00490 
00491 void CFEModel::WriteNodeSet(UnsignedInt32 xintIndex,
00492                             UnsignedInt32 xintNodeSetID,
00493                             int unique_id,
00494                             UnsignedInt32 xintColor,
00495                             UnsignedInt32 xintPointSymbol,
00496                             UnsignedInt32 xintNumTypes,
00497                             SNodeSetData* xpaNodeSetData,
00498                             const std::vector<char>& bcdata)
00499 {
00500     if(!mpWriteFile)
00501         throw CCubitFile::eFileWriteError;
00502     if(xintIndex >= mFEModel.mintNodeSetCount)
00503         throw CCubitFile::eNotFound;
00504     if(!mpaNodeSets)
00505         throw CCubitFile::eOrderError;
00506     if(mpaNodeSets[xintIndex].mintMemberTypeCount)
00507         throw CCubitFile::eDuplicateWrite;
00508 
00509     UnsignedInt32 lintNodeSet;
00510     if(xintNumTypes) {  
00511         // An empty node set is valid, but an incompletely defined one is not.
00512         if(!xpaNodeSetData)
00513             throw CCubitFile::ePassedNullPointer;
00514         for(lintNodeSet = 0; lintNodeSet < xintNumTypes; lintNodeSet++) {
00515             if(xpaNodeSetData[lintNodeSet].mintMemberCount &&
00516                 !xpaNodeSetData[lintNodeSet].mpaMemberIDs)
00517                 throw CCubitFile::ePassedNullPointer;
00518         }
00519     }
00520 
00521     mpaNodeSets[xintIndex].mintNodeSetID = xintNodeSetID;
00522     mpaNodeSets[xintIndex].mintMemberTypeCount = xintNumTypes;
00523     mpaNodeSets[xintIndex].mintNodeSetPointSym = xintPointSymbol;
00524     mpaNodeSets[xintIndex].mintNodeSetColor = xintColor;
00525     
00526     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00527     mpaNodeSets[xintIndex].mintMemberOffset =
00528         lpIO->BeginWriteBlock(mintFEModelOffset);
00529 
00530     for(lintNodeSet = 0; lintNodeSet < xintNumTypes; lintNodeSet++) {
00531         if(!xpaNodeSetData[lintNodeSet].mintMemberCount) {
00532             mpaNodeSets[xintIndex].mintMemberTypeCount--;
00533             continue;
00534         }
00535         mpaNodeSets[xintIndex].mintMemberCount +=
00536             xpaNodeSetData[lintNodeSet].mintMemberCount;
00537 
00538         lpIO->Write(&xpaNodeSetData[lintNodeSet].mintMemberType, 1);
00539         lpIO->Write(&xpaNodeSetData[lintNodeSet].mintMemberCount, 1);
00540         lpIO->Write(xpaNodeSetData[lintNodeSet].mpaMemberIDs,
00541             xpaNodeSetData[lintNodeSet].mintMemberCount);
00542     }
00543 
00544     UnsignedInt32 size = bcdata.size();
00545     if(size)
00546     {
00547         lpIO->Write("bc", 2);
00548         lpIO->Write(&size, 1);
00549         lpIO->Write(&bcdata[0], size);
00550     }
00551 
00552     lpIO->Write("id", 2);
00553     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
00554 
00555     mpaNodeSets[xintIndex].mintNodeSetLength = lpIO->EndWriteBlock();
00556     mFEModel.mintFEModelLength += mpaNodeSets[xintIndex].mintNodeSetLength;
00557     delete lpIO;
00558 }
00559 
00560 void CFEModel::WriteSideSet_11(UnsignedInt32 xintIndex,
00561                             UnsignedInt32 xintSideSetID,
00562                             int unique_id,
00563                             UnsignedInt32 xintColor,
00564                             UnsignedInt32 xintUseShells,
00565                             UnsignedInt32 xintNumTypes,
00566                             SSideSetData_11* xpaSideSetData,
00567                             UnsignedInt32 xintNumDistFact,
00568                             double* xpadblDistribution,
00569                             const std::vector<char>& bcdata)
00570 {
00571     if(!mpWriteFile)
00572         throw CCubitFile::eFileWriteError;
00573     if(xintIndex >= mFEModel.mintSideSetCount)
00574         throw CCubitFile::eNotFound;
00575     if(!mpaSideSets)
00576         throw CCubitFile::eOrderError;
00577     if(mpaSideSets[xintIndex].mintMemberTypeCount)
00578         throw CCubitFile::eDuplicateWrite;
00579 
00580     UnsignedInt32 lintSideSet;
00581     if(xintNumTypes) {  
00582         // An empty side set is valid, but an incompletely defined one is not.
00583         if(!xpaSideSetData)
00584             throw CCubitFile::ePassedNullPointer;
00585         for(lintSideSet = 0; lintSideSet < xintNumTypes; lintSideSet++) {
00586             if(xpaSideSetData[lintSideSet].mintMemberCount) {
00587                 if(!xpaSideSetData[lintSideSet].mpaintMemberTypes)
00588                     throw CCubitFile::ePassedNullPointer;
00589                 if(!xpaSideSetData[lintSideSet].mpaintMemberIDs)
00590                     throw CCubitFile::ePassedNullPointer;
00591                 if(!xpaSideSetData[lintSideSet].mpachrMemberSenses)
00592                     throw CCubitFile::ePassedNullPointer;
00593                 if(!xpaSideSetData[lintSideSet].mpaintMemberWRTEntities)
00594                     throw CCubitFile::ePassedNullPointer;
00595             }
00596         }
00597     }
00598     
00599     if(xintNumDistFact) {
00600         if(!xpadblDistribution)
00601             throw CCubitFile::ePassedNullPointer;
00602     }
00603 
00604     mpaSideSets[xintIndex].mintSideSetID = xintSideSetID;
00605     mpaSideSets[xintIndex].mintMemberTypeCount = xintNumTypes;
00606     mpaSideSets[xintIndex].mintSideSetColor = xintColor;
00607     mpaSideSets[xintIndex].mintUseShells = xintUseShells;
00608     mpaSideSets[xintIndex].mintNumDistFact = xintNumDistFact;
00609 
00610     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
00611     mpaSideSets[xintIndex].mintMemberOffset =
00612         lpIO->BeginWriteBlock(mintFEModelOffset);
00613 
00614     for(lintSideSet = 0; lintSideSet < xintNumTypes; lintSideSet++) {
00615         if(!xpaSideSetData[lintSideSet].mintMemberCount) {
00616             mpaSideSets[xintIndex].mintMemberTypeCount--;
00617             continue;
00618         }
00619         mpaSideSets[xintIndex].mintMemberCount +=
00620             xpaSideSetData[lintSideSet].mintMemberCount;
00621 
00622         lpIO->Write(&xpaSideSetData[lintSideSet].mintMemberCount, 1);
00623         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberTypes, 
00624             xpaSideSetData[lintSideSet].mintMemberCount);
00625         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberIDs,
00626             xpaSideSetData[lintSideSet].mintMemberCount);
00627 
00628         //for the zero-eth one, mpachrMemberSenses is intMemberCount long
00629         if( 0 == lintSideSet ) 
00630           lpIO->Write(xpaSideSetData[lintSideSet].mpachrMemberSenses,
00631             xpaSideSetData[lintSideSet].mintMemberCount, 1);
00632         else  //for 1-n, it is 1 long
00633           lpIO->Write(xpaSideSetData[lintSideSet].mpachrMemberSenses, 1, 1);
00634         UnsignedInt32* end = xpaSideSetData[lintSideSet].mpaintMemberWRTEntities;
00635         int i;
00636         for(i=0; i<(int)xpaSideSetData[lintSideSet].mintMemberCount; i++)
00637         {
00638             UnsignedInt32 num_wrt = *end;
00639             end = end + 1 + (num_wrt * 2);
00640         }
00641         UnsignedInt32 wrt_size = static_cast<UnsignedInt32>(end - xpaSideSetData[lintSideSet].mpaintMemberWRTEntities);
00642         lpIO->Write(&wrt_size, 1);
00643         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberWRTEntities, wrt_size);
00644     }
00645     if(xintNumDistFact)
00646         lpIO->Write(xpadblDistribution, xintNumDistFact);
00647 
00648     UnsignedInt32 size = bcdata.size();
00649     if(size)
00650     {
00651         lpIO->Write("bc", 2);
00652         lpIO->Write(&size, 1);
00653         lpIO->Write(&bcdata[0], size);
00654     }
00655 
00656     lpIO->Write("id", 2);
00657     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
00658 
00659     mpaSideSets[xintIndex].mintSideSetLength = lpIO->EndWriteBlock();
00660     mFEModel.mintFEModelLength += mpaSideSets[xintIndex].mintSideSetLength;
00661     delete lpIO;
00662 }
00663 
00664 UnsignedInt32 CFEModel::EndWrite()
00665 {
00666     CIOWrapper lIO(mpWriteFile);
00667 
00668     if(mFEModel.mintGeometryCount) {
00669         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintGeomTableOffset);
00670         lIO.Write((UnsignedInt32*)mpaGeoms,
00671             mFEModel.mintGeometryCount * mintSizeOfGeomEntry);
00672         lIO.EndWriteBlock();
00673     }
00674 
00675     if(mFEModel.mintGroupCount) {
00676         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintGroupTableOffset);
00677         lIO.Write((UnsignedInt32*)mpaGroups,
00678             mFEModel.mintGroupCount * mintSizeOfGroupEntry);
00679         lIO.EndWriteBlock();
00680     }
00681 
00682     if(mFEModel.mintBlockCount) {
00683         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintBlockTableOffset);
00684         lIO.Write((UnsignedInt32*)mpaBlocks,
00685             mFEModel.mintBlockCount * mintSizeOfBlockEntry);
00686         lIO.EndWriteBlock();
00687     }
00688 
00689     if(mFEModel.mintNodeSetCount) {
00690         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintNodeSetTableOffset);
00691         lIO.Write((UnsignedInt32*)mpaNodeSets,
00692             mFEModel.mintNodeSetCount * mintSizeOfNodeSetEntry);
00693         lIO.EndWriteBlock();
00694     }
00695 
00696     if(mFEModel.mintSideSetCount) {
00697         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintSideSetTableOffset);
00698         lIO.Write((UnsignedInt32*)mpaSideSets,
00699             mFEModel.mintSideSetCount * mintSizeOfSideSetEntry);
00700         lIO.EndWriteBlock();
00701     }
00702 
00703     UnsignedInt32 lintMetaDataLength;
00704     mGeomMetaData.WriteMetaData(mpWriteFile, mFEModel.mintGeomMetaDataOffset,
00705         lintMetaDataLength, mintFEModelOffset);
00706     mFEModel.mintFEModelLength += lintMetaDataLength;
00707     mNodeMetaData.WriteMetaData(mpWriteFile, mFEModel.mintNodeMetaDataOffset,
00708         lintMetaDataLength, mintFEModelOffset);
00709     mFEModel.mintFEModelLength += lintMetaDataLength;
00710     mElemMetaData.WriteMetaData(mpWriteFile, mFEModel.mintElemMetaDataOffset,
00711         lintMetaDataLength, mintFEModelOffset);
00712     mFEModel.mintFEModelLength += lintMetaDataLength;
00713     mGroupMetaData.WriteMetaData(mpWriteFile, mFEModel.mintGroupMetaDataOffset,
00714         lintMetaDataLength, mintFEModelOffset);
00715     mFEModel.mintFEModelLength += lintMetaDataLength;
00716     mBlockMetaData.WriteMetaData(mpWriteFile, mFEModel.mintBlockMetaDataOffset,
00717         lintMetaDataLength, mintFEModelOffset);
00718     mFEModel.mintFEModelLength += lintMetaDataLength;
00719     mNodeSetMetaData.WriteMetaData(mpWriteFile, mFEModel.mintNodeSetMetaDataOffset,
00720         lintMetaDataLength, mintFEModelOffset);
00721     mFEModel.mintFEModelLength += lintMetaDataLength;
00722     mSideSetMetaData.WriteMetaData(mpWriteFile, mFEModel.mintSideSetMetaDataOffset,
00723         lintMetaDataLength, mintFEModelOffset);
00724     mFEModel.mintFEModelLength += lintMetaDataLength;
00725 
00726     lIO.BeginRewriteBlock(mintFEModelOffset, 0);
00727     lIO.Write((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
00728     lIO.EndWriteBlock();
00729 
00730     mpWriteFile = NULL;
00731     return mFEModel.mintFEModelLength;
00732 }
00733 
00734 
00736 // Read Functions
00738 
00739 void CFEModel::InitRead(FILE* xpFile,
00740                         UnsignedInt32 xintAbsoluteOffset,
00741                         UnsignedInt32& xintGeomCount,
00742                         UnsignedInt32& xintGroupCount,
00743                         UnsignedInt32& xintBlockCount,
00744                         UnsignedInt32& xintNodeSetCount,
00745                         UnsignedInt32& xintSideSetCount)
00746 {
00747     if(mpReadFile)
00748         throw CCubitFile::eOrderError;
00749 
00750     mpReadFile = xpFile;
00751     mintFEModelOffset = xintAbsoluteOffset;
00752     CIOWrapper lIO(mpReadFile, xintAbsoluteOffset, 0);
00753 
00754     lIO.BeginReadBlock(mintFEModelOffset, 0);
00755     lIO.Read((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
00756     lIO.EndReadBlock();
00757     xintGeomCount = mFEModel.mintGeometryCount;
00758     xintGroupCount = mFEModel.mintGroupCount;
00759     xintBlockCount = mFEModel.mintBlockCount;
00760     xintNodeSetCount = mFEModel.mintNodeSetCount;
00761     xintSideSetCount = mFEModel.mintSideSetCount;
00762 
00763     // Restore the geometry definition header table if there is one.
00764     if(mFEModel.mintGeometryCount) {
00765         mpaGeoms = new SCubitFileGeomEntry[mFEModel.mintGeometryCount];
00766 
00767         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintGeomTableOffset);
00768         lIO.Read((UnsignedInt32*)mpaGeoms,
00769             mFEModel.mintGeometryCount * mintSizeOfGeomEntry);
00770         lIO.EndReadBlock();
00771     }
00772 
00773     // Restore the group definition header table if there is one.
00774     if(mFEModel.mintGroupCount) {
00775         mpaGroups = new SCubitFileGroupEntry[mFEModel.mintGroupCount];
00776 
00777         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintGroupTableOffset);
00778         lIO.Read((UnsignedInt32*)mpaGroups,
00779             mFEModel.mintGroupCount * mintSizeOfGroupEntry);
00780         lIO.EndReadBlock();
00781     }
00782 
00783     // Restore the block definition header table if there is one.
00784     if(mFEModel.mintBlockCount) {
00785         mpaBlocks = new SCubitFileBlockEntry[mFEModel.mintBlockCount];
00786 
00787         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintBlockTableOffset);
00788         lIO.Read((UnsignedInt32*)mpaBlocks,
00789             mFEModel.mintBlockCount * mintSizeOfBlockEntry);
00790         lIO.EndReadBlock();
00791     }
00792 
00793     // Restore the node set definition header table if there is one.
00794     if(mFEModel.mintNodeSetCount) {
00795         mpaNodeSets = new SCubitFileNodeSetEntry[mFEModel.mintNodeSetCount];
00796 
00797         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintNodeSetTableOffset);
00798         lIO.Read((UnsignedInt32*)mpaNodeSets,
00799             mFEModel.mintNodeSetCount * mintSizeOfNodeSetEntry);
00800         lIO.EndReadBlock();
00801     }
00802 
00803     // Restore the side set definition header table if there is one.
00804     if(mFEModel.mintSideSetCount) {
00805         mpaSideSets = new SCubitFileSideSetEntry[mFEModel.mintSideSetCount];
00806 
00807         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintSideSetTableOffset);
00808         lIO.Read((UnsignedInt32*)mpaSideSets,
00809             mFEModel.mintSideSetCount * mintSizeOfSideSetEntry);
00810         lIO.EndReadBlock();
00811     }
00812 
00813     mGeomMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00814         mFEModel.mintGeomMetaDataOffset, mFEModel.mintFEModelEndian);
00815     mNodeMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00816         mFEModel.mintNodeMetaDataOffset, mFEModel.mintFEModelEndian);
00817     mElemMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00818         mFEModel.mintElemMetaDataOffset, mFEModel.mintFEModelEndian);
00819     mGroupMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00820         mFEModel.mintGroupMetaDataOffset, mFEModel.mintFEModelEndian);
00821     mBlockMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00822         mFEModel.mintBlockMetaDataOffset, mFEModel.mintFEModelEndian);
00823     mNodeSetMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00824         mFEModel.mintNodeSetMetaDataOffset, mFEModel.mintFEModelEndian);
00825     mSideSetMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
00826         mFEModel.mintSideSetMetaDataOffset, mFEModel.mintFEModelEndian);
00827 }
00828 
00829 void CFEModel::ReadNodes(UnsignedInt32 xintIndex,
00830                          UnsignedInt32& xintGeomID,
00831                          UnsignedInt32& xintNodeCount,
00832                          UnsignedInt32*& xpaintNodeIDs,
00833                          double*& xpadblX,
00834                          double*& xpadblY,
00835                          double*& xpadblZ)
00836 {
00837     if(!mpReadFile)
00838         throw CCubitFile::eFileReadError;
00839     if(xintIndex >= mFEModel.mintGeometryCount)
00840         throw CCubitFile::eNotFound;
00841     if(!mpaGeoms)
00842         throw CCubitFile::eOrderError;
00843 
00844     xintGeomID = mpaGeoms[xintIndex].mintGeomID;
00845     xintNodeCount = mpaGeoms[xintIndex].mintNodeCount;
00846     if(xintNodeCount) {
00847         if(mNodeBuff.mintNumNodes < xintNodeCount) {
00848             if(mNodeBuff.mpaNodeIDs)
00849                 delete [] mNodeBuff.mpaNodeIDs;
00850             if(mNodeBuff.mpadblX)
00851                 delete [] mNodeBuff.mpadblX;
00852             if(mNodeBuff.mpadblY)
00853                 delete [] mNodeBuff.mpadblY;
00854             if(mNodeBuff.mpadblZ)
00855                 delete [] mNodeBuff.mpadblZ;
00856             mNodeBuff.mintNumNodes = xintNodeCount;
00857             mNodeBuff.mpaNodeIDs = new UnsignedInt32[xintNodeCount];
00858             mNodeBuff.mpadblX = new double[xintNodeCount];
00859             mNodeBuff.mpadblY = new double[xintNodeCount];
00860             mNodeBuff.mpadblZ = new double[xintNodeCount];
00861         }
00862         xpaintNodeIDs = mNodeBuff.mpaNodeIDs;
00863         xpadblX = mNodeBuff.mpadblX;
00864         xpadblY = mNodeBuff.mpadblY;
00865         xpadblZ = mNodeBuff.mpadblZ;
00866 
00867         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
00868     
00869         lpIO->BeginReadBlock(mintFEModelOffset,
00870             mpaGeoms[xintIndex].mintNodeOffset);
00871         lpIO->Read(mNodeBuff.mpaNodeIDs, xintNodeCount);
00872         lpIO->Read(mNodeBuff.mpadblX, xintNodeCount);
00873         lpIO->Read(mNodeBuff.mpadblY, xintNodeCount);
00874         lpIO->Read(mNodeBuff.mpadblZ, xintNodeCount);
00875         lpIO->EndReadBlock();
00876 
00877         delete lpIO;
00878     }
00879     else {
00880         xpaintNodeIDs = NULL;
00881         xpadblX = xpadblY = xpadblZ = NULL;
00882     }
00883 }
00884 
00885 void CFEModel::ReadElems(double data_version,
00886                          UnsignedInt32 xintIndex, UnsignedInt32& xintGeomID,
00887                          UnsignedInt32& xintNumTypes, SElemData*& xpaElemData)
00888 {
00889     if(!mpReadFile)
00890         throw CCubitFile::eFileReadError;
00891     if(xintIndex >= mFEModel.mintGeometryCount)
00892         throw CCubitFile::eNotFound;
00893     if(!mpaGeoms)
00894         throw CCubitFile::eOrderError;
00895 
00896     xintGeomID = mpaGeoms[xintIndex].mintGeomID;
00897     xintNumTypes = mpaGeoms[xintIndex].mintElemTypeCount;
00898     if(xintNumTypes) {
00899         // Resize the element return buffer if necessary and then set the return
00900         // pointers to the buffer.
00901         //
00902         // NOTE: if the number of element types is greater than 1, a single buffer
00903         // is allocated for the total number of elements.  In the read loop below
00904         // the pointer to the buffer needs to be updated with each loop so as
00905         // not to overwrite what was read previously.
00906         //
00907 
00908 
00909 
00910         UnsignedInt32 lintConnGuess = 
00911             mpaGeoms[xintIndex].mintElemLength / sizeof(UnsignedInt32) -
00912             mpaGeoms[xintIndex].mintElemCount;
00913             // - 3 * mpaGeoms[xintIndex].mintElemTypeCount; (exact)
00914         xpaElemData = AdjustBuffer(xintNumTypes,
00915             mElemBuff.mintNumTypes, mElemBuff.mpaElemData);
00916         UnsignedInt32* lpIDs =
00917             AdjustBuffer(mpaGeoms[xintIndex].mintElemCount,
00918             mElemBuff.mintNumElemIds, mElemBuff.mpaElemIDs);
00919         UnsignedInt32* lpGlobalIDs = NULL;
00920         if ( data_version >= 1.3 )
00921         {
00922           lpGlobalIDs =
00923             AdjustBuffer(mpaGeoms[xintIndex].mintElemCount,
00924             mElemBuff.mintNumElemGids, mElemBuff.mpaElemGlobalIDs);
00925         }
00926 
00927         UnsignedInt32* lpConnect =
00928             AdjustBuffer(lintConnGuess,
00929             mElemBuff.mintNumConnect, mElemBuff.mpaElemConnect);
00930 
00931         // Read the element from the file.
00932         UnsignedInt32 lintNumElems, lintNumConnect;
00933         UnsignedInt32 lintTotalElems = 0, lintTotalConnect = 0;
00934         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
00935 
00936         lpIO->BeginReadBlock(mintFEModelOffset,
00937             mpaGeoms[xintIndex].mintElemOffset);
00938         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
00939             lpIO->Read(&xpaElemData[lintType].mintElemType, 1);
00940             lpIO->Read(&xpaElemData[lintType].mintElemOrder, 1);
00941             lpIO->Read(&xpaElemData[lintType].mintElemCount, 1);
00942 
00943             xpaElemData[lintType].mpaElemIDs = lpIDs;
00944             xpaElemData[lintType].mpaElemGlobalIDs = lpGlobalIDs;
00945             xpaElemData[lintType].mpaElemConnect = lpConnect;
00946             lintNumElems = xpaElemData[lintType].mintElemCount;
00947             lintNumConnect = lintNumElems * xpaElemData[lintType].mintElemOrder;
00948             // Make sure the total number of elements or connection entries
00949             // does not exceed what was specified in the geometry table entry.
00950             lintTotalElems += lintNumElems;
00951             lintTotalConnect += lintNumConnect;
00952             if((lintTotalElems > mpaGeoms[xintIndex].mintElemCount) ||
00953                 (lintTotalConnect > lintConnGuess))
00954                 throw CCubitFile::eFileReadError;
00955 
00956             lpIO->Read(xpaElemData[lintType].mpaElemIDs, lintNumElems);
00957             if ( data_version >= 1.3 )
00958                 lpIO->Read(xpaElemData[lintType].mpaElemGlobalIDs, lintNumElems);
00959             if(xpaElemData[lintType].mintElemOrder)
00960                 lpIO->Read(xpaElemData[lintType].mpaElemConnect, lintNumConnect);
00961 
00962             // When the buffers are allocated above, a single buffer is allocated
00963             // based on the total number of elements.  So for the case that there are
00964             // multiple types being read in, move the pointer to the buffer past
00965             // the end of the data that has been read in so we don't overwrite.
00966             lpIDs = &lpIDs[lintNumElems];
00967             if ( data_version >= 1.3 )
00968                 lpGlobalIDs = &lpGlobalIDs[lintNumElems];
00969             lpConnect = &lpConnect[lintNumConnect];
00970         }
00971         lpIO->EndReadBlock();
00972         delete lpIO;
00973     }
00974     else
00975         xpaElemData = NULL;
00976 }
00977 
00978 void CFEModel::ReadGroupIdentity(UnsignedInt32 xintIndex,
00979                                  UnsignedInt32& xintGroupID,
00980                                  UnsignedInt32& xintGroupType,
00981                                  const char*& xpachrGroupName)
00982 {
00983     if(!mpReadFile)
00984         throw CCubitFile::eFileReadError;
00985     if(xintIndex >= mFEModel.mintGroupCount)
00986         throw CCubitFile::eNotFound;
00987     if(!mpaGroups)
00988         throw CCubitFile::eOrderError;
00989 
00990     xintGroupID = mpaGroups[xintIndex].mintGroupID;
00991     xintGroupType = mpaGroups[xintIndex].mintGroupType;
00992     if(mGroupMetaData.GetValue(xintGroupID, "NAME", xpachrGroupName) !=
00993         CCubitFile::eSuccess)
00994         xpachrGroupName = NULL;
00995 }
00996 
00997 void CFEModel::ReadGroupMembers(UnsignedInt32 xintIndex,
00998                                 UnsignedInt32& xintNumTypes,
00999                                 SGroupData*& xpaGroupData)
01000 {
01001     if(!mpReadFile)
01002         throw CCubitFile::eFileReadError;
01003     if(xintIndex >= mFEModel.mintGroupCount)
01004         throw CCubitFile::eNotFound;
01005     if(!mpaGroups)
01006         throw CCubitFile::eOrderError;
01007 
01008     xintNumTypes = mpaGroups[xintIndex].mintMemberTypeCount;
01009     if(xintNumTypes) {
01010         // Resize the group return buffer if necessary and then set the return
01011         // pointers to the buffer.
01012         xpaGroupData = AdjustBuffer(xintNumTypes,
01013             mGroupBuff.mintNumTypes, mGroupBuff.mpaGroupData);
01014         UnsignedInt32* lpIDs =
01015             AdjustBuffer(mpaGroups[xintIndex].mintMemberCount,
01016             mGroupBuff.mintNumMembers, mGroupBuff.mpaintMemberIDs);
01017 
01018         // Read the group member data from the file.
01019         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
01020         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
01021         lpIO->BeginReadBlock(mintFEModelOffset,
01022             mpaGroups[xintIndex].mintMemberOffset);
01023         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
01024             lpIO->Read(&xpaGroupData[lintType].mintMemberType, 1);
01025             lpIO->Read(&xpaGroupData[lintType].mintMemberCount, 1);
01026 
01027             xpaGroupData[lintType].mpaMemberIDs = lpIDs;
01028             lintNumMembers = xpaGroupData[lintType].mintMemberCount;
01029             // Make sure the total number of group members does not exceed what
01030             // was specified in the group table entry.
01031             lintTotalMembers += lintNumMembers;
01032             if(lintTotalMembers > mpaGroups[xintIndex].mintMemberCount)
01033                 throw CCubitFile::eFileReadError;
01034 
01035             lpIO->Read(xpaGroupData[lintType].mpaMemberIDs, lintNumMembers);
01036 
01037             lpIDs = &lpIDs[lintNumMembers];
01038         }
01039         lpIO->EndReadBlock();
01040         delete lpIO;
01041     }
01042     else
01043         xpaGroupData = NULL;
01044 }
01045 
01046 void CFEModel::ReadBlock(UnsignedInt32 xintIndex,
01047                          UnsignedInt32& xintBlockID,
01048                          int& unique_id,
01049                          UnsignedInt32& xintBlockType,
01050                          UnsignedInt32& xintBlockColor,
01051                          UnsignedInt32& xintMixedElemType,
01052                          UnsignedInt32& xintDefPyramidType,
01053                          UnsignedInt32& xintMaterialID,
01054                          UnsignedInt32& xintBlockDimension,
01055                          UnsignedInt32& xintNumTypes,
01056                          SBlockData*& xpaBlockData,
01057                          UnsignedInt32& xintAttributeOrder,
01058                          double*& xpadblAttributes)
01059 {
01060   unique_id = 0;
01061     if(!mpReadFile)
01062         throw CCubitFile::eFileReadError;
01063     if(xintIndex >= mFEModel.mintBlockCount)
01064         throw CCubitFile::eNotFound;
01065     if(!mpaBlocks)
01066         throw CCubitFile::eOrderError;
01067 
01068     xintBlockID = mpaBlocks[xintIndex].mintBlockID;
01069     xintBlockType = mpaBlocks[xintIndex].mintBlockElementType;
01070     xintNumTypes = mpaBlocks[xintIndex].mintMemberTypeCount;
01071     xintBlockColor = mpaBlocks[xintIndex].mintBlockColor;
01072     xintMixedElemType = mpaBlocks[xintIndex].mintBlockMixedElemType;
01073     xintDefPyramidType = mpaBlocks[xintIndex].mintBlockDefPyramidType;
01074     xintMaterialID = mpaBlocks[xintIndex].mintBlockMaterial;
01075     xintBlockDimension = mpaBlocks[xintIndex].mintBlockDimension;
01076     xintAttributeOrder = mpaBlocks[xintIndex].mintAttributeOrder;
01077 
01078     // Resize the block return buffer if necessary and then set the return
01079     // pointers to the buffer.
01080     xpaBlockData = AdjustBuffer(xintNumTypes,
01081         mBlockBuff.mintNumTypes, mBlockBuff.mpaBlockData);
01082     UnsignedInt32* lpIDs =
01083         AdjustBuffer(mpaBlocks[xintIndex].mintMemberCount,
01084         mBlockBuff.mintNumMembers, mBlockBuff.mpaintMemberIDs);
01085     xpadblAttributes = AdjustBuffer(xintAttributeOrder,
01086         mBlockBuff.mintAttributeOrder, mBlockBuff.mpadblAttributes);
01087 
01088     // Read the block from the file.
01089     UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
01090     CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
01091     lpIO->BeginReadBlock(mintFEModelOffset,
01092         mpaBlocks[xintIndex].mintMemberOffset);
01093     UnsignedInt32 start_location = lpIO->GetLocation();
01094     for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
01095         lpIO->Read(&xpaBlockData[lintType].mintMemberType, 1);
01096         lpIO->Read(&xpaBlockData[lintType].mintMemberCount, 1);
01097 
01098         xpaBlockData[lintType].mpaMemberIDs = lpIDs;
01099         lintNumMembers = xpaBlockData[lintType].mintMemberCount;
01100         // Make sure the total number of block members does not exceed what
01101         // was specified in the block table entry.
01102         lintTotalMembers += lintNumMembers;
01103         if(lintTotalMembers > mpaBlocks[xintIndex].mintMemberCount)
01104             throw CCubitFile::eFileReadError;
01105 
01106         lpIO->Read(xpaBlockData[lintType].mpaMemberIDs, lintNumMembers);
01107 
01108         lpIDs = &lpIDs[lintNumMembers];
01109     }
01110     if(xintAttributeOrder)
01111         lpIO->Read(xpadblAttributes, xintAttributeOrder);
01112 
01113     // see if there is more data
01114     int diff = lpIO->GetLocation() - start_location;
01115     int remaining = diff - mpaBlocks[xintIndex].mintBlockLength;
01116     while(remaining)
01117     {
01118         // remaining data could be bc data
01119         char type[2];
01120         lpIO->Read(type, 2);
01121         if(type[0] == 'i' && type[1] == 'd')
01122         {
01123             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
01124         }
01125         remaining = (lpIO->GetLocation() - start_location) -
01126             mpaBlocks[xintIndex].mintBlockLength;
01127     }
01128 
01129     lpIO->EndReadBlock();
01130     delete lpIO;
01131 }
01132 
01133 void CFEModel::ReadNodeSet(UnsignedInt32 xintIndex,
01134                            UnsignedInt32& xintNodeSetID,
01135                            int& unique_id,
01136                            UnsignedInt32& xintColor,
01137                            UnsignedInt32& xintPointSymbol,
01138                            UnsignedInt32& xintNumTypes,
01139                            SNodeSetData*& xpaNodeSetData,
01140                            std::vector<char>& bcdata)
01141 {
01142   unique_id = 0;
01143     if(!mpReadFile)
01144         throw CCubitFile::eFileReadError;
01145     if(xintIndex >= mFEModel.mintNodeSetCount)
01146         throw CCubitFile::eNotFound;
01147     if(!mpaNodeSets)
01148         throw CCubitFile::eOrderError;
01149 
01150     xintNodeSetID = mpaNodeSets[xintIndex].mintNodeSetID;
01151     xintNumTypes = mpaNodeSets[xintIndex].mintMemberTypeCount;
01152     xintPointSymbol = mpaNodeSets[xintIndex].mintNodeSetPointSym;
01153     xintColor = mpaNodeSets[xintIndex].mintNodeSetColor;
01154 
01155     // fix for bug 8623: empty nodesets are allowed
01156     //if(xintNumTypes) 
01157     //{
01158         // Resize the node set return buffer if necessary and then set the return
01159         // pointers to the buffer.
01160         xpaNodeSetData = AdjustBuffer(xintNumTypes,
01161             mNodeSetBuff.mintNumTypes, mNodeSetBuff.mpaNodeSetData);
01162         UnsignedInt32* lpIDs =
01163             AdjustBuffer(mpaNodeSets[xintIndex].mintMemberCount,
01164             mNodeSetBuff.mintNumMembers, mNodeSetBuff.mpaintMemberIDs);
01165 
01166         // Read the node set from the file.
01167         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
01168         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
01169         lpIO->BeginReadBlock(mintFEModelOffset,
01170             mpaNodeSets[xintIndex].mintMemberOffset);
01171         UnsignedInt32 start_location = lpIO->GetLocation();
01172         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
01173             lpIO->Read(&xpaNodeSetData[lintType].mintMemberType, 1);
01174             lpIO->Read(&xpaNodeSetData[lintType].mintMemberCount, 1);
01175 
01176             xpaNodeSetData[lintType].mpaMemberIDs = lpIDs;
01177             lintNumMembers = xpaNodeSetData[lintType].mintMemberCount;
01178             // Make sure the total number of node set members does not exceed
01179             // what was specified in the node set table entry.
01180             lintTotalMembers += lintNumMembers;
01181             if(lintTotalMembers > mpaNodeSets[xintIndex].mintMemberCount)
01182                 throw CCubitFile::eFileReadError;
01183 
01184             lpIO->Read(xpaNodeSetData[lintType].mpaMemberIDs, lintNumMembers);
01185 
01186             lpIDs = &lpIDs[lintNumMembers];
01187         }
01188         
01189         // see if there is more data
01190         int diff = lpIO->GetLocation() - start_location;
01191         int remaining = diff - mpaNodeSets[xintIndex].mintNodeSetLength;
01192         while(remaining)
01193         {
01194           // remaining data could be bc data
01195           char type[2];
01196           lpIO->Read(type, 2);
01197           if(type[0] == 'b' && type[1] == 'c')
01198           {
01199             // get serialize data size
01200             UnsignedInt32 size;
01201             lpIO->Read(&size, 1);
01202             bcdata.resize(size);
01203             lpIO->Read(&bcdata[0], size);
01204           }
01205           else if(type[0] == 'i' && type[1] == 'd')
01206           {
01207             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
01208           }
01209           remaining = (lpIO->GetLocation() - start_location) -
01210             mpaNodeSets[xintIndex].mintNodeSetLength;
01211         }
01212 
01213         lpIO->EndReadBlock();
01214         delete lpIO;
01215     /*}
01216     else
01217         xpaNodeSetData = NULL;*/
01218 }
01219 
01220 void CFEModel::ReadSideSet_10(UnsignedInt32 xintIndex,
01221                            UnsignedInt32& xintSideSetID,
01222                            UnsignedInt32& xintColor,
01223                            UnsignedInt32& xintUseShells,
01224                            UnsignedInt32& xintNumTypes,
01225                            SSideSetData_10*& xpaSideSetData,
01226                            UnsignedInt32& xintNumDistFact,
01227                            double*& xpadblDistribution)
01228 {
01229     if(!mpReadFile)
01230         throw CCubitFile::eFileReadError;
01231     if(xintIndex >= mFEModel.mintSideSetCount)
01232         throw CCubitFile::eNotFound;
01233     if(!mpaSideSets)
01234         throw CCubitFile::eOrderError;
01235 
01236     xintSideSetID = mpaSideSets[xintIndex].mintSideSetID;
01237     xintNumTypes = mpaSideSets[xintIndex].mintMemberTypeCount;
01238     xintColor = mpaSideSets[xintIndex].mintSideSetColor;
01239     xintUseShells = mpaSideSets[xintIndex].mintUseShells;
01240     xintNumDistFact = mpaSideSets[xintIndex].mintNumDistFact;
01241 
01242     if(xintNumTypes) {
01243         // Resize the side set return buffer if necessary and then set the return
01244         // pointers to the buffer.
01245         xpaSideSetData = AdjustBuffer(xintNumTypes,
01246             mSideSetBuff_10.mintNumTypes, mSideSetBuff_10.mpaSideSetData);
01247         UnsignedInt32* lpaintIDs =
01248             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01249             mSideSetBuff_10.mintNumMembersIDs, mSideSetBuff_10.mpaintMemberIDs);
01250         char* lpachrSense =
01251             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01252             mSideSetBuff_10.mintNumMembersSense8, mSideSetBuff_10.mpachrMemberSense);
01253         UnsignedInt32* lpaintSense =
01254             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01255             mSideSetBuff_10.mintNumMembersSense32, mSideSetBuff_10.mpaintMemberSense);
01256         char* lpachrSideNum =
01257             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01258             mSideSetBuff_10.mintNumMembersSideNum, mSideSetBuff_10.mpachrMemberSideNum);
01259         xpadblDistribution = AdjustBuffer(xintNumDistFact,
01260             mSideSetBuff_10.mintNumDistFact, mSideSetBuff_10.mpadblDistribution);
01261 
01262         // Read the block from the file.
01263         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
01264         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
01265         lpIO->BeginReadBlock(mintFEModelOffset,
01266             mpaSideSets[xintIndex].mintMemberOffset);
01267         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
01268             lpIO->Read(&xpaSideSetData[lintType].mintMemberType, 1);
01269             lpIO->Read(&xpaSideSetData[lintType].mintMemberCount, 1);
01270             lpIO->Read(&xpaSideSetData[lintType].mintMemberSenseSize, 1);
01271 
01272             xpaSideSetData[lintType].mpaintMemberIDs = lpaintIDs;
01273             xpaSideSetData[lintType].mpachrMemberSideNumber = lpachrSideNum;
01274             lintNumMembers = xpaSideSetData[lintType].mintMemberCount;
01275             // Make sure the total number of side set members does not exceed
01276             // what was specified in the side set table entry.
01277             lintTotalMembers += lintNumMembers;
01278             if(lintTotalMembers > mpaSideSets[xintIndex].mintMemberCount)
01279                 throw CCubitFile::eFileReadError;
01280 
01281             lpIO->Read(xpaSideSetData[lintType].mpaintMemberIDs, lintNumMembers);
01282             switch(xpaSideSetData[lintType].mintMemberSenseSize) {
01283             case CCubitFile::eSideSetSenseNone:
01284             default:
01285                 xpaSideSetData[lintType].mpachrMemberSense = NULL;
01286                 xpaSideSetData[lintType].mpaintMemberSense = NULL;
01287                 break;
01288             case CCubitFile::eSideSetSenseByte:
01289                 xpaSideSetData[lintType].mpachrMemberSense = lpachrSense;
01290                 xpaSideSetData[lintType].mpaintMemberSense = NULL;
01291                 lpIO->Read(xpaSideSetData[lintType].mpachrMemberSense,
01292                     lintNumMembers, 1);
01293                 lpaintSense = &lpaintSense[lintNumMembers];
01294                 break;
01295             case CCubitFile::eSideSetSenseInt32:
01296                 xpaSideSetData[lintType].mpachrMemberSense = NULL;
01297                 xpaSideSetData[lintType].mpaintMemberSense = lpaintSense;
01298                 lpIO->Read(xpaSideSetData[lintType].mpaintMemberSense,
01299                     lintNumMembers);
01300                 lpaintSense = &lpaintSense[lintNumMembers];
01301                 break;
01302             }
01303             lpIO->Read(xpaSideSetData[lintType].mpachrMemberSideNumber,
01304                 lintNumMembers, 1);
01305 
01306             lpaintIDs = &lpaintIDs[lintNumMembers];
01307             lpachrSideNum = &lpachrSideNum[lintNumMembers];
01308         }
01309         if(xintNumDistFact)
01310             lpIO->Read(xpadblDistribution, xintNumDistFact);
01311         lpIO->EndReadBlock();
01312         delete lpIO;
01313     }
01314     else {
01315         xpaSideSetData = NULL;
01316         xpadblDistribution = NULL;
01317     }
01318 }
01319 
01320 void CFEModel::ReadSideSet_11(UnsignedInt32 xintIndex,
01321                            UnsignedInt32& xintSideSetID,
01322                            int& unique_id,
01323                            UnsignedInt32& xintColor,
01324                            UnsignedInt32& xintUseShells,
01325                            UnsignedInt32& xintNumTypes,
01326                            SSideSetData_11*& xpaSideSetData,
01327                            UnsignedInt32& xintNumDistFact,
01328                            double*& xpadblDistribution,
01329                            std::vector<char>& bcdata)
01330 {
01331   unique_id = 0;
01332     if(!mpReadFile)
01333         throw CCubitFile::eFileReadError;
01334     if(xintIndex >= mFEModel.mintSideSetCount)
01335         throw CCubitFile::eNotFound;
01336     if(!mpaSideSets)
01337         throw CCubitFile::eOrderError;
01338 
01339     xintSideSetID = mpaSideSets[xintIndex].mintSideSetID;
01340     xintNumTypes = mpaSideSets[xintIndex].mintMemberTypeCount;
01341     xintColor = mpaSideSets[xintIndex].mintSideSetColor;
01342     xintUseShells = mpaSideSets[xintIndex].mintUseShells;
01343     xintNumDistFact = mpaSideSets[xintIndex].mintNumDistFact;
01344 
01345     // fix for bug 8623: don't do this check: empty sidesets are allowed
01346     //if(xintNumTypes) {
01347         // Resize the side set return buffer if necessary and then set the return
01348         // pointers to the buffer.
01349         xpaSideSetData = AdjustBuffer(xintNumTypes,
01350             mSideSetBuff_11.mintNumTypes, mSideSetBuff_11.mpaSideSetData);
01351         UnsignedInt32 count = mSideSetBuff_11.mintNumMembersIDs;
01352         UnsignedInt32* lpaintTypes =
01353             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01354             mSideSetBuff_11.mintNumMembersIDs, mSideSetBuff_11.mpaintMemberTypes);
01355         UnsignedInt32* lpaintIDs =
01356             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01357             count, mSideSetBuff_11.mpaintMemberIDs);
01358         char* lpachrSense =
01359             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
01360             mSideSetBuff_11.mintNumMembersSense, mSideSetBuff_11.mpachrMemberSense);
01361         xpadblDistribution = AdjustBuffer(xintNumDistFact,
01362             mSideSetBuff_11.mintNumDistFact, mSideSetBuff_11.mpadblDistribution);
01363 
01364         // Read the block from the file.
01365         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
01366         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
01367         lpIO->BeginReadBlock(mintFEModelOffset,
01368             mpaSideSets[xintIndex].mintMemberOffset);
01369         UnsignedInt32 start_location = lpIO->GetLocation();
01370         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
01371             lpIO->Read(&xpaSideSetData[lintType].mintMemberCount, 1);
01372             
01373             lintNumMembers = xpaSideSetData[lintType].mintMemberCount;
01374             
01375             xpaSideSetData[lintType].mpaintMemberTypes = lpaintTypes;
01376             xpaSideSetData[lintType].mpaintMemberIDs = lpaintIDs;
01377             
01378             // Make sure the total number of side set members does not exceed
01379             // what was specified in the side set table entry.
01380             lintTotalMembers += lintNumMembers;
01381             if(lintTotalMembers > mpaSideSets[xintIndex].mintMemberCount)
01382                 throw CCubitFile::eFileReadError;
01383 
01384             lpIO->Read(xpaSideSetData[lintType].mpaintMemberTypes, lintNumMembers);
01385 
01386             lpIO->Read(xpaSideSetData[lintType].mpaintMemberIDs, lintNumMembers);
01387 
01388             xpaSideSetData[lintType].mpachrMemberSenses = lpachrSense;
01389             if(lintType == 0)
01390               lpIO->Read(xpaSideSetData[lintType].mpachrMemberSenses, lintNumMembers, 1);
01391             else
01392               lpIO->Read(xpaSideSetData[lintType].mpachrMemberSenses, 1, 1);
01393 
01394             UnsignedInt32 wrt_size=0;
01395             lpIO->Read(&wrt_size, 1);
01396         
01397             UnsignedInt32* lpaintWRT = NULL;
01398             UnsignedInt32 orig_size = 0;
01399             AdjustBuffer(wrt_size, orig_size, lpaintWRT);
01400 
01401             xpaSideSetData[lintType].mpaintMemberWRTEntities = lpaintWRT;
01402         
01403             lpIO->Read(xpaSideSetData[lintType].mpaintMemberWRTEntities, wrt_size);
01404 
01405             lpaintIDs = &lpaintIDs[lintNumMembers];
01406             lpaintTypes = &lpaintTypes[lintNumMembers];
01407         }
01408         if(xintNumDistFact)
01409             lpIO->Read(xpadblDistribution, xintNumDistFact);
01410 
01411         // see if there is more data
01412         int diff = lpIO->GetLocation() - start_location;
01413         int remaining = diff - mpaSideSets[xintIndex].mintSideSetLength;
01414         while(remaining)
01415         {
01416           // remaining data could be bc data
01417           char type[2];
01418           lpIO->Read(type, 2);
01419           if(type[0] == 'b' && type[1] == 'c')
01420           {
01421             // get serialize data size
01422             UnsignedInt32 size;
01423             lpIO->Read(&size, 1);
01424             bcdata.resize(size);
01425             lpIO->Read(&bcdata[0], size);
01426           }
01427           // or unique id
01428           else if(type[0] == 'i' && type[1] == 'd')
01429           {
01430             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
01431           }
01432           remaining = (lpIO->GetLocation() - start_location) -
01433             mpaSideSets[xintIndex].mintSideSetLength;
01434         }
01435 
01436         lpIO->EndReadBlock();
01437         delete lpIO;
01438     //}
01439     //else {
01440     //    xpaSideSetData = NULL;
01441     //    xpadblDistribution = NULL;
01442     //}
01443 }
01444 
01445 void CFEModel::EndRead()
01446 {
01447     mpReadFile = NULL;
01448 }
01449 
01451 // Meta-Data Functions
01453 
01454 CMetaData& CFEModel::GetGeomMetaData()
01455 {
01456     return mGeomMetaData;
01457 }
01458 
01459 CMetaData& CFEModel::GetNodeMetaData()
01460 {
01461     return mNodeMetaData;
01462 }
01463 
01464 CMetaData& CFEModel::GetElemMetaData()
01465 {
01466     return mElemMetaData;
01467 }
01468 
01469 CMetaData& CFEModel::GetGroupMetaData()
01470 {
01471     return mGroupMetaData;
01472 }
01473 
01474 CMetaData& CFEModel::GetBlockMetaData()
01475 {
01476     return mBlockMetaData;
01477 }
01478 
01479 CMetaData& CFEModel::GetNodeSetMetaData()
01480 {
01481     return mNodeSetMetaData;
01482 }
01483 
01484 CMetaData& CFEModel::GetSideSetMetaData()
01485 {
01486     return mSideSetMetaData;
01487 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines