From: eap Date: Tue, 12 Nov 2013 10:00:29 +0000 (+0000) Subject: 22346: [CEA 963] Use GMF format instead of the old format with 2 files (.points and... X-Git-Tag: V7_3_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=efb8d44918f2097b2bf243bc5484a535f19bd0bb;p=plugins%2Fhybridplugin.git 22346: [CEA 963] Use GMF format instead of the old format with 2 files (.points and .faces) Use GMF format for the mesh on shape --- diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png index c41c62e..050152e 100644 Binary files a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png index 75126ee..3632608 100644 Binary files a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png differ diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index b18489b..96301ef 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -1150,17 +1150,19 @@ static void makeDomainGroups( std::vector< std::vector< const SMDS_MeshElement* static bool readGMFFile(const char* theFile, GHS3DPlugin_GHS3D* theAlgo, SMESH_MesherHelper* theHelper, - TopoDS_Shape theSolid, - vector & theNodeByGhs3dId, + std::vector & theNodeByGhs3dId, + std::vector & theFaceByGhs3dId, map & theNodeToGhs3dIdMap, std::vector & aNodeGroupByGhs3dId, std::vector & anEdgeGroupByGhs3dId, std::vector & aFaceGroupByGhs3dId, std::set & groupsToRemove, - bool toMakeGroupsOfDomains=false) + bool toMakeGroupsOfDomains=false, + bool toMeshHoles=true) { std::string tmpStr; SMESHDS_Mesh* theMeshDS = theHelper->GetMeshDS(); + const bool hasGeom = ( theHelper->GetMesh()->HasShapeToMesh() ); int nbInitialNodes = theNodeByGhs3dId.size(); int nbMeshNodes = theMeshDS->NbNodes(); @@ -1176,8 +1178,8 @@ static bool readGMFFile(const char* theFile, std::cout << "isQuadMesh: " << isQuadMesh << std::endl; #endif - if (theHelper->GetSubShapeID() != 0) - theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); + // if ( theHelper->GetSubShapeID() != 0 && hasGeom ) + // theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); // --------------------------------- // Read generated elements and nodes @@ -1190,8 +1192,8 @@ static bool readGMFFile(const char* theFile, std::map > subdomainId2tetraId; #endif std::map tabRef; - const bool force3d = true; // since there is no geometry - const int noID = 0; + const bool force3d = !hasGeom; + const int noID = 0; tabRef[GmfVertices] = 3; // for new nodes and enforced nodes tabRef[GmfCorners] = 1; @@ -1209,12 +1211,59 @@ static bool readGMFFile(const char* theFile, return false; MESSAGE("Done "); + // Read ids of domains + vector< int > solidIDByDomain; + if ( hasGeom ) + { + int solid1; // id used in case of 1 domain or some reading failure + if ( theHelper->GetSubShape().ShapeType() == TopAbs_SOLID ) + solid1 = theHelper->GetSubShapeID(); + else + solid1 = theMeshDS->ShapeToIndex + ( TopExp_Explorer( theHelper->GetSubShape(), TopAbs_SOLID ).Current() ); + + int nbDomains = GmfStatKwd( InpMsh, GmfSubDomainFromGeom ); + if ( nbDomains > 1 ) + { + solidIDByDomain.resize( nbDomains+1, theHelper->GetSubShapeID() ); + int faceNbNodes, faceIndex, orientation, domainNb; + GmfGotoKwd( InpMsh, GmfSubDomainFromGeom ); + for ( int i = 0; i < nbDomains; ++i ) + { + faceIndex = 0; + GmfGetLin( InpMsh, GmfSubDomainFromGeom, + &faceNbNodes, &faceIndex, &orientation, &domainNb); + solidIDByDomain[ domainNb ] = 1; + if ( 0 < faceIndex && faceIndex-1 < theFaceByGhs3dId.size() ) + { + const SMDS_MeshElement* face = theFaceByGhs3dId[ faceIndex-1 ]; + const SMDS_MeshNode* nn[3] = { face->GetNode(0), + face->GetNode(1), + face->GetNode(2) }; + if ( orientation < 0 ) + std::swap( nn[1], nn[2] ); + solidIDByDomain[ domainNb ] = + findShapeID( *theHelper->GetMesh(), nn[0], nn[1], nn[2], toMeshHoles ); + if ( solidIDByDomain[ domainNb ] > 0 ) + { + const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( solidIDByDomain[ domainNb ] ); + if ( ! theHelper->IsSubShape( foundShape, theHelper->GetSubShape() )) + solidIDByDomain[ domainNb ] = HOLE_ID; + } + } + } + } + if ( solidIDByDomain.size() < 2 ) + solidIDByDomain.resize( 2, solid1 ); + } + // Issue 0020682. Avoid creating nodes and tetras at place where // volumic elements already exist SMESH_ElementSearcher* elemSearcher = 0; std::vector< const SMDS_MeshElement* > foundVolumes; - if ( theHelper->GetMesh()->NbVolumes() > 0 ) - elemSearcher = SMESH_MeshAlgos::GetElementSearcher( *theHelper->GetMeshDS() ); + if ( !hasGeom && theHelper->GetMesh()->NbVolumes() > 0 ) + elemSearcher = SMESH_MeshAlgos::GetElementSearcher( *theMeshDS ); + auto_ptr< SMESH_ElementSearcher > elemSearcherDeleter( elemSearcher ); // IMP 0022172: [CEA 790] create the groups corresponding to domains std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain; @@ -1230,7 +1279,7 @@ static bool readGMFFile(const char* theFile, delete [] GMFNode; return false; } - int dummy; + int dummy, solidID; GmfKwdCod token = it->first; nbRef = it->second; @@ -1403,42 +1452,78 @@ static bool readGMFFile(const char* theFile, } break; 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; + if ( hasGeom ) + { + solidID = solidIDByDomain[ domainID[iElem]]; + if ( solidID != HOLE_ID ) + { + aCreatedElem = theHelper->AddVolume( node[1], node[0], node[2], node[3], + noID, force3d ); + theMeshDS->SetMeshElementOnShape( aCreatedElem, solidID ); + for ( int iN = 0; iN < 4; ++iN ) + if ( node[iN]->getshapeId() < 1 ) + theMeshDS->SetNodeInVolume( node[iN], solidID ); + } + } + else + { + 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; + } + aCreatedElem = theHelper->AddVolume( node[1], node[0], node[2], node[3], + noID, force3d ); } - aCreatedElem = theHelper->AddVolume( node[1], node[0], node[2], node[3], noID, force3d ); 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; + if ( hasGeom ) + { + solidID = solidIDByDomain[ domainID[iElem]]; + if ( solidID != HOLE_ID ) + { + aCreatedElem = theHelper->AddVolume( node[0], node[3], node[2], node[1], + node[4], node[7], node[6], node[5], + noID, force3d ); + theMeshDS->SetMeshElementOnShape( aCreatedElem, solidID ); + for ( int iN = 0; iN < 8; ++iN ) + if ( node[iN]->getshapeId() < 1 ) + theMeshDS->SetNodeInVolume( node[iN], solidID ); + } + } + else + { + 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; + } + aCreatedElem = theHelper->AddVolume( node[0], node[3], node[2], node[1], + node[4], node[7], node[6], node[5], + noID, force3d ); } - aCreatedElem = theHelper->AddVolume( node[0], node[3], node[2], node[1], - node[4], node[7], node[6], node[5], noID, force3d ); break; default: continue; - } + } // switch (token) + if ( aCreatedElem && toMakeGroupsOfDomains ) { if ( domainID[iElem] >= (int) elemsOfDomain.size() ) @@ -1451,6 +1536,14 @@ static bool readGMFFile(const char* theFile, } // switch (token) } // loop on tabRef + // remove nodes in holes + if ( hasGeom ) + { + for ( int i = 1; i <= nbVertices; ++i ) + if ( GMFNode[i]->NbInverseElements() == 0 ) + theMeshDS->RemoveFreeNode( GMFNode[i], /*sm=*/0, /*fromGroups=*/false ); + } + GmfCloseMesh(InpMsh); delete [] GMFNode; @@ -1480,21 +1573,17 @@ static bool readGMFFile(const char* theFile, aSubdomainFile.close(); #endif - if (elemSearcher) - { - MESSAGE("delete elemSearcher") - delete elemSearcher; - elemSearcher = 0; - } return true; } + static bool writeGMFFile(const char* theMeshFileName, const char* theRequiredFileName, const char* theSolFileName, const SMESH_ProxyMesh& theProxyMesh, - SMESH_Mesh * theMesh, + SMESH_MesherHelper& theHelper, std::vector & theNodeByGhs3dId, + std::vector & theFaceByGhs3dId, std::map & aNodeToGhs3dIdMap, std::vector & aNodeGroupByGhs3dId, std::vector & anEdgeGroupByGhs3dId, @@ -1522,6 +1611,8 @@ static bool writeGMFFile(const char* theMesh GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::iterator elemIt; TIDSortedElemSet::iterator elemSetIt; bool isOK; + SMESH_Mesh* theMesh = theHelper.GetMesh(); + const bool hasGeom = theMesh->HasShapeToMesh(); auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshAlgos::GetElementSearcher(*theMesh->GetMeshDS())); @@ -1530,6 +1621,7 @@ static bool writeGMFFile(const char* theMesh // count faces int nbFaces = theProxyMesh.NbFaces(); int nbNodes; + theFaceByGhs3dId.reserve( nbFaces ); // groups management int usedEnforcedNodes = 0; @@ -1544,7 +1636,8 @@ static bool writeGMFFile(const char* theMesh /* ========================== FACES ========================== */ /* TRIANGLES ========================== */ - SMDS_ElemIteratorPtr eIt = theProxyMesh.GetFaces(); + SMDS_ElemIteratorPtr eIt = + hasGeom ? theProxyMesh.GetFaces( theHelper.GetSubShape()) : theProxyMesh.GetFaces(); while ( eIt->more() ) { elem = eIt->next(); @@ -1984,6 +2077,7 @@ static bool writeGMFFile(const char* theMesh int k=0; for(elemSetIt = anElemSet.begin() ; elemSetIt != anElemSet.end() ; ++elemSetIt,++k) { elem = (*elemSetIt); + theFaceByGhs3dId.push_back( elem ); nodeIt = elem->nodesIterator(); int index=0; for ( int j = 0; j < 3; ++j ) { @@ -1998,6 +2092,8 @@ static bool writeGMFFile(const char* theMesh GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint); aFaceGroupByGhs3dId[k] = ""; } + if ( !theHelper.GetMesh()->HasShapeToMesh() ) + SMESHUtils::FreeVector( theFaceByGhs3dId ); if (theKeptEnforcedTriangles.size()) { for(elemSetIt = theKeptEnforcedTriangles.begin() ; elemSetIt != theKeptEnforcedTriangles.end() ; ++elemSetIt,++k) { elem = (*elemSetIt); @@ -3264,80 +3360,59 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // we count the number of shapes // _nbShape = countShape( meshDS, TopAbs_SOLID ); -- 0020330: Pb with ghs3d as a submesh - _nbShape = 0; + // _nbShape = 0; TopExp_Explorer expBox ( theShape, TopAbs_SOLID ); - for ( ; expBox.More(); expBox.Next() ) - _nbShape++; + // for ( ; expBox.More(); expBox.Next() ) + // _nbShape++; // create bounding box for every shape inside the compound - int iShape = 0; - TopoDS_Shape* tabShape; - double** tabBox; - tabShape = new TopoDS_Shape[_nbShape]; - tabBox = new double*[_nbShape]; - for (int i=0; i<_nbShape; i++) - tabBox[i] = new double[6]; - Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; - - for (expBox.ReInit(); expBox.More(); expBox.Next()) { - tabShape[iShape] = expBox.Current(); - Bnd_Box BoundingBox; - BRepBndLib::Add(expBox.Current(), BoundingBox); - BoundingBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); - tabBox[iShape][0] = Xmin; tabBox[iShape][1] = Xmax; - tabBox[iShape][2] = Ymin; tabBox[iShape][3] = Ymax; - tabBox[iShape][4] = Zmin; tabBox[iShape][5] = Zmax; - iShape++; - } + // int iShape = 0; + // TopoDS_Shape* tabShape; + // double** tabBox; + // tabShape = new TopoDS_Shape[_nbShape]; + // tabBox = new double*[_nbShape]; + // for (int i=0; i<_nbShape; i++) + // tabBox[i] = new double[6]; + // Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + + // for (expBox.ReInit(); expBox.More(); expBox.Next()) { + // tabShape[iShape] = expBox.Current(); + // Bnd_Box BoundingBox; + // BRepBndLib::Add(expBox.Current(), BoundingBox); + // BoundingBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + // tabBox[iShape][0] = Xmin; tabBox[iShape][1] = Xmax; + // tabBox[iShape][2] = Ymin; tabBox[iShape][3] = Ymax; + // tabBox[iShape][4] = Zmin; tabBox[iShape][5] = Zmax; + // iShape++; + // } // a unique working file name // to avoid access to the same files by eg different users _genericName = GHS3DPlugin_Hypothesis::GetFileName(_hyp); TCollection_AsciiString aGenericName((char*) _genericName.c_str() ); + TCollection_AsciiString aGenericNameRequired = aGenericName + "_required"; - TCollection_AsciiString aResultFileName; TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log - // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) -// TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; -// TCollection_AsciiString aGenericNameRequired = aGenericName + "_required"; -// #ifdef _DEBUG_ -// aGMFFileName = aGenericName + ".mesh"; // GMF mesh file -// aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file -// aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file -// aSolFileName = aGenericName + "_required.sol"; // GMF solution file -// #else -// aGMFFileName = aGenericName + ".meshb"; // GMF mesh file -// aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file -// aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file -// aSolFileName = aGenericName + "_required.solb"; // GMF solution file -// #endif - - TCollection_AsciiString aFacesFileName, aPointsFileName, aBadResFileName, aBbResFileName; + TCollection_AsciiString aResultFileName; - 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 + TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; +//#ifdef _DEBUG_ + aGMFFileName = aGenericName + ".mesh"; // GMF mesh file + aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file + aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file + aSolFileName = aGenericNameRequired + ".sol"; // GMF solution file +//#else +// aGMFFileName = aGenericName + ".meshb"; // GMF mesh file +// aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file +// aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file +// aSolFileName = aGenericNameRequired + ".solb"; // GMF solution file +//#endif - // ----------------- - // 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); - } - std::map aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap; std::map aGhs3dIdToNodeMap; std::map nodeID2nodeIndexMap; + std::map, std::string> enfVerticesWithGroup; GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues coordsSizeMap = GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize(_hyp); GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp); GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp); @@ -3357,6 +3432,10 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, SMESH_MesherHelper helper( theMesh ); helper.SetSubShape( theShape ); + std::vector aNodeByGhs3dId, anEnforcedNodeByGhs3dId; + std::vector aFaceByGhs3dId; + std::map aNodeToGhs3dIdMap; + std::vector aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId; { SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh )); @@ -3386,19 +3465,20 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, return false; } - Ok = (writePoints( aPointsFile, helper, - aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap, - nodeIDToSizeMap, - coordsSizeMap, enforcedNodes, enforcedEdges, enforcedTriangles) - && - writeFaces ( aFacesFile, *proxyMesh, theShape, - aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, - enforcedEdges, enforcedTriangles )); -// Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), -// helper, *proxyMesh, -// aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, -// enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/ -// coordsSizeMap); + // Ok = (writePoints( aPointsFile, helper, + // aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap, + // nodeIDToSizeMap, + // coordsSizeMap, enforcedNodes, enforcedEdges, enforcedTriangles) + // && + // writeFaces ( aFacesFile, *proxyMesh, theShape, + // aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, + // enforcedEdges, enforcedTriangles )); + Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), + *proxyMesh, helper, + aNodeByGhs3dId, aFaceByGhs3dId, aNodeToGhs3dIdMap, + aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, + enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/ + enfVerticesWithGroup, coordsSizeMap); } // Write aSmdsToGhs3dIdMap to temp file @@ -3418,16 +3498,12 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } aIdsFile.close(); - aFacesFile.close(); - aPointsFile.close(); if ( ! Ok ) { if ( !_keepFiles ) { -// removeFile( aGMFFileName ); -// removeFile( aRequiredVerticesFileName ); -// removeFile( aSolFileName ); - removeFile( aFacesFileName ); - removeFile( aPointsFileName ); + removeFile( aGMFFileName ); + removeFile( aRequiredVerticesFileName ); + removeFile( aSolFileName ); removeFile( aSmdsToGhs3dIdMapFileName ); } return error(COMPERR_BAD_INPUT_MESH); @@ -3439,15 +3515,13 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // ----------------- TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() ); - cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read + cmd += TCollection_AsciiString(" --in ") + aGenericName; + if ( nbEnforcedVertices + nbEnforcedNodes) + cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; + cmd += TCollection_AsciiString(" --out ") + aResultFileName; if ( !_logInStandardOutput ) cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file - // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) -// cmd += TCollection_AsciiString(" --in ") + aGenericName; -// cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; -// cmd += TCollection_AsciiString(" --out ") + aResultGMFFileName; -// cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file std::cout << std::endl; std::cout << "Ghs3d execution..." << std::endl; @@ -3466,15 +3540,16 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, // Mapping the result file - int fileOpen; - 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 { + // int fileOpen; + // 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 { + GHS3DPlugin_Hypothesis::TSetStrings groupsToRemove = GHS3DPlugin_Hypothesis::GetGroupsToRemove(_hyp); bool toMeshHoles = _hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles(); const bool toMakeGroupsOfDomains = GHS3DPlugin_Hypothesis::GetToMakeGroupsOfDomains( _hyp ); @@ -3482,29 +3557,26 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, helper.IsQuadraticSubMesh( theShape ); helper.SetElementsOnShape( false ); - Ok = readResultFile( fileOpen, -#ifdef WIN32 - aResultFileName.ToCString(), -#endif - this, - /*theMesh, */helper, tabShape, tabBox, _nbShape, - aGhs3dIdToNodeMap, aNodeId2NodeIndexMap, - toMeshHoles, - nbEnforcedVertices, nbEnforcedNodes, - enforcedEdges, enforcedTriangles, - toMakeGroupsOfDomains ); - -// Ok = readGMFFile( -// #ifndef GMF_HAS_SUBDOMAIN_INFO -// fileOpen, +// Ok = readResultFile( fileOpen, +// #ifdef WIN32 +// aResultFileName.ToCString(), // #endif -// aGenericName.ToCString(), theMesh, -// _nbShape, tabShape, tabBox, -// aGhs3dIdToNodeMap, toMeshHoles, -// nbEnforcedVertices, nbEnforcedNodes); +// this, +// /*theMesh, */helper, tabShape, tabBox, _nbShape, +// aGhs3dIdToNodeMap, aNodeId2NodeIndexMap, +// toMeshHoles, +// nbEnforcedVertices, nbEnforcedNodes, +// enforcedEdges, enforcedTriangles, +// toMakeGroupsOfDomains ); + + Ok = readGMFFile(aResultFileName.ToCString(), + this, + &helper, aNodeByGhs3dId, aFaceByGhs3dId, aNodeToGhs3dIdMap, + aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, + groupsToRemove, toMakeGroupsOfDomains, toMeshHoles); removeEmptyGroupsOfDomains( helper.GetMesh(), /*notEmptyAsWell =*/ !toMakeGroupsOfDomains ); - } + //} @@ -3537,12 +3609,11 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( !_keepFiles ) { if (! Ok && _compute_canceled) - removeFile( aLogFileName ); - removeFile( aFacesFileName ); - removeFile( aPointsFileName ); + removeFile( aLogFileName ); + removeFile( aGMFFileName ); + removeFile( aRequiredVerticesFileName ); + removeFile( aSolFileName ); removeFile( aResultFileName ); - removeFile( aBadResFileName ); - removeFile( aBbResFileName ); removeFile( aSmdsToGhs3dIdMapFileName ); } std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file "; @@ -3551,9 +3622,9 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, std::cout << "treated !" << std::endl; std::cout << std::endl; - _nbShape = 0; // re-initializing _nbShape for the next Compute() method call - delete [] tabShape; - delete [] tabBox; + // _nbShape = 0; // re-initializing _nbShape for the next Compute() method call + // delete [] tabShape; + // delete [] tabBox; return Ok; } @@ -3684,6 +3755,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, std::cout << nbEnforcedVertices << " enforced " << tmpStr << " from hypo" << std::endl; std::vector aNodeByGhs3dId, anEnforcedNodeByGhs3dId; + std::vector aFaceByGhs3dId; std::map aNodeToGhs3dIdMap; std::vector aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId; { @@ -3696,8 +3768,8 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, } Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), - *proxyMesh, &theMesh, - aNodeByGhs3dId, aNodeToGhs3dIdMap, + *proxyMesh, *theHelper, + aNodeByGhs3dId, aFaceByGhs3dId, aNodeToGhs3dIdMap, aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, enforcedNodes, enforcedEdges, enforcedTriangles, enfVerticesWithGroup, coordsSizeMap); @@ -3735,7 +3807,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, Ok = readGMFFile(aResultFileName.ToCString(), this, - theHelper, theShape, aNodeByGhs3dId, aNodeToGhs3dIdMap, + theHelper, aNodeByGhs3dId, aFaceByGhs3dId, aNodeToGhs3dIdMap, aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, groupsToRemove, toMakeGroupsOfDomains); @@ -3775,7 +3847,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, if ( !_keepFiles ) { if (! Ok && _compute_canceled) - removeFile( aLogFileName ); + removeFile( aLogFileName ); removeFile( aGMFFileName ); removeFile( aResultFileName ); removeFile( aRequiredVerticesFileName ); @@ -4539,8 +4611,8 @@ bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh, bool GHS3DPlugin_GHS3D::importGMFMesh(const char* theGMFFileName, SMESH_Mesh& theMesh) { SMESH_MesherHelper* helper = new SMESH_MesherHelper(theMesh ); -// TopoDS_Shape theShape = theMesh.GetShapeToMesh(); std::vector dummyNodeVector; + std::vector aFaceByGhs3dId; std::map dummyNodeMap; std::map, std::string> dummyEnfVertGroup; std::vector dummyElemGroup; @@ -4548,7 +4620,7 @@ bool GHS3DPlugin_GHS3D::importGMFMesh(const char* theGMFFileName, SMESH_Mesh& th bool ok = readGMFFile(theGMFFileName, this, - helper, theMesh.GetShapeToMesh(), dummyNodeVector, dummyNodeMap, dummyElemGroup, dummyElemGroup, dummyElemGroup, dummyGroupsToRemove); + helper, dummyNodeVector, aFaceByGhs3dId, dummyNodeMap, dummyElemGroup, dummyElemGroup, dummyElemGroup, dummyGroupsToRemove); theMesh.GetMeshDS()->Modified(); return ok; } diff --git a/src/GUI/GHS3DPluginGUI_Enums.h b/src/GUI/GHS3DPluginGUI_Enums.h index 844ddcb..95939ae 100644 --- a/src/GUI/GHS3DPluginGUI_Enums.h +++ b/src/GUI/GHS3DPluginGUI_Enums.h @@ -58,7 +58,7 @@ enum { // Enforced vertices widget inputs enum { ENF_VER_WARNING = 0, - ENF_VER_VERTEX,// = 0, + ENF_VER_VERTEX = 0, ENF_VER_X_COORD, ENF_VER_Y_COORD, ENF_VER_Z_COORD, @@ -71,7 +71,7 @@ enum { // Enforced meshes widget inputs enum { ENF_MESH_WARNING = 0, - ENF_MESH_MESH /*= 0*/, + ENF_MESH_MESH = 0, ENF_MESH_CONSTRAINT, ENF_MESH_GROUP, ENF_MESH_BTN, diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index a03361f..2429298 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -502,17 +502,17 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() // myGlobalGroupName = new QCheckBox(tr("GHS3D_ENF_VER_GROUPS"), myEnfGroup); // myGlobalGroupName->setChecked(false); - QGroupBox* GroupBox = new QGroupBox( myEnfGroup ); - QLabel* info = new QLabel( GroupBox ); - info->setText( tr( "GHS3D_ENF_VER_INFO" ) ); - info->setWordWrap( true ); - QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox ); - GroupBoxVLayout->setSpacing( 6 ); - GroupBoxVLayout->setMargin( 11 ); - GroupBoxVLayout->addWidget( info ); + // QGroupBox* GroupBox = new QGroupBox( myEnfGroup ); + // QLabel* info = new QLabel( GroupBox ); + // info->setText( tr( "GHS3D_ENF_VER_INFO" ) ); + // info->setWordWrap( true ); + // QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox ); + // GroupBoxVLayout->setSpacing( 6 ); + // GroupBoxVLayout->setMargin( 11 ); + // GroupBoxVLayout->addWidget( info ); - anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 ); + //anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 ); anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1); QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup); @@ -581,16 +581,16 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() // addEnfMeshButton->setEnabled(false); removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup); - QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup ); - QLabel* info2 = new QLabel( GroupBox2 ); - info2->setText( tr( "GHS3D_ENF_MESH_INFO" ) ); - info2->setWordWrap( true ); - QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 ); - GroupBox2VLayout->setSpacing( 6 ); - GroupBox2VLayout->setMargin( 11 ); - GroupBox2VLayout->addWidget( info2 ); + // QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup ); + // QLabel* info2 = new QLabel( GroupBox2 ); + // info2->setText( tr( "GHS3D_ENF_MESH_INFO" ) ); + // info2->setWordWrap( true ); + // QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 ); + // GroupBox2VLayout->setSpacing( 6 ); + // GroupBox2VLayout->setMargin( 11 ); + // GroupBox2VLayout->addWidget( info2 ); - anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 ); + // anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 ); anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1); QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);