]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Hexotic size maps: size maps writing in DriverGMF has been rewritten to use a vector...
authorrnc <rnc@opencascade.com>
Tue, 25 Jun 2013 16:32:30 +0000 (16:32 +0000)
committerrnc <rnc@opencascade.com>
Tue, 25 Jun 2013 16:32:30 +0000 (16:32 +0000)
src/DriverGMF/DriverGMF_Write.cxx
src/DriverGMF/DriverGMF_Write.hxx

index 691405f3b2bf3962a3610bfeee9d0fa8bed2081f..54d179a3668b5c79df5df849b2b13e14f556f18e 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <Basics_Utils.hxx>
 
+#include "utilities.h"
+
 extern "C"
 {
 #include "libmesh5.h"
@@ -76,10 +78,10 @@ extern "C"
 #define END_EXTRA_VERTICES_WRITE()           \
   );                                         \
   }}}}
-
-
+  
+  
 DriverGMF_Write::DriverGMF_Write():
-  Driver_SMESHDS_Mesh(), _exportRequiredGroups( true ), mySizeMapVerticesNumber( 0 ), mySizeMapMeshes(), myLocalSizes()
+  Driver_SMESHDS_Mesh(), _exportRequiredGroups( true ), mySizeMapVerticesNumber( 0 ), mySizeMapMeshes(), myLocalSizes()//, mySizeMaps()
 {
 }
 DriverGMF_Write::~DriverGMF_Write()
@@ -387,51 +389,110 @@ void DriverGMF_Write::AddSizeMapFromMesh( SMESHDS_Mesh* mesh, double size)
   myLocalSizes.push_back(TLocalSize(mesh->NbNodes(), size));
 }
 
