From: gdd Date: Tue, 27 Mar 2012 09:34:16 +0000 (+0000) Subject: Enforced meshes can now have common nodes with the 2D initial skin mesh. X-Git-Tag: V6_5_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f507508e4648d346ad052eb74db58110bd8b6ed5;p=plugins%2Fghs3dplugin.git Enforced meshes can now have common nodes with the 2D initial skin mesh. --- diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index 27e4952..880ce95 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -1409,7 +1409,6 @@ static bool writeGMFFile(const char* theMesh const SMESH_ProxyMesh& theProxyMesh, SMESH_Mesh * theMesh, std::vector & theNodeByGhs3dId, - std::vector & theEnforcedNodeByGhs3dId, std::map & aNodeToGhs3dIdMap, std::vector & aNodeGroupByGhs3dId, std::vector & anEdgeGroupByGhs3dId, @@ -1429,7 +1428,11 @@ static bool writeGMFFile(const char* theMesh const SMDS_MeshElement* elem; TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles; SMDS_ElemIteratorPtr nodeIt; - map anEnforcedNodeToGhs3dIdMap; + std::vector theEnforcedNodeByGhs3dId; + map anEnforcedNodeToGhs3dIdMap, anExistingEnforcedNodeToGhs3dIdMap; + std::vector< const SMDS_MeshElement* > foundElems; + map aNodeToTopAbs_StateMap; + int nbFoundElems; GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::iterator elemIt; TIDSortedElemSet::iterator elemSetIt; bool isOK; @@ -1440,6 +1443,10 @@ static bool writeGMFFile(const char* theMesh // count faces int nbFaces = theProxyMesh.NbFaces(); int nbNodes; + + // groups management + int usedEnforcedNodes = 0; + std::string gn = ""; if ( nbFaces == 0 ) return false; @@ -1480,21 +1487,40 @@ static bool writeGMFFile(const char* theMesh // Test if point is inside shape to mesh gp_Pnt myPoint(node->X(),node->Y(),node->Z()); TopAbs_State result = pntCls->GetPointState( myPoint ); - if ( result != TopAbs_IN ) { + if ( result == TopAbs_OUT ) { isOK = false; break; } + aNodeToTopAbs_StateMap.insert( make_pair( node, result )); } if (isOK) { nodeIt = elem->nodesIterator(); nbNodes = 2; + int newId = -1; while ( nodeIt->more() && nbNodes-- ) { // find GHS3D ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1 - anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId )); + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); + std::cout << "Node at "<X()<<", "<Y()<<", "<Z()<X(),node->Y(),node->Z()); TopAbs_State result = pntCls->GetPointState( myPoint ); - if ( result != TopAbs_IN ) { + if ( result == TopAbs_OUT ) { isOK = false; break; } + aNodeToTopAbs_StateMap.insert( make_pair( node, result )); } if (isOK) { nodeIt = elem->nodesIterator(); nbNodes = 3; + int newId = -1; while ( nodeIt->more() && nbNodes--) { // find GHS3D ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - int newId = aNodeToGhs3dIdMap.size() + anEnforcedNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1 - anEnforcedNodeToGhs3dIdMap.insert( make_pair( node, newId )); + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); + std::cout << "Nb nodes found : "<first: "<first<second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // ghs3d ids count from 1 + if (n2id->second > aNodeToGhs3dIdMap.size()) { + theEnforcedNodeByGhs3dId[ n2id->second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // ghs3d ids count from 1 + } } @@ -1582,14 +1627,37 @@ static bool writeGMFFile(const char* theMesh coords.push_back(node->X()); coords.push_back(node->Y()); coords.push_back(node->Z()); + std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z(); if (nodesCoords.find(coords) != nodesCoords.end()) { - std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z() << " found" << std::endl; + // node already exists in original mesh + std::cout << " found" << std::endl; continue; } - if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) + if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) { + // node already exists in enforced vertices + std::cout << " found" << std::endl; continue; + } + +// gp_Pnt myPoint(node->X(),node->Y(),node->Z()); +// nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +// if (nbFoundElems ==0) { +// std::cout << " not found" << std::endl; +// if ((*aNodeToTopAbs_StateMap.find(node)).second == TopAbs_IN) { +// nodesCoords.insert(coords); +// theOrderedNodes.push_back(node); +// } +// } +// else { +// std::cout << " found in initial mesh" << std::endl; +// const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); +// nodesCoords.insert(coords); +// theOrderedNodes.push_back(existingNode); +// } + + std::cout << " not found" << std::endl; nodesCoords.insert(coords); theOrderedNodes.push_back(node); @@ -1608,21 +1676,51 @@ static bool writeGMFFile(const char* theMesh coords.push_back(node->X()); coords.push_back(node->Y()); coords.push_back(node->Z()); + std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z(); + + // Test if point is inside shape to mesh + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + TopAbs_State result = pntCls->GetPointState( myPoint ); + if ( result == TopAbs_OUT ) { + std::cout << " out of volume" << std::endl; + continue; + } if (nodesCoords.find(coords) != nodesCoords.end()) { - std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z() << " found" << std::endl; + std::cout << " found in nodesCoords" << std::endl; +// theRequiredNodes.push_back(node); continue; } - if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) + if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) { + std::cout << " found in theEnforcedVertices" << std::endl; continue; + } - // Test if point is inside shape to mesh - gp_Pnt myPoint(node->X(),node->Y(),node->Z()); - TopAbs_State result = pntCls->GetPointState( myPoint ); - if ( result != TopAbs_IN ) - continue; +// nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +// if (nbFoundElems ==0) { +// std::cout << " not found" << std::endl; +// if (result == TopAbs_IN) { +// nodesCoords.insert(coords); +// theRequiredNodes.push_back(node); +// } +// } +// else { +// std::cout << " found in initial mesh" << std::endl; +// const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); +// // nodesCoords.insert(coords); +// theRequiredNodes.push_back(existingNode); +// } +// +// +// +// if (pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems) == 0) +// continue; + +// if ( result != TopAbs_IN ) +// continue; + std::cout << " not found" << std::endl; nodesCoords.insert(coords); // theOrderedNodes.push_back(node); theRequiredNodes.push_back(node); @@ -1643,8 +1741,13 @@ static bool writeGMFFile(const char* theMesh // Test if point is inside shape to mesh gp_Pnt myPoint(x,y,z); TopAbs_State result = pntCls->GetPointState( myPoint ); - if ( result != TopAbs_IN ) + if ( result == TopAbs_OUT ) + continue; + if (pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems) == 0) continue; + +// if ( result != TopAbs_IN ) +// continue; std::vector coords; coords.push_back(x); coords.push_back(y); @@ -1654,12 +1757,15 @@ static bool writeGMFFile(const char* theMesh solSize++; } } - + + // GmfVertices std::cout << "Begin writting required nodes in GmfVertices" << std::endl; + std::cout << "Nb vertices: " << theOrderedNodes.size() << std::endl; GmfSetKwd(idx, GmfVertices, theOrderedNodes.size()/*+solSize*/); - for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt) + for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt) { GmfSetLin(idx, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint); + } std::cout << "End writting required nodes in GmfVertices" << std::endl; @@ -1681,8 +1787,8 @@ static bool writeGMFFile(const char* theMesh int TypTab[] = {GmfSca}; GmfSetKwd(idxRequired, GmfVertices, requiredNodes + solSize); GmfSetKwd(idxSol, GmfSolAtVertices, requiredNodes + solSize, 1, TypTab); - int usedEnforcedNodes = 0; - std::string gn = ""; +// int usedEnforcedNodes = 0; +// std::string gn = ""; for (ghs3dNodeIt = theRequiredNodes.begin();ghs3dNodeIt != theRequiredNodes.end();++ghs3dNodeIt) { GmfSetLin(idxRequired, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint); GmfSetLin(idxSol, GmfSolAtVertices, 0.0); @@ -1724,8 +1830,11 @@ static bool writeGMFFile(const char* theMesh // find GHS3D ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node); - if (it == anEnforcedNodeToGhs3dIdMap.end()) - throw "Node not found"; + if (it == anEnforcedNodeToGhs3dIdMap.end()) { + it = anExistingEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) + throw "Node not found"; + } nedge[index] = it->second; index++; } @@ -1776,8 +1885,11 @@ static bool writeGMFFile(const char* theMesh // find GHS3D ID const SMDS_MeshNode* node = castToNode( nodeIt->next() ); map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node); - if (it == anEnforcedNodeToGhs3dIdMap.end()) - throw "Node not found"; + if (it == anEnforcedNodeToGhs3dIdMap.end()) { + it = anExistingEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) + throw "Node not found"; + } ntri[index] = it->second; index++; } @@ -3456,7 +3568,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), *proxyMesh, &theMesh, - aNodeByGhs3dId, anEnforcedNodeByGhs3dId, aNodeToGhs3dIdMap, + aNodeByGhs3dId, aNodeToGhs3dIdMap, aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, enforcedNodes, enforcedEdges, enforcedTriangles, enfVerticesWithGroup, coordsSizeMap); diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index c76903d..aae689f 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -921,7 +921,7 @@ void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() { that->checkVertexIsDefined(); } -/** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( x, y, z, vertexName, geomEntry, groupName) +/** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName) This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName. */ void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, double size, std::string groupName)