Fix crashes caused by mesh compacting

This commit is contained in:
eap 2017-09-28 17:47:26 +03:00
parent 25c9e04a61
commit e1969210a9
2 changed files with 21 additions and 11 deletions

View File

@ -23,8 +23,11 @@ Mesh_1.Compute()
# define arguments for MakePolyLine # define arguments for MakePolyLine
segments = [] segments = []
# between nodes 20 and 1, default plane
segments.append( SMESH.PolySegment( 20, 0, 1, 0, smesh.MakeDirStruct(0,0,0) )) segments.append( SMESH.PolySegment( 20, 0, 1, 0, smesh.MakeDirStruct(0,0,0) ))
# between nodes 1 and 100, default plane
segments.append( SMESH.PolySegment( 1, 0, 200, 0, smesh.MakeDirStruct(0,0,0) )) segments.append( SMESH.PolySegment( 1, 0, 200, 0, smesh.MakeDirStruct(0,0,0) ))
# between nodes 200 and edge (578, 577), plane includes vector (1,1,1)
segments.append( SMESH.PolySegment( 200, 0, 578, 577, smesh.MakeDirStruct(1,1,1) )) segments.append( SMESH.PolySegment( 200, 0, 578, 577, smesh.MakeDirStruct(1,1,1) ))
Mesh_1.MakePolyLine( segments, "1D group") Mesh_1.MakePolyLine( segments, "1D group")

View File

@ -12878,19 +12878,23 @@ namespace // utils for MakePolyLine
void Path::Remove( std::vector< Path > & paths, size_t& i ) void Path::Remove( std::vector< Path > & paths, size_t& i )
{ {
size_t j = paths.size() - 1; // last item to be removed if ( paths.size() > 1 )
if ( i < j )
{ {
paths[ i ].myPoints.swap( paths[ j ].myPoints ); size_t j = paths.size() - 1; // last item to be removed
paths[ i ].myFace = paths[ j ].myFace; if ( i < j )
paths[ i ].myNodeInd1 = paths[ j ].myNodeInd1; {
paths[ i ].myNodeInd2 = paths[ j ].myNodeInd2; paths[ i ].myPoints.swap( paths[ j ].myPoints );
paths[ i ].myNode1 = paths[ j ].myNode1; paths[ i ].myFace = paths[ j ].myFace;
paths[ i ].myNode2 = paths[ j ].myNode2; paths[ i ].myNodeInd1 = paths[ j ].myNodeInd1;
paths[ i ].myLength = paths[ j ].myLength; paths[ i ].myNodeInd2 = paths[ j ].myNodeInd2;
paths[ i ].myNode1 = paths[ j ].myNode1;
paths[ i ].myNode2 = paths[ j ].myNode2;
paths[ i ].myLength = paths[ j ].myLength;
}
} }
paths.pop_back(); paths.pop_back();
--i; if ( i > 0 )
--i;
} }
//================================================================================ //================================================================================
@ -13183,7 +13187,7 @@ void SMESH_MeshEditor::MakePolyLine( TListOfPolySegments& theSegments,
SMESHUtils::Deleter<SMESH_ElementSearcher> delSearcher; SMESHUtils::Deleter<SMESH_ElementSearcher> delSearcher;
if ( !searcher ) if ( !searcher )
{ {
searcher = SMESH_MeshAlgos::GetElementSearcher( *myMesh->GetMeshDS() ); searcher = SMESH_MeshAlgos::GetElementSearcher( *GetMeshDS() );
delSearcher._obj = searcher; delSearcher._obj = searcher;
} }
@ -13217,6 +13221,9 @@ void SMESH_MeshEditor::MakePolyLine( TListOfPolySegments& theSegments,
} }
} }
// assure that inverse elements are constructed, avoid their concurrent building in threads
GetMeshDS()->nodesIterator()->next()->NbInverseElements();
// find paths // find paths
PolyPathCompute algo( theSegments, segPaths, myMesh ); PolyPathCompute algo( theSegments, segPaths, myMesh );