]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
fix #7051 libmesh5.c/h DriverGMF_Read.cxx/hxx
authorChristian Van Wambeke <christian.van-wambeke@cea.fr>
Fri, 28 Feb 2020 08:57:30 +0000 (09:57 +0100)
committereap <eap@opencascade.com>
Wed, 4 Mar 2020 15:54:52 +0000 (18:54 +0300)
src/DriverGMF/DriverGMF_Read.cxx
src/DriverGMF/DriverGMF_Read.hxx
src/DriverGMF/libmesh5.c
src/DriverGMF/libmesh5.h

index d0a698fb4b1d618e240bccb77510c1775c1874bf..fe036239c09db576fd1b7046dd12462bafc84dc3 100644 (file)
@@ -43,7 +43,8 @@ extern "C"
 // --------------------------------------------------------------------------------
 DriverGMF_Read::DriverGMF_Read():
   Driver_SMESHDS_Mesh(),
-  _makeRequiredGroups( true )
+  _makeRequiredGroups( true ),
+  _makeFaultGroups( true )
 {
 }
 // --------------------------------------------------------------------------------
@@ -401,10 +402,9 @@ Driver_Mesh::Status DriverGMF_Read::Perform()
     }
   }
 
-  // Read required entities into groups
+  // Read some entities into groups
+  // see MeshGems/Docs/meshgems_formats_description.pdf
 
-  if ( _makeRequiredGroups )
-  {
     // get ids of existing groups
     std::set< int > groupIDs;
     const std::set<SMESHDS_GroupBase*>&          groups = myMesh->GetGroups();
@@ -413,14 +413,20 @@ Driver_Mesh::Status DriverGMF_Read::Perform()
       groupIDs.insert( (*grIter)->GetID() );
     if ( groupIDs.empty() ) groupIDs.insert( 0 );
 
+  // Read required entities into groups
+  if ( _makeRequiredGroups )
+  {
+
     const int kes[4][3] = { { GmfRequiredVertices,      SMDSAbs_Node, nodeIDShift },
                             { GmfRequiredEdges,         SMDSAbs_Edge, edgeIDShift },
                             { GmfRequiredTriangles,     SMDSAbs_Face, triaIDShift },
-                            { GmfRequiredQuadrilaterals,SMDSAbs_Face, quadIDShift }};
+                            { GmfRequiredQuadrilaterals,SMDSAbs_Face, quadIDShift }
+                          };
     const char* names[4] = { "_required_Vertices"      ,
                              "_required_Edges"         ,
                              "_required_Triangles"     ,
-                             "_required_Quadrilaterals" };
+                             "_required_Quadrilaterals" 
+                           };
     for ( int i = 0; i < 4; ++i )
     {
       int                 gmfKwd = kes[i][0];
@@ -444,6 +450,50 @@ Driver_Mesh::Status DriverGMF_Read::Perform()
     }
   }
 
+  // Read fault entities into groups
+  if ( _makeFaultGroups )
+  {
+
+    const int kes[7][3] = { { GmfFault_SmallTri,     SMDSAbs_Face, triaIDShift },
+                            { GmfFault_BadShape,     SMDSAbs_Face, triaIDShift },
+                            { GmfFault_Overlap,      SMDSAbs_Face, triaIDShift },
+                            { GmfFault_Inter,        SMDSAbs_Face, triaIDShift },
+                            { GmfFault_NearTri,      SMDSAbs_Face, triaIDShift },
+                            { GmfFault_FreeEdge,     SMDSAbs_Face, triaIDShift },
+                            { GmfFault_MultipleEdge, SMDSAbs_Face, triaIDShift }
+                          };
+    const char* names[7] = { "Fault_SmallTri",
+                             "Fault_BadShape",
+                             "Fault_Overlap",
+                             "Fault_Inter", 
+                             "Fault_NearTri",
+                             "Fault_FreeEdge",
+                             "Fault_MultipleEdge"
+                           };
+    for ( int i = 0; i < 7; ++i )
+    {
+      int                 gmfKwd = kes[i][0];
+      SMDSAbs_ElementType entity = (SMDSAbs_ElementType) kes[i][1];
+      int                 shift  = kes[i][2];
+      if ( int nb = GmfStatKwd(meshID, gmfKwd))
+      {
+        const int newID = *groupIDs.rbegin() + 1;
+        groupIDs.insert( newID );
+        SMESHDS_Group* group = new SMESHDS_Group( newID, myMesh, entity );
+        group->SetStoreName( names[i] );
+        myMesh->AddGroup( group );
+
+        GmfGotoKwd(meshID, gmfKwd);
+        for ( int i = 0; i < nb; ++i )
+        {
+          GmfGetLin(meshID, gmfKwd, &iN[0] );
+          group->Add( shift + iN[0] );
+        }
+      }
+    }
+  }
+
+
   myMesh->Modified();
   myMesh->CompactMesh();
 
