LCOV - code coverage report
Current view: top level - util/cgm - CubitFileFEModel.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 11 0.0 %
Date: 2020-06-30 00:58:45 Functions: 0 7 0.0 %
Branches: 0 82 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.hpp
      16                 :            : 
      17                 :            :  Purpose       : Defines an interface for the reading and writing functionality
      18                 :            :                  for a FE 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                 :            : #ifndef CubitFileFEModel_HPP
      31                 :            : #define CubitFileFEModel_HPP
      32                 :            : 
      33                 :            : #include "CubitFileMetaData.hpp"
      34                 :            : #include "CGMUtilConfigure.h"
      35                 :            : #include <vector>
      36                 :            : 
      37                 :            : namespace NCubitFile {
      38                 :            : 
      39                 :            : class CUBIT_UTIL_EXPORT CFEModel {
      40                 :            : public:
      41                 :            :     CFEModel();
      42                 :            :     virtual ~CFEModel();
      43                 :            :     
      44                 :            :     UnsignedInt32 InitWrite(FILE* xpFile,
      45                 :            :         UnsignedInt32 xintGeomCount, UnsignedInt32 xintGroupCount,
      46                 :            :         UnsignedInt32 xintBlockCount, UnsignedInt32 xintNodeSetCount,
      47                 :            :         UnsignedInt32 xintSideSetCount);
      48                 :            :     void WriteNodes(UnsignedInt32 xintIndex, UnsignedInt32 xintGeomID,
      49                 :            :         UnsignedInt32 xintNodeCount, UnsignedInt32 *xpaintNodeIDs,
      50                 :            :         double *xpadblX, double *xpadblY, double *xpadblZ);
      51                 :            :     void WriteElems(UnsignedInt32 xintIndex,
      52                 :            :         UnsignedInt32 xintNumTypes, SElemData* xpaElemData);
      53                 :            :     void WriteGroup(UnsignedInt32 xintIndex, UnsignedInt32 xintGroupID,
      54                 :            :         UnsignedInt32 xintGroupType, const char* xpachrGroupName,
      55                 :            :         UnsignedInt32 xintNumTypes, SGroupData* xpaGroupData);
      56                 :            :     void WriteBlock(UnsignedInt32 xintIndex,
      57                 :            :         UnsignedInt32 xintBlockID, int unique_id, UnsignedInt32 xintBlockType,
      58                 :            :         UnsignedInt32 xintBlockColor, UnsignedInt32 xintMixedElemType,
      59                 :            :         UnsignedInt32 xintDefPyramidType, UnsignedInt32 xintMaterialID,
      60                 :            :         UnsignedInt32 xintBlockDimension,
      61                 :            :         UnsignedInt32 xintNumTypes, SBlockData* xpaBlockData,
      62                 :            :         UnsignedInt32 xintAttributeOrder, double* xpadblAttributes);
      63                 :            :     void WriteNodeSet(UnsignedInt32 xintIndex,
      64                 :            :         UnsignedInt32 xintNodeSetID, int unique_id, UnsignedInt32 xintColor,
      65                 :            :         UnsignedInt32 xintPointSymbol,
      66                 :            :         UnsignedInt32 xintNumTypes, SNodeSetData* xpaNodeSetData,
      67                 :            :         const std::vector<char>& bcdata);
      68                 :            :     void WriteSideSet_11(UnsignedInt32 xintIndex,
      69                 :            :         UnsignedInt32 xintSideSetID, int unique_id, UnsignedInt32 xintColor,
      70                 :            :         UnsignedInt32 xintUseShells,
      71                 :            :         UnsignedInt32 xintNumTypes, SSideSetData_11* xpaSideSetData,
      72                 :            :         UnsignedInt32 xintNumDistFact, double* xpadblDistribution,
      73                 :            :         const std::vector<char>& bcdata);
      74                 :            :     UnsignedInt32 EndWrite();
      75                 :            :     
      76                 :            :     void InitRead(FILE* xpFile, UnsignedInt32 xintAbsoluteOffset,
      77                 :            :         UnsignedInt32& xintGeomCount, UnsignedInt32& xintGroupCount,
      78                 :            :         UnsignedInt32& xintBlockCount, UnsignedInt32& xintNodeSetCount,
      79                 :            :         UnsignedInt32& xintSideSetCount); 
      80                 :            :     void ReadNodes(UnsignedInt32 xintIndex, UnsignedInt32& xintGeomID,
      81                 :            :         UnsignedInt32& xintNodeCount, UnsignedInt32*& xpaintNodeIDs,
      82                 :            :         double*& xpadblX, double*& xpadblY, double*& xpadblZ);
      83                 :            :     void ReadElems(double data_version,
      84                 :            :         UnsignedInt32 xintIndex, UnsignedInt32& xintGeomID,
      85                 :            :         UnsignedInt32& xintNumTypes, SElemData*& xpaElemData);
      86                 :            :     void ReadGroupIdentity(UnsignedInt32 xintIndex, UnsignedInt32& xintGroupID,
      87                 :            :         UnsignedInt32& xintGroupType, const char*& xpachrGroupName);
      88                 :            :     void ReadGroupMembers(UnsignedInt32 xintIndex,
      89                 :            :         UnsignedInt32& xintNumTypes, SGroupData*& xpaGroupData);
      90                 :            :     void ReadBlock(UnsignedInt32 xintIndex,
      91                 :            :         UnsignedInt32& xintBlockID, int& unique_id, UnsignedInt32& xintBlockType,
      92                 :            :         UnsignedInt32& xintBlockColor, UnsignedInt32& xintMixedElemType,
      93                 :            :         UnsignedInt32& xintDefPyramidType, UnsignedInt32& xintMaterialID,
      94                 :            :         UnsignedInt32& xintBlockDimension,
      95                 :            :         UnsignedInt32& xintNumTypes, SBlockData*& xpaBlockData,
      96                 :            :         UnsignedInt32& xintAttributeOrder, double*& xpadblAttributes);
      97                 :            :     void ReadNodeSet(UnsignedInt32 xintIndex,
      98                 :            :         UnsignedInt32& xintNodeSetID, int& unique_id, UnsignedInt32& xintColor,
      99                 :            :         UnsignedInt32& xintPointSymbol,
     100                 :            :         UnsignedInt32& xintNumTypes, SNodeSetData*& xpaNodeSetData,
     101                 :            :         std::vector<char>& bcdata);
     102                 :            :     void ReadSideSet_10(UnsignedInt32 xintIndex,
     103                 :            :         UnsignedInt32& xintSideSetID, UnsignedInt32& xintColor,
     104                 :            :         UnsignedInt32& xintUseShells,
     105                 :            :         UnsignedInt32& xintNumTypes, SSideSetData_10*& xpaSideSetData,
     106                 :            :         UnsignedInt32& xintNumDistFact, double*& xpadblDistribution);
     107                 :            :     void ReadSideSet_11(UnsignedInt32 xintIndex,
     108                 :            :         UnsignedInt32& xintSideSetID, int& unique_id, UnsignedInt32& xintColor,
     109                 :            :         UnsignedInt32& xintUseShells,
     110                 :            :         UnsignedInt32& xintNumTypes, SSideSetData_11*& xpaSideSetData,
     111                 :            :         UnsignedInt32& xintNumDistFact, double*& xpadblDistribution,
     112                 :            :         std::vector<char>& bcdata);
     113                 :            :     void EndRead();
     114                 :            :     
     115                 :            :     CMetaData& GetGeomMetaData();
     116                 :            :     CMetaData& GetNodeMetaData();
     117                 :            :     CMetaData& GetElemMetaData();
     118                 :            :     CMetaData& GetGroupMetaData();
     119                 :            :     CMetaData& GetBlockMetaData();
     120                 :            :     CMetaData& GetNodeSetMetaData();
     121                 :            :     CMetaData& GetSideSetMetaData();
     122                 :            :     
     123                 :            : private:
     124                 :            :     FILE* mpReadFile;
     125                 :            :     FILE* mpWriteFile;
     126                 :            :     UnsignedInt32 mintFEModelOffset;
     127                 :            :     CMetaData mGeomMetaData;
     128                 :            :     CMetaData mNodeMetaData;
     129                 :            :     CMetaData mElemMetaData;
     130                 :            :     CMetaData mGroupMetaData;
     131                 :            :     CMetaData mBlockMetaData;
     132                 :            :     CMetaData mNodeSetMetaData;
     133                 :            :     CMetaData mSideSetMetaData;
     134                 :            : 
     135                 :            :     // Data storage structures:
     136                 :            :     // CAUTION: These structures must be 64 bit word aligned!!!
     137                 :            :     struct SCubitFileFEModelHeader {
     138                 :            :         UnsignedInt32 mintFEModelEndian;
     139                 :            :         UnsignedInt32 mintFEModelSchema;
     140                 :            :         UnsignedInt32 mintFEModelCompress;
     141                 :            :         UnsignedInt32 mintFEModelLength;
     142                 :            :         UnsignedInt32 mintGeometryCount;
     143                 :            :         UnsignedInt32 mintGeomTableOffset;
     144                 :            :         UnsignedInt32 mintGeomMetaDataOffset;
     145                 :            :         UnsignedInt32 mintNodeMetaDataOffset;
     146                 :            :         UnsignedInt32 mintElemMetaDataOffset;
     147                 :            :         UnsignedInt32 mintGroupCount;
     148                 :            :         UnsignedInt32 mintGroupTableOffset;
     149                 :            :         UnsignedInt32 mintGroupMetaDataOffset;
     150                 :            :         UnsignedInt32 mintBlockCount;
     151                 :            :         UnsignedInt32 mintBlockTableOffset;
     152                 :            :         UnsignedInt32 mintBlockMetaDataOffset;
     153                 :            :         UnsignedInt32 mintNodeSetCount;
     154                 :            :         UnsignedInt32 mintNodeSetTableOffset;
     155                 :            :         UnsignedInt32 mintNodeSetMetaDataOffset;
     156                 :            :         UnsignedInt32 mintSideSetCount;
     157                 :            :         UnsignedInt32 mintSideSetTableOffset;
     158                 :            :         UnsignedInt32 mintSideSetMetaDataOffset;
     159                 :            :         UnsignedInt32 mintPadFor64bitOS;
     160                 :            :     } mFEModel;
     161                 :            :     static const UnsignedInt32 mintSizeOfFEModelHeader;
     162                 :            :     struct SCubitFileGeomEntry {
     163                 :            :         UnsignedInt32 mintNodeCount;
     164                 :            :         UnsignedInt32 mintNodeOffset;
     165                 :            :         UnsignedInt32 mintElemCount;
     166                 :            :         UnsignedInt32 mintElemOffset;
     167                 :            :         UnsignedInt32 mintElemTypeCount;
     168                 :            :         UnsignedInt32 mintElemLength;
     169                 :            :                 UnsignedInt32 mintGeomID;
     170                 :            :         UnsignedInt32 mintPadFor64bitOS;
     171                 :            :     } *mpaGeoms;
     172                 :            :     static const UnsignedInt32 mintSizeOfGeomEntry;
     173                 :            :     struct SCubitFileGroupEntry {
     174                 :            :         UnsignedInt32 mintGroupID;
     175                 :            :         UnsignedInt32 mintGroupType;
     176                 :            :         UnsignedInt32 mintMemberCount;
     177                 :            :         UnsignedInt32 mintMemberOffset;
     178                 :            :         UnsignedInt32 mintMemberTypeCount;
     179                 :            :         UnsignedInt32 mintGroupLength;
     180                 :            :     } *mpaGroups;
     181                 :            :     static const UnsignedInt32 mintSizeOfGroupEntry;
     182                 :            :     struct SCubitFileBlockEntry {
     183                 :            :         UnsignedInt32 mintBlockID;
     184                 :            :         UnsignedInt32 mintBlockElementType;
     185                 :            :         UnsignedInt32 mintMemberCount;
     186                 :            :         UnsignedInt32 mintMemberOffset;
     187                 :            :         UnsignedInt32 mintMemberTypeCount;
     188                 :            :         UnsignedInt32 mintAttributeOrder;
     189                 :            :         UnsignedInt32 mintBlockColor;
     190                 :            :         UnsignedInt32 mintBlockMixedElemType;
     191                 :            :         UnsignedInt32 mintBlockDefPyramidType;
     192                 :            :         UnsignedInt32 mintBlockMaterial;
     193                 :            :         UnsignedInt32 mintBlockLength;
     194                 :            :         UnsignedInt32 mintBlockDimension;
     195                 :            :     } *mpaBlocks;
     196                 :            :     static const UnsignedInt32 mintSizeOfBlockEntry;
     197                 :            :     struct SCubitFileNodeSetEntry {
     198                 :            :         UnsignedInt32 mintNodeSetID;
     199                 :            :         UnsignedInt32 mintMemberCount;
     200                 :            :         UnsignedInt32 mintMemberOffset;
     201                 :            :         UnsignedInt32 mintMemberTypeCount;
     202                 :            :         UnsignedInt32 mintNodeSetPointSym;
     203                 :            :         UnsignedInt32 mintNodeSetColor;
     204                 :            :         UnsignedInt32 mintNodeSetLength;
     205                 :            :         UnsignedInt32 mintPadFor64bitOS;
     206                 :            :     } *mpaNodeSets;
     207                 :            :     static const UnsignedInt32 mintSizeOfNodeSetEntry;
     208                 :            :     struct SCubitFileSideSetEntry {
     209                 :            :         UnsignedInt32 mintSideSetID;
     210                 :            :         UnsignedInt32 mintMemberCount;
     211                 :            :         UnsignedInt32 mintMemberOffset;
     212                 :            :         UnsignedInt32 mintMemberTypeCount;
     213                 :            :         UnsignedInt32 mintNumDistFact;
     214                 :            :         UnsignedInt32 mintSideSetColor;
     215                 :            :         UnsignedInt32 mintUseShells;
     216                 :            :         UnsignedInt32 mintSideSetLength;
     217                 :            :     } *mpaSideSets;
     218                 :            :     static const UnsignedInt32 mintSizeOfSideSetEntry;
     219                 :            :     
     220                 :            :     // Buffers for read operations.
     221                 :            :     struct SNodeReturnBuffer {
     222                 :            :         UnsignedInt32 mintNumNodes;
     223                 :            :         UnsignedInt32* mpaNodeIDs;
     224                 :            :         double* mpadblX;
     225                 :            :         double* mpadblY;
     226                 :            :         double* mpadblZ;
     227                 :            :     } mNodeBuff;
     228                 :            :     struct SElemReturnBuffer {
     229                 :            :         UnsignedInt32 mintNumTypes;
     230                 :            :         UnsignedInt32 mintNumElemIds;
     231                 :            :         UnsignedInt32 mintNumElemGids;
     232                 :            :         UnsignedInt32 mintNumConnect;
     233                 :            :         SElemData* mpaElemData;
     234                 :            :         UnsignedInt32* mpaElemIDs;
     235                 :            :         UnsignedInt32* mpaElemGlobalIDs;
     236                 :            :         UnsignedInt32* mpaElemConnect;
     237                 :            :     } mElemBuff;
     238                 :            :     struct SGroupReturnBuffer {
     239                 :            :         UnsignedInt32 mintNumTypes;
     240                 :            :         UnsignedInt32 mintNumMembers;
     241                 :            :         SGroupData* mpaGroupData;
     242                 :            :         UnsignedInt32* mpaintMemberIDs;
     243                 :            :     } mGroupBuff;
     244                 :            :     struct SBlockReturnBuffer {
     245                 :            :         UnsignedInt32 mintNumTypes;
     246                 :            :         UnsignedInt32 mintNumMembers;
     247                 :            :         UnsignedInt32 mintAttributeOrder;
     248                 :            :         SBlockData* mpaBlockData;
     249                 :            :         UnsignedInt32* mpaintMemberIDs;
     250                 :            :         double* mpadblAttributes;
     251                 :            :     } mBlockBuff;
     252                 :            :     struct SNodeSetReturnBuffer {
     253                 :            :         UnsignedInt32 mintNumTypes;
     254                 :            :         UnsignedInt32 mintNumMembers;
     255                 :            :         SNodeSetData* mpaNodeSetData;
     256                 :            :         UnsignedInt32* mpaintMemberIDs;
     257                 :            :     } mNodeSetBuff;
     258                 :            : 
     259                 :            :     // these sideset buffers are big arrays and the mpaSideSetData can reference parts of these buffers
     260                 :            :     // I guess the reason for that is memory ownership is a bit more clear when passing data around
     261                 :            :     struct SSideSetReturnBuffer_10 {
     262                 :            :         UnsignedInt32 mintNumTypes;
     263                 :            :         UnsignedInt32 mintNumMembersIDs;
     264                 :            :         UnsignedInt32 mintNumMembersSense8;
     265                 :            :         UnsignedInt32 mintNumMembersSense32;
     266                 :            :         UnsignedInt32 mintNumMembersSideNum;
     267                 :            :         UnsignedInt32 mintNumDistFact;
     268                 :            :         SSideSetData_10* mpaSideSetData;
     269                 :            :         UnsignedInt32* mpaintMemberIDs;
     270                 :            :         char* mpachrMemberSense;
     271                 :            :         UnsignedInt32* mpaintMemberSense;
     272                 :            :         char* mpachrMemberSideNum;
     273                 :            :         double* mpadblDistribution;
     274                 :            :     } mSideSetBuff_10;
     275                 :            :     struct SSideSetReturnBuffer_11 {
     276                 :            :         UnsignedInt32 mintNumTypes;
     277                 :            :         UnsignedInt32 mintNumMembersIDs;
     278                 :            :         UnsignedInt32 mintNumMembersSense;
     279                 :            :         UnsignedInt32 mintNumMembersSideNum;
     280                 :            :         UnsignedInt32 mintNumDistFact;
     281                 :            :         SSideSetData_11* mpaSideSetData;
     282                 :            :         UnsignedInt32* mpaintMemberTypes;
     283                 :            :         UnsignedInt32* mpaintMemberIDs;
     284                 :            :         char* mpachrMemberSense;
     285                 :            :         UnsignedInt32 mintNumWRTEntities;
     286                 :            :         UnsignedInt32* mpaintMemberWRTEntities;
     287                 :            :         double* mpadblDistribution;
     288                 :            :     } mSideSetBuff_11;
     289                 :            : 
     290                 :            :     template <class TBuffer>
     291                 :          0 :     TBuffer* AdjustBuffer(UnsignedInt32 xintRequiredSize,
     292                 :            :         UnsignedInt32& xintActualSize, TBuffer*& xpaBuffer)
     293                 :            :     {
     294 [ #  # ][ #  # ]:          0 :         if(!xintRequiredSize)  return NULL;  // Nothing requested, return nothing.
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     295                 :            : 
     296 [ #  # ][ #  # ]:          0 :         if(xintActualSize < xintRequiredSize) {
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     297 [ #  # ][ #  # ]:          0 :             if(xpaBuffer)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     298 [ #  # ][ #  # ]:          0 :                 delete [] xpaBuffer;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     299                 :          0 :             xintActualSize = xintRequiredSize;
     300 [ #  # ][ #  # ]:          0 :             xpaBuffer = new TBuffer[xintActualSize];
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     301   [ #  #  #  #  :          0 :             if(!xpaBuffer) {
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     302                 :          0 :                 xintActualSize = 0;
     303                 :          0 :                 throw CCubitFile::eMemoryError;
     304                 :            :             }
     305                 :            :         }
     306                 :          0 :         return xpaBuffer;
     307                 :            :     }
     308                 :            : };
     309                 :            : 
     310                 :            : } // namespace NCubitFile
     311                 :            : 
     312                 :            : #endif
     313                 :            : 

Generated by: LCOV version 1.11