23418: [OCC] Mesh: Minimization of memory usage of SMESH

This commit is contained in:
eap 2017-12-22 14:16:51 +03:00
parent 34f646e465
commit 5015755559
3 changed files with 21 additions and 14 deletions

View File

@ -1375,9 +1375,11 @@ bool NETGENPlugin_Mesher::FillNgMesh(netgen::OCCGeometry& occgeom,
PShapeIteratorPtr solidIt=helper.GetAncestors(geomFace,*sm->GetFather(),TopAbs_SOLID); PShapeIteratorPtr solidIt=helper.GetAncestors(geomFace,*sm->GetFather(),TopAbs_SOLID);
if ( const TopoDS_Shape * solid = solidIt->next() ) if ( const TopoDS_Shape * solid = solidIt->next() )
sm = _mesh->GetSubMesh( *solid ); sm = _mesh->GetSubMesh( *solid );
SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); SMESH_BadInputElements* badElems =
smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle sub-mesh")); new SMESH_BadInputElements( helper.GetMeshDS(), COMPERR_BAD_INPUT_MESH,
smError->myBadElements.push_back( f ); "Not triangle sub-mesh");
badElems->add( f );
sm->GetComputeError().reset( badElems );
return false; return false;
} }
@ -3318,7 +3320,7 @@ bool NETGENPlugin_Mesher::Compute()
_mesh->GetMeshDS()->RemoveFreeNode( nodeVec[i], 0, /*fromGroups=*/false ); _mesh->GetMeshDS()->RemoveFreeNode( nodeVec[i], 0, /*fromGroups=*/false );
} }
SMESH_ComputeErrorPtr readErr = ReadErrors(nodeVec); SMESH_ComputeErrorPtr readErr = ReadErrors(nodeVec);
if ( readErr && !readErr->myBadElements.empty() ) if ( readErr && readErr->HasBadElems() )
{ {
error = readErr; error = readErr;
if ( !comment.empty() && !readErr->myComment.empty() ) comment += "\n"; if ( !comment.empty() && !readErr->myComment.empty() ) comment += "\n";
@ -3380,9 +3382,10 @@ bool NETGENPlugin_Mesher::Compute()
{ {
smError->myName = COMPERR_WARNING; smError->myName = COMPERR_WARNING;
} }
else if ( !smError->myBadElements.empty() ) // bad surface mesh else if ( smError->HasBadElems() ) // bad surface mesh
{ {
if ( !hasBadElemOnSolid( smError->myBadElements, sm )) if ( !hasBadElemOnSolid
( static_cast<SMESH_BadInputElements*>( smError.get() )->myBadElements, sm ))
smError.reset(); smError.reset();
} }
} }
@ -3712,8 +3715,10 @@ double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* holder,
SMESH_ComputeErrorPtr SMESH_ComputeErrorPtr
NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec) NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
{ {
SMESH_ComputeErrorPtr err = SMESH_ComputeError::New if ( nodeVec.size() < 2 ) return SMESH_ComputeErrorPtr();
(COMPERR_BAD_INPUT_MESH, "Some edges multiple times in surface mesh"); SMESH_BadInputElements* err =
new SMESH_BadInputElements( nodeVec.back()->GetMesh(), COMPERR_BAD_INPUT_MESH,
"Some edges multiple times in surface mesh");
SMESH_File file("test.out"); SMESH_File file("test.out");
vector<int> two(2); vector<int> two(2);
vector<int> three1(3), three2(3); vector<int> three1(3), three2(3);
@ -3773,7 +3778,7 @@ NETGENPlugin_Mesher::ReadErrors(const vector<const SMDS_MeshNode* >& nodeVec)
if ( nbBadElems ) nbBadElems++; // avoid warning: variable set but not used if ( nbBadElems ) nbBadElems++; // avoid warning: variable set but not used
#endif #endif
return err; return SMESH_ComputeErrorPtr( err );
} }
//================================================================================ //================================================================================

View File

@ -538,7 +538,7 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
if ( err ) if ( err )
{ {
SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec); SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec);
if ( ce && !ce->myBadElements.empty() ) if ( ce && ce->HasBadElems() )
error( ce ); error( ce );
} }

View File

@ -109,7 +109,8 @@ namespace
{ {
// set bad faces into a compute error // set bad faces into a compute error
const char* text = "Non-manifold mesh. Only manifold mesh can be re-meshed"; const char* text = "Non-manifold mesh. Only manifold mesh can be re-meshed";
SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text ); SMESH_BadInputElements* error =
new SMESH_BadInputElements( myMeshDS, COMPERR_BAD_INPUT_MESH, text );
SMESH::Controls::MultiConnection2D fun; SMESH::Controls::MultiConnection2D fun;
fun.SetMesh( myMeshDS ); fun.SetMesh( myMeshDS );
SMDS_ElemIteratorPtr fIt = myMeshDS->elementsIterator( SMDSAbs_Face ); SMDS_ElemIteratorPtr fIt = myMeshDS->elementsIterator( SMDSAbs_Face );
@ -119,7 +120,7 @@ namespace
if ( fun.GetValue( f->GetID() ) > 2 ) if ( fun.GetValue( f->GetID() ) > 2 )
error->myBadElements.push_back( f ); error->myBadElements.push_back( f );
} }
theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error; theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError().reset( error );
throw SALOME_Exception( text ); throw SALOME_Exception( text );
} }
@ -153,12 +154,13 @@ namespace
if ( !freeBords._coincidentGroups.empty() ) if ( !freeBords._coincidentGroups.empty() )
{ {
const char* text = "Can't re-meshed a mesh with coincident free edges"; const char* text = "Can't re-meshed a mesh with coincident free edges";
SMESH_ComputeErrorPtr error = SMESH_ComputeError::New( COMPERR_BAD_INPUT_MESH, text ); SMESH_BadInputElements* error =
new SMESH_BadInputElements( myMeshDS, COMPERR_BAD_INPUT_MESH, text );
for ( size_t i = 0; i < freeBords._borders.size(); ++i ) for ( size_t i = 0; i < freeBords._borders.size(); ++i )
error->myBadElements.insert( error->myBadElements.end(), error->myBadElements.insert( error->myBadElements.end(),
freeBords._borders[i].begin(), freeBords._borders[i].begin(),
freeBords._borders[i].end() ); freeBords._borders[i].end() );
theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError() = error; theMesh.GetSubMesh( theMesh.GetShapeToMesh() )->GetComputeError().reset( error );
throw SALOME_Exception( text ); throw SALOME_Exception( text );
} }
} }