From: rnc Date: Tue, 4 Jun 2013 16:29:27 +0000 (+0000) Subject: allow multiple size-maps definition X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b41bee030fad6b0fbcd8a0e23e4ac78d295a167b;p=modules%2Fsmesh.git allow multiple size-maps definition --- diff --git a/src/DriverGMF/DriverGMF_Write.cxx b/src/DriverGMF/DriverGMF_Write.cxx index 36b94df47..ea28f31cf 100644 --- a/src/DriverGMF/DriverGMF_Write.cxx +++ b/src/DriverGMF/DriverGMF_Write.cxx @@ -79,7 +79,7 @@ extern "C" DriverGMF_Write::DriverGMF_Write(): - Driver_SMESHDS_Mesh(), _exportRequiredGroups( true ) + Driver_SMESHDS_Mesh(), _exportRequiredGroups( true ), mySizeMapVerticesNumber( 0 ), mySizeMapMeshes(), myLocalSizes() { } DriverGMF_Write::~DriverGMF_Write() @@ -370,49 +370,94 @@ Driver_Mesh::Status DriverGMF_Write::Perform() // return nbVertices; // } // -// int DriverGMF_Write::OpenFileToWrite() +// int DriverGMF_Write::BeginSizeMap() // { // const int dim = 3, version = sizeof(long) == 4 ? 2 : 3; -// int meshID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim ); -// return meshID; +// myGmfID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim ); // } -// -// void DriverGMF_Write::CloseFile( int meshID ) +// +// void DriverGMF_Write::EndSizeMap() // { -// GmfCloseMesh( meshID ); +// GmfCloseMesh( myGmfID ); // } +void DriverGMF_Write::AddSizeMapFromMesh( SMESHDS_Mesh* mesh, double size) +{ + mySizeMapMeshes.push_back( mesh ); + mySizeMapVerticesNumber += mesh->NbNodes(); + myLocalSizes.push_back(TLocalSize(mesh->NbNodes(), size)); +} -void DriverGMF_Write::WriteSizeMapFromMesh( double size ) +Driver_Mesh::Status DriverGMF_Write::PerformSizeMap() { // Open file const int dim = 3, version = sizeof(long) == 4 ? 2 : 3; int meshID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim ); // Vertices Keyword - int iN = 0, nbNodes = myMesh->NbNodes(); - GmfSetKwd( meshID, GmfVertices, nbNodes ); + GmfSetKwd( meshID, GmfVertices, mySizeMapVerticesNumber ); double xyz[3]; - SMDS_NodeIteratorPtr nodeIt = myMesh->nodesIterator(); - while ( nodeIt->more() ) + std::list::iterator sizes_it; + std::list::iterator meshes_it; + SMESHDS_Mesh* aMesh; + for ( sizes_it = myLocalSizes.begin(), meshes_it = mySizeMapMeshes.begin() + ; sizes_it != myLocalSizes.end() + ; sizes_it++, meshes_it++ ) { - const SMDS_MeshNode* n = nodeIt->next(); - n->GetXYZ( xyz ); - GmfSetLin( meshID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() ); - } + aMesh= *meshes_it; + SMDS_NodeIteratorPtr nodeIt = aMesh->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* n = nodeIt->next(); + n->GetXYZ( xyz ); + GmfSetLin( meshID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() ); + } + + // solAtVertices Keyword + int TypTab[] = {GmfSca}; + GmfSetKwd(meshID, GmfSolAtVertices, mySizeMapVerticesNumber, 1, TypTab); - // solAtVertices Keyword - int TypTab[] = {GmfSca}; - GmfSetKwd(meshID, GmfSolAtVertices, nbNodes, 1, TypTab); - for ( int i=1; i<= nbNodes; i++) - { - double ValTab[] = {size}; - GmfSetLin( meshID, GmfSolAtVertices, ValTab); + for ( int i = 1; i <= sizes_it->nbNodes; i++ ) + { + double ValTab[] = {sizes_it->size}; + GmfSetLin( meshID, GmfSolAtVertices, ValTab); + } } // Close File GmfCloseMesh( meshID ); } +// void DriverGMF_Write::WriteSizeMapFromMesh( double size ) +// { +// // Open file +// const int dim = 3, version = sizeof(long) == 4 ? 2 : 3; +// int meshID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim ); +// +// // Vertices Keyword +// int iN = 0, nbNodes = myMesh->NbNodes(); +// GmfSetKwd( meshID, GmfVertices, nbNodes ); +// double xyz[3]; +// SMDS_NodeIteratorPtr nodeIt = myMesh->nodesIterator(); +// while ( nodeIt->more() ) +// { +// const SMDS_MeshNode* n = nodeIt->next(); +// n->GetXYZ( xyz ); +// GmfSetLin( meshID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() ); +// } +// +// // solAtVertices Keyword +// int TypTab[] = {GmfSca}; +// GmfSetKwd(meshID, GmfSolAtVertices, nbNodes, 1, TypTab); +// for ( int i=1; i<= nbNodes; i++) +// { +// double ValTab[] = {size}; +// GmfSetLin( meshID, GmfSolAtVertices, ValTab); +// } +// +// // Close File +// GmfCloseMesh( meshID ); +// } + //================================================================================ /*! * \brief Returns an iterator on elements of a certain type diff --git a/src/DriverGMF/DriverGMF_Write.hxx b/src/DriverGMF/DriverGMF_Write.hxx index 35d845a43..a1779a674 100644 --- a/src/DriverGMF/DriverGMF_Write.hxx +++ b/src/DriverGMF/DriverGMF_Write.hxx @@ -33,6 +33,17 @@ #include "SMDSAbs_ElementType.hxx" #include "SMDS_ElemIterator.hxx" +struct TLocalSize +{ + TLocalSize( int theNbNodes, double theSize) + { + nbNodes = theNbNodes; + size = theSize; + } + int nbNodes; + double size; +}; + /*! * \brief Driver Writing a mesh into a GMF file. */ @@ -48,8 +59,10 @@ public: _exportRequiredGroups = toExport; } - virtual Status Perform(); - void WriteSizeMapFromMesh( double size ); + virtual Status Perform(); + Status PerformSizeMap(); + void AddSizeMapFromMesh( SMESHDS_Mesh* mesh, double size); +// void WriteSizeMapFromMesh( double size ); // void AddSizeMapSection( int meshID, int nbControlPoints ); // void AppendSize( int meshID, double size ); // int NbVerticesInFile(); @@ -63,6 +76,9 @@ public: SMDS_ElemIteratorPtr elementIterator(SMDSAbs_GeometryType type); bool _exportRequiredGroups; + int mySizeMapVerticesNumber; + std::list mySizeMapMeshes; + std::list myLocalSizes; }; #endif