IPAL53919: Pb with nodes after element removal

This commit is contained in:
eap 2017-02-01 17:41:37 +03:00
parent 2e5f78b7d2
commit b99e203236
4 changed files with 118 additions and 99 deletions

View File

@ -126,6 +126,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myIsPointsVisible = false; myIsPointsVisible = false;
myIsEntityModeCache = false; myIsEntityModeCache = false;
myRepresentationCache = 0;
myHighlightActor = SMESH_SVTKActor::New(); myHighlightActor = SMESH_SVTKActor::New();
myHighlightActor->Delete(); // vtkSmartPointer! myHighlightActor->Delete(); // vtkSmartPointer!
@ -1559,30 +1560,30 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
void SMESH_ActorDef::SetEntityMode(unsigned int theMode) void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
{ {
myEntityState = eAllEntity; // entities present in my object unsigned int anObjectEntities = eAllEntity; // entities present in my object
if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) { if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
myEntityState &= ~e0DElements; anObjectEntities &= ~e0DElements;
theMode &= ~e0DElements; theMode &= ~e0DElements;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) { if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
myEntityState &= ~eBallElem; anObjectEntities &= ~eBallElem;
theMode &= ~eBallElem; theMode &= ~eBallElem;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) { if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
myEntityState &= ~eEdges; anObjectEntities &= ~eEdges;
theMode &= ~eEdges; theMode &= ~eEdges;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) { if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
myEntityState &= ~eFaces; anObjectEntities &= ~eFaces;
theMode &= ~eFaces; theMode &= ~eFaces;
} }
if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) { if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
myEntityState &= ~eVolumes; anObjectEntities &= ~eVolumes;
theMode &= ~eVolumes; theMode &= ~eVolumes;
} }
@ -1603,34 +1604,39 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
theMode |= eVolumes; theMode |= eVolumes;
} }
myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState); myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
{
myRepresentationCache = GetRepresentation();
SetRepresentation( ePoint );
}
if ( myEntityMode != theMode )
{
myEntityMode = theMode; // entities to show myEntityMode = theMode; // entities to show
VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid(); // Set cell types to extract
aFilter->ClearRegisteredCellsWithType();
VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
aHightFilter->ClearRegisteredCellsWithType();
bool isPassAll = VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
(( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) && VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) && aFilter->ClearRegisteredCellsWithType();
( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) && aHltFilter->ClearRegisteredCellsWithType();
( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) &&
( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 )); bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
if ( isPassAll && myEntityMode ) if ( isPassAll )
{ {
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
} }
else else
{ {
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
if (myEntityMode & e0DElements) { if (myEntityMode & e0DElements) {
aFilter->RegisterCellsWithType(VTK_VERTEX); aFilter->RegisterCellsWithType(VTK_VERTEX);
aHightFilter->RegisterCellsWithType(VTK_VERTEX); aHltFilter->RegisterCellsWithType(VTK_VERTEX);
} }
if (myEntityMode & eBallElem) { if (myEntityMode & eBallElem) {
@ -1641,8 +1647,8 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
aHightFilter->RegisterCellsWithType(VTK_LINE); aHltFilter->RegisterCellsWithType(VTK_LINE);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
} }
if (myEntityMode & eFaces) { if (myEntityMode & eFaces) {
@ -1655,14 +1661,14 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
aHightFilter->RegisterCellsWithType(VTK_TRIANGLE); aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
aHightFilter->RegisterCellsWithType(VTK_QUAD); aHltFilter->RegisterCellsWithType(VTK_QUAD);
aHightFilter->RegisterCellsWithType(VTK_POLYGON); aHltFilter->RegisterCellsWithType(VTK_POLYGON);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD); aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE); aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
} }
if (myEntityMode & eVolumes) { if (myEntityMode & eVolumes) {
@ -1680,25 +1686,27 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
aFilter->RegisterCellsWithType(VTK_POLYHEDRON); aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
aHightFilter->RegisterCellsWithType(VTK_TETRA); aHltFilter->RegisterCellsWithType(VTK_TETRA);
aHightFilter->RegisterCellsWithType(VTK_VOXEL); aHltFilter->RegisterCellsWithType(VTK_VOXEL);
aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
aHightFilter->RegisterCellsWithType(VTK_WEDGE); aHltFilter->RegisterCellsWithType(VTK_WEDGE);
aHightFilter->RegisterCellsWithType(VTK_PYRAMID); aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM); aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON); aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID); aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET); aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON); aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
} }
} }
if ( GetVisibility() ) if ( GetVisibility() )
aFilter->Update(); aFilter->Update();
if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells()); if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
SetVisibility(GetVisibility(),false); }
SetVisibility( GetVisibility(), myRepresentationCache != 0 );
} }
void SMESH_ActorDef::SetRepresentation (int theMode) void SMESH_ActorDef::SetRepresentation (int theMode)
@ -1709,6 +1717,15 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement); int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball); int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
{
theMode = myRepresentationCache;
if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
theMode = eEdge;
else
myRepresentationCache = 0;
}
if (theMode < 0) { if (theMode < 0) {
myRepresentation = eSurface; myRepresentation = eSurface;
if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) { if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {

View File

@ -295,8 +295,8 @@ class SMESH_ActorDef : public SMESH_Actor
SMESH_DeviceActor* my0DExtActor; SMESH_DeviceActor* my0DExtActor;
unsigned int myEntityMode; unsigned int myEntityMode;
unsigned int myEntityState;
unsigned int myEntityModeCache; unsigned int myEntityModeCache;
int myRepresentationCache;
bool myIsEntityModeCache; bool myIsEntityModeCache;
bool myIsPointsVisible; bool myIsPointsVisible;

View File

@ -714,6 +714,7 @@ SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
} }
} }
HasModificationsToDiscard(); // to reset _isModified flag if a mesh becomes empty HasModificationsToDiscard(); // to reset _isModified flag if a mesh becomes empty
GetMeshDS()->Modified();
if(MYDEBUG) subMesh->DumpAlgoState(true); if(MYDEBUG) subMesh->DumpAlgoState(true);
if(MYDEBUG) SCRUTE(ret); if(MYDEBUG) SCRUTE(ret);
@ -784,6 +785,7 @@ SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
} }
HasModificationsToDiscard(); // to reset _isModified flag if mesh become empty HasModificationsToDiscard(); // to reset _isModified flag if mesh become empty
GetMeshDS()->Modified();
if(MYDEBUG) subMesh->DumpAlgoState(true); if(MYDEBUG) subMesh->DumpAlgoState(true);
if(MYDEBUG) SCRUTE(ret); if(MYDEBUG) SCRUTE(ret);

View File

@ -4493,7 +4493,7 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule ); popupMgr()->setRule( action( SMESHOp::OpDMShading ), "displayMode = 'eSurface'", QtxPopupMgr::ToggleRule );
popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 ); popupMgr()->insert( action( SMESHOp::OpDMNodes ), anId, -1 );
popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpDMNodes ), aMeshInVTK + "&&" + hasNodes + "&&" + hasElems, QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule ); popupMgr()->setRule( action( SMESHOp::OpDMNodes ), "displayMode = 'ePoint'", QtxPopupMgr::ToggleRule );
popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( separator(), anId, -1 );
@ -4532,7 +4532,7 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( separator(), anId, -1 );
popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 ); popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 );
popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + isNotEmpty, QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentElems, QtxPopupMgr::VisibleRule );
popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( separator(), anId, -1 );