From ce44b53a3367fc92294721c9e72122da6011a069 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Tue, 29 Nov 2016 11:38:04 +0100 Subject: [PATCH] Add quadrangle support in writeGMFFile Do not deal with enforced quadrangles since enforced entities are not supported by MG-Hybrid. --- src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx | 47 ++++++++++++++++++++---- src/HYBRIDPlugin/MG_HYBRID_API.cxx | 2 +- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx index 4758b87..90fe559 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx @@ -1103,7 +1103,7 @@ static bool writeGMFFile(MG_HYBRID_API* MGInput HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues::const_iterator vertexIt; std::vector enfVertexSizes; const SMDS_MeshElement* elem; - TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles; + TIDSortedElemSet anElemSetTri, anElemSetQuad, theKeptEnforcedEdges, theKeptEnforcedTriangles; SMDS_ElemIteratorPtr nodeIt; std::vector theEnforcedNodeByHybridId; std::map 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); diff --git a/src/HYBRIDPlugin/MG_HYBRID_API.cxx b/src/HYBRIDPlugin/MG_HYBRID_API.cxx index c260a70..767d5ce 100644 --- a/src/HYBRIDPlugin/MG_HYBRID_API.cxx +++ b/src/HYBRIDPlugin/MG_HYBRID_API.cxx @@ -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 ); } //================================================================================ -- 2.39.2