+void DriverGMF_Write::AddSizeMap( const std::vector<gp_Pnt>& points, double size )
+{
+//   TSizeMap aMap( points, size );
+//   mySizeMaps.push_back( aMap );
+  std::vector<gp_Pnt>::const_iterator it;
+  for( it = points.begin(); it != points.end(); it++)
+  {
+    myPoints.push_back( *it );
+  }
+  mySizeMapVerticesNumber += points.size();
+  myLocalSizes.push_back(TLocalSize(points.size(), 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 );  
+//   const int dim = 3, version = sizeof(long) == 4 ? 2 : 3;
+  const int dim = 3, version = 2; // Version 3 not supported by mg-hexa
+  std::string aVerticesFile = mySizeMapPrefix + ".mesh";
+  std::string aSolFile = mySizeMapPrefix + ".sol";
+  
+  // Open files
+  int verticesFileID = GmfOpenMesh( aVerticesFile.c_str(), GmfWrite, version, dim );  
+  int solFileID = GmfOpenMesh( aSolFile.c_str(), GmfWrite, version, dim );
   
   // Vertices Keyword
-  GmfSetKwd( meshID, GmfVertices, mySizeMapVerticesNumber );
-  double xyz[3];
-  std::vector<SMESHDS_Mesh*>::iterator meshes_it;
-  SMESHDS_Mesh* aMesh;
+  GmfSetKwd( verticesFileID, GmfVertices, mySizeMapVerticesNumber );
   
-  // Iterate on size map meshes
-  for (meshes_it = mySizeMapMeshes.begin(); meshes_it != mySizeMapMeshes.end(); meshes_it++ )
+  std::vector<gp_Pnt>::iterator points_it;
+  // Iterate on sizeMaps
+  for (points_it = myPoints.begin(); points_it != myPoints.end(); points_it++ )
   {
-    aMesh= *meshes_it;
-    SMDS_NodeIteratorPtr nodeIt = aMesh->nodesIterator();
-    
-    // Iterate on the nodes of the mesh and write their coordinates under the GmfVertices keyword
-    while ( nodeIt->more() )
-    {
-      const SMDS_MeshNode* n = nodeIt->next();
-      n->GetXYZ( xyz );
-      GmfSetLin( meshID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() );
-    }
+//     MESSAGE("Point : X = "<<points_it->X()<<", Y ="<<points_it->Y()<<", Z = "<<points_it->Z())
+    GmfSetLin( verticesFileID, GmfVertices, points_it->X(), points_it->Y(), points_it->Z(), 0 );
   }
+  
   // SolAtVertices Keyword
   int TypTab[] = {GmfSca};
-  GmfSetKwd(meshID, GmfSolAtVertices, mySizeMapVerticesNumber, 1, TypTab);
-  
+  GmfSetKwd(solFileID, GmfSolAtVertices, mySizeMapVerticesNumber, 1, TypTab);
   std::vector<TLocalSize>::iterator sizes_it; 
   for ( sizes_it = myLocalSizes.begin(); sizes_it != myLocalSizes.end(); sizes_it++ )
   {
-    for ( int i = 1; i <= sizes_it->nbNodes; i++ )
+    for ( int i = 1; i <= sizes_it->nbPoints ; i++ )
     {
       double ValTab[] = {sizes_it->size};
-      GmfSetLin( meshID, GmfSolAtVertices, ValTab);
+      GmfSetLin( solFileID, GmfSolAtVertices, ValTab);
     }
   }
   
-  // Close File
-  GmfCloseMesh( meshID );
+  // Close Files
+  GmfCloseMesh( verticesFileID );
+  GmfCloseMesh( solFileID );
 }
 
+// Driver_Mesh::Status DriverGMF_Write::PerformSizeMap()
+// {
+// //   const int dim = 3, version = sizeof(long) == 4 ? 2 : 3;
+//   const int dim = 3, version = 2; // Version 3 not supported by mg-hexa
+//   std::string aVerticesFile = mySizeMapPrefix + ".mesh";
+//   std::string aSolFile = mySizeMapPrefix + ".sol";
+//   
+//   // Open files
+//   int verticesFileID = GmfOpenMesh( aVerticesFile.c_str(), GmfWrite, version, dim );  
+//   int solFileID = GmfOpenMesh( aSolFile.c_str(), GmfWrite, version, dim );
+//   
+//   // Vertices Keyword
+//   GmfSetKwd( verticesFileID, GmfVertices, mySizeMapVerticesNumber );
+//   double xyz[3];
+//   std::vector<SMESHDS_Mesh*>::iterator meshes_it;
+//   SMESHDS_Mesh* aMesh;
+//   
+//   // Iterate on size map meshes
+//   for (meshes_it = mySizeMapMeshes.begin(); meshes_it != mySizeMapMeshes.end(); meshes_it++ )
+//   {
+//     aMesh= *meshes_it;
+//     SMDS_NodeIteratorPtr nodeIt = aMesh->nodesIterator();
+//     
+//     // Iterate on the nodes of the mesh and write their coordinates under the GmfVertices keyword
+//     while ( nodeIt->more() )
+//     {
+//       const SMDS_MeshNode* n = nodeIt->next();
+//       n->GetXYZ( xyz );
+//       GmfSetLin( verticesFileID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() );
+//     }
+//   }
+//  
+//   // SolAtVertices Keyword
+//   int TypTab[] = {GmfSca};
+//   GmfSetKwd(solFileID, GmfSolAtVertices, mySizeMapVerticesNumber, 1, TypTab);
+//   
+//   std::vector<TLocalSize>::iterator sizes_it; 
+//   for ( sizes_it = myLocalSizes.begin(); sizes_it != myLocalSizes.end(); sizes_it++ )
+//   {
+//     for ( int i = 1; i <= sizes_it->nbNodes; i++ )
+//     {
+//       double ValTab[] = {sizes_it->size};
+//       GmfSetLin( solFileID, GmfSolAtVertices, ValTab);
+//     }
+//   }
+//   
+//   // Close Files
+//   GmfCloseMesh( verticesFileID );
+//   GmfCloseMesh( solFileID );
+// }
+
 // void DriverGMF_Write::WriteSizeMapFromMesh( double size )
 // {
 //   // Open file
index 36d3b230a15dce7e7a3d361f2127722b9d9d6605..e647c38989bf21893bbf0e55bfc47d69ee9d18ef 100644 (file)
 #include "SMDSAbs_ElementType.hxx"
 #include "SMDS_ElemIterator.hxx"
 
+#include <gp_Pnt.hxx>
+
 struct TLocalSize
 {
-  TLocalSize( int theNbNodes, double theSize)
+  TLocalSize( int theNbPoints, double theSize)
   {
-    nbNodes = theNbNodes;
+    nbPoints = theNbPoints;
     size = theSize;
   }
-  int nbNodes;
+  int nbPoints;
   double size;
 };
 
+// struct gp_Pnt
+// {
+//   gp_Pnt( double theX, double theY, double theZ )
+//   {
+//     x = theX;
+//     y = theY;
+//     z = theZ; 
+//   };
+//   double x;
+//   double y;
+//   double z;
+// };
+
+// class TSizeMap
+// { 
+// public:
+//   TSizeMap():
+//     points(), size(0.0)
+//   {
+//   };
+// 
+//   TSizeMap(const std::vector<gp_Pnt>& thePoints, double theSize )
+//   {
+//     points = thePoints;
+//     size = theSize;
+//   };
+//   
+//   double GetSize(){ return size; };
+//   std::vector<gp_Pnt> GetPoints(){ return points; };
+//   
+// private:
+//   std::vector<gp_Pnt> points;
+//   double              size;
+// };
+
 /*!
  * \brief Driver Writing a mesh into a GMF file.
  */
@@ -62,6 +99,11 @@ public:
   virtual Status Perform();
   Status PerformSizeMap();
   void AddSizeMapFromMesh( SMESHDS_Mesh* mesh, double size);
+  void AddSizeMap( const std::vector<gp_Pnt>& points, double size );
+  void SetSizeMapPrefix( std::string prefix )
+  {
+    mySizeMapPrefix = prefix;
+  };
 //   void WriteSizeMapFromMesh( double size );
 //   void AddSizeMapSection( int meshID, int nbControlPoints );
 //   void AppendSize( int meshID, double size );
@@ -77,8 +119,11 @@ public:
 
   bool _exportRequiredGroups;
   int mySizeMapVerticesNumber;
+  std::string mySizeMapPrefix;
   std::vector<SMESHDS_Mesh*> mySizeMapMeshes;
   std::vector<TLocalSize> myLocalSizes;
+  std::vector<gp_Pnt> myPoints;
+//   std::vector<TSizeMap> mySizeMaps;
 };
 
 #endif