]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
Add quadrangle support in writeGMFFile cbr/add_quadrangle_support
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 29 Nov 2016 10:38:04 +0000 (11:38 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Tue, 29 Nov 2016 10:38:04 +0000 (11:38 +0100)
Do not deal with enforced quadrangles since enforced entities are not supported by MG-Hybrid.

src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx
src/HYBRIDPlugin/MG_HYBRID_API.cxx

index 4758b872eab08c63d86063f5e14e354b0a40e112..90fe559db5b844787c384458d23aaff64dd97291 100644 (file)
@@ -1103,7 +1103,7 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
   HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues::const_iterator vertexIt;
   std::vector<double> enfVertexSizes;
   const SMDS_MeshElement* elem;
-  TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles;
+  TIDSortedElemSet anElemSetTri, anElemSetQuad, theKeptEnforcedEdges, theKeptEnforcedTriangles;
   SMDS_ElemIteratorPtr nodeIt;
   std::vector <const SMDS_MeshNode*> theEnforcedNodeByHybridId;
   std::map<const SMDS_MeshNode*,int> anEnforcedNodeToHybridIdMap, anExistingEnforcedNodeToHybridIdMap;
@@ -1143,9 +1143,17 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
   while ( eIt->more() )
   {
     elem = eIt->next();
-    anElemSet.insert(elem);
     nodeIt = elem->nodesIterator();
     nbNodes = elem->NbCornerNodes();
+    if (nbNodes == 3)
+      anElemSetTri.insert(elem);
+    else if (nbNodes == 4)
+      anElemSetQuad.insert(elem);
+    else
+    {
+      std::cout << "Unexpected number of nodes: " << nbNodes << std::endl;
+      throw ("Unexpected number of nodes" );
+    }
     while ( nodeIt->more() && nbNodes--)
     {
       // find HYBRID ID
@@ -1528,7 +1536,7 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
     std::cout << "End writing in req and sol file" << std::endl;
   }
 
-  int nedge[2], ntri[3];
+  int nedge[2], ntri[3], nquad[4];
     
   // GmfEdges
   int usedEnforcedEdges = 0;
@@ -1573,11 +1581,11 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
 
   // GmfTriangles
   int usedEnforcedTriangles = 0;
-  if (anElemSet.size()+theKeptEnforcedTriangles.size()) {
-    aFaceGroupByHybridId.resize( anElemSet.size()+theKeptEnforcedTriangles.size() );
-    MGInput->GmfSetKwd(idx, GmfTriangles, anElemSet.size()+theKeptEnforcedTriangles.size());
+  if (anElemSetTri.size()+theKeptEnforcedTriangles.size()) {
+    aFaceGroupByHybridId.resize( anElemSetTri.size()+theKeptEnforcedTriangles.size() );
+    MGInput->GmfSetKwd(idx, GmfTriangles, anElemSetTri.size()+theKeptEnforcedTriangles.size());
     int k=0;
-    for(elemSetIt = anElemSet.begin() ; elemSetIt != anElemSet.end() ; ++elemSetIt,++k) {
+    for(elemSetIt = anElemSetTri.begin() ; elemSetIt != anElemSetTri.end() ; ++elemSetIt,++k) {
       elem = (*elemSetIt);
       theFaceByHybridId.push_back( elem );
       nodeIt = elem->nodesIterator();
@@ -1625,7 +1633,30 @@ static bool writeGMFFile(MG_HYBRID_API*                                  MGInput
   if (usedEnforcedTriangles) {
     MGInput->GmfSetKwd(idx, GmfRequiredTriangles, usedEnforcedTriangles);
     for (int enfID=1;enfID<=usedEnforcedTriangles;enfID++)
-      MGInput->GmfSetLin(idx, GmfRequiredTriangles, anElemSet.size()+enfID);
+      MGInput->GmfSetLin(idx, GmfRequiredTriangles, anElemSetTri.size()+enfID);
+  }
+  
+  if (anElemSetQuad.size()) {
+    MGInput->GmfSetKwd(idx, GmfQuadrilaterals, anElemSetQuad.size());
+    int k=0;
+    for(elemSetIt = anElemSetQuad.begin() ; elemSetIt != anElemSetQuad.end() ; ++elemSetIt,++k) {
+      elem = (*elemSetIt);
+      theFaceByHybridId.push_back( elem );
+      nodeIt = elem->nodesIterator();
+      int index=0;
+      for ( int j = 0; j < 4; ++j ) {
+        // find HYBRID ID
+        const SMDS_MeshNode* node = castToNode( nodeIt->next() );
+        std::map< const SMDS_MeshNode*,int >::iterator it = aNodeToHybridIdMap.find(node);
+        if (it == aNodeToHybridIdMap.end())
+          throw "Node not found";
+        nquad[index] = it->second;
+        index++;
+      }
+      MGInput->GmfSetLin(idx, GmfQuadrilaterals, nquad[0], nquad[1], nquad[2], nquad[3], dummyint5);
+      // _CEA_cbo what is it for???
+      //aFaceGroupByHybridId[k] = "";
+    }
   }
 
   MGInput->GmfCloseMesh(idx);
index c260a70cc2d0a13a636d3bc4a75800d47d9fccf9..767d5ce5d9b7020b054a69f003599b3f693fc885 100644 (file)
@@ -1256,7 +1256,7 @@ void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, i
     return;
 #endif
   }
-  ::GmfSetLin(iMesh, what, node1, node2, node3, domain );
+  ::GmfSetLin(iMesh, what, node1, node2, node3, node4, domain );
 }
 
 //================================================================================