DriverGMF_Write::DriverGMF_Write():
- Driver_SMESHDS_Mesh(), _exportRequiredGroups( true )
+ Driver_SMESHDS_Mesh(), _exportRequiredGroups( true ), mySizeMapVerticesNumber( 0 ), mySizeMapMeshes(), myLocalSizes()
{
}
DriverGMF_Write::~DriverGMF_Write()
// 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<TLocalSize>::iterator sizes_it;
+ std::list<SMESHDS_Mesh*>::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
#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.
*/
_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();
SMDS_ElemIteratorPtr elementIterator(SMDSAbs_GeometryType type);
bool _exportRequiredGroups;
+ int mySizeMapVerticesNumber;
+ std::list<SMESHDS_Mesh*> mySizeMapMeshes;
+ std::list<TLocalSize> myLocalSizes;
};
#endif