index 866f06fb4b0a37cd3fce59a1a23c5594496271f7..7e7b64e96ae1c061f7bc6600f6183279c09da13f 100644 (file)
@@ -50,6 +50,11 @@ public:
     _makeRequiredGroups = theMakeRequiredGroups;
   }
 
+  void SetMakeFaultGroups( bool theMakeFaultGroups )
+  {
+    _makeFaultGroups = theMakeFaultGroups;
+  }
+
   virtual Status Perform();
 
  private:
@@ -57,6 +62,7 @@ public:
   Status storeBadNodeIds(const char* gmfKwd, int elemNb, int nb, ...);
 
   bool _makeRequiredGroups;
+  bool _makeFaultGroups;
 
 };
 
index 889b69747137b6fd6b4eb4054a9390dba741f1c4..2c889ccc2299eb9e9842c2e2f4c7a7d1426b4612 100644 (file)
@@ -78,6 +78,7 @@ typedef struct
 
 static int GmfIniFlg=0;
 static GmfMshSct *GmfMshTab[ MaxMsh + 1 ];
+// see MeshGems/Docs/meshgems_formats_description.pdf
 static const char *GmfKwdFmt[ GmfMaxKwd + 1 ][4] = 
 {       {"Reserved", "", "", ""},
         {"MeshVersionFormatted", "", "", "i"},
@@ -159,7 +160,8 @@ static const char *GmfKwdFmt[ GmfMaxKwd + 1 ][4] =
         {"Iterations", "","","i"},
         {"Time", "","","r"},
         {"Fault_SmallTri", "Fault_SmallTri","i","i"},
-        {"CoarseHexahedra", "CoarseHexahedron", "i", "i"}
+        {"CoarseHexahedra", "CoarseHexahedron", "i", "i"},
+        {"Fault_MultipleEdge", "Fault_MultipleEdge", "i", "i"}
  };
 
 
@@ -1062,7 +1064,7 @@ static int ScaKwdTab(GmfMshSct *msh)
                         {
                                 /* Search which kwd code this string is associated with, 
                                         then get its header and save the current position in file (just before the data) */
-
+                                // printf("libmesh ScaKwdTab %s\n", str);
                                 for(KwdCod=1; KwdCod<= GmfMaxKwd; KwdCod++)
                                         if(!strcmp(str, GmfKwdFmt[ KwdCod ][0]))
                                         {
index 066853f52fb5d386fe01659cfa7b16b4c8d5279d..6345d1df373772ea08ec9518ac4b4b6dcc7584ac 100644 (file)
@@ -22,7 +22,7 @@
 
 #define GmfStrSiz 1024
 #define GmfMaxTyp 1000
-#define GmfMaxKwd 80
+#define GmfMaxKwd 81
 #define GmfMshVer 1
 #define GmfRead 1
 #define GmfWrite 2
@@ -33,6 +33,7 @@
 #define GmfFloat 1
 #define GmfDouble 2
 
+// see MeshGems/Docs/meshgems_formats_description.pdf
 enum GmfKwdCod
 {
         GmfReserved1, \
@@ -115,7 +116,8 @@ enum GmfKwdCod
         GmfIterations, \
         GmfTime, \
         GmfFault_SmallTri, \
-        GmfCoarseHexahedra
+        GmfCoarseHexahedra, \
+        GmfFault_MultipleEdge
 };