From: gdd Date: Fri, 6 May 2011 18:31:21 +0000 (+0000) Subject: Update plugin X-Git-Tag: V6_3_0~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f2c0b7d79aa1af7221c7800bd1018b7160eed65d;p=plugins%2Fhybridplugin.git Update plugin --- diff --git a/configure.ac b/configure.ac index 7d8c995..78ddc3b 100644 --- a/configure.ac +++ b/configure.ac @@ -352,6 +352,10 @@ echo --------------------------------------------- echo CHECK_GHS3D +if test "${GHS3D_ok}" = "yes"; then + GHS3D_VERSION=`ghs3d -u |grep "TETMESH-GHS3D SOFTWARE"|awk '{print $3}'|awk -F- '{print $1}'|awk -F. '{print $1$2}'` + AC_DEFINE_UNQUOTED(GHS3D_VERSION,${GHS3D_VERSION}) +fi echo echo --------------------------------------------- diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index 85edec5..f9ba1c3 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -529,10 +529,7 @@ static int findShapeID(SMESH_Mesh& mesh, // map & theGhs3dIdToNodeMap, // bool toMeshHoles, // int nbEnforcedVertices, -// int nbEnforcedNodes, -// TIDSortedNodeSet & theEnforcedNodes, -// TIDSortedElemSet & theEnforcedTriangles, -// TIDSortedElemSet & theEnforcedQuadrangles) +// int nbEnforcedNodes) // { // TopoDS_Shape aShape; // TopoDS_Vertex aVertex; @@ -969,23 +966,25 @@ static bool readGMFFile(const char* theFile, GHS3DPlugin_GHS3D* theAlgo, #endif SMESH_MesherHelper* theHelper, + TopoDS_Shape theSolid, vector & theNodeByGhs3dId, - TIDSortedNodeSet & theEnforcedNodes, - TIDSortedElemSet & theEnforcedTriangles, - TIDSortedElemSet & theEnforcedQuadrangles) + map & theNodeToGhs3dIdMap) { SMESHDS_Mesh* theMeshDS = theHelper->GetMeshDS(); int nbInitialNodes = theNodeByGhs3dId.size(); std::cout << "theNodeByGhs3dId.size(): " << nbInitialNodes << std::endl; - + int nbMeshNodes = theMeshDS->NbNodes(); + std::cout << "theHelper->GetMesh()->NbNodes(): " << nbMeshNodes << std::endl; + const bool isQuadMesh = theHelper->GetMesh()->NbEdges( ORDER_QUADRATIC ) || theHelper->GetMesh()->NbFaces( ORDER_QUADRATIC ) || theHelper->GetMesh()->NbVolumes( ORDER_QUADRATIC ); std::cout << "isQuadMesh: " << isQuadMesh << std::endl; - theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); + if (theHelper->GetSubShapeID() != 0) + theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); // --------------------------------- // Read generated elements and nodes @@ -998,25 +997,27 @@ static bool readGMFFile(const char* theFile, std::map tabRef; tabRef[GmfVertices] = 3; // for new nodes and enforced nodes -// tabRef[GmfCorners] = 1; + tabRef[GmfCorners] = 1; tabRef[GmfEdges] = 2; // for enforced edges -// tabRef[GmfRidges] = 1; + tabRef[GmfRidges] = 1; tabRef[GmfTriangles] = 3; // for enforced faces -// tabRef[GmfQuadrilaterals] = 4; + tabRef[GmfQuadrilaterals] = 4; tabRef[GmfTetrahedra] = 4; // for new tetras -// tabRef[GmfHexahedra] = 8; + tabRef[GmfHexahedra] = 8; int ver, dim; MESSAGE("Read " << theFile << " file"); int InpMsh = GmfOpenMesh(theFile, GmfRead, &ver, &dim); if (!InpMsh) return false; + MESSAGE("Done "); - // TODO: - // Do not clear mesh : DONE - // Skip input nodes : DONE - // Skip input face (keep only enforced faces) : DONE - // Skip input edge (keep only enforced edges) : DONE + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + SMESH_ElementSearcher* elemSearcher = 0; + vector< const SMDS_MeshElement* > foundVolumes; + if ( theHelper->GetMesh()->NbVolumes() > 0 ) + elemSearcher = SMESH_MeshEditor( theHelper->GetMesh() ).GetElementSearcher(); int nbVertices = GmfStatKwd(InpMsh, GmfVertices) - nbInitialNodes; GMFNode = new SMDS_MeshNode*[ nbVertices + 1 ]; @@ -1051,12 +1052,26 @@ static bool readGMFFile(const char* theFile, std::cout << " vertices" << std::endl; std::cout << nbInitialNodes << " from input mesh " << std::endl; + // Remove orphan nodes from previous enforced mesh which was cleared + if ( nbElem < nbMeshNodes ) { + const SMDS_MeshNode* node; + SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator(); + while ( nodeIt->more() ) + { + node = nodeIt->next(); + if (theNodeToGhs3dIdMap.find(node) != theNodeToGhs3dIdMap.end()) + theMeshDS->RemoveNode(node); + } + } + + int aGMFID; float VerTab_f[nbElem][3]; double VerTab_d[nbElem][3]; SMDS_MeshNode * aGMFNode; + shapeID = theMeshDS->ShapeToIndex( theSolid ); for ( int iElem = 0; iElem < nbElem; iElem++ ) { #ifdef WITH_SMESH_CANCEL_COMPUTE if(theAlgo->computeCanceled()) { @@ -1084,16 +1099,16 @@ static bool readGMFFile(const char* theFile, } } } -// else if (token == GmfCorners && nbElem > 0) { -// std::cout << " corners" << std::endl; -// for ( int iElem = 0; iElem < nbElem; iElem++ ) -// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); -// } -// else if (token == GmfRidges && nbElem > 0) { -// std::cout << " ridges" << std::endl; -// for ( int iElem = 0; iElem < nbElem; iElem++ ) -// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); -// } + else if (token == GmfCorners && nbElem > 0) { + std::cout << " corners" << std::endl; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); + } + else if (token == GmfRidges && nbElem > 0) { + std::cout << " ridges" << std::endl; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); + } else if (token == GmfEdges && nbElem > 0) { std::cout << " edges" << std::endl; for ( int iElem = 0; iElem < nbElem; iElem++ ) @@ -1104,32 +1119,32 @@ static bool readGMFFile(const char* theFile, for ( int iElem = 0; iElem < nbElem; iElem++ ) GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &dummy); } -// else if (token == GmfQuadrilaterals && nbElem > 0) { -// std::cout << " Quadrilaterals" << std::endl; -// for ( int iElem = 0; iElem < nbElem; iElem++ ) -// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &dummy); -// } + else if (token == GmfQuadrilaterals && nbElem > 0) { + std::cout << " Quadrilaterals" << std::endl; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &dummy); + } else if (token == GmfTetrahedra && nbElem > 0) { std::cout << " Tetrahedra" << std::endl; for ( int iElem = 0; iElem < nbElem; iElem++ ) GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &dummy); } -// else if (token == GmfHexahedra && nbElem > 0) { -// std::cout << " Hexahedra" << std::endl; -// for ( int iElem = 0; iElem < nbElem; iElem++ ) -// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], -// &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &dummy); -// } + else if (token == GmfHexahedra && nbElem > 0) { + std::cout << " Hexahedra" << std::endl; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], + &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &dummy); + } std::cout << std::endl; switch (token) { -// case GmfCorners: -// case GmfRidges: + case GmfCorners: + case GmfRidges: case GmfEdges: case GmfTriangles: -// case GmfQuadrilaterals: + case GmfQuadrilaterals: case GmfTetrahedra: -// case GmfHexahedra: + case GmfHexahedra: { std::vector< const SMDS_MeshNode* > node( nbRef ); std::vector< int > nodeID( nbRef ); @@ -1166,36 +1181,68 @@ static bool readGMFFile(const char* theFile, switch (token) { - case GmfEdges: { + case GmfEdges: if (fullyCreatedElement) theHelper->AddEdge( node[0], node[1], /*id =*/0, /*force3d =*/false ); break; - } - case GmfTriangles: { - if (fullyCreatedElement) + case GmfTriangles: + if (fullyCreatedElement) { theHelper->AddFace( node[0], node[1], node[2], /*id =*/0, /*force3d =*/false ); + for ( int iRef = 0; iRef < nbRef; iRef++ ) + nodeAssigne[ nodeID[ iRef ]] = 1; + } break; - } -// case GmfQuadrilaterals: -// theHelper->AddFace( node[0], node[1], node[2], node[3] ); break; + case GmfQuadrilaterals: + if (fullyCreatedElement) { + theHelper->AddFace( node[0], node[1], node[2], node[3], /*id =*/0, /*force3d =*/false ); + for ( int iRef = 0; iRef < nbRef; iRef++ ) + nodeAssigne[ nodeID[ iRef ]] = 1; + } case GmfTetrahedra: + if ( elemSearcher ) { + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + if ( !node[1] || !node[0] || !node[2] || !node[3] ) + continue; + if ( elemSearcher->FindElementsByPoint((SMESH_TNodeXYZ(node[0]) + + SMESH_TNodeXYZ(node[1]) + + SMESH_TNodeXYZ(node[2]) + + SMESH_TNodeXYZ(node[3]) ) / 4., + SMDSAbs_Volume, foundVolumes )) + break; + } theHelper->AddVolume( node[1], node[0], node[2], node[3], /*id =*/0, /*force3d =*/false ); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + break; + case GmfHexahedra: + if ( elemSearcher ) { + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + if ( !node[1] || !node[0] || !node[2] || !node[3] || !node[4] || !node[5] || !node[6] || !node[7]) + continue; + if ( elemSearcher->FindElementsByPoint((SMESH_TNodeXYZ(node[0]) + + SMESH_TNodeXYZ(node[1]) + + SMESH_TNodeXYZ(node[2]) + + SMESH_TNodeXYZ(node[3]) + + SMESH_TNodeXYZ(node[4]) + + SMESH_TNodeXYZ(node[5]) + + SMESH_TNodeXYZ(node[6]) + + SMESH_TNodeXYZ(node[7])) / 8., + SMDSAbs_Volume, foundVolumes )) + break; + } + theHelper->AddVolume( node[0], node[3], node[2], node[1], + node[4], node[7], node[6], node[5], /*id =*/0, /*force3d =*/false ); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); break; -// case GmfHexahedra: -// theHelper->AddVolume( node[0], node[3], node[2], node[1], -// node[4], node[7], node[6], node[5] ); break; default: continue; } - if ( token == GmfTriangles /*|| token == GmfQuadrilaterals*/ ) - for ( int iRef = 0; iRef < nbRef; iRef++ ) - nodeAssigne[ nodeID[ iRef ]] = 1; } break; } } } - shapeID = theHelper->GetSubShapeID(); for ( int i = 0; i < nbVertices; ++i ) { if ( !nodeAssigne[ i+1 ]) theMeshDS->SetNodeInVolume( GMFNode[ i+1 ], shapeID ); @@ -1214,11 +1261,12 @@ static bool writeGMFFile(const char* theMesh SMESH_Mesh * theMesh, vector & theNodeByGhs3dId, vector & theEnforcedNodeByGhs3dId, + map & aNodeToGhs3dIdMap, TIDSortedNodeSet & theEnforcedNodes, TIDSortedElemSet & theEnforcedEdges, TIDSortedElemSet & theEnforcedTriangles, - TIDSortedElemSet & theEnforcedQuadrangles, - GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices ) +// TIDSortedElemSet & theEnforcedQuadrangles, + GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices) { MESSAGE("writeGMFFile w/o geometry"); int idx, idxRequired, idxSol; @@ -1226,20 +1274,16 @@ static bool writeGMFFile(const char* theMesh GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt; std::vector enfVertexSizes; const SMDS_MeshElement* elem; - TIDSortedElemSet anElemSet, anEnforcedEdgeSet, anEnforcedTriangleSet/*, anEnforcedQuadrangleSet*/; + TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles/*, theKeptEnforcedQuadrangles*/; // GHS3D does not accept EdgesP2 in input mesh file (Ghs3d 4.2) // TIDSortedElemSet aQuadElemSet, aQuadEnforcedEdgeSet, aQuadEnforcedTriangleSet, aQuadEnforcedQuadrangleSet; SMDS_ElemIteratorPtr nodeIt; - map aNodeToGhs3dIdMap, anEnforcedNodeToGhs3dIdMap; + map /*aNodeToGhs3dIdMap,*/ anEnforcedNodeToGhs3dIdMap; TIDSortedElemSet::iterator elemIt; bool isOK; auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher()); int nbEnforcedVertices = theEnforcedVertices.size(); -// int nbEnforcedNodes = theEnforcedNodes.size(); -// int nbEnforcedEdges = theEnforcedEdges.size(); -// int nbEnforcedTriangles = theEnforcedTriangles.size(); -// int nbEnforcedQuadrangles = theEnforcedQuadrangles.size(); // count faces int nbFaces = theProxyMesh.NbFaces(); @@ -1306,7 +1350,7 @@ static bool writeGMFFile(const char* theMesh // if (elem->IsQuadratic()) // aQuadEnforcedEdgeSet.insert(elem); // else - anEnforcedEdgeSet.insert(elem); + theKeptEnforcedEdges.insert(elem); } } @@ -1342,45 +1386,10 @@ static bool writeGMFFile(const char* theMesh // if (elem->IsQuadratic()) // aQuadEnforcedTriangleSet.insert(elem); // else - anEnforcedTriangleSet.insert(elem); + theKeptEnforcedTriangles.insert(elem); } } - /* ENFORCED QUADRANGLES ========================== */ - // TODO: add pyramids ? -// // Iterate over the enforced quadrangles -// for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) { -// elem = (*elemIt); -// isOK = true; -// nodeIt = elem->nodesIterator(); -// while ( nodeIt->more() ) { -// // find GHS3D ID -// const SMDS_MeshNode* node = castToNode( nodeIt->next() ); -// // 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 ) { -// isOK = false; -// break; -// } -// } -// if (isOK) { -// nodeIt = elem->nodesIterator(); -// while ( nodeIt->more() ) { -// // 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 )); -// } -// // GHS3D does not accept QuadrilateralsQ2 in input mesh file (Ghs3d 4.2) -// // if (elem->IsQuadratic()) -// // aQuadEnforcedQuadrangleSet.insert(elem); -// // else -// anEnforcedQuadrangleSet.insert(elem); -// } -// } - - // put nodes to theNodeByGhs3dId vector std::cout << "aNodeToGhs3dIdMap.size(): "<nodesIterator(); int index=0; @@ -1629,7 +1638,7 @@ static bool writeGMFFile(const char* theMesh // // if (!idxRequired) // // return false; // GmfSetKwd(idx, GmfEdgesP2, aQuadEnforcedEdgeSet.size()); -// // GmfSetKwd(idxRequired, GmfEdges, anEnforcedEdgeSet.size()); +// // GmfSetKwd(idxRequired, GmfEdges, theKeptEnforcedEdges.size()); // for(elemIt = aQuadEnforcedEdgeSet.begin() ; elemIt != aQuadEnforcedEdgeSet.end() ; ++elemIt) { // elem = (*elemIt); // nodeIt = elem->nodesIterator(); @@ -1659,8 +1668,8 @@ static bool writeGMFFile(const char* theMesh // GmfTriangles int usedEnforcedTriangles = 0; - if (anElemSet.size()+anEnforcedTriangleSet.size()) { - GmfSetKwd(idx, GmfTriangles, anElemSet.size()+anEnforcedTriangleSet.size()); + if (anElemSet.size()+theKeptEnforcedTriangles.size()) { + GmfSetKwd(idx, GmfTriangles, anElemSet.size()+theKeptEnforcedTriangles.size()); for(elemIt = anElemSet.begin() ; elemIt != anElemSet.end() ; ++elemIt) { elem = (*elemIt); nodeIt = elem->nodesIterator(); @@ -1676,8 +1685,8 @@ static bool writeGMFFile(const char* theMesh } GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint); } - if (anEnforcedTriangleSet.size()) { - for(elemIt = anEnforcedTriangleSet.begin() ; elemIt != anEnforcedTriangleSet.end() ; ++elemIt) { + if (theKeptEnforcedTriangles.size()) { + for(elemIt = theKeptEnforcedTriangles.begin() ; elemIt != theKeptEnforcedTriangles.end() ; ++elemIt) { elem = (*elemIt); nodeIt = elem->nodesIterator(); int index=0; @@ -1807,18 +1816,19 @@ static bool writeGMFFile(const char* theMesh } -static bool writeGMFFile(const char* theMeshFileName, - const char* theRequiredFileName, - const char* theSolFileName, - SMESH_MesherHelper& theHelper, - const SMESH_ProxyMesh& theProxyMesh, - map & theSmdsToGhs3dIdMap, - map & theGhs3dIdToNodeMap, - TIDSortedNodeSet & theEnforcedNodes, - TIDSortedElemSet & theEnforcedEdges, - TIDSortedElemSet & theEnforcedTriangles, - TIDSortedElemSet & theEnforcedQuadrangles, - GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices) +static bool writeGMFFile(const char* theMeshFileName, + const char* theRequiredFileName, + const char* theSolFileName, + SMESH_MesherHelper& theHelper, + const SMESH_ProxyMesh& theProxyMesh, + std::map & theNodeId2NodeIndexMap, + std::map & theSmdsToGhs3dIdMap, + std::map & theGhs3dIdToNodeMap, + TIDSortedNodeSet & theEnforcedNodes, + TIDSortedElemSet & theEnforcedEdges, + TIDSortedElemSet & theEnforcedTriangles, +// TIDSortedElemSet & theEnforcedQuadrangles, + GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices) { MESSAGE("writeGMFFile with geometry"); int idx, nbv, nbev, nben, aGhs3dID = 0; @@ -1828,7 +1838,6 @@ static bool writeGMFFile(const char* theMeshFileName, TIDSortedNodeSet::const_iterator enfNodeIt; const SMDS_MeshNode* node; SMDS_NodeIteratorPtr nodeIt; - std::map theNodeId2NodeIndexMap; idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION); if (!idx) @@ -1877,6 +1886,7 @@ static bool writeGMFFile(const char* theMeshFileName, theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC ); std::vector > VerTab; + std::set > VerMap; VerTab.clear(); std::vector aVerTab; // Loop from 1 to NB_NODES @@ -1891,18 +1901,26 @@ static bool writeGMFFile(const char* theMeshFileName, if ( n2nDegen.count( node ) ) // Issue 0020674 continue; - aVerTab.clear(); - aVerTab.push_back(node->X()); - aVerTab.push_back(node->Y()); - aVerTab.push_back(node->Z()); - VerTab.push_back(aVerTab); + std::vector coords; + coords.push_back(node->X()); + coords.push_back(node->Y()); + coords.push_back(node->Z()); + if (VerMap.find(coords) != VerMap.end()) { + aGhs3dID = theSmdsToGhs3dIdMap[node->GetID()]; + theGhs3dIdToNodeMap[theSmdsToGhs3dIdMap[node->GetID()]] = node; + continue; + } + VerTab.push_back(coords); + VerMap.insert(coords); aGhs3dID++; theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID )); theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node )); } + /* ENFORCED NODES ========================== */ if (nben) { + std::cout << "Add " << nben << " enforced nodes to input .mesh file" << std::endl; for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) { double x = (*enfNodeIt)->X(); double y = (*enfNodeIt)->Y(); @@ -1920,26 +1938,19 @@ static bool writeGMFFile(const char* theMeshFileName, coords.push_back(z); if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) continue; - aVerTab.clear(); - aVerTab.push_back(x); - aVerTab.push_back(y); - aVerTab.push_back(z); - VerTab.push_back(aVerTab); + if (VerMap.find(coords) != VerMap.end()) + continue; + VerTab.push_back(coords); + VerMap.insert(coords); aGhs3dID++; theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID )); } } - - /* Write vertices number */ - MESSAGE("Number of vertices: "< > ReqVerTab; ReqVerTab.clear(); std::vector aReqVerTab; @@ -1956,11 +1967,14 @@ static bool writeGMFFile(const char* theMeshFileName, if ( result != TopAbs_IN ) continue; enfVertexSizes.push_back(vertexIt->second); - aReqVerTab.clear(); - aReqVerTab.push_back(x); - aReqVerTab.push_back(y); - aReqVerTab.push_back(z); - ReqVerTab.push_back(aReqVerTab); + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (VerMap.find(coords) != VerMap.end()) + continue; + ReqVerTab.push_back(coords); + VerMap.insert(coords); solSize++; } @@ -1989,8 +2003,8 @@ static bool writeGMFFile(const char* theMeshFileName, /* ========================== FACES ========================== */ - int nbTriangles = 0, nbQuadrangles = 0, aSmdsID; - TopTools_IndexedMapOfShape facesMap, trianglesMap, quadranglesMap; + int nbTriangles = 0/*, nbQuadrangles = 0*/, aSmdsID; + TopTools_IndexedMapOfShape facesMap, trianglesMap/*, quadranglesMap*/; TIDSortedElemSet::const_iterator elemIt; const SMESHDS_SubMesh* theSubMesh; TopoDS_Shape aShape; @@ -2012,16 +2026,17 @@ static bool writeGMFFile(const char* theMeshFileName, while (it->more()) { const SMDS_MeshElement *elem = it->next(); - if (elem->NbCornerNodes() == 3) + int nbCornerNodes = elem->NbCornerNodes(); + if (nbCornerNodes == 3) { trianglesMap.Add(facesMap(i)); nbTriangles ++; } - else if (elem->NbCornerNodes() == 4) - { - quadranglesMap.Add(facesMap(i)); - nbQuadrangles ++; - } +// else if (nbCornerNodes == 4) +// { +// quadranglesMap.Add(facesMap(i)); +// nbQuadrangles ++; +// } } } @@ -2054,32 +2069,119 @@ static bool writeGMFFile(const char* theMeshFileName, } if (theEnforcedTriangles.size()) { + std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles to input .mesh file" << std::endl; // Iterate over the enforced triangles for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { aFace = (*elemIt); - bool isOK = true; itOnSubFace = aFace->nodesIterator(); + bool isOK = true; att.clear(); + for ( int j = 0; j < 3; ++j ) { - int aNodeID = itOnSubFace->next()->GetID(); - itOnMap = theNodeId2NodeIndexMap.find(aNodeID); - if (itOnMap != theNodeId2NodeIndexMap.end()) - att.push_back((*itOnMap).second); - else { + node = castToNode( itOnSubFace->next() ); + if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() ) + node = n2nDegenIt->second; +// std::cout << node; + double x = node->X(); + double y = node->Y(); + double z = node->Z(); + // Test if point is inside shape to mesh + gp_Pnt myPoint(x,y,z); + BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); + scl.Perform(myPoint, 1e-7); + TopAbs_State result = scl.State(); + if ( result != TopAbs_IN ) { isOK = false; theEnforcedTriangles.erase(elemIt); - break; + continue; + } + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (VerMap.find(coords) != VerMap.end()) { + att.push_back(theNodeId2NodeIndexMap[node->GetID()]); + continue; } + VerTab.push_back(coords); + VerMap.insert(coords); + aGhs3dID++; + theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID )); + att.push_back(aGhs3dID); } if (isOK) tt.push_back(att); } } + + /* ========================== EDGES ========================== */ + + if (theEnforcedEdges.size()) { + // Iterate over the enforced edges + std::cout << "Add " << theEnforcedEdges.size() << " enforced edges to input .mesh file" << std::endl; + for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { + aFace = (*elemIt); + bool isOK = true; + itOnSubFace = aFace->nodesIterator(); + aet.clear(); + for ( int j = 0; j < 2; ++j ) { + node = castToNode( itOnSubFace->next() ); + if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() ) + node = n2nDegenIt->second; + double x = node->X(); + double y = node->Y(); + double z = node->Z(); + // Test if point is inside shape to mesh + gp_Pnt myPoint(x,y,z); + BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); + scl.Perform(myPoint, 1e-7); + TopAbs_State result = scl.State(); + if ( result != TopAbs_IN ) { + isOK = false; + theEnforcedEdges.erase(elemIt); + continue; + } + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (VerMap.find(coords) != VerMap.end()) { + aet.push_back(theNodeId2NodeIndexMap[node->GetID()]); + continue; + } + VerTab.push_back(coords); + VerMap.insert(coords); + + aGhs3dID++; + theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID )); + aet.push_back(aGhs3dID); + } + if (isOK) + et.push_back(aet); + } + } + + + /* Write vertices number */ + MESSAGE("Number of vertices: "<nodesIterator(); - aet.clear(); - for ( int j = 0; j < 2; ++j ) { - int aNodeID = itOnSubFace->next()->GetID(); - itOnMap = theNodeId2NodeIndexMap.find(aNodeID); - if (itOnMap != theNodeId2NodeIndexMap.end()) - aet.push_back((*itOnMap).second); - else { - isOK = false; - theEnforcedEdges.erase(elemIt); - break; - } - } - if (isOK) - et.push_back(aet); - } - } - - if (et.size()) { - GmfSetKwd(idx, GmfEdges, et.size()); - for (int i=0;i& theGhs3dIdToNodeMap, + std::map & theNodeId2NodeIndexMap, bool toMeshHoles, int nbEnforcedVertices, int nbEnforcedNodes, TIDSortedElemSet & theEnforcedEdges, - TIDSortedElemSet & theEnforcedTriangles, - TIDSortedElemSet & theEnforcedQuadrangles) + TIDSortedElemSet & theEnforcedTriangles) { MESSAGE("GHS3DPlugin_GHS3D::readResultFile()"); Kernel_Utils::Localizer loc; @@ -2210,9 +2281,7 @@ static bool readResultFile(const int fileOpen, SMESHDS_Mesh* theMeshDS = theHelper.GetMeshDS(); - int fileStat; int nbElems, nbNodes, nbInputNodes; - int nodeId; int nbTriangle; int ID, shapeID, ghs3dShapeID; int IdShapeRef = 1; @@ -2237,7 +2306,7 @@ static bool readResultFile(const int fileOpen, #endif // Read the file state - fileStat = fstat(fileOpen, &status); + fstat(fileOpen, &status); length = status.st_size; // Mapping the result file into memory @@ -2266,10 +2335,11 @@ static bool readResultFile(const int fileOpen, // Reading the nodeId for (int i=0; i < 4*nbElems; i++) - nodeId = strtol(ptr, &ptr, 10); + strtol(ptr, &ptr, 10); MESSAGE("nbInputNodes: "<::const_iterator itOnMap; + shapeID = compoundID; + // Enforced edges + if (theEnforcedEdges.size()) { + std::cout << "Add " << theEnforcedEdges.size() << " enforced edges" << std::endl; + std::vector< const SMDS_MeshNode* > node( 2 ); + // Iterate over the enforced edges + for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { + anElem = (*elemIt); + bool addElem = true; + itOnEnfElem = anElem->nodesIterator(); + for ( int j = 0; j < 2; ++j ) { + int aNodeID = itOnEnfElem->next()->GetID(); + itOnMap = theNodeId2NodeIndexMap.find(aNodeID); + if (itOnMap != theNodeId2NodeIndexMap.end()) { + itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second); + if (itOnNode != theGhs3dIdToNodeMap.end()) { + node.push_back((*itOnNode).second); +// shapeID =(*itOnNode).second->getshapeId(); + } + else + addElem = false; + } + else + addElem = false; + } + if (addElem) { + aTet = theHelper.AddEdge( node[0], node[1], 0, false); + theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + } + } + } + // Enforced faces + if (theEnforcedTriangles.size()) { + std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles" << std::endl; + std::vector< const SMDS_MeshNode* > node( 3 ); + // Iterate over the enforced triangles + for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { + anElem = (*elemIt); + bool addElem = true; + itOnEnfElem = anElem->nodesIterator(); + for ( int j = 0; j < 3; ++j ) { + int aNodeID = itOnEnfElem->next()->GetID(); + itOnMap = theNodeId2NodeIndexMap.find(aNodeID); + if (itOnMap != theNodeId2NodeIndexMap.end()) { + itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second); + if (itOnNode != theGhs3dIdToNodeMap.end()) { + node.push_back((*itOnNode).second); +// shapeID =(*itOnNode).second->getshapeId(); + } + else + addElem = false; + } + else + addElem = false; + } + if (addElem) { + aTet = theHelper.AddFace( node[0], node[1], node[2], 0, false); + theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + } + } + } + // Remove nodes of tetras inside holes if !toMeshHoles if ( !toMeshHoles ) { itOnNode = theGhs3dIdToNodeMap.find( nbInputNodes ); @@ -2506,29 +2648,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, TCollection_AsciiString aResultFileName; TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log -// #if GHS3D_VERSION < 42 -// TCollection_AsciiString aFacesFileName, aPointsFileName; -// TCollection_AsciiString aBadResFileName, aBbResFileName; -// aFacesFileName = aGenericName + ".faces"; // in faces -// aPointsFileName = aGenericName + ".points"; // in points -// aResultFileName = aGenericName + ".noboite";// out points and volumes -// aBadResFileName = aGenericName + ".boite"; // out bad result -// aBbResFileName = aGenericName + ".bb"; // out vertex stepsize -// -// // ----------------- -// // make input files -// // ----------------- -// -// ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out); -// ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out); -// -// Ok = -// aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open(); -// if (!Ok) { -// INFOS( "Can't write into " << aFacesFileName); -// return error(SMESH_Comment("Can't write into ") << aFacesFileName); -// } -// #else TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; TCollection_AsciiString aResultGMFFileName; @@ -2550,19 +2669,20 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file aSolFileName = aGenericName + "_required.solb"; // GMF solution file #endif - map aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap; - map aGhs3dIdToNodeMap; + std::map aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap; + std::map aGhs3dIdToNodeMap; std::map nodeID2nodeIndexMap; GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp); TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp); TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp); TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp); - TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); +// TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp); -// GHS3DPlugin_Hypothesis::TID2SizeMap elemIDToSizeMap = GHS3DPlugin_Hypothesis::GetElementIDToSizeMap(_hyp); int nbEnforcedVertices = enforcedVertices.size(); int nbEnforcedNodes = enforcedNodes.size(); + std::cout << nbEnforcedNodes << " enforced nodes from hypo" << std::endl; + std::cout << nbEnforcedVertices << " enforced vertices from hypo" << std::endl; SMESH_MesherHelper helper( theMesh ); helper.SetSubShape( theShape ); @@ -2595,22 +2715,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( !proxyMesh ) return false; } -// #if GHS3D_VERSION < 42 -// Ok = (writePoints( aPointsFile, helper, -// aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap, -// nodeIDToSizeMap, -// enforcedVertices, enforcedNodes) -// && -// writeFaces ( aFacesFile, *proxyMesh, theShape, -// aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, -// enforcedEdges, enforcedTriangles, enforcedQuadrangles)); -// #else + Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), helper, *proxyMesh, - aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, - enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles, + aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, + enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/ enforcedVertices); -// #endif } // Write aSmdsToGhs3dIdMap to temp file @@ -2630,21 +2740,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } aIdsFile.close(); -// #if GHS3D_VERSION < 42 -// aFacesFile.close(); -// aPointsFile.close(); -// #endif if ( ! Ok ) { if ( !_keepFiles ) { -// #if GHS3D_VERSION < 42 -// removeFile( aFacesFileName ); -// removeFile( aPointsFileName ); -// #else removeFile( aGMFFileName ); removeFile( aRequiredVerticesFileName ); removeFile( aSolFileName ); -// #endif removeFile( aSmdsToGhs3dIdMapFileName ); } return error(COMPERR_BAD_INPUT_MESH); @@ -2681,7 +2782,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // read a result // -------------- -// #if GHS3D_VERSION < 42 // Mapping the result file int fileOpen; @@ -2706,24 +2806,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, #ifdef WITH_SMESH_CANCEL_COMPUTE this, #endif - /*theMesh, */helper, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap, + /*theMesh, */helper, tabShape, tabBox, _nbShape, + aGhs3dIdToNodeMap, aNodeId2NodeIndexMap, toMeshHoles, nbEnforcedVertices, nbEnforcedNodes, - enforcedEdges, enforcedTriangles, enforcedQuadrangles ); - } -// /*/*#else -// #ifndef GMF_HAS_SUBDOMAIN_INFO -// // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) -// -// int fileOpen = open( aResultFileName.ToCString(), O_RDONLY); -// if ( fileOpen < 0 ) { -// std::cout << std::endl; -// std::cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << std::endl; -// std::cout << "Log: " << aLogFileName << std::endl; -// Ok = false; -// } -// else { -// #endif + enforcedEdges, enforcedTriangles ); + // Ok = readGMFFile( // #ifndef GMF_HAS_SUBDOMAIN_INFO // fileOpen, @@ -2731,12 +2819,11 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // aGenericName.ToCString(), theMesh, // _nbShape, tabShape, tabBox, // aGhs3dIdToNodeMap, toMeshHoles, -// nbEnforcedVertices, nbEnforcedNodes, -// enforcedNodes, enforcedTriangles, enforcedQuadrangles); -// #ifndef GMF_HAS_SUBDOMAIN_INFO -// } -// #endif -// #endif*/*/ +// nbEnforcedVertices, nbEnforcedNodes); + } + + + // --------------------- // remove working files @@ -2762,13 +2849,6 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } if ( !_keepFiles ) { -// #if GHS3D_VERSION < 42 -// removeFile( aFacesFileName ); -// removeFile( aPointsFileName ); -// removeFile( aResultFileName ); -// removeFile( aBadResFileName ); -// removeFile( aBbResFileName ); -// #endif removeFile( aSmdsToGhs3dIdMapFileName ); // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) @@ -2812,27 +2892,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log TCollection_AsciiString aResultFileName; bool Ok; -// #if GHS3D_VERSION < 42 -// TCollection_AsciiString aFacesFileName, aPointsFileName; -// TCollection_AsciiString aBadResFileName, aBbResFileName; -// aFacesFileName = aGenericName + ".faces"; // in faces -// aPointsFileName = aGenericName + ".points"; // in points -// aResultFileName = aGenericName + ".noboite";// out points and volumes -// aBadResFileName = aGenericName + ".boite"; // out bad result -// aBbResFileName = aGenericName + ".bb"; // out vertex stepsize -// -// // ----------------- -// // make input files -// // ----------------- -// -// ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out); -// ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out); -// Ok = aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open(); -// if (!Ok) { -// INFOS( "Can't write into " << aFacesFileName); -// return error( SMESH_Comment("Can't write into ") << aFacesFileName); -// } -// #else + TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; #ifdef _DEBUG_ aGMFFileName = aGenericName + ".mesh"; // GMF mesh file @@ -2845,17 +2905,22 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file aSolFileName = aGenericName + ".solb"; // GMF solution file #endif -// #endif std::map nodeID2nodeIndexMap; GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp); TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp); TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp); TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp); - TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); +// TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp); + int nbEnforcedVertices = enforcedVertices.size(); + int nbEnforcedNodes = enforcedNodes.size(); + std::cout << nbEnforcedNodes << " enforced nodes from hypo" << std::endl; + std::cout << nbEnforcedVertices << " enforced vertices from hypo" << std::endl; + vector aNodeByGhs3dId, anEnforcedNodeByGhs3dId; + map aNodeToGhs3dIdMap; { SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh )); if ( theMesh.NbQuadrangles() > 0 ) @@ -2864,52 +2929,23 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, aQuad2Trias->Compute( theMesh ); proxyMesh.reset( aQuad2Trias ); } -// #if GHS3D_VERSION < 42 -// Ok = (writeFaces ( aFacesFile, *proxyMesh, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId, -// enforcedEdges, enforcedTriangles, enforcedQuadrangles ) && -// writePoints( aPointsFile, &theMesh, aNodeByGhs3dId, anEnforcedNodeByGhs3dId, -// nodeIDToSizeMap, enforcedVertices, enforcedNodes)); -// int nbEnforcedVertices = enforcedVertices.size(); -// int nbEnforcedNodes = enforcedNodes.size(); -// #else + Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), *proxyMesh, &theMesh, - aNodeByGhs3dId, anEnforcedNodeByGhs3dId, - enforcedNodes, enforcedEdges, enforcedTriangles, enforcedQuadrangles, + aNodeByGhs3dId, anEnforcedNodeByGhs3dId, aNodeToGhs3dIdMap, + enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/ enforcedVertices); -// #endif } - - TIDSortedNodeSet enforcedNodesFromEnforcedElem; - for (int i=0;i" ) + aLogFileName; // dump into file std::cout << std::endl; @@ -2928,35 +2964,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // -------------- // read a result // -------------- -// #if GHS3D_VERSION < 42 -// int fileOpen = open( aResultFileName.ToCString(), O_RDONLY); -// if ( fileOpen < 0 ) { -// std::cout << std::endl; -// std::cout << "Error when opening the " << aResultFileName.ToCString() << " file" << std::endl; -// std::cout << "Log: " << aLogFileName << std::endl; -// std::cout << std::endl; -// Ok = false; -// } -// else { -// Ok = readResultFile( fileOpen, -// #ifdef WNT -// aResultFileName.ToCString(), -// #endif -// #ifdef WITH_SMESH_CANCEL_COMPUTE -// this, -// #endif -// theMesh, theShape ,aNodeByGhs3dId, anEnforcedNodeByGhs3dId, -// nbEnforcedVertices, nbEnforcedNodes, -// enforcedEdges, enforcedTriangles, enforcedQuadrangles ); -// } -// #else + Ok = readGMFFile(aResultFileName.ToCString(), #ifdef WITH_SMESH_CANCEL_COMPUTE this, #endif - theHelper, aNodeByGhs3dId, - enforcedNodesFromEnforcedElem, enforcedTriangles, enforcedQuadrangles); -// #endif + theHelper, theShape, aNodeByGhs3dId, aNodeToGhs3dIdMap); // --------------------- // remove working files @@ -2979,7 +2992,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); } -// #if GHS3D_VERSION < 42 + if ( !_keepFiles ) { #ifdef WITH_SMESH_CANCEL_COMPUTE @@ -2987,13 +3000,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if(_compute_canceled) removeFile( aLogFileName ); #endif -// removeFile( aFacesFileName ); -// removeFile( aPointsFileName ); -// removeFile( aResultFileName ); -// removeFile( aBadResFileName ); -// removeFile( aBbResFileName ); } -// #endif return Ok; } @@ -3595,13 +3602,13 @@ bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh, bool GHS3DPlugin_GHS3D::importGMFMesh(const char* theGMFFileName, SMESH_Mesh& theMesh) { - SMESH_MesherHelper* helper = new SMESH_MesherHelper(theMesh ); - TIDSortedElemSet dummyElemSet; - TIDSortedNodeSet dummyNodeSet; + SMESH_MesherHelper* helper = new SMESH_MesherHelper(theMesh ); +// TopoDS_Shape theShape = theMesh.GetShapeToMesh(); vector dummyNodeVector; + map dummyNodeMap; return readGMFFile(theGMFFileName, #ifdef WITH_SMESH_CANCEL_COMPUTE this, #endif - helper, dummyNodeVector, dummyNodeSet , dummyElemSet, dummyElemSet); + helper, theMesh.GetShapeToMesh(), dummyNodeVector, dummyNodeMap); } diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index 7498235..d93a1d7 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -54,14 +54,14 @@ GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen myEnforcedVertices(DefaultEnforcedVertices()), _enfNodes(DefaultIDSortedNodeSet()), _enfEdges(DefaultIDSortedElemSet()), - _enfTriangles(DefaultIDSortedElemSet()), - _enfQuadrangles(DefaultIDSortedElemSet()) + _enfTriangles(DefaultIDSortedElemSet())/*,*/ +// _enfQuadrangles(DefaultIDSortedElemSet()) { _name = "GHS3D_Parameters"; _param_algo_dim = 3; _edgeID2nodeIDMap.clear(); _triID2nodeIDMap.clear(); - _quadID2nodeIDMap.clear(); +// _quadID2nodeIDMap.clear(); _nodeIDToSizeMap.clear(); _elementIDToSizeMap.clear(); } @@ -392,6 +392,7 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedElements"); TIDSortedElemSet::const_iterator it = theElemSet.begin(); const SMDS_MeshElement* elem; + bool added = false; for (;it != theElemSet.end();++it) { elem = (*it); @@ -403,6 +404,7 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM // MESSAGE("This is a node"); _enfNodes.insert(node); _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); + added = true; } else { // MESSAGE("This is an element"); @@ -410,8 +412,8 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); for (;nodeIt->more();) _nodeIDToSizeMap.insert(make_pair(nodeIt->next()->GetID(), size)); + added = true; } - NotifySubMeshesHypothesisModification(); break; case SMESH::EDGE: if (node) { @@ -429,6 +431,7 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM _edgeID2nodeIDMap[elem->GetID()].push_back(node->GetID()); _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); } + added = true; } else if (elem->GetType() > SMDSAbs_Edge) { SMDS_ElemIteratorPtr it = elem->edgesIterator(); @@ -444,9 +447,9 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); } } + added = true; } } - NotifySubMeshesHypothesisModification(); break; case SMESH::FACE: if (node) { @@ -456,62 +459,68 @@ void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM // MESSAGE("This is an element"); if (elem->GetType() == SMDSAbs_Face) { - if (elem->NbNodes() == 3) { + if (elem->NbCornerNodes() == 3) { _enfTriangles.insert(elem); // _enfNodes.insert(elem->begin_nodes(),elem->end_nodes()); _elementIDToSizeMap.insert(make_pair(elem->GetID(), size)); - SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); - for (;nodeIt->more();) { - node = dynamic_cast(nodeIt->next()); - _triID2nodeIDMap[elem->GetID()].push_back(node->GetID()); - _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); - } - } - else if (elem->NbNodes() == 4) { - _enfQuadrangles.insert(elem); -// _enfNodes.insert(elem->begin_nodes(),elem->end_nodes()); - _elementIDToSizeMap.insert(make_pair(elem->GetID(), size)); - SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); - for (;nodeIt->more();) { - node = dynamic_cast(nodeIt->next()); - _quadID2nodeIDMap[elem->GetID()].push_back(node->GetID()); - _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); - } +// TEST +// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); +// for ( int j = 0; j < 3; ++j ) { +// node = dynamic_cast(nodeIt->next()); +// _triID2nodeIDMap[elem->GetID()].push_back(node->GetID()); +// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); +// } + added = true; } +// else if (elem->NbCornerNodes() == 4) { +// _enfQuadrangles.insert(elem); +// // _enfNodes.insert(elem->begin_nodes(),elem->end_nodes()); +// _elementIDToSizeMap.insert(make_pair(elem->GetID(), size)); +// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); +// for (int j = 0; j < 4; ++j) { +// node = dynamic_cast(nodeIt->next()); +// _quadID2nodeIDMap[elem->GetID()].push_back(node->GetID()); +// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); +// } +// added = true; +// } } - else if (elem->GetType() > SMDSAbs_Face) { + else if (elem->GetType() > SMDSAbs_Face) { // Group of faces SMDS_ElemIteratorPtr it = elem->facesIterator(); for (;it->more();) { const SMDS_MeshElement* aFace = it->next(); - if (aFace->NbNodes() == 3) { + if (aFace->NbCornerNodes() == 3) { _enfTriangles.insert(aFace); // _enfNodes.insert(aFace->begin_nodes(),aFace->end_nodes()); _elementIDToSizeMap.insert(make_pair(aFace->GetID(), size)); SMDS_ElemIteratorPtr nodeIt = aFace->nodesIterator(); - for (;nodeIt->more();) { + for (int j = 0; j < 3; ++j) { node = dynamic_cast(nodeIt->next()); _triID2nodeIDMap[aFace->GetID()].push_back(node->GetID()); _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); } + added = true; } - else if (aFace->NbNodes() == 4) { - _enfQuadrangles.insert(aFace); -// _enfNodes.insert(aFace->begin_nodes(),aFace->end_nodes()); - _elementIDToSizeMap.insert(make_pair(aFace->GetID(), size)); - SMDS_ElemIteratorPtr nodeIt = aFace->nodesIterator(); - for (;nodeIt->more();) { - node = dynamic_cast(nodeIt->next()); - _quadID2nodeIDMap[aFace->GetID()].push_back(node->GetID()); - _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); - } - } +// else if (aFace->NbCornerNodes() == 4) { +// _enfQuadrangles.insert(aFace); +// // _enfNodes.insert(aFace->begin_nodes(),aFace->end_nodes()); +// _elementIDToSizeMap.insert(make_pair(aFace->GetID(), size)); +// SMDS_ElemIteratorPtr nodeIt = aFace->nodesIterator(); +// for (int j = 0; j < 4; ++j) { +// node = dynamic_cast(nodeIt->next()); +// _quadID2nodeIDMap[aFace->GetID()].push_back(node->GetID()); +// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); +// } +// added = true; +// } } } } - NotifySubMeshesHypothesisModification(); break; }; } + if (added) + NotifySubMeshesHypothesisModification(); } //======================================================================= @@ -571,7 +580,7 @@ void GHS3DPlugin_Hypothesis::ClearEnforcedMeshes() _enfNodes.clear(); _enfEdges.clear(); _enfTriangles.clear(); - _enfQuadrangles.clear(); +// _enfQuadrangles.clear(); // _edgeID2nodeIDMap.clear(); // _triID2nodeIDMap.clear(); // _quadID2nodeIDMap.clear(); @@ -1109,10 +1118,10 @@ TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedTriangles(const GHS3DPlugin_ return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemSet(); } -TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp) -{ - return hyp ? hyp->_GetEnforcedQuadrangles():DefaultIDSortedElemSet(); -} +// TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp) +// { +// return hyp ? hyp->_GetEnforcedQuadrangles():DefaultIDSortedElemSet(); +// } GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetEdgeID2NodeIDMap(const GHS3DPlugin_Hypothesis* hyp) { @@ -1124,10 +1133,10 @@ GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetTri2NodeMap return hyp ? hyp->_GetTri2NodeMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap(); } -GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetQuad2NodeMap(const GHS3DPlugin_Hypothesis* hyp) -{ - return hyp ? hyp->_GetQuad2NodeMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap(); -} +// GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetQuad2NodeMap(const GHS3DPlugin_Hypothesis* hyp) +// { +// return hyp ? hyp->_GetQuad2NodeMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap(); +// } GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp) { diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index ac54676..13bb908 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -169,11 +169,11 @@ public: const TIDSortedNodeSet _GetEnforcedNodes() const { return _enfNodes; } const TIDSortedElemSet _GetEnforcedEdges() const { return _enfEdges; } const TIDSortedElemSet _GetEnforcedTriangles() const { return _enfTriangles; } - const TIDSortedElemSet _GetEnforcedQuadrangles() const { return _enfQuadrangles; } +// const TIDSortedElemSet _GetEnforcedQuadrangles() const { return _enfQuadrangles; } typedef std::map > TElemID2NodeIDMap; const TElemID2NodeIDMap _GetEdgeID2NodeIDMap() const {return _edgeID2nodeIDMap; } const TElemID2NodeIDMap _GetTri2NodeMap() const {return _triID2nodeIDMap; } - const TElemID2NodeIDMap _GetQuad2NodeMap() const {return _quadID2nodeIDMap; } +// const TElemID2NodeIDMap _GetQuad2NodeMap() const {return _quadID2nodeIDMap; } typedef std::map TID2SizeMap; const TID2SizeMap _GetNodeIDToSizeMap() const {return _nodeIDToSizeMap; } const TID2SizeMap _GetElementIDToSizeMap() const {return _elementIDToSizeMap; } @@ -209,7 +209,7 @@ public: static TIDSortedNodeSet GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp); static TIDSortedElemSet GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp); static TIDSortedElemSet GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp); - static TIDSortedElemSet GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp); +// static TIDSortedElemSet GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp); static TElemID2NodeIDMap GetEdgeID2NodeIDMap(const GHS3DPlugin_Hypothesis* hyp); static TElemID2NodeIDMap GetTri2NodeMap(const GHS3DPlugin_Hypothesis* hyp); static TElemID2NodeIDMap GetQuad2NodeMap(const GHS3DPlugin_Hypothesis* hyp); @@ -250,10 +250,10 @@ private: TIDSortedNodeSet _enfNodes; TIDSortedElemSet _enfEdges; TIDSortedElemSet _enfTriangles; - TIDSortedElemSet _enfQuadrangles; +// TIDSortedElemSet _enfQuadrangles; TElemID2NodeIDMap _edgeID2nodeIDMap; TElemID2NodeIDMap _triID2nodeIDMap; - TElemID2NodeIDMap _quadID2nodeIDMap; +// TElemID2NodeIDMap _quadID2nodeIDMap; TID2SizeMap _nodeIDToSizeMap; TID2SizeMap _elementIDToSizeMap; };