From: eap Date: Fri, 22 Dec 2017 11:20:51 +0000 (+0300) Subject: 23418: [OCC] Mesh: Minimization of memory usage of SMESH X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Feap%2F23418;p=plugins%2Fghs3dplugin.git 23418: [OCC] Mesh: Minimization of memory usage of SMESH --- diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx index b792999..6c47d7e 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -2386,7 +2386,9 @@ GHS3DPlugin_GHS3D::getErrorDescription(const char* logFile, const _Ghs2smdsConvertor & toSmdsConvertor, const bool isOk/* = false*/ ) { - SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( COMPERR_ALGO_FAILED ); + SMESH_BadInputElements* badElemsErr = + new SMESH_BadInputElements( toSmdsConvertor.getMesh(), COMPERR_ALGO_FAILED ); + SMESH_ComputeErrorPtr err( badElemsErr ); char* ptr = const_cast( log.c_str() ); char* buf = ptr, * bufEnd = ptr + log.size(); @@ -2424,7 +2426,7 @@ GHS3DPlugin_GHS3D::getErrorDescription(const char* logFile, if ( strncmp( ptr, "ERR ", 4 ) != 0 ) continue; - list& badElems = err->myBadElements; + list& badElems = badElemsErr->myBadElements; vector nodeIds; ptr += 4; @@ -2632,7 +2634,7 @@ GHS3DPlugin_GHS3D::getErrorDescription(const char* logFile, err->myComment = errDescription; - if ( err->myComment.empty() && err->myBadElements.empty() ) + if ( err->myComment.empty() && !err->HasBadElems() ) err = SMESH_ComputeError::New(); // OK return err; @@ -2707,6 +2709,16 @@ const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector& ghsNod return 0; } +//================================================================================ +/*! + * \brief Return a mesh + */ +//================================================================================ + +const SMDS_Mesh* _Ghs2smdsConvertor::getMesh() const +{ + return _mesh->GetMeshDS(); +} //============================================================================= /*! diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx index b5f4c8b..a800cfc 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx @@ -124,6 +124,7 @@ public: SMESH_ProxyMesh::Ptr mesh); const SMDS_MeshElement* getElement(const std::vector& ghsNodes) const; + const SMDS_Mesh* getMesh() const; }; #endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index eeafd0b..da1b7c3 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -42,32 +42,33 @@ using namespace std; GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), - myToMeshHoles(DefaultMeshHoles()), - myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()), - myMaximumMemory(-1), - myInitialMemory(-1), - myOptimizationLevel(DefaultOptimizationLevel()), - myKeepFiles(DefaultKeepFiles()), - myWorkingDirectory(DefaultWorkingDirectory()), - myVerboseLevel(DefaultVerboseLevel()), - myToCreateNewNodes(DefaultToCreateNewNodes()), - myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()), - myToUseFemCorrection(DefaultToUseFEMCorrection()), - myToRemoveCentralPoint(DefaultToRemoveCentralPoint()), - myLogInStandardOutput(DefaultStandardOutputLog()), - myGradation(DefaultGradation()), - _enfVertexList(DefaultGHS3DEnforcedVertexList()), - _enfVertexCoordsSizeList(DefaultGHS3DEnforcedVertexCoordsValues()), - _enfVertexEntrySizeList(DefaultGHS3DEnforcedVertexEntryValues()), - _coordsEnfVertexMap(DefaultCoordsGHS3DEnforcedVertexMap()), - _geomEntryEnfVertexMap(DefaultGeomEntryGHS3DEnforcedVertexMap()), - _enfMeshList(DefaultGHS3DEnforcedMeshList()), - _entryEnfMeshMap(DefaultEntryGHS3DEnforcedMeshListMap()), - _enfNodes(TIDSortedNodeGroupMap()), - _enfEdges(TIDSortedElemGroupMap()), - _enfTriangles(TIDSortedElemGroupMap()), - _nodeIDToSizeMap(DefaultID2SizeMap()), - _groupsToRemove(DefaultGroupsToRemove()) + myToMeshHoles(DefaultMeshHoles()), + myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()), + myMaximumMemory(-1), + myInitialMemory(-1), + myOptimizationLevel(DefaultOptimizationLevel()), + myKeepFiles(DefaultKeepFiles()), + myWorkingDirectory(DefaultWorkingDirectory()), + myVerboseLevel(DefaultVerboseLevel()), + myToCreateNewNodes(DefaultToCreateNewNodes()), + myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()), + myToUseFemCorrection(DefaultToUseFEMCorrection()), + myToRemoveCentralPoint(DefaultToRemoveCentralPoint()), + myLogInStandardOutput(DefaultStandardOutputLog()), + myRemoveLogOnSuccess(DefaultRemoveLogOnSuccess()), + myGradation(DefaultGradation()), + _enfVertexList(DefaultGHS3DEnforcedVertexList()), + _enfVertexCoordsSizeList(DefaultGHS3DEnforcedVertexCoordsValues()), + _enfVertexEntrySizeList(DefaultGHS3DEnforcedVertexEntryValues()), + _coordsEnfVertexMap(DefaultCoordsGHS3DEnforcedVertexMap()), + _geomEntryEnfVertexMap(DefaultGeomEntryGHS3DEnforcedVertexMap()), + _enfMeshList(DefaultGHS3DEnforcedMeshList()), + _entryEnfMeshMap(DefaultEntryGHS3DEnforcedMeshListMap()), + _enfNodes(TIDSortedNodeGroupMap()), + _enfEdges(TIDSortedElemGroupMap()), + _enfTriangles(TIDSortedElemGroupMap()), + _nodeIDToSizeMap(DefaultID2SizeMap()), + _groupsToRemove(DefaultGroupsToRemove()) { _name = GetHypType(); _param_algo_dim = 3; @@ -628,7 +629,6 @@ bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM nodeRet = _enfNodes.insert(make_pair(node,groupName)); added = added && nodeRet.second; } -// added = true;s } break; case SMESH::EDGE: @@ -637,12 +637,12 @@ bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM added = added && elemRet.second; } else if (elem->GetType() > SMDSAbs_Edge) { - SMDS_ElemIteratorPtr it = elem->edgesIterator(); - for (;it->more();) { - const SMDS_MeshElement* anEdge = it->next(); - elemRet = _enfEdges.insert(make_pair(anEdge,groupName)); - added = added && elemRet.second; - } + // SMDS_ElemIteratorPtr it = elem->edgesIterator(); + // for (;it->more();) { + // const SMDS_MeshElement* anEdge = it->next(); + // elemRet = _enfEdges.insert(make_pair(anEdge,groupName)); + // added = added && elemRet.second; + // } } break; case SMESH::FACE: @@ -654,14 +654,14 @@ bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SM } } 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->NbCornerNodes() == 3) { - elemRet = _enfTriangles.insert(make_pair(aFace,groupName)); - added = added && elemRet.second; - } - } + // SMDS_ElemIteratorPtr it = elem->facesIterator(); + // for (;it->more();) { + // const SMDS_MeshElement* aFace = it->next(); + // if (aFace->NbCornerNodes() == 3) { + // elemRet = _enfTriangles.insert(make_pair(aFace,groupName)); + // added = added && elemRet.second; + // } + // } } break; default: diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index f2e5a8a..951a050 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -111,7 +111,7 @@ public: struct TIDMeshIDCompare { bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const - { return e1->getMeshId() == e2->getMeshId() ? e1->GetID() < e2->GetID() : e1->getMeshId() < e2->getMeshId() ; } + { return e1->GetMesh() == e2->GetMesh() ? e1->GetID() < e2->GetID() : e1->GetMesh() < e2->GetMesh() ; } }; typedef std::map TIDSortedElemGroupMap; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx index a2ef475..99a7d8a 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Optimizer.cxx @@ -164,7 +164,7 @@ namespace SMESHDS_Mesh* meshDS = theHelper->GetMeshDS(); if ( meshDS->NbNodes() != meshDS->MaxNodeID() ) - meshDS->compactMesh(); + meshDS->CompactMesh(); theMGInput->GmfSetKwd( mfile, GmfVertices, meshDS->NbNodes() ); int TypTab[] = { GmfSca };