Salome HOME
0021543: EDF 1978 SMESH: Viscous layer for 2D meshes
[modules/smesh.git] / src / DriverCGNS / DriverCGNS_Read.cxx
index f051d55083278474d75d7bd428d85e3480051206..97fafe3b1962fb60d3204b83318978cf0b81200a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -77,7 +77,7 @@ namespace
     bool IsStructured() const { return ( _type == CGNS_ENUMV( Structured )); }
     int IndexSize() const { return IsStructured() ? _meshDim : 1; }
     string ReadZonesConnection(int file, int base, const map< string, TZoneData >& zonesByName);
-    void ReplaceNodes( int* ids, int nbIds, int idShift = 0 ) const;
+    void ReplaceNodes( cgsize_t* ids, int nbIds, int idShift = 0 ) const;
 
     // Methods for a structured zone
 
@@ -331,16 +331,16 @@ namespace
             continue; // donor zone not yet read
           const TZoneData& zone2 = n_z->second;
 
-          vector< int > ids( nb * IndexSize() );
-          vector< int > donorIds( donorNb * zone2.IndexSize() );
+          vector< cgsize_t > ids( nb * IndexSize() );
+          vector< cgsize_t > donorIds( donorNb * zone2.IndexSize() );
           if (cg_conn_read ( file, base, _id, I,
                              &ids[0], CGNS_ENUMV(Integer), &donorIds[0]) == CG_OK )
           {
             for ( int isThisZone = 0; isThisZone < 2; ++isThisZone )
             {
-              const TZoneData&           zone = isThisZone ? *this : zone2;
+              const TZoneData&            zone = isThisZone ? *this : zone2;
               CGNS_ENUMT(PointSetType_t) type = isThisZone ? ptype : donorPtype;
-              vector< int >&           points = isThisZone ? ids : donorIds;
+              vector< cgsize_t >&      points = isThisZone ? ids : donorIds;
               if ( type == CGNS_ENUMV( PointRange ))
               {
                 TPointRangeIterator rangeIt( &points[0], zone._meshDim );
@@ -350,7 +350,7 @@ namespace
               }
               else if ( zone.IsStructured() )
               {
-                vector< int > resIDs; resIDs.reserve( points.size() / IndexSize() );
+                vector< cgsize_t > resIDs; resIDs.reserve( points.size() / IndexSize() );
                 for ( size_t i = 0; i < points.size(); i += IndexSize() )
                   resIDs.push_back( zone.NodeID( points[i+0], points[i+1], points[i+2] ));
                 resIDs.swap( points );
@@ -438,6 +438,10 @@ namespace
   {
     return mesh->AddFaceWithID( ids[0],ids[3],ids[2],ids[1],ids[7],ids[6],ids[5],ids[4], ID );
   }
+  SMDS_MeshElement* add_QUAD_9(cgsize_t* ids, SMESHDS_Mesh* mesh, int ID)
+  {
+    return mesh->AddFaceWithID( ids[0],ids[3],ids[2],ids[1],ids[7],ids[6],ids[5],ids[4],ids[8], ID);
+  }
   SMDS_MeshElement* add_TETRA_4(cgsize_t* ids, SMESHDS_Mesh* mesh, int ID)
   {
     return mesh->AddVolumeWithID( ids[0], ids[2], ids[1], ids[3], ID );
@@ -475,6 +479,13 @@ namespace
                                   ids[5],ids[11],ids[10],ids[9],ids[8],ids[12],ids[15],
                                   ids[14],ids[13],ids[19],ids[18],ids[17],ids[16], ID );
   }
+  SMDS_MeshElement* add_HEXA_27(cgsize_t* ids, SMESHDS_Mesh* mesh, int ID)
+  {
+    return mesh->AddVolumeWithID( ids[0],ids[3],ids[2],ids[1],ids[4],ids[7],ids[6],
+                                  ids[5],ids[11],ids[10],ids[9],ids[8],ids[12],ids[15],
+                                  ids[14],ids[13],ids[19],ids[18],ids[17],ids[16],
+                                  ids[20],ids[24],ids[23],ids[22],ids[21],ids[25],ids[26], ID );
+  }
   SMDS_MeshElement* add_NGON(cgsize_t* ids, SMESHDS_Mesh* mesh, int ID)
   {
     vector<int> idVec( ids[0] );
@@ -504,7 +515,7 @@ namespace
       funVec[ CGNS_ENUMV( TRI_6    )] = add_TRI_6   ;
       funVec[ CGNS_ENUMV( QUAD_4   )] = add_QUAD_4  ;
       funVec[ CGNS_ENUMV( QUAD_8   )] = add_QUAD_8  ;
-      funVec[ CGNS_ENUMV( QUAD_9   )] = add_QUAD_8  ;
+      funVec[ CGNS_ENUMV( QUAD_9   )] = add_QUAD_9  ;
       funVec[ CGNS_ENUMV( TETRA_4  )] = add_TETRA_4 ;
       funVec[ CGNS_ENUMV( TETRA_10 )] = add_TETRA_10;
       funVec[ CGNS_ENUMV( PYRA_5   )] = add_PYRA_5  ;
@@ -515,7 +526,7 @@ namespace
       funVec[ CGNS_ENUMV( PENTA_18 )] = add_PENTA_15;
       funVec[ CGNS_ENUMV( HEXA_8   )] = add_HEXA_8  ;
       funVec[ CGNS_ENUMV( HEXA_20  )] = add_HEXA_20 ;
-      funVec[ CGNS_ENUMV( HEXA_27  )] = add_HEXA_20 ;
+      funVec[ CGNS_ENUMV( HEXA_27  )] = add_HEXA_27 ;
       funVec[ CGNS_ENUMV( NGON_n   )] = add_NGON    ;
     }
     return &funVec[0];
@@ -656,8 +667,8 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
     }
     // read coordinates
 
-    int rmin[3] = {1,1,1}; // range of nodes to read
-    int rmax[3] = {1,1,1};
+    cgsize_t rmin[3] = {1,1,1}; // range of nodes to read
+    cgsize_t rmax[3] = {1,1,1};
     int nbNodes = rmax[0] = zone._sizes[0];
     if ( zone.IsStructured())
       for ( int i = 1; i < meshDim; ++i )
@@ -760,7 +771,8 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
 
       CGNS_ENUMT( ElementType_t ) elemType;
       cgsize_t start, end; // range of ids of elements of a zone
-      int nbBnd, parent_flag, eDataSize = 0;
+      cgsize_t eDataSize = 0;
+      int nbBnd, parent_flag;
       for ( int iSec = 1; iSec <= nbSections; ++iSec )
       {
         if ( cg_section_read( _fn, cgnsBase, iZone, iSec, name, &elemType,
@@ -810,7 +822,7 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
               nodes.reserve( nbFaces * 4 );
               for ( int iF = 0; iF < nbFaces; ++iF )
               {
-                const int faceID = Abs( elemData[ pos++ ]) + zone._elemIdShift; 
+                const int faceID = std::abs( elemData[ pos++ ]) + zone._elemIdShift; 
                 if (( face = myMesh->FindElement( faceID )) && face->GetType() == SMDSAbs_Face )
                 {
                   const bool reverse = ( elemData[ pos-1 ] < 0 );
@@ -843,11 +855,10 @@ Driver_Mesh::Status DriverCGNS_Read::Perform()
               //                       Nnodes2, Node12, Node22, ... NodeN2,
               //                       ...
               //                       NnodesM, Node1M, Node2M, ... NodeNM
-              cgnsNbNodes = elemData[ pos ];
-              zone.ReplaceNodes( &elemData[pos+1], cgnsNbNodes, zone._nodeIdShift );
+              const int nbNodes = elemData[ pos ];
+              zone.ReplaceNodes( &elemData[pos+1], nbNodes, zone._nodeIdShift );
               newElem = add_NGON( &elemData[pos  ], myMesh, elemID );
-              pos += cgnsNbNodes + 1;
-              cgnsNbNodes = 0; // as mark of poly elements
+              pos += nbNodes + 1;
             }
           }
           else // standard elements