LCOV - code coverage report
Current view: top level - util - CubitFileFEModel.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 850 0.0 %
Date: 2020-06-30 00:58:45 Functions: 0 27 0.0 %
Branches: 0 889 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*******************************************************************************
       2                 :            :     COPYRIGHT 2002 CATERPILLAR INC.  ALL RIGHTS RESERVED
       3                 :            : 
       4                 :            :     This program is the property of Caterpillar Inc., includes Caterpillar's
       5                 :            :     confidential and trade secret information, and is maintained as an
       6                 :            :     unpublished copyrighted work.  It is not to be copied or used by others
       7                 :            :     except under license from Caterpillar.  This program is also protected as an
       8                 :            :     unpublished work in accordance with the copyright act of 1976.  In the event
       9                 :            :     of either inadvertent or deliberate publication, Caterpillar Inc. intends to
      10                 :            :     maintain copyright protection for this work under the relevant copyright
      11                 :            :     laws pertaining to published works.  The inclusion of a copyright notice
      12                 :            :     hereon is precautionary only, and does not imply publication or disclosure.
      13                 :            : 
      14                 :            :  
      15                 :            :  Filename      : CubitFileFEModel.cpp
      16                 :            : 
      17                 :            :  Purpose       : Implements the reading and writing functionality for a FE
      18                 :            :                  model section of a Cubit (*.cub) format file.
      19                 :            :            
      20                 :            :  Special Notes :
      21                 :            : 
      22                 :            :  Creator       : Will A. Helden
      23                 :            : 
      24                 :            :  Creation Date : 02/15/02
      25                 :            : 
      26                 :            :  Owner         : Will A. Helden
      27                 :            : 
      28                 :            : *******************************************************************************/
      29                 :            : 
      30                 :            : #include "CubitFileFEModel.hpp"
      31                 :            : #include "CubitFileIOWrapper.hpp"
      32                 :            : 
      33                 :            : using namespace NCubitFile;
      34                 :            : 
      35                 :            : ///////////////////////////////////////////////////////////////////////////////
      36                 :            : // CFEModel
      37                 :            : ///////////////////////////////////////////////////////////////////////////////
      38                 :            : 
      39                 :            : // The number of 32 bit words contained int each of the stored structures.
      40                 :            : const UnsignedInt32 CFEModel::mintSizeOfFEModelHeader =
      41                 :            :     sizeof(SCubitFileFEModelHeader) / sizeof(UnsignedInt32);
      42                 :            : const UnsignedInt32 CFEModel::mintSizeOfGeomEntry =
      43                 :            :     sizeof(SCubitFileGeomEntry) / sizeof(UnsignedInt32);
      44                 :            : const UnsignedInt32 CFEModel::mintSizeOfGroupEntry =
      45                 :            :     sizeof(SCubitFileGroupEntry) / sizeof(UnsignedInt32);
      46                 :            : const UnsignedInt32 CFEModel::mintSizeOfBlockEntry =
      47                 :            :     sizeof(SCubitFileBlockEntry) / sizeof(UnsignedInt32);
      48                 :            : const UnsignedInt32 CFEModel::mintSizeOfNodeSetEntry =
      49                 :            :     sizeof(SCubitFileNodeSetEntry) / sizeof(UnsignedInt32);
      50                 :            : const UnsignedInt32 CFEModel::mintSizeOfSideSetEntry =
      51                 :            :     sizeof(SCubitFileSideSetEntry) / sizeof(UnsignedInt32);
      52                 :            : 
      53 [ #  # ][ #  # ]:          0 : CFEModel::CFEModel()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      54                 :            : {
      55                 :          0 :     mpReadFile = mpWriteFile = NULL;
      56                 :          0 :     mpaGeoms = NULL;
      57                 :          0 :     mpaGroups = NULL;
      58                 :          0 :     mpaBlocks = NULL;
      59                 :          0 :     mpaNodeSets = NULL;
      60                 :          0 :     mpaSideSets = NULL;
      61                 :            : 
      62                 :          0 :     mintFEModelOffset = 0;
      63                 :          0 :     memset(&mFEModel, 0, sizeof(SCubitFileFEModelHeader));
      64                 :          0 :     mFEModel.mintFEModelEndian = CCubitFile::mintNativeEndian;
      65                 :            : 
      66                 :            :     // Initialize the return buffers for file data - all memory allocated by
      67                 :            :     // this object should also be freed up by it.
      68                 :          0 :     memset(&mNodeBuff, 0, sizeof(SNodeReturnBuffer));
      69                 :          0 :     memset(&mElemBuff, 0, sizeof(SElemReturnBuffer));
      70                 :          0 :     memset(&mGroupBuff, 0, sizeof(SGroupReturnBuffer));
      71                 :          0 :     memset(&mBlockBuff, 0, sizeof(SBlockReturnBuffer));
      72                 :          0 :     memset(&mNodeSetBuff, 0, sizeof(SNodeSetReturnBuffer));
      73                 :          0 :     memset(&mSideSetBuff_10, 0, sizeof(SSideSetReturnBuffer_10));
      74                 :          0 :     memset(&mSideSetBuff_11, 0, sizeof(SSideSetReturnBuffer_11));
      75                 :          0 : }
      76                 :            : 
      77 [ #  # ][ #  # ]:          0 : CFEModel::~CFEModel()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      78                 :            : {
      79         [ #  # ]:          0 :     if(mpaGeoms)
      80         [ #  # ]:          0 :         delete [] mpaGeoms;
      81         [ #  # ]:          0 :     if(mpaGroups)
      82         [ #  # ]:          0 :         delete [] mpaGroups;
      83         [ #  # ]:          0 :     if(mpaBlocks)
      84         [ #  # ]:          0 :         delete [] mpaBlocks;
      85         [ #  # ]:          0 :     if(mpaNodeSets)
      86         [ #  # ]:          0 :         delete [] mpaNodeSets;
      87         [ #  # ]:          0 :     if(mpaSideSets)
      88         [ #  # ]:          0 :         delete [] mpaSideSets;
      89                 :            : 
      90         [ #  # ]:          0 :     if(mNodeBuff.mpaNodeIDs)
      91         [ #  # ]:          0 :         delete [] mNodeBuff.mpaNodeIDs;
      92         [ #  # ]:          0 :     if(mNodeBuff.mpadblX)
      93         [ #  # ]:          0 :         delete [] mNodeBuff.mpadblX;
      94         [ #  # ]:          0 :     if(mNodeBuff.mpadblY)
      95         [ #  # ]:          0 :         delete [] mNodeBuff.mpadblY;
      96         [ #  # ]:          0 :     if(mNodeBuff.mpadblZ)
      97         [ #  # ]:          0 :         delete [] mNodeBuff.mpadblZ;
      98         [ #  # ]:          0 :     if(mElemBuff.mpaElemData)
      99         [ #  # ]:          0 :         delete [] mElemBuff.mpaElemData;
     100         [ #  # ]:          0 :     if(mElemBuff.mpaElemIDs)
     101         [ #  # ]:          0 :         delete [] mElemBuff.mpaElemIDs;
     102         [ #  # ]:          0 :     if(mElemBuff.mpaElemGlobalIDs)
     103         [ #  # ]:          0 :         delete [] mElemBuff.mpaElemGlobalIDs;
     104         [ #  # ]:          0 :     if(mElemBuff.mpaElemConnect)
     105         [ #  # ]:          0 :         delete [] mElemBuff.mpaElemConnect;
     106         [ #  # ]:          0 :     if(mGroupBuff.mpaGroupData)
     107         [ #  # ]:          0 :         delete [] mGroupBuff.mpaGroupData;
     108         [ #  # ]:          0 :     if(mGroupBuff.mpaintMemberIDs)
     109         [ #  # ]:          0 :         delete [] mGroupBuff.mpaintMemberIDs;
     110         [ #  # ]:          0 :     if(mBlockBuff.mpaBlockData)
     111         [ #  # ]:          0 :         delete [] mBlockBuff.mpaBlockData;
     112         [ #  # ]:          0 :     if(mBlockBuff.mpaintMemberIDs)
     113         [ #  # ]:          0 :         delete [] mBlockBuff.mpaintMemberIDs;
     114         [ #  # ]:          0 :     if(mBlockBuff.mpadblAttributes)
     115         [ #  # ]:          0 :         delete [] mBlockBuff.mpadblAttributes;
     116         [ #  # ]:          0 :     if(mNodeSetBuff.mpaNodeSetData)
     117         [ #  # ]:          0 :         delete [] mNodeSetBuff.mpaNodeSetData;
     118         [ #  # ]:          0 :     if(mNodeSetBuff.mpaintMemberIDs)
     119         [ #  # ]:          0 :         delete [] mNodeSetBuff.mpaintMemberIDs;
     120                 :            :     
     121         [ #  # ]:          0 :     if(mSideSetBuff_10.mpaSideSetData)
     122         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpaSideSetData;
     123         [ #  # ]:          0 :     if(mSideSetBuff_10.mpaintMemberIDs)
     124         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpaintMemberIDs; 
     125         [ #  # ]:          0 :     if(mSideSetBuff_10.mpachrMemberSense)
     126         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpachrMemberSense;
     127         [ #  # ]:          0 :     if(mSideSetBuff_10.mpaintMemberSense)
     128         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpaintMemberSense;
     129         [ #  # ]:          0 :     if(mSideSetBuff_10.mpachrMemberSideNum)
     130         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpachrMemberSideNum;
     131         [ #  # ]:          0 :     if(mSideSetBuff_10.mpadblDistribution)
     132         [ #  # ]:          0 :         delete [] mSideSetBuff_10.mpadblDistribution;
     133                 :            :     
     134         [ #  # ]:          0 :     if(mSideSetBuff_11.mpaSideSetData)
     135         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpaSideSetData;
     136         [ #  # ]:          0 :     if(mSideSetBuff_11.mpaintMemberTypes)
     137         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpaintMemberTypes; 
     138         [ #  # ]:          0 :     if(mSideSetBuff_11.mpaintMemberIDs)
     139         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpaintMemberIDs; 
     140         [ #  # ]:          0 :     if(mSideSetBuff_11.mpachrMemberSense)
     141         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpachrMemberSense;
     142         [ #  # ]:          0 :     if(mSideSetBuff_11.mpaintMemberWRTEntities)
     143         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpaintMemberWRTEntities;
     144         [ #  # ]:          0 :     if(mSideSetBuff_11.mpadblDistribution)
     145         [ #  # ]:          0 :         delete [] mSideSetBuff_11.mpadblDistribution;
     146         [ #  # ]:          0 : }
     147                 :            : 
     148                 :            : 
     149                 :            : ///////////////////////////////////////////////////////////////////////////////
     150                 :            : // Write Functions
     151                 :            : ///////////////////////////////////////////////////////////////////////////////
     152                 :            : 
     153                 :          0 : UnsignedInt32 CFEModel::InitWrite(FILE* xpFile,
     154                 :            :                                   UnsignedInt32 xintGeomCount,
     155                 :            :                                   UnsignedInt32 xintGroupCount,
     156                 :            :                                   UnsignedInt32 xintBlockCount,
     157                 :            :                                   UnsignedInt32 xintNodeSetCount,
     158                 :            :                                   UnsignedInt32 xintSideSetCount)
     159                 :            : {
     160         [ #  # ]:          0 :     if(mpWriteFile)  throw CCubitFile::eFileWriteError;
     161                 :            : 
     162                 :          0 :     mpWriteFile = xpFile;
     163         [ #  # ]:          0 :     CIOWrapper lIO(mpWriteFile);
     164                 :            : 
     165                 :            :     // Write out the FE model header to reserve its position and size in the
     166                 :            :     // file.
     167         [ #  # ]:          0 :     mintFEModelOffset = lIO.BeginWriteBlock();
     168         [ #  # ]:          0 :     lIO.Write((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
     169         [ #  # ]:          0 :     mFEModel.mintFEModelLength = lIO.EndWriteBlock();
     170                 :            : 
     171                 :          0 :     mFEModel.mintGeometryCount = xintGeomCount;
     172         [ #  # ]:          0 :     if(xintGeomCount) {
     173                 :            :         // Create a geometry entity array for storing ownership statistics and
     174                 :            :         // initially blank it.
     175 [ #  # ][ #  # ]:          0 :         mpaGeoms = new SCubitFileGeomEntry[xintGeomCount];
     176                 :          0 :         memset(mpaGeoms, 0, sizeof(SCubitFileGeomEntry) * xintGeomCount);
     177                 :            : 
     178                 :            :         // Write the blank geometry table to the file to reserve its position
     179                 :            :         // and size in the file.
     180         [ #  # ]:          0 :         mFEModel.mintGeomTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
     181                 :            :         lIO.Write((UnsignedInt32*)mpaGeoms,
     182         [ #  # ]:          0 :             xintGeomCount * mintSizeOfGeomEntry);
     183         [ #  # ]:          0 :         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
     184                 :            :     }
     185                 :            : 
     186                 :          0 :     mFEModel.mintGroupCount = xintGroupCount;
     187         [ #  # ]:          0 :     if(xintGroupCount) {
     188                 :            :         // Create a group array for storing ownership statistics and
     189                 :            :         // initially blank it.
     190 [ #  # ][ #  # ]:          0 :         mpaGroups = new SCubitFileGroupEntry[xintGroupCount];
     191                 :          0 :         memset(mpaGroups, 0, sizeof(SCubitFileGroupEntry) * xintGroupCount);
     192                 :            : 
     193                 :            :         // Write the blank group table to the file to reserve its position
     194                 :            :         // and size in the file.
     195         [ #  # ]:          0 :         mFEModel.mintGroupTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
     196                 :            :         lIO.Write((UnsignedInt32*)mpaGroups,
     197         [ #  # ]:          0 :             xintGroupCount * mintSizeOfGroupEntry);
     198         [ #  # ]:          0 :         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
     199                 :            :     }
     200                 :            : 
     201                 :          0 :     mFEModel.mintBlockCount = xintBlockCount;
     202         [ #  # ]:          0 :     if(xintBlockCount) {
     203                 :            :         // Create a block array for storing ownership statistics and
     204                 :            :         // initially blank it.
     205 [ #  # ][ #  # ]:          0 :         mpaBlocks = new SCubitFileBlockEntry[xintBlockCount];
     206                 :          0 :         memset(mpaBlocks, 0, sizeof(SCubitFileBlockEntry) * xintBlockCount);
     207                 :            : 
     208                 :            :         // Write the blank block table to the file to reserve its position
     209                 :            :         // and size in the file.
     210         [ #  # ]:          0 :         mFEModel.mintBlockTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
     211                 :            :         lIO.Write((UnsignedInt32*)mpaBlocks,
     212         [ #  # ]:          0 :             xintBlockCount * mintSizeOfBlockEntry);
     213         [ #  # ]:          0 :         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
     214                 :            :     }
     215                 :            : 
     216                 :          0 :     mFEModel.mintNodeSetCount = xintNodeSetCount;
     217         [ #  # ]:          0 :     if(xintNodeSetCount) {
     218                 :            :         // Create a node set array for storing ownership statistics and
     219                 :            :         // initially blank it.
     220 [ #  # ][ #  # ]:          0 :         mpaNodeSets = new SCubitFileNodeSetEntry[xintNodeSetCount];
     221                 :          0 :         memset(mpaNodeSets, 0, sizeof(SCubitFileNodeSetEntry) * xintNodeSetCount);
     222                 :            : 
     223                 :            :         // Write the blank geometry table to the file to reserve its position
     224                 :            :         // and size in the file.
     225         [ #  # ]:          0 :         mFEModel.mintNodeSetTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
     226                 :            :         lIO.Write((UnsignedInt32*)mpaNodeSets,
     227         [ #  # ]:          0 :             xintNodeSetCount * mintSizeOfNodeSetEntry);
     228         [ #  # ]:          0 :         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
     229                 :            :     }
     230                 :            : 
     231                 :          0 :     mFEModel.mintSideSetCount = xintSideSetCount;
     232         [ #  # ]:          0 :     if(xintSideSetCount) {
     233                 :            :         // Create a SideSet array for storing ownership statistics and
     234                 :            :         // initially blank it.
     235 [ #  # ][ #  # ]:          0 :         mpaSideSets = new SCubitFileSideSetEntry[xintSideSetCount];
     236                 :          0 :         memset(mpaSideSets, 0, sizeof(SCubitFileSideSetEntry) * xintSideSetCount);
     237                 :            : 
     238                 :            :         // Write the blank geometry table to the file to reserve its position
     239                 :            :         // and size in the file.
     240         [ #  # ]:          0 :         mFEModel.mintSideSetTableOffset = lIO.BeginWriteBlock(mintFEModelOffset);
     241                 :            :         lIO.Write((UnsignedInt32*)mpaSideSets,
     242         [ #  # ]:          0 :             xintSideSetCount * mintSizeOfSideSetEntry);
     243         [ #  # ]:          0 :         mFEModel.mintFEModelLength += lIO.EndWriteBlock();
     244                 :            :     }
     245                 :            : 
     246         [ #  # ]:          0 :     return mintFEModelOffset;
     247                 :            : }
     248                 :            : 
     249                 :          0 : void CFEModel::WriteNodes(UnsignedInt32 xintIndex,
     250                 :            :                                                   UnsignedInt32 xintGeomID,
     251                 :            :                           UnsignedInt32 xintNodeCount,
     252                 :            :                           UnsignedInt32 *xpaintNodeIDs,
     253                 :            :                           double *xpadblX, double *xpadblY, double *xpadblZ)
     254                 :            : {
     255         [ #  # ]:          0 :     if(!mpWriteFile)
     256                 :          0 :         throw CCubitFile::eFileWriteError;
     257         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGeometryCount)
     258                 :          0 :         throw CCubitFile::eNotFound;
     259         [ #  # ]:          0 :     if(!mpaGeoms)
     260                 :          0 :         throw CCubitFile::eOrderError;
     261         [ #  # ]:          0 :     if(mpaGeoms[xintIndex].mintNodeCount)
     262                 :          0 :         throw CCubitFile::eDuplicateWrite;
     263                 :            : 
     264                 :          0 :         mpaGeoms[xintIndex].mintGeomID = xintGeomID;
     265                 :            : 
     266         [ #  # ]:          0 :     if(xintNodeCount) {
     267 [ #  # ][ #  # ]:          0 :         if(!xpaintNodeIDs || !xpadblX || !xpadblY || !xpadblZ)
         [ #  # ][ #  # ]
     268                 :          0 :             throw CCubitFile::ePassedNullPointer;
     269                 :            : 
     270         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     271                 :            : 
     272                 :          0 :         mpaGeoms[xintIndex].mintNodeCount = xintNodeCount;
     273                 :          0 :         mpaGeoms[xintIndex].mintNodeOffset =
     274                 :          0 :             lpIO->BeginWriteBlock(mintFEModelOffset);
     275                 :            : 
     276                 :          0 :         lpIO->Write(xpaintNodeIDs, xintNodeCount);
     277                 :          0 :         lpIO->Write(xpadblX, xintNodeCount);
     278                 :          0 :         lpIO->Write(xpadblY, xintNodeCount);
     279                 :          0 :         lpIO->Write(xpadblZ, xintNodeCount);
     280                 :            : 
     281                 :          0 :         mFEModel.mintFEModelLength += lpIO->EndWriteBlock();
     282                 :            : 
     283         [ #  # ]:          0 :         delete lpIO;
     284                 :            :     }
     285                 :          0 : }
     286                 :            : 
     287                 :          0 : void CFEModel::WriteElems(UnsignedInt32 xintIndex,
     288                 :            :                           UnsignedInt32 xintNumTypes, SElemData* xpaElemData)
     289                 :            : {
     290         [ #  # ]:          0 :     if(!mpWriteFile)
     291                 :          0 :         throw CCubitFile::eFileWriteError;
     292         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGeometryCount)
     293                 :          0 :         throw CCubitFile::eNotFound;
     294         [ #  # ]:          0 :     if(!mpaGeoms)
     295                 :          0 :         throw CCubitFile::eOrderError;
     296         [ #  # ]:          0 :     if(mpaGeoms[xintIndex].mintElemTypeCount)
     297                 :          0 :         throw CCubitFile::eDuplicateWrite;
     298                 :            : 
     299         [ #  # ]:          0 :     if(xintNumTypes) {
     300         [ #  # ]:          0 :         if(!xpaElemData)
     301                 :          0 :             throw CCubitFile::ePassedNullPointer;
     302                 :            :         UnsignedInt32 lintElem;
     303         [ #  # ]:          0 :         for(lintElem = 0; lintElem < xintNumTypes; lintElem++) {
     304         [ #  # ]:          0 :             if(xpaElemData[lintElem].mintElemCount) {
     305         [ #  # ]:          0 :                 if(!xpaElemData[lintElem].mpaElemIDs)
     306                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     307         [ #  # ]:          0 :                 if(!xpaElemData[lintElem].mpaElemGlobalIDs)
     308                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     309         [ #  # ]:          0 :                 if(xpaElemData[lintElem].mintElemOrder)
     310         [ #  # ]:          0 :                     if(!xpaElemData[lintElem].mpaElemConnect)
     311                 :          0 :                         throw CCubitFile::ePassedNullPointer;
     312                 :            :             }
     313                 :            :         }
     314                 :            : 
     315         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     316                 :          0 :         mpaGeoms[xintIndex].mintElemTypeCount = xintNumTypes;
     317                 :          0 :         mpaGeoms[xintIndex].mintElemOffset =
     318                 :          0 :             lpIO->BeginWriteBlock(mintFEModelOffset);
     319                 :            : 
     320         [ #  # ]:          0 :         for(lintElem = 0; lintElem < xintNumTypes; lintElem++) {
     321         [ #  # ]:          0 :             if(!xpaElemData[lintElem].mintElemCount) {
     322                 :          0 :                 mpaGeoms[xintIndex].mintElemTypeCount--;
     323                 :          0 :                 continue;
     324                 :            :             }
     325                 :            :             mpaGeoms[xintIndex].mintElemCount +=
     326                 :          0 :                 xpaElemData[lintElem].mintElemCount;
     327                 :            :         
     328                 :          0 :             lpIO->Write(&xpaElemData[lintElem].mintElemType, 1);
     329                 :          0 :             lpIO->Write(&xpaElemData[lintElem].mintElemOrder, 1);
     330                 :          0 :             lpIO->Write(&xpaElemData[lintElem].mintElemCount, 1);
     331                 :          0 :             lpIO->Write(xpaElemData[lintElem].mpaElemIDs,
     332                 :          0 :                 xpaElemData[lintElem].mintElemCount);
     333                 :          0 :             lpIO->Write(xpaElemData[lintElem].mpaElemGlobalIDs,
     334                 :          0 :                 xpaElemData[lintElem].mintElemCount);
     335         [ #  # ]:          0 :             if(xpaElemData[lintElem].mintElemOrder) {
     336                 :          0 :                 lpIO->Write(xpaElemData[lintElem].mpaElemConnect,
     337                 :          0 :                     xpaElemData[lintElem].mintElemCount *
     338                 :          0 :                     xpaElemData[lintElem].mintElemOrder);
     339                 :            :             }
     340                 :            :         }
     341                 :            : 
     342                 :          0 :         mpaGeoms[xintIndex].mintElemLength = lpIO->EndWriteBlock();
     343                 :          0 :         mFEModel.mintFEModelLength += mpaGeoms[xintIndex].mintElemLength;
     344         [ #  # ]:          0 :         delete lpIO;
     345                 :            :     }
     346                 :          0 : }
     347                 :            : 
     348                 :          0 : void CFEModel::WriteGroup(UnsignedInt32 xintIndex,
     349                 :            :                           UnsignedInt32 xintGroupID,
     350                 :            :                           UnsignedInt32 xintGroupType,
     351                 :            :                           const char* xpachrGroupName,
     352                 :            :                           UnsignedInt32 xintNumTypes,
     353                 :            :                           SGroupData* xpaGroupData)
     354                 :            : {
     355         [ #  # ]:          0 :     if(!mpWriteFile)
     356                 :          0 :         throw CCubitFile::eFileWriteError;
     357         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGroupCount)
     358                 :          0 :         throw CCubitFile::eNotFound;
     359         [ #  # ]:          0 :     if(!mpaGroups)
     360                 :          0 :         throw CCubitFile::eOrderError;
     361         [ #  # ]:          0 :     if(mpaGroups[xintIndex].mintMemberTypeCount)
     362                 :          0 :         throw CCubitFile::eDuplicateWrite;
     363                 :            : 
     364         [ #  # ]:          0 :     if(xintNumTypes) {  
     365                 :            :         // An empty group is valid, but an incompletely defined one is not.
     366         [ #  # ]:          0 :         if(!xpaGroupData)
     367                 :          0 :             throw CCubitFile::ePassedNullPointer;
     368         [ #  # ]:          0 :         for(UnsignedInt32 lintGroup = 0; lintGroup < xintNumTypes; lintGroup++) {
     369 [ #  # ][ #  # ]:          0 :             if(xpaGroupData[lintGroup].mintMemberCount &&
     370                 :          0 :                 !xpaGroupData[lintGroup].mpaMemberIDs)
     371                 :          0 :                 throw CCubitFile::ePassedNullPointer;
     372                 :            :         }
     373                 :            :     }
     374                 :            : 
     375                 :          0 :     mpaGroups[xintIndex].mintGroupID = xintGroupID;
     376                 :          0 :     mpaGroups[xintIndex].mintGroupType = xintGroupType;
     377                 :          0 :     mpaGroups[xintIndex].mintMemberTypeCount = xintNumTypes;
     378         [ #  # ]:          0 :     if(mGroupMetaData.SetValue(xintGroupID, "NAME", xpachrGroupName) !=
     379                 :            :         CCubitFile::eSuccess)
     380                 :          0 :         throw CCubitFile::eFileWriteError;
     381                 :            :     
     382         [ #  # ]:          0 :     if(xintNumTypes) {
     383         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     384                 :          0 :         mpaGroups[xintIndex].mintMemberOffset =
     385                 :          0 :             lpIO->BeginWriteBlock(mintFEModelOffset);
     386                 :            : 
     387         [ #  # ]:          0 :         for(UnsignedInt32 lintGroup = 0; lintGroup < xintNumTypes; lintGroup++) {
     388         [ #  # ]:          0 :             if(!xpaGroupData[lintGroup].mintMemberCount) {
     389                 :          0 :                 mpaGroups[xintIndex].mintMemberTypeCount--;
     390                 :          0 :                 continue;
     391                 :            :             }
     392                 :            :             mpaGroups[xintIndex].mintMemberCount +=
     393                 :          0 :                 xpaGroupData[lintGroup].mintMemberCount;
     394                 :            :             
     395                 :          0 :             lpIO->Write(&xpaGroupData[lintGroup].mintMemberType, 1);
     396                 :          0 :             lpIO->Write(&xpaGroupData[lintGroup].mintMemberCount, 1);
     397                 :          0 :             lpIO->Write(xpaGroupData[lintGroup].mpaMemberIDs,
     398                 :          0 :                 xpaGroupData[lintGroup].mintMemberCount);
     399                 :            :         }
     400                 :            :         
     401                 :          0 :         mpaGroups[xintIndex].mintGroupLength = lpIO->EndWriteBlock();
     402                 :          0 :         mFEModel.mintFEModelLength += mpaGroups[xintIndex].mintGroupLength;
     403         [ #  # ]:          0 :         delete lpIO;
     404                 :            :     }
     405                 :            :     else {
     406                 :            :         // An empty group does not have a data block in the file.
     407                 :          0 :         mpaGroups[xintIndex].mintMemberOffset = 0;
     408                 :          0 :         mpaGroups[xintIndex].mintGroupLength = 0;
     409                 :            :     }
     410                 :          0 : }
     411                 :            : 
     412                 :          0 : void CFEModel::WriteBlock(UnsignedInt32 xintIndex,
     413                 :            :                           UnsignedInt32 xintBlockID,
     414                 :            :                           int unique_id,
     415                 :            :                           UnsignedInt32 xintBlockType,
     416                 :            :                           UnsignedInt32 xintBlockColor,
     417                 :            :                           UnsignedInt32 xintMixedElemType,
     418                 :            :                           UnsignedInt32 xintDefPyramidType,
     419                 :            :                           UnsignedInt32 xintMaterialID,
     420                 :            :                           UnsignedInt32 xintBlockDimension,
     421                 :            :                           UnsignedInt32 xintNumTypes,
     422                 :            :                           SBlockData* xpaBlockData,
     423                 :            :                           UnsignedInt32 xintAttributeOrder,
     424                 :            :                           double* xpadblAttributes)
     425                 :            : {
     426         [ #  # ]:          0 :     if(!mpWriteFile)
     427                 :          0 :         throw CCubitFile::eFileWriteError;
     428         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintBlockCount)
     429                 :          0 :         throw CCubitFile::eNotFound;
     430         [ #  # ]:          0 :     if(!mpaBlocks)
     431                 :          0 :         throw CCubitFile::eOrderError;
     432         [ #  # ]:          0 :     if(mpaBlocks[xintIndex].mintMemberTypeCount)
     433                 :          0 :         throw CCubitFile::eDuplicateWrite;
     434                 :            : 
     435                 :            :     UnsignedInt32 lintBlock;
     436         [ #  # ]:          0 :     if(xintNumTypes) {  
     437                 :            :         // An empty block is valid, but an incompletely defined one is not.
     438         [ #  # ]:          0 :         if(!xpaBlockData)
     439                 :          0 :             throw CCubitFile::ePassedNullPointer;
     440         [ #  # ]:          0 :         for(lintBlock = 0; lintBlock < xintNumTypes; lintBlock++) {
     441 [ #  # ][ #  # ]:          0 :             if(xpaBlockData[lintBlock].mintMemberCount &&
     442                 :          0 :                 !xpaBlockData[lintBlock].mpaMemberIDs)
     443                 :          0 :                 throw CCubitFile::ePassedNullPointer;
     444                 :            :         }
     445                 :            :     }
     446                 :            : 
     447         [ #  # ]:          0 :     if(xintAttributeOrder) {
     448         [ #  # ]:          0 :         if(!xpadblAttributes)
     449                 :          0 :             throw CCubitFile::ePassedNullPointer;
     450                 :            :     }
     451                 :            : 
     452                 :          0 :     mpaBlocks[xintIndex].mintBlockID = xintBlockID;
     453                 :          0 :     mpaBlocks[xintIndex].mintBlockElementType = xintBlockType;
     454                 :          0 :     mpaBlocks[xintIndex].mintMemberTypeCount = xintNumTypes;
     455                 :          0 :     mpaBlocks[xintIndex].mintBlockColor = xintBlockColor;
     456                 :          0 :     mpaBlocks[xintIndex].mintBlockMixedElemType = xintMixedElemType;
     457                 :          0 :     mpaBlocks[xintIndex].mintBlockDefPyramidType = xintDefPyramidType;
     458                 :          0 :     mpaBlocks[xintIndex].mintBlockMaterial = xintMaterialID;
     459                 :          0 :     mpaBlocks[xintIndex].mintBlockDimension = xintBlockDimension;
     460                 :          0 :     mpaBlocks[xintIndex].mintAttributeOrder = xintAttributeOrder;
     461                 :            :     
     462                 :            :     
     463         [ #  # ]:          0 :     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     464                 :          0 :     mpaBlocks[xintIndex].mintMemberOffset =
     465                 :          0 :         lpIO->BeginWriteBlock(mintFEModelOffset);
     466                 :            : 
     467         [ #  # ]:          0 :     for(lintBlock = 0; lintBlock < xintNumTypes; lintBlock++) {
     468         [ #  # ]:          0 :         if(!xpaBlockData[lintBlock].mintMemberCount) {
     469                 :          0 :             mpaBlocks[xintIndex].mintMemberTypeCount--;
     470                 :          0 :             continue;
     471                 :            :         }
     472                 :            :         mpaBlocks[xintIndex].mintMemberCount +=
     473                 :          0 :             xpaBlockData[lintBlock].mintMemberCount;
     474                 :            : 
     475                 :          0 :         lpIO->Write(&xpaBlockData[lintBlock].mintMemberType, 1);
     476                 :          0 :         lpIO->Write(&xpaBlockData[lintBlock].mintMemberCount, 1);
     477                 :          0 :         lpIO->Write(xpaBlockData[lintBlock].mpaMemberIDs,
     478                 :          0 :             xpaBlockData[lintBlock].mintMemberCount);
     479                 :            :     }
     480         [ #  # ]:          0 :     if(xintAttributeOrder)
     481                 :          0 :         lpIO->Write(xpadblAttributes, xintAttributeOrder);
     482                 :            : 
     483                 :          0 :     lpIO->Write("id", 2);
     484                 :          0 :     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
     485                 :            : 
     486                 :          0 :     mpaBlocks[xintIndex].mintBlockLength = lpIO->EndWriteBlock();
     487                 :          0 :     mFEModel.mintFEModelLength += mpaBlocks[xintIndex].mintBlockLength;
     488         [ #  # ]:          0 :     delete lpIO;
     489                 :          0 : }
     490                 :            : 
     491                 :          0 : void CFEModel::WriteNodeSet(UnsignedInt32 xintIndex,
     492                 :            :                             UnsignedInt32 xintNodeSetID,
     493                 :            :                             int unique_id,
     494                 :            :                             UnsignedInt32 xintColor,
     495                 :            :                             UnsignedInt32 xintPointSymbol,
     496                 :            :                             UnsignedInt32 xintNumTypes,
     497                 :            :                             SNodeSetData* xpaNodeSetData,
     498                 :            :                             const std::vector<char>& bcdata)
     499                 :            : {
     500         [ #  # ]:          0 :     if(!mpWriteFile)
     501                 :          0 :         throw CCubitFile::eFileWriteError;
     502         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintNodeSetCount)
     503                 :          0 :         throw CCubitFile::eNotFound;
     504         [ #  # ]:          0 :     if(!mpaNodeSets)
     505                 :          0 :         throw CCubitFile::eOrderError;
     506         [ #  # ]:          0 :     if(mpaNodeSets[xintIndex].mintMemberTypeCount)
     507                 :          0 :         throw CCubitFile::eDuplicateWrite;
     508                 :            : 
     509                 :            :     UnsignedInt32 lintNodeSet;
     510         [ #  # ]:          0 :     if(xintNumTypes) {  
     511                 :            :         // An empty node set is valid, but an incompletely defined one is not.
     512         [ #  # ]:          0 :         if(!xpaNodeSetData)
     513                 :          0 :             throw CCubitFile::ePassedNullPointer;
     514         [ #  # ]:          0 :         for(lintNodeSet = 0; lintNodeSet < xintNumTypes; lintNodeSet++) {
     515 [ #  # ][ #  # ]:          0 :             if(xpaNodeSetData[lintNodeSet].mintMemberCount &&
     516                 :          0 :                 !xpaNodeSetData[lintNodeSet].mpaMemberIDs)
     517                 :          0 :                 throw CCubitFile::ePassedNullPointer;
     518                 :            :         }
     519                 :            :     }
     520                 :            : 
     521                 :          0 :     mpaNodeSets[xintIndex].mintNodeSetID = xintNodeSetID;
     522                 :          0 :     mpaNodeSets[xintIndex].mintMemberTypeCount = xintNumTypes;
     523                 :          0 :     mpaNodeSets[xintIndex].mintNodeSetPointSym = xintPointSymbol;
     524                 :          0 :     mpaNodeSets[xintIndex].mintNodeSetColor = xintColor;
     525                 :            :     
     526 [ #  # ][ #  # ]:          0 :     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     527                 :          0 :     mpaNodeSets[xintIndex].mintMemberOffset =
     528         [ #  # ]:          0 :         lpIO->BeginWriteBlock(mintFEModelOffset);
     529                 :            : 
     530         [ #  # ]:          0 :     for(lintNodeSet = 0; lintNodeSet < xintNumTypes; lintNodeSet++) {
     531         [ #  # ]:          0 :         if(!xpaNodeSetData[lintNodeSet].mintMemberCount) {
     532                 :          0 :             mpaNodeSets[xintIndex].mintMemberTypeCount--;
     533                 :          0 :             continue;
     534                 :            :         }
     535                 :            :         mpaNodeSets[xintIndex].mintMemberCount +=
     536                 :          0 :             xpaNodeSetData[lintNodeSet].mintMemberCount;
     537                 :            : 
     538         [ #  # ]:          0 :         lpIO->Write(&xpaNodeSetData[lintNodeSet].mintMemberType, 1);
     539         [ #  # ]:          0 :         lpIO->Write(&xpaNodeSetData[lintNodeSet].mintMemberCount, 1);
     540                 :          0 :         lpIO->Write(xpaNodeSetData[lintNodeSet].mpaMemberIDs,
     541         [ #  # ]:          0 :             xpaNodeSetData[lintNodeSet].mintMemberCount);
     542                 :            :     }
     543                 :            : 
     544         [ #  # ]:          0 :     UnsignedInt32 size = bcdata.size();
     545         [ #  # ]:          0 :     if(size)
     546                 :            :     {
     547         [ #  # ]:          0 :         lpIO->Write("bc", 2);
     548         [ #  # ]:          0 :         lpIO->Write(&size, 1);
     549 [ #  # ][ #  # ]:          0 :         lpIO->Write(&bcdata[0], size);
     550                 :            :     }
     551                 :            : 
     552         [ #  # ]:          0 :     lpIO->Write("id", 2);
     553         [ #  # ]:          0 :     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
     554                 :            : 
     555         [ #  # ]:          0 :     mpaNodeSets[xintIndex].mintNodeSetLength = lpIO->EndWriteBlock();
     556                 :          0 :     mFEModel.mintFEModelLength += mpaNodeSets[xintIndex].mintNodeSetLength;
     557 [ #  # ][ #  # ]:          0 :     delete lpIO;
     558                 :          0 : }
     559                 :            : 
     560                 :          0 : void CFEModel::WriteSideSet_11(UnsignedInt32 xintIndex,
     561                 :            :                             UnsignedInt32 xintSideSetID,
     562                 :            :                             int unique_id,
     563                 :            :                             UnsignedInt32 xintColor,
     564                 :            :                             UnsignedInt32 xintUseShells,
     565                 :            :                             UnsignedInt32 xintNumTypes,
     566                 :            :                             SSideSetData_11* xpaSideSetData,
     567                 :            :                             UnsignedInt32 xintNumDistFact,
     568                 :            :                             double* xpadblDistribution,
     569                 :            :                             const std::vector<char>& bcdata)
     570                 :            : {
     571         [ #  # ]:          0 :     if(!mpWriteFile)
     572                 :          0 :         throw CCubitFile::eFileWriteError;
     573         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintSideSetCount)
     574                 :          0 :         throw CCubitFile::eNotFound;
     575         [ #  # ]:          0 :     if(!mpaSideSets)
     576                 :          0 :         throw CCubitFile::eOrderError;
     577         [ #  # ]:          0 :     if(mpaSideSets[xintIndex].mintMemberTypeCount)
     578                 :          0 :         throw CCubitFile::eDuplicateWrite;
     579                 :            : 
     580                 :            :     UnsignedInt32 lintSideSet;
     581         [ #  # ]:          0 :     if(xintNumTypes) {  
     582                 :            :         // An empty side set is valid, but an incompletely defined one is not.
     583         [ #  # ]:          0 :         if(!xpaSideSetData)
     584                 :          0 :             throw CCubitFile::ePassedNullPointer;
     585         [ #  # ]:          0 :         for(lintSideSet = 0; lintSideSet < xintNumTypes; lintSideSet++) {
     586         [ #  # ]:          0 :             if(xpaSideSetData[lintSideSet].mintMemberCount) {
     587         [ #  # ]:          0 :                 if(!xpaSideSetData[lintSideSet].mpaintMemberTypes)
     588                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     589         [ #  # ]:          0 :                 if(!xpaSideSetData[lintSideSet].mpaintMemberIDs)
     590                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     591         [ #  # ]:          0 :                 if(!xpaSideSetData[lintSideSet].mpachrMemberSenses)
     592                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     593         [ #  # ]:          0 :                 if(!xpaSideSetData[lintSideSet].mpaintMemberWRTEntities)
     594                 :          0 :                     throw CCubitFile::ePassedNullPointer;
     595                 :            :             }
     596                 :            :         }
     597                 :            :     }
     598                 :            :     
     599         [ #  # ]:          0 :     if(xintNumDistFact) {
     600         [ #  # ]:          0 :         if(!xpadblDistribution)
     601                 :          0 :             throw CCubitFile::ePassedNullPointer;
     602                 :            :     }
     603                 :            : 
     604                 :          0 :     mpaSideSets[xintIndex].mintSideSetID = xintSideSetID;
     605                 :          0 :     mpaSideSets[xintIndex].mintMemberTypeCount = xintNumTypes;
     606                 :          0 :     mpaSideSets[xintIndex].mintSideSetColor = xintColor;
     607                 :          0 :     mpaSideSets[xintIndex].mintUseShells = xintUseShells;
     608                 :          0 :     mpaSideSets[xintIndex].mintNumDistFact = xintNumDistFact;
     609                 :            : 
     610 [ #  # ][ #  # ]:          0 :     CIOWrapper* lpIO = new CIOWrapper(mpWriteFile);
     611                 :          0 :     mpaSideSets[xintIndex].mintMemberOffset =
     612         [ #  # ]:          0 :         lpIO->BeginWriteBlock(mintFEModelOffset);
     613                 :            : 
     614         [ #  # ]:          0 :     for(lintSideSet = 0; lintSideSet < xintNumTypes; lintSideSet++) {
     615         [ #  # ]:          0 :         if(!xpaSideSetData[lintSideSet].mintMemberCount) {
     616                 :          0 :             mpaSideSets[xintIndex].mintMemberTypeCount--;
     617                 :          0 :             continue;
     618                 :            :         }
     619                 :            :         mpaSideSets[xintIndex].mintMemberCount +=
     620                 :          0 :             xpaSideSetData[lintSideSet].mintMemberCount;
     621                 :            : 
     622         [ #  # ]:          0 :         lpIO->Write(&xpaSideSetData[lintSideSet].mintMemberCount, 1);
     623                 :          0 :         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberTypes, 
     624         [ #  # ]:          0 :             xpaSideSetData[lintSideSet].mintMemberCount);
     625                 :          0 :         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberIDs,
     626         [ #  # ]:          0 :             xpaSideSetData[lintSideSet].mintMemberCount);
     627                 :            : 
     628                 :            :         //for the zero-eth one, mpachrMemberSenses is intMemberCount long
     629         [ #  # ]:          0 :         if( 0 == lintSideSet ) 
     630                 :          0 :           lpIO->Write(xpaSideSetData[lintSideSet].mpachrMemberSenses,
     631         [ #  # ]:          0 :             xpaSideSetData[lintSideSet].mintMemberCount, 1);
     632                 :            :         else  //for 1-n, it is 1 long
     633         [ #  # ]:          0 :           lpIO->Write(xpaSideSetData[lintSideSet].mpachrMemberSenses, 1, 1);
     634                 :          0 :         UnsignedInt32* end = xpaSideSetData[lintSideSet].mpaintMemberWRTEntities;
     635                 :            :         int i;
     636         [ #  # ]:          0 :         for(i=0; i<(int)xpaSideSetData[lintSideSet].mintMemberCount; i++)
     637                 :            :         {
     638                 :          0 :             UnsignedInt32 num_wrt = *end;
     639                 :          0 :             end = end + 1 + (num_wrt * 2);
     640                 :            :         }
     641                 :          0 :         UnsignedInt32 wrt_size = static_cast<UnsignedInt32>(end - xpaSideSetData[lintSideSet].mpaintMemberWRTEntities);
     642         [ #  # ]:          0 :         lpIO->Write(&wrt_size, 1);
     643         [ #  # ]:          0 :         lpIO->Write(xpaSideSetData[lintSideSet].mpaintMemberWRTEntities, wrt_size);
     644                 :            :     }
     645         [ #  # ]:          0 :     if(xintNumDistFact)
     646         [ #  # ]:          0 :         lpIO->Write(xpadblDistribution, xintNumDistFact);
     647                 :            : 
     648         [ #  # ]:          0 :     UnsignedInt32 size = bcdata.size();
     649         [ #  # ]:          0 :     if(size)
     650                 :            :     {
     651         [ #  # ]:          0 :         lpIO->Write("bc", 2);
     652         [ #  # ]:          0 :         lpIO->Write(&size, 1);
     653 [ #  # ][ #  # ]:          0 :         lpIO->Write(&bcdata[0], size);
     654                 :            :     }
     655                 :            : 
     656         [ #  # ]:          0 :     lpIO->Write("id", 2);
     657         [ #  # ]:          0 :     lpIO->Write(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
     658                 :            : 
     659         [ #  # ]:          0 :     mpaSideSets[xintIndex].mintSideSetLength = lpIO->EndWriteBlock();
     660                 :          0 :     mFEModel.mintFEModelLength += mpaSideSets[xintIndex].mintSideSetLength;
     661 [ #  # ][ #  # ]:          0 :     delete lpIO;
     662                 :          0 : }
     663                 :            : 
     664                 :          0 : UnsignedInt32 CFEModel::EndWrite()
     665                 :            : {
     666         [ #  # ]:          0 :     CIOWrapper lIO(mpWriteFile);
     667                 :            : 
     668         [ #  # ]:          0 :     if(mFEModel.mintGeometryCount) {
     669         [ #  # ]:          0 :         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintGeomTableOffset);
     670                 :            :         lIO.Write((UnsignedInt32*)mpaGeoms,
     671         [ #  # ]:          0 :             mFEModel.mintGeometryCount * mintSizeOfGeomEntry);
     672         [ #  # ]:          0 :         lIO.EndWriteBlock();
     673                 :            :     }
     674                 :            : 
     675         [ #  # ]:          0 :     if(mFEModel.mintGroupCount) {
     676         [ #  # ]:          0 :         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintGroupTableOffset);
     677                 :            :         lIO.Write((UnsignedInt32*)mpaGroups,
     678         [ #  # ]:          0 :             mFEModel.mintGroupCount * mintSizeOfGroupEntry);
     679         [ #  # ]:          0 :         lIO.EndWriteBlock();
     680                 :            :     }
     681                 :            : 
     682         [ #  # ]:          0 :     if(mFEModel.mintBlockCount) {
     683         [ #  # ]:          0 :         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintBlockTableOffset);
     684                 :            :         lIO.Write((UnsignedInt32*)mpaBlocks,
     685         [ #  # ]:          0 :             mFEModel.mintBlockCount * mintSizeOfBlockEntry);
     686         [ #  # ]:          0 :         lIO.EndWriteBlock();
     687                 :            :     }
     688                 :            : 
     689         [ #  # ]:          0 :     if(mFEModel.mintNodeSetCount) {
     690         [ #  # ]:          0 :         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintNodeSetTableOffset);
     691                 :            :         lIO.Write((UnsignedInt32*)mpaNodeSets,
     692         [ #  # ]:          0 :             mFEModel.mintNodeSetCount * mintSizeOfNodeSetEntry);
     693         [ #  # ]:          0 :         lIO.EndWriteBlock();
     694                 :            :     }
     695                 :            : 
     696         [ #  # ]:          0 :     if(mFEModel.mintSideSetCount) {
     697         [ #  # ]:          0 :         lIO.BeginRewriteBlock(mintFEModelOffset, mFEModel.mintSideSetTableOffset);
     698                 :            :         lIO.Write((UnsignedInt32*)mpaSideSets,
     699         [ #  # ]:          0 :             mFEModel.mintSideSetCount * mintSizeOfSideSetEntry);
     700         [ #  # ]:          0 :         lIO.EndWriteBlock();
     701                 :            :     }
     702                 :            : 
     703                 :            :     UnsignedInt32 lintMetaDataLength;
     704                 :            :     mGeomMetaData.WriteMetaData(mpWriteFile, mFEModel.mintGeomMetaDataOffset,
     705         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     706                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     707                 :            :     mNodeMetaData.WriteMetaData(mpWriteFile, mFEModel.mintNodeMetaDataOffset,
     708         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     709                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     710                 :            :     mElemMetaData.WriteMetaData(mpWriteFile, mFEModel.mintElemMetaDataOffset,
     711         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     712                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     713                 :            :     mGroupMetaData.WriteMetaData(mpWriteFile, mFEModel.mintGroupMetaDataOffset,
     714         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     715                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     716                 :            :     mBlockMetaData.WriteMetaData(mpWriteFile, mFEModel.mintBlockMetaDataOffset,
     717         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     718                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     719                 :            :     mNodeSetMetaData.WriteMetaData(mpWriteFile, mFEModel.mintNodeSetMetaDataOffset,
     720         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     721                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     722                 :            :     mSideSetMetaData.WriteMetaData(mpWriteFile, mFEModel.mintSideSetMetaDataOffset,
     723         [ #  # ]:          0 :         lintMetaDataLength, mintFEModelOffset);
     724                 :          0 :     mFEModel.mintFEModelLength += lintMetaDataLength;
     725                 :            : 
     726         [ #  # ]:          0 :     lIO.BeginRewriteBlock(mintFEModelOffset, 0);
     727         [ #  # ]:          0 :     lIO.Write((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
     728         [ #  # ]:          0 :     lIO.EndWriteBlock();
     729                 :            : 
     730                 :          0 :     mpWriteFile = NULL;
     731         [ #  # ]:          0 :     return mFEModel.mintFEModelLength;
     732                 :            : }
     733                 :            : 
     734                 :            : 
     735                 :            : ///////////////////////////////////////////////////////////////////////////////
     736                 :            : // Read Functions
     737                 :            : ///////////////////////////////////////////////////////////////////////////////
     738                 :            : 
     739                 :          0 : void CFEModel::InitRead(FILE* xpFile,
     740                 :            :                         UnsignedInt32 xintAbsoluteOffset,
     741                 :            :                         UnsignedInt32& xintGeomCount,
     742                 :            :                         UnsignedInt32& xintGroupCount,
     743                 :            :                         UnsignedInt32& xintBlockCount,
     744                 :            :                         UnsignedInt32& xintNodeSetCount,
     745                 :            :                         UnsignedInt32& xintSideSetCount)
     746                 :            : {
     747         [ #  # ]:          0 :     if(mpReadFile)
     748                 :          0 :         throw CCubitFile::eOrderError;
     749                 :            : 
     750                 :          0 :     mpReadFile = xpFile;
     751                 :          0 :     mintFEModelOffset = xintAbsoluteOffset;
     752         [ #  # ]:          0 :     CIOWrapper lIO(mpReadFile, xintAbsoluteOffset, 0);
     753                 :            : 
     754         [ #  # ]:          0 :     lIO.BeginReadBlock(mintFEModelOffset, 0);
     755         [ #  # ]:          0 :     lIO.Read((UnsignedInt32*)&mFEModel, mintSizeOfFEModelHeader);
     756         [ #  # ]:          0 :     lIO.EndReadBlock();
     757                 :          0 :     xintGeomCount = mFEModel.mintGeometryCount;
     758                 :          0 :     xintGroupCount = mFEModel.mintGroupCount;
     759                 :          0 :     xintBlockCount = mFEModel.mintBlockCount;
     760                 :          0 :     xintNodeSetCount = mFEModel.mintNodeSetCount;
     761                 :          0 :     xintSideSetCount = mFEModel.mintSideSetCount;
     762                 :            : 
     763                 :            :     // Restore the geometry definition header table if there is one.
     764         [ #  # ]:          0 :     if(mFEModel.mintGeometryCount) {
     765 [ #  # ][ #  # ]:          0 :         mpaGeoms = new SCubitFileGeomEntry[mFEModel.mintGeometryCount];
     766                 :            : 
     767         [ #  # ]:          0 :         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintGeomTableOffset);
     768                 :            :         lIO.Read((UnsignedInt32*)mpaGeoms,
     769         [ #  # ]:          0 :             mFEModel.mintGeometryCount * mintSizeOfGeomEntry);
     770         [ #  # ]:          0 :         lIO.EndReadBlock();
     771                 :            :     }
     772                 :            : 
     773                 :            :     // Restore the group definition header table if there is one.
     774         [ #  # ]:          0 :     if(mFEModel.mintGroupCount) {
     775 [ #  # ][ #  # ]:          0 :         mpaGroups = new SCubitFileGroupEntry[mFEModel.mintGroupCount];
     776                 :            : 
     777         [ #  # ]:          0 :         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintGroupTableOffset);
     778                 :            :         lIO.Read((UnsignedInt32*)mpaGroups,
     779         [ #  # ]:          0 :             mFEModel.mintGroupCount * mintSizeOfGroupEntry);
     780         [ #  # ]:          0 :         lIO.EndReadBlock();
     781                 :            :     }
     782                 :            : 
     783                 :            :     // Restore the block definition header table if there is one.
     784         [ #  # ]:          0 :     if(mFEModel.mintBlockCount) {
     785 [ #  # ][ #  # ]:          0 :         mpaBlocks = new SCubitFileBlockEntry[mFEModel.mintBlockCount];
     786                 :            : 
     787         [ #  # ]:          0 :         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintBlockTableOffset);
     788                 :            :         lIO.Read((UnsignedInt32*)mpaBlocks,
     789         [ #  # ]:          0 :             mFEModel.mintBlockCount * mintSizeOfBlockEntry);
     790         [ #  # ]:          0 :         lIO.EndReadBlock();
     791                 :            :     }
     792                 :            : 
     793                 :            :     // Restore the node set definition header table if there is one.
     794         [ #  # ]:          0 :     if(mFEModel.mintNodeSetCount) {
     795 [ #  # ][ #  # ]:          0 :         mpaNodeSets = new SCubitFileNodeSetEntry[mFEModel.mintNodeSetCount];
     796                 :            : 
     797         [ #  # ]:          0 :         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintNodeSetTableOffset);
     798                 :            :         lIO.Read((UnsignedInt32*)mpaNodeSets,
     799         [ #  # ]:          0 :             mFEModel.mintNodeSetCount * mintSizeOfNodeSetEntry);
     800         [ #  # ]:          0 :         lIO.EndReadBlock();
     801                 :            :     }
     802                 :            : 
     803                 :            :     // Restore the side set definition header table if there is one.
     804         [ #  # ]:          0 :     if(mFEModel.mintSideSetCount) {
     805 [ #  # ][ #  # ]:          0 :         mpaSideSets = new SCubitFileSideSetEntry[mFEModel.mintSideSetCount];
     806                 :            : 
     807         [ #  # ]:          0 :         lIO.BeginReadBlock(mintFEModelOffset, mFEModel.mintSideSetTableOffset);
     808                 :            :         lIO.Read((UnsignedInt32*)mpaSideSets,
     809         [ #  # ]:          0 :             mFEModel.mintSideSetCount * mintSizeOfSideSetEntry);
     810         [ #  # ]:          0 :         lIO.EndReadBlock();
     811                 :            :     }
     812                 :            : 
     813                 :            :     mGeomMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     814         [ #  # ]:          0 :         mFEModel.mintGeomMetaDataOffset, mFEModel.mintFEModelEndian);
     815                 :            :     mNodeMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     816         [ #  # ]:          0 :         mFEModel.mintNodeMetaDataOffset, mFEModel.mintFEModelEndian);
     817                 :            :     mElemMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     818         [ #  # ]:          0 :         mFEModel.mintElemMetaDataOffset, mFEModel.mintFEModelEndian);
     819                 :            :     mGroupMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     820         [ #  # ]:          0 :         mFEModel.mintGroupMetaDataOffset, mFEModel.mintFEModelEndian);
     821                 :            :     mBlockMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     822         [ #  # ]:          0 :         mFEModel.mintBlockMetaDataOffset, mFEModel.mintFEModelEndian);
     823                 :            :     mNodeSetMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     824         [ #  # ]:          0 :         mFEModel.mintNodeSetMetaDataOffset, mFEModel.mintFEModelEndian);
     825                 :            :     mSideSetMetaData.ReadMetaData(mpReadFile, mintFEModelOffset,
     826 [ #  # ][ #  # ]:          0 :         mFEModel.mintSideSetMetaDataOffset, mFEModel.mintFEModelEndian);
     827                 :          0 : }
     828                 :            : 
     829                 :          0 : void CFEModel::ReadNodes(UnsignedInt32 xintIndex,
     830                 :            :                                                  UnsignedInt32& xintGeomID,
     831                 :            :                          UnsignedInt32& xintNodeCount,
     832                 :            :                          UnsignedInt32*& xpaintNodeIDs,
     833                 :            :                          double*& xpadblX,
     834                 :            :                          double*& xpadblY,
     835                 :            :                          double*& xpadblZ)
     836                 :            : {
     837         [ #  # ]:          0 :     if(!mpReadFile)
     838                 :          0 :         throw CCubitFile::eFileReadError;
     839         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGeometryCount)
     840                 :          0 :         throw CCubitFile::eNotFound;
     841         [ #  # ]:          0 :     if(!mpaGeoms)
     842                 :          0 :         throw CCubitFile::eOrderError;
     843                 :            : 
     844                 :          0 :         xintGeomID = mpaGeoms[xintIndex].mintGeomID;
     845                 :          0 :     xintNodeCount = mpaGeoms[xintIndex].mintNodeCount;
     846         [ #  # ]:          0 :     if(xintNodeCount) {
     847         [ #  # ]:          0 :         if(mNodeBuff.mintNumNodes < xintNodeCount) {
     848         [ #  # ]:          0 :             if(mNodeBuff.mpaNodeIDs)
     849         [ #  # ]:          0 :                 delete [] mNodeBuff.mpaNodeIDs;
     850         [ #  # ]:          0 :             if(mNodeBuff.mpadblX)
     851         [ #  # ]:          0 :                 delete [] mNodeBuff.mpadblX;
     852         [ #  # ]:          0 :             if(mNodeBuff.mpadblY)
     853         [ #  # ]:          0 :                 delete [] mNodeBuff.mpadblY;
     854         [ #  # ]:          0 :             if(mNodeBuff.mpadblZ)
     855         [ #  # ]:          0 :                 delete [] mNodeBuff.mpadblZ;
     856                 :          0 :             mNodeBuff.mintNumNodes = xintNodeCount;
     857         [ #  # ]:          0 :             mNodeBuff.mpaNodeIDs = new UnsignedInt32[xintNodeCount];
     858         [ #  # ]:          0 :             mNodeBuff.mpadblX = new double[xintNodeCount];
     859         [ #  # ]:          0 :             mNodeBuff.mpadblY = new double[xintNodeCount];
     860         [ #  # ]:          0 :             mNodeBuff.mpadblZ = new double[xintNodeCount];
     861                 :            :         }
     862                 :          0 :         xpaintNodeIDs = mNodeBuff.mpaNodeIDs;
     863                 :          0 :         xpadblX = mNodeBuff.mpadblX;
     864                 :          0 :         xpadblY = mNodeBuff.mpadblY;
     865                 :          0 :         xpadblZ = mNodeBuff.mpadblZ;
     866                 :            : 
     867         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
     868                 :            :     
     869                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
     870                 :          0 :             mpaGeoms[xintIndex].mintNodeOffset);
     871                 :          0 :         lpIO->Read(mNodeBuff.mpaNodeIDs, xintNodeCount);
     872                 :          0 :         lpIO->Read(mNodeBuff.mpadblX, xintNodeCount);
     873                 :          0 :         lpIO->Read(mNodeBuff.mpadblY, xintNodeCount);
     874                 :          0 :         lpIO->Read(mNodeBuff.mpadblZ, xintNodeCount);
     875                 :          0 :         lpIO->EndReadBlock();
     876                 :            : 
     877         [ #  # ]:          0 :         delete lpIO;
     878                 :            :     }
     879                 :            :     else {
     880                 :          0 :         xpaintNodeIDs = NULL;
     881                 :          0 :         xpadblX = xpadblY = xpadblZ = NULL;
     882                 :            :     }
     883                 :          0 : }
     884                 :            : 
     885                 :          0 : void CFEModel::ReadElems(double data_version,
     886                 :            :                          UnsignedInt32 xintIndex, UnsignedInt32& xintGeomID,
     887                 :            :                          UnsignedInt32& xintNumTypes, SElemData*& xpaElemData)
     888                 :            : {
     889         [ #  # ]:          0 :     if(!mpReadFile)
     890                 :          0 :         throw CCubitFile::eFileReadError;
     891         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGeometryCount)
     892                 :          0 :         throw CCubitFile::eNotFound;
     893         [ #  # ]:          0 :     if(!mpaGeoms)
     894                 :          0 :         throw CCubitFile::eOrderError;
     895                 :            : 
     896                 :          0 :         xintGeomID = mpaGeoms[xintIndex].mintGeomID;
     897                 :          0 :     xintNumTypes = mpaGeoms[xintIndex].mintElemTypeCount;
     898         [ #  # ]:          0 :     if(xintNumTypes) {
     899                 :            :         // Resize the element return buffer if necessary and then set the return
     900                 :            :         // pointers to the buffer.
     901                 :            :         //
     902                 :            :         // NOTE: if the number of element types is greater than 1, a single buffer
     903                 :            :         // is allocated for the total number of elements.  In the read loop below
     904                 :            :         // the pointer to the buffer needs to be updated with each loop so as
     905                 :            :         // not to overwrite what was read previously.
     906                 :            :         //
     907                 :            : 
     908                 :            : 
     909                 :            : 
     910                 :            :         UnsignedInt32 lintConnGuess = 
     911                 :          0 :             mpaGeoms[xintIndex].mintElemLength / sizeof(UnsignedInt32) -
     912                 :          0 :             mpaGeoms[xintIndex].mintElemCount;
     913                 :            :             // - 3 * mpaGeoms[xintIndex].mintElemTypeCount; (exact)
     914                 :            :         xpaElemData = AdjustBuffer(xintNumTypes,
     915                 :          0 :             mElemBuff.mintNumTypes, mElemBuff.mpaElemData);
     916                 :            :         UnsignedInt32* lpIDs =
     917                 :          0 :             AdjustBuffer(mpaGeoms[xintIndex].mintElemCount,
     918                 :          0 :             mElemBuff.mintNumElemIds, mElemBuff.mpaElemIDs);
     919                 :          0 :         UnsignedInt32* lpGlobalIDs = NULL;
     920         [ #  # ]:          0 :         if ( data_version >= 1.3 )
     921                 :            :         {
     922                 :            :           lpGlobalIDs =
     923                 :          0 :             AdjustBuffer(mpaGeoms[xintIndex].mintElemCount,
     924                 :          0 :             mElemBuff.mintNumElemGids, mElemBuff.mpaElemGlobalIDs);
     925                 :            :         }
     926                 :            : 
     927                 :            :         UnsignedInt32* lpConnect =
     928                 :            :             AdjustBuffer(lintConnGuess,
     929                 :          0 :             mElemBuff.mintNumConnect, mElemBuff.mpaElemConnect);
     930                 :            : 
     931                 :            :         // Read the element from the file.
     932                 :            :         UnsignedInt32 lintNumElems, lintNumConnect;
     933                 :          0 :         UnsignedInt32 lintTotalElems = 0, lintTotalConnect = 0;
     934         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
     935                 :            : 
     936                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
     937                 :          0 :             mpaGeoms[xintIndex].mintElemOffset);
     938         [ #  # ]:          0 :         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
     939                 :          0 :             lpIO->Read(&xpaElemData[lintType].mintElemType, 1);
     940                 :          0 :             lpIO->Read(&xpaElemData[lintType].mintElemOrder, 1);
     941                 :          0 :             lpIO->Read(&xpaElemData[lintType].mintElemCount, 1);
     942                 :            : 
     943                 :          0 :             xpaElemData[lintType].mpaElemIDs = lpIDs;
     944                 :          0 :             xpaElemData[lintType].mpaElemGlobalIDs = lpGlobalIDs;
     945                 :          0 :             xpaElemData[lintType].mpaElemConnect = lpConnect;
     946                 :          0 :             lintNumElems = xpaElemData[lintType].mintElemCount;
     947                 :          0 :             lintNumConnect = lintNumElems * xpaElemData[lintType].mintElemOrder;
     948                 :            :             // Make sure the total number of elements or connection entries
     949                 :            :             // does not exceed what was specified in the geometry table entry.
     950                 :          0 :             lintTotalElems += lintNumElems;
     951                 :          0 :             lintTotalConnect += lintNumConnect;
     952 [ #  # ][ #  # ]:          0 :             if((lintTotalElems > mpaGeoms[xintIndex].mintElemCount) ||
     953                 :            :                 (lintTotalConnect > lintConnGuess))
     954                 :          0 :                 throw CCubitFile::eFileReadError;
     955                 :            : 
     956                 :          0 :             lpIO->Read(xpaElemData[lintType].mpaElemIDs, lintNumElems);
     957         [ #  # ]:          0 :             if ( data_version >= 1.3 )
     958                 :          0 :                 lpIO->Read(xpaElemData[lintType].mpaElemGlobalIDs, lintNumElems);
     959         [ #  # ]:          0 :             if(xpaElemData[lintType].mintElemOrder)
     960                 :          0 :                 lpIO->Read(xpaElemData[lintType].mpaElemConnect, lintNumConnect);
     961                 :            : 
     962                 :            :             // When the buffers are allocated above, a single buffer is allocated
     963                 :            :             // based on the total number of elements.  So for the case that there are
     964                 :            :             // multiple types being read in, move the pointer to the buffer past
     965                 :            :             // the end of the data that has been read in so we don't overwrite.
     966                 :          0 :             lpIDs = &lpIDs[lintNumElems];
     967         [ #  # ]:          0 :             if ( data_version >= 1.3 )
     968                 :          0 :                 lpGlobalIDs = &lpGlobalIDs[lintNumElems];
     969                 :          0 :             lpConnect = &lpConnect[lintNumConnect];
     970                 :            :         }
     971                 :          0 :         lpIO->EndReadBlock();
     972         [ #  # ]:          0 :         delete lpIO;
     973                 :            :     }
     974                 :            :     else
     975                 :          0 :         xpaElemData = NULL;
     976                 :          0 : }
     977                 :            : 
     978                 :          0 : void CFEModel::ReadGroupIdentity(UnsignedInt32 xintIndex,
     979                 :            :                                  UnsignedInt32& xintGroupID,
     980                 :            :                                  UnsignedInt32& xintGroupType,
     981                 :            :                                  const char*& xpachrGroupName)
     982                 :            : {
     983         [ #  # ]:          0 :     if(!mpReadFile)
     984                 :          0 :         throw CCubitFile::eFileReadError;
     985         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGroupCount)
     986                 :          0 :         throw CCubitFile::eNotFound;
     987         [ #  # ]:          0 :     if(!mpaGroups)
     988                 :          0 :         throw CCubitFile::eOrderError;
     989                 :            : 
     990                 :          0 :     xintGroupID = mpaGroups[xintIndex].mintGroupID;
     991                 :          0 :     xintGroupType = mpaGroups[xintIndex].mintGroupType;
     992         [ #  # ]:          0 :     if(mGroupMetaData.GetValue(xintGroupID, "NAME", xpachrGroupName) !=
     993                 :            :         CCubitFile::eSuccess)
     994                 :          0 :         xpachrGroupName = NULL;
     995                 :          0 : }
     996                 :            : 
     997                 :          0 : void CFEModel::ReadGroupMembers(UnsignedInt32 xintIndex,
     998                 :            :                                 UnsignedInt32& xintNumTypes,
     999                 :            :                                 SGroupData*& xpaGroupData)
    1000                 :            : {
    1001         [ #  # ]:          0 :     if(!mpReadFile)
    1002                 :          0 :         throw CCubitFile::eFileReadError;
    1003         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintGroupCount)
    1004                 :          0 :         throw CCubitFile::eNotFound;
    1005         [ #  # ]:          0 :     if(!mpaGroups)
    1006                 :          0 :         throw CCubitFile::eOrderError;
    1007                 :            : 
    1008                 :          0 :     xintNumTypes = mpaGroups[xintIndex].mintMemberTypeCount;
    1009         [ #  # ]:          0 :     if(xintNumTypes) {
    1010                 :            :         // Resize the group return buffer if necessary and then set the return
    1011                 :            :         // pointers to the buffer.
    1012                 :            :         xpaGroupData = AdjustBuffer(xintNumTypes,
    1013                 :          0 :             mGroupBuff.mintNumTypes, mGroupBuff.mpaGroupData);
    1014                 :            :         UnsignedInt32* lpIDs =
    1015                 :          0 :             AdjustBuffer(mpaGroups[xintIndex].mintMemberCount,
    1016                 :          0 :             mGroupBuff.mintNumMembers, mGroupBuff.mpaintMemberIDs);
    1017                 :            : 
    1018                 :            :         // Read the group member data from the file.
    1019                 :          0 :         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
    1020         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
    1021                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
    1022                 :          0 :             mpaGroups[xintIndex].mintMemberOffset);
    1023         [ #  # ]:          0 :         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
    1024                 :          0 :             lpIO->Read(&xpaGroupData[lintType].mintMemberType, 1);
    1025                 :          0 :             lpIO->Read(&xpaGroupData[lintType].mintMemberCount, 1);
    1026                 :            : 
    1027                 :          0 :             xpaGroupData[lintType].mpaMemberIDs = lpIDs;
    1028                 :          0 :             lintNumMembers = xpaGroupData[lintType].mintMemberCount;
    1029                 :            :             // Make sure the total number of group members does not exceed what
    1030                 :            :             // was specified in the group table entry.
    1031                 :          0 :             lintTotalMembers += lintNumMembers;
    1032         [ #  # ]:          0 :             if(lintTotalMembers > mpaGroups[xintIndex].mintMemberCount)
    1033                 :          0 :                 throw CCubitFile::eFileReadError;
    1034                 :            : 
    1035                 :          0 :             lpIO->Read(xpaGroupData[lintType].mpaMemberIDs, lintNumMembers);
    1036                 :            : 
    1037                 :          0 :             lpIDs = &lpIDs[lintNumMembers];
    1038                 :            :         }
    1039                 :          0 :         lpIO->EndReadBlock();
    1040         [ #  # ]:          0 :         delete lpIO;
    1041                 :            :     }
    1042                 :            :     else
    1043                 :          0 :         xpaGroupData = NULL;
    1044                 :          0 : }
    1045                 :            : 
    1046                 :          0 : void CFEModel::ReadBlock(UnsignedInt32 xintIndex,
    1047                 :            :                          UnsignedInt32& xintBlockID,
    1048                 :            :                          int& unique_id,
    1049                 :            :                          UnsignedInt32& xintBlockType,
    1050                 :            :                          UnsignedInt32& xintBlockColor,
    1051                 :            :                          UnsignedInt32& xintMixedElemType,
    1052                 :            :                          UnsignedInt32& xintDefPyramidType,
    1053                 :            :                          UnsignedInt32& xintMaterialID,
    1054                 :            :                          UnsignedInt32& xintBlockDimension,
    1055                 :            :                          UnsignedInt32& xintNumTypes,
    1056                 :            :                          SBlockData*& xpaBlockData,
    1057                 :            :                          UnsignedInt32& xintAttributeOrder,
    1058                 :            :                          double*& xpadblAttributes)
    1059                 :            : {
    1060                 :          0 :   unique_id = 0;
    1061         [ #  # ]:          0 :     if(!mpReadFile)
    1062                 :          0 :         throw CCubitFile::eFileReadError;
    1063         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintBlockCount)
    1064                 :          0 :         throw CCubitFile::eNotFound;
    1065         [ #  # ]:          0 :     if(!mpaBlocks)
    1066                 :          0 :         throw CCubitFile::eOrderError;
    1067                 :            : 
    1068                 :          0 :     xintBlockID = mpaBlocks[xintIndex].mintBlockID;
    1069                 :          0 :     xintBlockType = mpaBlocks[xintIndex].mintBlockElementType;
    1070                 :          0 :     xintNumTypes = mpaBlocks[xintIndex].mintMemberTypeCount;
    1071                 :          0 :     xintBlockColor = mpaBlocks[xintIndex].mintBlockColor;
    1072                 :          0 :     xintMixedElemType = mpaBlocks[xintIndex].mintBlockMixedElemType;
    1073                 :          0 :     xintDefPyramidType = mpaBlocks[xintIndex].mintBlockDefPyramidType;
    1074                 :          0 :     xintMaterialID = mpaBlocks[xintIndex].mintBlockMaterial;
    1075                 :          0 :     xintBlockDimension = mpaBlocks[xintIndex].mintBlockDimension;
    1076                 :          0 :     xintAttributeOrder = mpaBlocks[xintIndex].mintAttributeOrder;
    1077                 :            : 
    1078                 :            :     // Resize the block return buffer if necessary and then set the return
    1079                 :            :     // pointers to the buffer.
    1080                 :            :     xpaBlockData = AdjustBuffer(xintNumTypes,
    1081                 :          0 :         mBlockBuff.mintNumTypes, mBlockBuff.mpaBlockData);
    1082                 :            :     UnsignedInt32* lpIDs =
    1083                 :          0 :         AdjustBuffer(mpaBlocks[xintIndex].mintMemberCount,
    1084                 :          0 :         mBlockBuff.mintNumMembers, mBlockBuff.mpaintMemberIDs);
    1085                 :            :     xpadblAttributes = AdjustBuffer(xintAttributeOrder,
    1086                 :          0 :         mBlockBuff.mintAttributeOrder, mBlockBuff.mpadblAttributes);
    1087                 :            : 
    1088                 :            :     // Read the block from the file.
    1089                 :          0 :     UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
    1090         [ #  # ]:          0 :     CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
    1091                 :            :     lpIO->BeginReadBlock(mintFEModelOffset,
    1092                 :          0 :         mpaBlocks[xintIndex].mintMemberOffset);
    1093                 :          0 :     UnsignedInt32 start_location = lpIO->GetLocation();
    1094         [ #  # ]:          0 :     for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
    1095                 :          0 :         lpIO->Read(&xpaBlockData[lintType].mintMemberType, 1);
    1096                 :          0 :         lpIO->Read(&xpaBlockData[lintType].mintMemberCount, 1);
    1097                 :            : 
    1098                 :          0 :         xpaBlockData[lintType].mpaMemberIDs = lpIDs;
    1099                 :          0 :         lintNumMembers = xpaBlockData[lintType].mintMemberCount;
    1100                 :            :         // Make sure the total number of block members does not exceed what
    1101                 :            :         // was specified in the block table entry.
    1102                 :          0 :         lintTotalMembers += lintNumMembers;
    1103         [ #  # ]:          0 :         if(lintTotalMembers > mpaBlocks[xintIndex].mintMemberCount)
    1104                 :          0 :             throw CCubitFile::eFileReadError;
    1105                 :            : 
    1106                 :          0 :         lpIO->Read(xpaBlockData[lintType].mpaMemberIDs, lintNumMembers);
    1107                 :            : 
    1108                 :          0 :         lpIDs = &lpIDs[lintNumMembers];
    1109                 :            :     }
    1110         [ #  # ]:          0 :     if(xintAttributeOrder)
    1111                 :          0 :         lpIO->Read(xpadblAttributes, xintAttributeOrder);
    1112                 :            : 
    1113                 :            :     // see if there is more data
    1114                 :          0 :     int diff = lpIO->GetLocation() - start_location;
    1115                 :          0 :     int remaining = diff - mpaBlocks[xintIndex].mintBlockLength;
    1116         [ #  # ]:          0 :     while(remaining)
    1117                 :            :     {
    1118                 :            :         // remaining data could be bc data
    1119                 :            :         char type[2];
    1120         [ #  # ]:          0 :         lpIO->Read(type, 2);
    1121 [ #  # ][ #  # ]:          0 :         if(type[0] == 'i' && type[1] == 'd')
    1122                 :            :         {
    1123         [ #  # ]:          0 :             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
    1124                 :            :         }
    1125         [ #  # ]:          0 :         remaining = (lpIO->GetLocation() - start_location) -
    1126                 :          0 :             mpaBlocks[xintIndex].mintBlockLength;
    1127                 :            :     }
    1128                 :            : 
    1129                 :          0 :     lpIO->EndReadBlock();
    1130         [ #  # ]:          0 :     delete lpIO;
    1131                 :          0 : }
    1132                 :            : 
    1133                 :          0 : void CFEModel::ReadNodeSet(UnsignedInt32 xintIndex,
    1134                 :            :                            UnsignedInt32& xintNodeSetID,
    1135                 :            :                            int& unique_id,
    1136                 :            :                            UnsignedInt32& xintColor,
    1137                 :            :                            UnsignedInt32& xintPointSymbol,
    1138                 :            :                            UnsignedInt32& xintNumTypes,
    1139                 :            :                            SNodeSetData*& xpaNodeSetData,
    1140                 :            :                            std::vector<char>& bcdata)
    1141                 :            : {
    1142                 :          0 :   unique_id = 0;
    1143         [ #  # ]:          0 :     if(!mpReadFile)
    1144                 :          0 :         throw CCubitFile::eFileReadError;
    1145         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintNodeSetCount)
    1146                 :          0 :         throw CCubitFile::eNotFound;
    1147         [ #  # ]:          0 :     if(!mpaNodeSets)
    1148                 :          0 :         throw CCubitFile::eOrderError;
    1149                 :            : 
    1150                 :          0 :     xintNodeSetID = mpaNodeSets[xintIndex].mintNodeSetID;
    1151                 :          0 :     xintNumTypes = mpaNodeSets[xintIndex].mintMemberTypeCount;
    1152                 :          0 :     xintPointSymbol = mpaNodeSets[xintIndex].mintNodeSetPointSym;
    1153                 :          0 :     xintColor = mpaNodeSets[xintIndex].mintNodeSetColor;
    1154                 :            : 
    1155                 :            :     // fix for bug 8623: empty nodesets are allowed
    1156                 :            :     //if(xintNumTypes) 
    1157                 :            :     //{
    1158                 :            :         // Resize the node set return buffer if necessary and then set the return
    1159                 :            :         // pointers to the buffer.
    1160                 :            :         xpaNodeSetData = AdjustBuffer(xintNumTypes,
    1161                 :          0 :             mNodeSetBuff.mintNumTypes, mNodeSetBuff.mpaNodeSetData);
    1162                 :            :         UnsignedInt32* lpIDs =
    1163                 :          0 :             AdjustBuffer(mpaNodeSets[xintIndex].mintMemberCount,
    1164                 :          0 :             mNodeSetBuff.mintNumMembers, mNodeSetBuff.mpaintMemberIDs);
    1165                 :            : 
    1166                 :            :         // Read the node set from the file.
    1167                 :          0 :         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
    1168         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
    1169                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
    1170                 :          0 :             mpaNodeSets[xintIndex].mintMemberOffset);
    1171                 :          0 :         UnsignedInt32 start_location = lpIO->GetLocation();
    1172         [ #  # ]:          0 :         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
    1173                 :          0 :             lpIO->Read(&xpaNodeSetData[lintType].mintMemberType, 1);
    1174                 :          0 :             lpIO->Read(&xpaNodeSetData[lintType].mintMemberCount, 1);
    1175                 :            : 
    1176                 :          0 :             xpaNodeSetData[lintType].mpaMemberIDs = lpIDs;
    1177                 :          0 :             lintNumMembers = xpaNodeSetData[lintType].mintMemberCount;
    1178                 :            :             // Make sure the total number of node set members does not exceed
    1179                 :            :             // what was specified in the node set table entry.
    1180                 :          0 :             lintTotalMembers += lintNumMembers;
    1181         [ #  # ]:          0 :             if(lintTotalMembers > mpaNodeSets[xintIndex].mintMemberCount)
    1182                 :          0 :                 throw CCubitFile::eFileReadError;
    1183                 :            : 
    1184                 :          0 :             lpIO->Read(xpaNodeSetData[lintType].mpaMemberIDs, lintNumMembers);
    1185                 :            : 
    1186                 :          0 :             lpIDs = &lpIDs[lintNumMembers];
    1187                 :            :         }
    1188                 :            :         
    1189                 :            :         // see if there is more data
    1190                 :          0 :         int diff = lpIO->GetLocation() - start_location;
    1191                 :          0 :         int remaining = diff - mpaNodeSets[xintIndex].mintNodeSetLength;
    1192         [ #  # ]:          0 :         while(remaining)
    1193                 :            :         {
    1194                 :            :           // remaining data could be bc data
    1195                 :            :           char type[2];
    1196         [ #  # ]:          0 :           lpIO->Read(type, 2);
    1197 [ #  # ][ #  # ]:          0 :           if(type[0] == 'b' && type[1] == 'c')
    1198                 :            :           {
    1199                 :            :             // get serialize data size
    1200                 :            :             UnsignedInt32 size;
    1201         [ #  # ]:          0 :             lpIO->Read(&size, 1);
    1202         [ #  # ]:          0 :             bcdata.resize(size);
    1203 [ #  # ][ #  # ]:          0 :             lpIO->Read(&bcdata[0], size);
    1204                 :            :           }
    1205 [ #  # ][ #  # ]:          0 :           else if(type[0] == 'i' && type[1] == 'd')
    1206                 :            :           {
    1207         [ #  # ]:          0 :             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
    1208                 :            :           }
    1209         [ #  # ]:          0 :           remaining = (lpIO->GetLocation() - start_location) -
    1210                 :          0 :             mpaNodeSets[xintIndex].mintNodeSetLength;
    1211                 :            :         }
    1212                 :            : 
    1213                 :          0 :         lpIO->EndReadBlock();
    1214         [ #  # ]:          0 :         delete lpIO;
    1215                 :            :     /*}
    1216                 :            :     else
    1217                 :            :         xpaNodeSetData = NULL;*/
    1218                 :          0 : }
    1219                 :            : 
    1220                 :          0 : void CFEModel::ReadSideSet_10(UnsignedInt32 xintIndex,
    1221                 :            :                            UnsignedInt32& xintSideSetID,
    1222                 :            :                            UnsignedInt32& xintColor,
    1223                 :            :                            UnsignedInt32& xintUseShells,
    1224                 :            :                            UnsignedInt32& xintNumTypes,
    1225                 :            :                            SSideSetData_10*& xpaSideSetData,
    1226                 :            :                            UnsignedInt32& xintNumDistFact,
    1227                 :            :                            double*& xpadblDistribution)
    1228                 :            : {
    1229         [ #  # ]:          0 :     if(!mpReadFile)
    1230                 :          0 :         throw CCubitFile::eFileReadError;
    1231         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintSideSetCount)
    1232                 :          0 :         throw CCubitFile::eNotFound;
    1233         [ #  # ]:          0 :     if(!mpaSideSets)
    1234                 :          0 :         throw CCubitFile::eOrderError;
    1235                 :            : 
    1236                 :          0 :     xintSideSetID = mpaSideSets[xintIndex].mintSideSetID;
    1237                 :          0 :     xintNumTypes = mpaSideSets[xintIndex].mintMemberTypeCount;
    1238                 :          0 :     xintColor = mpaSideSets[xintIndex].mintSideSetColor;
    1239                 :          0 :     xintUseShells = mpaSideSets[xintIndex].mintUseShells;
    1240                 :          0 :     xintNumDistFact = mpaSideSets[xintIndex].mintNumDistFact;
    1241                 :            : 
    1242         [ #  # ]:          0 :     if(xintNumTypes) {
    1243                 :            :         // Resize the side set return buffer if necessary and then set the return
    1244                 :            :         // pointers to the buffer.
    1245                 :            :         xpaSideSetData = AdjustBuffer(xintNumTypes,
    1246                 :          0 :             mSideSetBuff_10.mintNumTypes, mSideSetBuff_10.mpaSideSetData);
    1247                 :            :         UnsignedInt32* lpaintIDs =
    1248                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1249                 :          0 :             mSideSetBuff_10.mintNumMembersIDs, mSideSetBuff_10.mpaintMemberIDs);
    1250                 :            :         char* lpachrSense =
    1251                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1252                 :          0 :             mSideSetBuff_10.mintNumMembersSense8, mSideSetBuff_10.mpachrMemberSense);
    1253                 :            :         UnsignedInt32* lpaintSense =
    1254                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1255                 :          0 :             mSideSetBuff_10.mintNumMembersSense32, mSideSetBuff_10.mpaintMemberSense);
    1256                 :            :         char* lpachrSideNum =
    1257                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1258                 :          0 :             mSideSetBuff_10.mintNumMembersSideNum, mSideSetBuff_10.mpachrMemberSideNum);
    1259                 :            :         xpadblDistribution = AdjustBuffer(xintNumDistFact,
    1260                 :          0 :             mSideSetBuff_10.mintNumDistFact, mSideSetBuff_10.mpadblDistribution);
    1261                 :            : 
    1262                 :            :         // Read the block from the file.
    1263                 :          0 :         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
    1264         [ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
    1265                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
    1266                 :          0 :             mpaSideSets[xintIndex].mintMemberOffset);
    1267         [ #  # ]:          0 :         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
    1268                 :          0 :             lpIO->Read(&xpaSideSetData[lintType].mintMemberType, 1);
    1269                 :          0 :             lpIO->Read(&xpaSideSetData[lintType].mintMemberCount, 1);
    1270                 :          0 :             lpIO->Read(&xpaSideSetData[lintType].mintMemberSenseSize, 1);
    1271                 :            : 
    1272                 :          0 :             xpaSideSetData[lintType].mpaintMemberIDs = lpaintIDs;
    1273                 :          0 :             xpaSideSetData[lintType].mpachrMemberSideNumber = lpachrSideNum;
    1274                 :          0 :             lintNumMembers = xpaSideSetData[lintType].mintMemberCount;
    1275                 :            :             // Make sure the total number of side set members does not exceed
    1276                 :            :             // what was specified in the side set table entry.
    1277                 :          0 :             lintTotalMembers += lintNumMembers;
    1278         [ #  # ]:          0 :             if(lintTotalMembers > mpaSideSets[xintIndex].mintMemberCount)
    1279                 :          0 :                 throw CCubitFile::eFileReadError;
    1280                 :            : 
    1281                 :          0 :             lpIO->Read(xpaSideSetData[lintType].mpaintMemberIDs, lintNumMembers);
    1282      [ #  #  # ]:          0 :             switch(xpaSideSetData[lintType].mintMemberSenseSize) {
    1283                 :            :             case CCubitFile::eSideSetSenseNone:
    1284                 :            :             default:
    1285                 :          0 :                 xpaSideSetData[lintType].mpachrMemberSense = NULL;
    1286                 :          0 :                 xpaSideSetData[lintType].mpaintMemberSense = NULL;
    1287                 :          0 :                 break;
    1288                 :            :             case CCubitFile::eSideSetSenseByte:
    1289                 :          0 :                 xpaSideSetData[lintType].mpachrMemberSense = lpachrSense;
    1290                 :          0 :                 xpaSideSetData[lintType].mpaintMemberSense = NULL;
    1291                 :          0 :                 lpIO->Read(xpaSideSetData[lintType].mpachrMemberSense,
    1292                 :          0 :                     lintNumMembers, 1);
    1293                 :          0 :                 lpaintSense = &lpaintSense[lintNumMembers];
    1294                 :          0 :                 break;
    1295                 :            :             case CCubitFile::eSideSetSenseInt32:
    1296                 :          0 :                 xpaSideSetData[lintType].mpachrMemberSense = NULL;
    1297                 :          0 :                 xpaSideSetData[lintType].mpaintMemberSense = lpaintSense;
    1298                 :          0 :                 lpIO->Read(xpaSideSetData[lintType].mpaintMemberSense,
    1299                 :          0 :                     lintNumMembers);
    1300                 :          0 :                 lpaintSense = &lpaintSense[lintNumMembers];
    1301                 :          0 :                 break;
    1302                 :            :             }
    1303                 :          0 :             lpIO->Read(xpaSideSetData[lintType].mpachrMemberSideNumber,
    1304                 :          0 :                 lintNumMembers, 1);
    1305                 :            : 
    1306                 :          0 :             lpaintIDs = &lpaintIDs[lintNumMembers];
    1307                 :          0 :             lpachrSideNum = &lpachrSideNum[lintNumMembers];
    1308                 :            :         }
    1309         [ #  # ]:          0 :         if(xintNumDistFact)
    1310                 :          0 :             lpIO->Read(xpadblDistribution, xintNumDistFact);
    1311                 :          0 :         lpIO->EndReadBlock();
    1312         [ #  # ]:          0 :         delete lpIO;
    1313                 :            :     }
    1314                 :            :     else {
    1315                 :          0 :         xpaSideSetData = NULL;
    1316                 :          0 :         xpadblDistribution = NULL;
    1317                 :            :     }
    1318                 :          0 : }
    1319                 :            : 
    1320                 :          0 : void CFEModel::ReadSideSet_11(UnsignedInt32 xintIndex,
    1321                 :            :                            UnsignedInt32& xintSideSetID,
    1322                 :            :                            int& unique_id,
    1323                 :            :                            UnsignedInt32& xintColor,
    1324                 :            :                            UnsignedInt32& xintUseShells,
    1325                 :            :                            UnsignedInt32& xintNumTypes,
    1326                 :            :                            SSideSetData_11*& xpaSideSetData,
    1327                 :            :                            UnsignedInt32& xintNumDistFact,
    1328                 :            :                            double*& xpadblDistribution,
    1329                 :            :                            std::vector<char>& bcdata)
    1330                 :            : {
    1331                 :          0 :   unique_id = 0;
    1332         [ #  # ]:          0 :     if(!mpReadFile)
    1333                 :          0 :         throw CCubitFile::eFileReadError;
    1334         [ #  # ]:          0 :     if(xintIndex >= mFEModel.mintSideSetCount)
    1335                 :          0 :         throw CCubitFile::eNotFound;
    1336         [ #  # ]:          0 :     if(!mpaSideSets)
    1337                 :          0 :         throw CCubitFile::eOrderError;
    1338                 :            : 
    1339                 :          0 :     xintSideSetID = mpaSideSets[xintIndex].mintSideSetID;
    1340                 :          0 :     xintNumTypes = mpaSideSets[xintIndex].mintMemberTypeCount;
    1341                 :          0 :     xintColor = mpaSideSets[xintIndex].mintSideSetColor;
    1342                 :          0 :     xintUseShells = mpaSideSets[xintIndex].mintUseShells;
    1343                 :          0 :     xintNumDistFact = mpaSideSets[xintIndex].mintNumDistFact;
    1344                 :            : 
    1345                 :            :     // fix for bug 8623: don't do this check: empty sidesets are allowed
    1346                 :            :     //if(xintNumTypes) {
    1347                 :            :         // Resize the side set return buffer if necessary and then set the return
    1348                 :            :         // pointers to the buffer.
    1349                 :            :         xpaSideSetData = AdjustBuffer(xintNumTypes,
    1350         [ #  # ]:          0 :             mSideSetBuff_11.mintNumTypes, mSideSetBuff_11.mpaSideSetData);
    1351                 :          0 :         UnsignedInt32 count = mSideSetBuff_11.mintNumMembersIDs;
    1352                 :            :         UnsignedInt32* lpaintTypes =
    1353                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1354         [ #  # ]:          0 :             mSideSetBuff_11.mintNumMembersIDs, mSideSetBuff_11.mpaintMemberTypes);
    1355                 :            :         UnsignedInt32* lpaintIDs =
    1356                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1357         [ #  # ]:          0 :             count, mSideSetBuff_11.mpaintMemberIDs);
    1358                 :            :         char* lpachrSense =
    1359                 :          0 :             AdjustBuffer(mpaSideSets[xintIndex].mintMemberCount,
    1360         [ #  # ]:          0 :             mSideSetBuff_11.mintNumMembersSense, mSideSetBuff_11.mpachrMemberSense);
    1361                 :            :         xpadblDistribution = AdjustBuffer(xintNumDistFact,
    1362         [ #  # ]:          0 :             mSideSetBuff_11.mintNumDistFact, mSideSetBuff_11.mpadblDistribution);
    1363                 :            : 
    1364                 :            :         // Read the block from the file.
    1365                 :          0 :         UnsignedInt32 lintNumMembers, lintTotalMembers = 0;
    1366 [ #  # ][ #  # ]:          0 :         CIOWrapper* lpIO = new CIOWrapper(mpReadFile, mFEModel.mintFEModelEndian);
    1367                 :            :         lpIO->BeginReadBlock(mintFEModelOffset,
    1368         [ #  # ]:          0 :             mpaSideSets[xintIndex].mintMemberOffset);
    1369         [ #  # ]:          0 :         UnsignedInt32 start_location = lpIO->GetLocation();
    1370         [ #  # ]:          0 :         for(UnsignedInt32 lintType = 0; lintType < xintNumTypes; lintType++) {
    1371         [ #  # ]:          0 :             lpIO->Read(&xpaSideSetData[lintType].mintMemberCount, 1);
    1372                 :            :             
    1373                 :          0 :             lintNumMembers = xpaSideSetData[lintType].mintMemberCount;
    1374                 :            :             
    1375                 :          0 :             xpaSideSetData[lintType].mpaintMemberTypes = lpaintTypes;
    1376                 :          0 :             xpaSideSetData[lintType].mpaintMemberIDs = lpaintIDs;
    1377                 :            :             
    1378                 :            :             // Make sure the total number of side set members does not exceed
    1379                 :            :             // what was specified in the side set table entry.
    1380                 :          0 :             lintTotalMembers += lintNumMembers;
    1381         [ #  # ]:          0 :             if(lintTotalMembers > mpaSideSets[xintIndex].mintMemberCount)
    1382                 :          0 :                 throw CCubitFile::eFileReadError;
    1383                 :            : 
    1384         [ #  # ]:          0 :             lpIO->Read(xpaSideSetData[lintType].mpaintMemberTypes, lintNumMembers);
    1385                 :            : 
    1386         [ #  # ]:          0 :             lpIO->Read(xpaSideSetData[lintType].mpaintMemberIDs, lintNumMembers);
    1387                 :            : 
    1388                 :          0 :             xpaSideSetData[lintType].mpachrMemberSenses = lpachrSense;
    1389         [ #  # ]:          0 :             if(lintType == 0)
    1390         [ #  # ]:          0 :               lpIO->Read(xpaSideSetData[lintType].mpachrMemberSenses, lintNumMembers, 1);
    1391                 :            :             else
    1392         [ #  # ]:          0 :               lpIO->Read(xpaSideSetData[lintType].mpachrMemberSenses, 1, 1);
    1393                 :            : 
    1394                 :          0 :             UnsignedInt32 wrt_size=0;
    1395         [ #  # ]:          0 :             lpIO->Read(&wrt_size, 1);
    1396                 :            :         
    1397                 :          0 :             UnsignedInt32* lpaintWRT = NULL;
    1398                 :          0 :             UnsignedInt32 orig_size = 0;
    1399         [ #  # ]:          0 :             AdjustBuffer(wrt_size, orig_size, lpaintWRT);
    1400                 :            : 
    1401                 :          0 :             xpaSideSetData[lintType].mpaintMemberWRTEntities = lpaintWRT;
    1402                 :            :         
    1403         [ #  # ]:          0 :             lpIO->Read(xpaSideSetData[lintType].mpaintMemberWRTEntities, wrt_size);
    1404                 :            : 
    1405                 :          0 :             lpaintIDs = &lpaintIDs[lintNumMembers];
    1406                 :          0 :             lpaintTypes = &lpaintTypes[lintNumMembers];
    1407                 :            :         }
    1408         [ #  # ]:          0 :         if(xintNumDistFact)
    1409         [ #  # ]:          0 :             lpIO->Read(xpadblDistribution, xintNumDistFact);
    1410                 :            : 
    1411                 :            :         // see if there is more data
    1412         [ #  # ]:          0 :         int diff = lpIO->GetLocation() - start_location;
    1413                 :          0 :         int remaining = diff - mpaSideSets[xintIndex].mintSideSetLength;
    1414         [ #  # ]:          0 :         while(remaining)
    1415                 :            :         {
    1416                 :            :           // remaining data could be bc data
    1417                 :            :           char type[2];
    1418         [ #  # ]:          0 :           lpIO->Read(type, 2);
    1419 [ #  # ][ #  # ]:          0 :           if(type[0] == 'b' && type[1] == 'c')
    1420                 :            :           {
    1421                 :            :             // get serialize data size
    1422                 :            :             UnsignedInt32 size;
    1423         [ #  # ]:          0 :             lpIO->Read(&size, 1);
    1424         [ #  # ]:          0 :             bcdata.resize(size);
    1425 [ #  # ][ #  # ]:          0 :             lpIO->Read(&bcdata[0], size);
    1426                 :            :           }
    1427                 :            :           // or unique id
    1428 [ #  # ][ #  # ]:          0 :           else if(type[0] == 'i' && type[1] == 'd')
    1429                 :            :           {
    1430         [ #  # ]:          0 :             lpIO->Read(reinterpret_cast<UnsignedInt32*>(&unique_id), 1);
    1431                 :            :           }
    1432         [ #  # ]:          0 :           remaining = (lpIO->GetLocation() - start_location) -
    1433                 :          0 :             mpaSideSets[xintIndex].mintSideSetLength;
    1434                 :            :         }
    1435                 :            : 
    1436         [ #  # ]:          0 :         lpIO->EndReadBlock();
    1437 [ #  # ][ #  # ]:          0 :         delete lpIO;
    1438                 :            :     //}
    1439                 :            :     //else {
    1440                 :            :     //    xpaSideSetData = NULL;
    1441                 :            :     //    xpadblDistribution = NULL;
    1442                 :            :     //}
    1443                 :          0 : }
    1444                 :            : 
    1445                 :          0 : void CFEModel::EndRead()
    1446                 :            : {
    1447                 :          0 :     mpReadFile = NULL;
    1448                 :          0 : }
    1449                 :            : 
    1450                 :            : ///////////////////////////////////////////////////////////////////////////////
    1451                 :            : // Meta-Data Functions
    1452                 :            : ///////////////////////////////////////////////////////////////////////////////
    1453                 :            : 
    1454                 :          0 : CMetaData& CFEModel::GetGeomMetaData()
    1455                 :            : {
    1456                 :          0 :     return mGeomMetaData;
    1457                 :            : }
    1458                 :            : 
    1459                 :          0 : CMetaData& CFEModel::GetNodeMetaData()
    1460                 :            : {
    1461                 :          0 :     return mNodeMetaData;
    1462                 :            : }
    1463                 :            : 
    1464                 :          0 : CMetaData& CFEModel::GetElemMetaData()
    1465                 :            : {
    1466                 :          0 :     return mElemMetaData;
    1467                 :            : }
    1468                 :            : 
    1469                 :          0 : CMetaData& CFEModel::GetGroupMetaData()
    1470                 :            : {
    1471                 :          0 :     return mGroupMetaData;
    1472                 :            : }
    1473                 :            : 
    1474                 :          0 : CMetaData& CFEModel::GetBlockMetaData()
    1475                 :            : {
    1476                 :          0 :     return mBlockMetaData;
    1477                 :            : }
    1478                 :            : 
    1479                 :          0 : CMetaData& CFEModel::GetNodeSetMetaData()
    1480                 :            : {
    1481                 :          0 :     return mNodeSetMetaData;
    1482                 :            : }
    1483                 :            : 
    1484                 :          0 : CMetaData& CFEModel::GetSideSetMetaData()
    1485                 :            : {
    1486                 :          0 :     return mSideSetMetaData;
    1487                 :            : }

Generated by: LCOV version 1.11