mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-03-16 01:41:27 +05:00
fix FindShape() to resolve a regression of SMESH_TEST/Grids/smesh/bugs/L9
This commit is contained in:
parent
2db2c3ab90
commit
5a57da6b1e
@ -365,46 +365,56 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem)
|
|||||||
if ( aMesh->ShapeToMesh().IsNull() )
|
if ( aMesh->ShapeToMesh().IsNull() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( theElem->GetType() == SMDSAbs_Node )
|
|
||||||
{
|
|
||||||
int aShapeID = theElem->getshapeId();
|
int aShapeID = theElem->getshapeId();
|
||||||
if (aShapeID <= 0)
|
if ( aShapeID < 1 )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
|
||||||
|
if ( SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID ))
|
||||||
|
if ( sm->Contains( theElem ))
|
||||||
return aShapeID;
|
return aShapeID;
|
||||||
|
|
||||||
|
if ( theElem->GetType() == SMDSAbs_Node ) {
|
||||||
|
MESSAGE( ":( Error: invalid myShapeId of node " << theElem->GetID() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MESSAGE( ":( Error: invalid myShapeId of element " << theElem->GetID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TopoDS_Shape aShape; // the shape a node is on
|
TopoDS_Shape aShape; // the shape a node of theElem is on
|
||||||
|
if ( theElem->GetType() != SMDSAbs_Node )
|
||||||
|
{
|
||||||
SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator();
|
SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator();
|
||||||
while ( nodeIt->more() ) {
|
while ( nodeIt->more() ) {
|
||||||
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
|
const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
|
||||||
int aShapeID = node->getshapeId();
|
if ((aShapeID = node->getshapeId()) > 0) {
|
||||||
if (aShapeID > 0) {
|
if ( SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID ) ) {
|
||||||
SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID );
|
|
||||||
if ( sm ) {
|
|
||||||
if ( sm->Contains( theElem ))
|
if ( sm->Contains( theElem ))
|
||||||
return aShapeID;
|
return aShapeID;
|
||||||
if ( aShape.IsNull() )
|
if ( aShape.IsNull() )
|
||||||
aShape = aMesh->IndexToShape( aShapeID );
|
aShape = aMesh->IndexToShape( aShapeID );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
//MESSAGE ( "::FindShape() No SubShape for aShapeID " << aShapeID );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// None of nodes is on a proper shape,
|
// None of nodes is on a proper shape,
|
||||||
// find the shape among ancestors of aShape on which a node is
|
// find the shape among ancestors of aShape on which a node is
|
||||||
if ( aShape.IsNull() ) {
|
if ( !aShape.IsNull() ) {
|
||||||
//MESSAGE ("::FindShape() - NONE node is on shape")
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
TopTools_ListIteratorOfListOfShape ancIt( GetMesh()->GetAncestors( aShape ));
|
TopTools_ListIteratorOfListOfShape ancIt( GetMesh()->GetAncestors( aShape ));
|
||||||
for ( ; ancIt.More(); ancIt.Next() ) {
|
for ( ; ancIt.More(); ancIt.Next() ) {
|
||||||
SMESHDS_SubMesh * sm = aMesh->MeshElements( ancIt.Value() );
|
SMESHDS_SubMesh * sm = aMesh->MeshElements( ancIt.Value() );
|
||||||
if ( sm && sm->Contains( theElem ))
|
if ( sm && sm->Contains( theElem ))
|
||||||
return aMesh->ShapeToIndex( ancIt.Value() );
|
return aMesh->ShapeToIndex( ancIt.Value() );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const map<int,SMESHDS_SubMesh*>& id2sm = GetMeshDS()->SubMeshes();
|
||||||
|
map<int,SMESHDS_SubMesh*>::const_iterator id_sm = id2sm.begin();
|
||||||
|
for ( ; id_sm != id2sm.end(); ++id_sm )
|
||||||
|
if ( id_sm->second->Contains( theElem ))
|
||||||
|
return id_sm->first;
|
||||||
|
}
|
||||||
|
|
||||||
//MESSAGE ("::FindShape() - SHAPE NOT FOUND")
|
//MESSAGE ("::FindShape() - SHAPE NOT FOUND")
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user