Back to index

salome-smesh  6.5.0
DriverCGNS_Write.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 // File      : DriverCGNS_Write.cxx
00023 // Created   : Fri Aug  5 17:43:54 2011
00024 // Author    : Edward AGAPOV (eap)
00025 
00026 #include "DriverCGNS_Write.hxx"
00027 
00028 #include "SMDS_MeshNode.hxx"
00029 #include "SMDS_VolumeTool.hxx"
00030 #include "SMESHDS_GroupBase.hxx"
00031 #include "SMESHDS_Mesh.hxx"
00032 #include "SMESH_Comment.hxx"
00033 
00034 #include <limits>
00035 #include <cgnslib.h>
00036 
00037 #if CGNS_VERSION < 3100
00038 # define cgsize_t int
00039 #endif
00040 
00041 using namespace std;
00042 
00043 namespace
00044 {
00045   //================================================================================
00049   //================================================================================
00050 
00051   const int* getInterlaceAndType( const SMDSAbs_EntityType      smType,
00052                                   CGNS_ENUMT( ElementType_t ) & cgType )
00053   {
00054     static vector< const int* >                 interlaces;
00055     static vector< CGNS_ENUMT( ElementType_t )> cgTypes; 
00056     if ( interlaces.empty() )
00057     {
00058       interlaces.resize( SMDSEntity_Last, 0 );
00059       cgTypes.resize( SMDSEntity_Last, CGNS_ENUMV( ElementTypeNull ));
00060       {
00061         static int ids[] = {0};
00062         interlaces[SMDSEntity_0D] = ids;
00063         cgTypes   [SMDSEntity_0D] = CGNS_ENUMV( NODE );
00064       }
00065       {
00066         static int ids[] = { 0, 1 };
00067         interlaces[SMDSEntity_Edge] = ids;
00068         cgTypes   [SMDSEntity_Edge] = CGNS_ENUMV( BAR_2 );
00069       }
00070       {
00071         static int ids[] = { 0, 1, 2 };
00072         interlaces[SMDSEntity_Quad_Edge] = ids;
00073         cgTypes   [SMDSEntity_Quad_Edge] = CGNS_ENUMV( BAR_3 );
00074       }
00075       {
00076         static int ids[] = { 0, 2, 1 };
00077         interlaces[SMDSEntity_Triangle] = ids;
00078         cgTypes   [SMDSEntity_Triangle] = CGNS_ENUMV( TRI_3 );
00079       }
00080       {
00081         static int ids[] = { 0, 2, 1, 5, 4, 3 };
00082         interlaces[SMDSEntity_Quad_Triangle] = ids;
00083         cgTypes   [SMDSEntity_Quad_Triangle] = CGNS_ENUMV( TRI_6 );
00084       }
00085       {
00086         static int ids[] = { 0, 3, 2, 1 };
00087         interlaces[SMDSEntity_Quadrangle] = ids;
00088         cgTypes   [SMDSEntity_Quadrangle] = CGNS_ENUMV( QUAD_4 );
00089       }
00090       {
00091         static int ids[] = { 0,3,2,1,7,6,5,4 };
00092         interlaces[SMDSEntity_Quad_Quadrangle] = ids;
00093         cgTypes   [SMDSEntity_Quad_Quadrangle] = CGNS_ENUMV( QUAD_8 );
00094       }
00095       {
00096         static int ids[] = { 0,3,2,1,7,6,5,4,8 };
00097         interlaces[SMDSEntity_BiQuad_Quadrangle] = ids;
00098         cgTypes   [SMDSEntity_BiQuad_Quadrangle] = CGNS_ENUMV( QUAD_9 );
00099       }
00100       {
00101         static int ids[] = { 0, 2, 1, 3 };
00102         interlaces[SMDSEntity_Tetra] = ids;
00103         cgTypes   [SMDSEntity_Tetra] = CGNS_ENUMV( TETRA_4 );
00104       }
00105       {
00106         static int ids[] = { 0,2,1,3,6,5,4,7,9,8 };
00107         interlaces[SMDSEntity_Quad_Tetra] = ids;
00108         cgTypes   [SMDSEntity_Quad_Tetra] = CGNS_ENUMV( TETRA_10 );
00109       }
00110       {
00111         static int ids[] = { 0,3,2,1,4 };
00112         interlaces[SMDSEntity_Pyramid] = ids;
00113         cgTypes   [SMDSEntity_Pyramid] = CGNS_ENUMV( PYRA_5 );
00114       }
00115       {
00116         static int ids[] = { 0,3,2,1,4,8,7,6,5,9,12,11,10 };
00117         interlaces[SMDSEntity_Quad_Pyramid] = ids;
00118         cgTypes   [SMDSEntity_Quad_Pyramid] = CGNS_ENUMV( PYRA_13 );
00119       }
00120       {
00121         static int ids[] = { 0,2,1,3,5,4 };
00122         interlaces[SMDSEntity_Penta] = ids;
00123         cgTypes   [SMDSEntity_Penta] = CGNS_ENUMV( PENTA_6 );
00124       }
00125       {
00126         static int ids[] = { 0,2,1,3,5,4,8,7,6,9,11,10,14,13,12 };
00127         interlaces[SMDSEntity_Quad_Penta] = ids;
00128         cgTypes   [SMDSEntity_Quad_Penta] = CGNS_ENUMV( PENTA_15 );
00129       }
00130       {
00131         static int ids[] = { 0,3,2,1,4,7,6,5 };
00132         interlaces[SMDSEntity_Hexa] = ids;
00133         cgTypes   [SMDSEntity_Hexa] = CGNS_ENUMV( HEXA_8 );
00134       }
00135       {
00136         static int ids[] = { 0,3,2,1,4,7,6,5,11,10,9,8,12,15,14,13,19,18,17,16 };
00137         interlaces[SMDSEntity_Quad_Hexa] = ids;
00138         cgTypes   [SMDSEntity_Quad_Hexa] = CGNS_ENUMV( HEXA_20 );
00139       }
00140       {
00141         static int ids[] = { 0,3,2,1,4,7,6,5,11,10,9,8,12,15,14,13,19,18,17,16,
00142                              20, 24,23,22,21, 25};
00143         interlaces[SMDSEntity_TriQuad_Hexa] = ids;
00144         cgTypes   [SMDSEntity_TriQuad_Hexa] = CGNS_ENUMV( HEXA_27 );
00145       }
00146       {
00147         cgTypes[SMDSEntity_Polygon]         = CGNS_ENUMV( NGON_n );
00148         cgTypes[SMDSEntity_Polyhedra]       = CGNS_ENUMV( NFACE_n );
00149         cgTypes[SMDSEntity_Hexagonal_Prism] = CGNS_ENUMV( NFACE_n );
00150       }
00151     }
00152     cgType  = cgTypes[ smType ];
00153     return interlaces[ smType ];
00154   }
00155 
00156   //================================================================================
00160   //================================================================================
00161 
00162   CGNS_ENUMT( BCType_t ) getBCType( string& groupName )
00163   {
00164     CGNS_ENUMT( BCType_t ) bcType = CGNS_ENUMV( BCGeneral ); // default type
00165 
00166     // boundary condition type starts from "BC"
00167     size_t bcBeg = groupName.find("BC");
00168     if ( bcBeg != string::npos )
00169     {
00170       for ( int t = 0; t < NofValidBCTypes; ++t )
00171       {
00172         CGNS_ENUMT( BCType_t ) type = CGNS_ENUMT( BCType_t)( t );
00173         string typeName = cg_BCTypeName( type );
00174         if ( typeName == &groupName[0] + bcBeg )
00175         {
00176           bcType = type;
00177           while ( bcBeg > 0 && isspace( bcBeg-1 ))
00178             --bcBeg;
00179           if ( bcBeg == 0 )
00180             groupName = "Group";
00181           else
00182             groupName = groupName.substr( 0, bcBeg-1 );
00183         }
00184       }
00185     }
00186     return bcType;
00187   }
00188 
00189   //================================================================================
00193   struct TPolyhedFace
00194   {
00195     int _id; // id of NGON_n
00196     vector< int > _nodes; // lowest node IDs used for sorting
00197 
00198     TPolyhedFace( const SMDS_MeshNode** nodes, const int nbNodes, int ID):_id(ID)
00199     {
00200       set< int > ids;
00201       for ( int i = 0; i < nbNodes; ++i )
00202         ids.insert( nodes[i]->GetID() );
00203 
00204       _nodes.resize( 3 ); // std::min( nbNodes, 4 )); hope 3 nodes is enough
00205       set< int >::iterator idIt = ids.begin();
00206       for ( size_t j = 0; j < _nodes.size(); ++j, ++idIt )
00207         _nodes[j] = *idIt;
00208     }
00209     bool operator< (const TPolyhedFace& o ) const
00210     {
00211       return _nodes < o._nodes;
00212     }
00213   };
00214   //================================================================================
00218   //================================================================================
00219 
00220   cgsize_t cgnsID( const SMDS_MeshElement*                         elem,
00221                    const map< const SMDS_MeshElement*, cgsize_t >& elem2cgID )
00222   {
00223     map< const SMDS_MeshElement*, cgsize_t >::const_iterator e2id = elem2cgID.find( elem );
00224     return ( e2id == elem2cgID.end() ? elem->GetID() : e2id->second );
00225   }
00226 
00227 } // namespace
00228 
00229 //================================================================================
00233 //================================================================================
00234 
00235 Driver_Mesh::Status DriverCGNS_Write::Perform()
00236 {
00237   myErrorMessages.clear();
00238 
00239   if ( !myMesh || myMesh->GetMeshInfo().NbElements() < 1 )
00240     return addMessage( !myMesh ? "NULL mesh" : "Empty mesh (no elements)", /*fatal = */true );
00241 
00242   // open the file
00243   if ( cg_open(myFile.c_str(), CG_MODE_MODIFY, &_fn) != CG_OK &&
00244        cg_open(myFile.c_str(), CG_MODE_WRITE,  &_fn) != CG_OK )
00245     return addMessage( cg_get_error(), /*fatal = */true );
00246 
00247   // create a Base
00248   // --------------
00249 
00250   const int spaceDim = 3;
00251   int meshDim = 1;
00252   if ( myMesh->NbFaces() > 0 ) meshDim = 2;
00253   if ( myMesh->NbVolumes() > 0 ) meshDim = 3;
00254 
00255   if ( myMeshName.empty() )
00256   {
00257     int nbases = 0;
00258     if ( cg_nbases( _fn, &nbases) == CG_OK)
00259       myMeshName = ( SMESH_Comment("Base_") << nbases+1 );
00260     else
00261       myMeshName = "Base_0";
00262   }
00263   int iBase;
00264   if ( cg_base_write( _fn, myMeshName.c_str(), meshDim, spaceDim, &iBase))
00265     return addMessage( cg_get_error(), /*fatal = */true );
00266 
00267   // create a Zone
00268   // --------------
00269 
00270   int nbCells = myMesh->NbEdges();
00271   if ( meshDim == 3 )
00272     nbCells = myMesh->NbVolumes();
00273   else if ( meshDim == 2 )
00274     nbCells = myMesh->NbFaces();
00275 
00276   cgsize_t size[9] = { myMesh->NbNodes(), nbCells, /*NBoundVertex=*/0, 0,0,0,0,0,0 };
00277   int iZone;
00278   if ( cg_zone_write( _fn, iBase, "SMESH_Mesh", size,
00279                       CGNS_ENUMV( Unstructured ), &iZone) != CG_OK )
00280     return addMessage( cg_get_error(), /*fatal = */true );
00281 
00282   // Map to store only elements whose an SMDS ID differs from a CGNS one
00283   typedef map< const SMDS_MeshElement*, cgsize_t > TElem2cgIDMap;
00284   vector< TElem2cgIDMap > elem2cgIDByEntity( SMDSEntity_Last );
00285   TElem2cgIDMap::iterator elem2cgIDIter;
00286 
00287   TElem2cgIDMap & n2cgID = elem2cgIDByEntity[ SMDSEntity_Node ];
00288 
00289   // Write nodes
00290   // ------------
00291   {
00292     vector< double > coords( myMesh->NbNodes() );
00293     int iC;
00294     // X
00295     SMDS_NodeIteratorPtr nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
00296     for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->X();
00297     if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
00298                           "CoordinateX", &coords[0], &iC) != CG_OK )
00299       return addMessage( cg_get_error(), /*fatal = */true );
00300     // Y
00301     nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
00302     for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->Y();
00303     if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
00304                           "CoordinateY", &coords[0], &iC) != CG_OK )
00305       return addMessage( cg_get_error(), /*fatal = */true );
00306     // Z
00307     nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
00308     for ( int i = 0; nIt->more(); ++i ) coords[i] = nIt->next()->Z();
00309     if ( cg_coord_write( _fn, iBase, iZone, CGNS_ENUMV(RealDouble),
00310                           "CoordinateZ", &coords[0], &iC) != CG_OK )
00311       return addMessage( cg_get_error(), /*fatal = */true );
00312 
00313     // store CGNS ids of nodes
00314     nIt = myMesh->nodesIterator( /*idInceasingOrder=*/true );
00315     for ( int i = 0; nIt->more(); ++i )
00316     {
00317       const SMDS_MeshElement* n = nIt->next();
00318       if ( n->GetID() != i+1 )
00319         n2cgID.insert( n2cgID.end(), make_pair( n, i+1 ));
00320     }
00321   }
00322   // Write elements
00323   // ---------------
00324   
00325   cgsize_t cgID = 1, startID;
00326 
00327   // write into a section all successive elements of one geom type
00328   int iSec;
00329   vector< cgsize_t > elemData;
00330   SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator();
00331   const SMDS_MeshElement* elem = elemIt->next();
00332   while ( elem )
00333   {
00334     const SMDSAbs_EntityType elemType = elem->GetEntityType();
00335     CGNS_ENUMT( ElementType_t ) cgType;
00336     const int* interlace = getInterlaceAndType( elemType, cgType );
00337 
00338     TElem2cgIDMap & elem2cgID = elem2cgIDByEntity[ elemType ];
00339 
00340     elemData.clear();
00341     startID = cgID;
00342 
00343     if ( interlace ) // STANDARD elements
00344       do
00345       {
00346         for ( int i = 0, nb = elem->NbNodes(); i < nb; ++i )
00347           elemData.push_back( cgnsID( elem->GetNode( interlace[i] ), n2cgID ));
00348         if ( elem->GetID() != cgID )
00349           elem2cgID.insert( elem2cgID.end(), make_pair( elem, cgID ));
00350         ++cgID;
00351         elem = elemIt->more() ? elemIt->next() : 0;
00352       }
00353       while ( elem && elem->GetEntityType() == elemType );
00354 
00355     else if ( elemType == SMDSEntity_Polygon ) // POLYGONS
00356       do
00357       {
00358         elemData.push_back( elem->NbNodes() );
00359         for ( int i = 0, nb = elem->NbNodes(); i < nb; ++i )
00360           elemData.push_back( cgnsID( elem->GetNode(i), n2cgID ));
00361         if ( elem->GetID() != cgID )
00362           elem2cgID.insert( elem2cgID.end(), make_pair( elem, cgID ));
00363         ++cgID;
00364         elem = elemIt->more() ? elemIt->next() : 0;
00365       }
00366       while ( elem && elem->GetEntityType() == elemType );
00367 
00368     else if ( elemType == SMDSEntity_Polyhedra ||
00369               elemType == SMDSEntity_Hexagonal_Prism) // POLYHEDRA
00370     {
00371       // to save polyhedrons after all
00372       const SMDS_MeshInfo& meshInfo = myMesh->GetMeshInfo();
00373       if ( meshInfo.NbPolyhedrons() == meshInfo.NbElements() - cgID + 1 )
00374         break; // only polyhedrons remain
00375       while ( elem && elem->GetEntityType() == elemType )
00376         elem = elemIt->more() ? elemIt->next() : 0;
00377       continue;
00378     }
00379 
00380     SMESH_Comment sectionName( cg_ElementTypeName( cgType ));
00381     sectionName << " " << startID << " - " << cgID-1;
00382 
00383     if ( cg_section_write(_fn, iBase, iZone, sectionName.c_str(), cgType, startID,
00384                           cgID-1, /*nbndry=*/0, &elemData[0], &iSec) != CG_OK )
00385       return addMessage( cg_get_error(), /*fatal = */true );
00386   }
00387   // Write polyhedral volumes
00388   // -------------------------
00389 
00390   if ( myMesh->GetMeshInfo().NbElements() > cgID-1 ) // polyhedra or hexagonal prisms remain
00391   {
00392     // the polyhedron (NFACE_n) is described as a set of signed face IDs,
00393     // so first we are to write all polygones (NGON_n) bounding polyhedrons
00394 
00395     vector< cgsize_t > faceData;
00396     set< TPolyhedFace > faces;
00397     set< TPolyhedFace >::iterator faceInSet;
00398     vector<const SMDS_MeshNode *> faceNodesVec;
00399     int nbPolygones = 0, faceID;
00400 
00401     SMDS_VolumeTool vol;
00402 
00403     elemData.clear();
00404 
00405     int nbPolyhTreated = 0;
00406 
00407     TElem2cgIDMap * elem2cgID = 0;
00408     TElem2cgIDMap & n2cgID    = elem2cgIDByEntity[ SMDSEntity_Node ];
00409 
00410     SMDS_ElemIteratorPtr elemIt = myMesh->elementsIterator();
00411     while ( elemIt->more() )
00412     {
00413       elem = elemIt->next();
00414       SMDSAbs_EntityType type = elem->GetEntityType();
00415       if ( type == SMDSEntity_Polyhedra ||
00416            type == SMDSEntity_Hexagonal_Prism )
00417       {
00418         ++nbPolyhTreated;
00419         vol.Set( elem );
00420         vol.SetExternalNormal();
00421         const int nbFaces = vol.NbFaces();
00422         elemData.push_back( nbFaces );
00423         for ( int iF = 0; iF < nbFaces; ++iF )
00424         {
00425           const int nbNodes = vol.NbFaceNodes( iF );
00426           const SMDS_MeshNode** faceNodes = vol.GetFaceNodes( iF );
00427           faceNodesVec.assign( faceNodes, faceNodes + nbNodes );
00428           if (( elem = myMesh->FindElement( faceNodesVec, SMDSAbs_Face, /*noMedium=*/false)))
00429           {
00430             // a face of the polyhedron is present in the mesh
00431             faceID = cgnsID( elem, elem2cgIDByEntity[ elem->GetEntityType() ]);
00432           }
00433           else if ( vol.IsFreeFace( iF ))
00434           {
00435             // the face is not shared by volumes
00436             faceID = cgID++;
00437             ++nbPolygones;
00438             faceData.push_back( nbNodes );
00439             for ( int i = 0; i < nbNodes; ++i )
00440               faceData.push_back( cgnsID( faceNodes[i], n2cgID ));
00441           }
00442           else
00443           {
00444             TPolyhedFace face( faceNodes, nbNodes, cgID );
00445             faceInSet = faces.insert( faces.end(), face );
00446             if ( faceInSet->_id == cgID ) // the face encounters for the 1st time
00447             {
00448               faceID = cgID++;
00449               ++nbPolygones;
00450               faceData.push_back( nbNodes );
00451               for ( int i = 0; i < nbNodes; ++i )
00452                 faceData.push_back( cgnsID( faceNodes[i], n2cgID ));
00453             }
00454             else
00455             {
00456               // the face encounters for the 2nd time; we hope it won't encounter once more,
00457               // for that we can erase it from the set of faces
00458               faceID = -faceInSet->_id;
00459               faces.erase( faceInSet );
00460             }
00461           }
00462           elemData.push_back( faceID );
00463         }
00464       }
00465     }
00466 
00467     if ( nbPolygones > 0 )
00468     {
00469       if ( cg_section_write(_fn, iBase, iZone, "Faces of Polyhedrons",
00470                              CGNS_ENUMV( NGON_n ), cgID - nbPolygones, cgID-1,
00471                              /*nbndry=*/0, &faceData[0], &iSec) != CG_OK )
00472         return addMessage( cg_get_error(), /*fatal = */true );
00473     }
00474     
00475     if ( cg_section_write(_fn, iBase, iZone, "Polyhedrons", 
00476                              CGNS_ENUMV( NFACE_n ), cgID, cgID+nbPolyhTreated-1,
00477                            /*nbndry=*/0, &elemData[0], &iSec) != CG_OK )
00478       return addMessage( cg_get_error(), /*fatal = */true );
00479 
00480     if ( !myMesh->GetGroups().empty() )
00481     {
00482       // store CGNS ids of polyhedrons
00483       elem2cgID = &elem2cgIDByEntity[ SMDSEntity_Polyhedra ];
00484       elemIt = myMesh->elementsIterator();
00485       while ( elemIt->more() )
00486       {
00487         elem = elemIt->next();
00488         if ( elem->GetEntityType() == SMDSEntity_Polyhedra )
00489         {
00490           if ( elem->GetID() != cgID )
00491             elem2cgID->insert( elem2cgID->end(), make_pair( elem, cgID ));
00492           ++cgID;
00493         }
00494       }
00495     }
00496   } // write polyhedral volumes
00497 
00498 
00499   // Write groups as boundary conditions
00500   // ------------------------------------
00501 
00502   const set<SMESHDS_GroupBase*>& groups = myMesh->GetGroups();
00503   set<SMESHDS_GroupBase*>::const_iterator grpIt = groups.begin();
00504   set< string > groupNames; groupNames.insert(""); // to avoid duplicated and empty names
00505   for ( ; grpIt != groups.end(); ++grpIt )
00506   {
00507     const SMESHDS_GroupBase* group = *grpIt;
00508 
00509     // write BC location (default is Vertex)
00510     CGNS_ENUMT( GridLocation_t ) location = CGNS_ENUMV( Vertex );
00511     if ( group->GetType() != SMDSAbs_Node )
00512     {
00513       switch ( meshDim ) {
00514       case 3:
00515         switch ( group->GetType() ) {
00516         case SMDSAbs_Volume: location = CGNS_ENUMV( FaceCenter ); break; // !!!
00517         case SMDSAbs_Face:   location = CGNS_ENUMV( FaceCenter ); break; // OK
00518         case SMDSAbs_Edge:   location = CGNS_ENUMV( EdgeCenter ); break; // OK
00519         default:;
00520         }
00521         break;
00522       case 2:
00523         switch ( group->GetType() ) {
00524         case SMDSAbs_Face: location = CGNS_ENUMV( FaceCenter ); break; // ???
00525         case SMDSAbs_Edge: location = CGNS_ENUMV( EdgeCenter ); break; // OK
00526         default:;
00527         }
00528         break;
00529       case 1:
00530         location = CGNS_ENUMV( EdgeCenter ); break; // ???
00531         break;
00532       }
00533     }
00534 
00535     // try to extract type of boundary condition from the group name
00536     string name = group->GetStoreName();
00537     CGNS_ENUMT( BCType_t ) bcType = getBCType( name );
00538     while ( !groupNames.insert( name ).second )
00539       name = (SMESH_Comment( "Group_") << groupNames.size());
00540 
00541     // write IDs of elements
00542     vector< cgsize_t > pnts;
00543     pnts.reserve( group->Extent() );
00544     SMDS_ElemIteratorPtr elemIt = group->GetElements();
00545     while ( elemIt->more() )
00546     {
00547       const SMDS_MeshElement* elem = elemIt->next();
00548       pnts.push_back( cgnsID( elem, elem2cgIDByEntity[ elem->GetEntityType() ]));
00549     }
00550     int iBC;
00551     if ( cg_boco_write( _fn, iBase, iZone, name.c_str(), bcType,
00552                         CGNS_ENUMV( PointList ), pnts.size(), &pnts[0], &iBC) != CG_OK )
00553       return addMessage( cg_get_error(), /*fatal = */true);
00554 
00555     // write BC location
00556     if ( location != CGNS_ENUMV( Vertex ))
00557     {
00558       if ( cg_boco_gridlocation_write( _fn, iBase, iZone, iBC, location) != CG_OK )
00559         return addMessage( cg_get_error(), /*fatal = */false);
00560     }
00561   }
00562   return DRS_OK;
00563 }
00564 
00565 //================================================================================
00569 //================================================================================
00570 
00571 DriverCGNS_Write::DriverCGNS_Write(): _fn(0)
00572 {
00573 }
00574 
00575 //================================================================================
00579 //================================================================================
00580 
00581 DriverCGNS_Write::~DriverCGNS_Write()
00582 {
00583   if ( _fn > 0 )
00584     cg_close( _fn );
00585 }