23315: [CEA 1929] Too much memory used to display a mesh in shading and wireframe

Use my1DActor only to show edge numbers and controls of all edges
       => 10% decrease memory usage
This commit is contained in:
eap 2016-11-18 19:39:59 +03:00
parent 270d55cf05
commit d053feed93
3 changed files with 92 additions and 92 deletions

View File

@ -323,6 +323,10 @@ SMESH_ActorDef::SMESH_ActorDef()
myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
myEdgeProp->SetLineWidth(aLineWidth); myEdgeProp->SetLineWidth(aLineWidth);
// my1DActor is used to
// - show numbers
// - show controls on all edges (eg Length)
// since edges are shown by myHighlitableActor
my1DActor = SMESH_CellLabelActor::New(); my1DActor = SMESH_CellLabelActor::New();
my1DActor->SetStoreClippingMapping(true); my1DActor->SetStoreClippingMapping(true);
my1DActor->SetUserMatrix(aMatrix); my1DActor->SetUserMatrix(aMatrix);
@ -350,6 +354,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc); my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
my1DExtProp->SetPointSize(aElem0DSize); my1DExtProp->SetPointSize(aElem0DSize);
// my1DExtActor is used to show filtered edges or links between nodes
my1DExtActor = SMESH_DeviceActor::New(); my1DExtActor = SMESH_DeviceActor::New();
my1DExtActor->SetUserMatrix(aMatrix); my1DExtActor->SetUserMatrix(aMatrix);
my1DExtActor->PickableOff(); my1DExtActor->PickableOff();
@ -995,8 +1000,7 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
return; return;
} }
vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid(); int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
vtkIdType aNbCells = aGrid->GetNumberOfCells();
bool aShowOnlyScalarBarTitle = false; bool aShowOnlyScalarBarTitle = false;
if(aNbCells) { if(aNbCells) {
myControlMode = theMode; myControlMode = theMode;
@ -1055,25 +1059,13 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
SetEntityMode(eEdges); SetEntityMode(eEdges);
} }
else if(myControlActor == my2DActor) { else if(myControlActor == my2DActor) {
switch(myControlMode) {
case eLength2D:
case eFreeEdges:
case eFreeFaces:
case eMultiConnection2D:
if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true;
}
SetEntityMode(eFaces);
break;
default:
if (!myIsEntityModeCache){ if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode(); myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true; myIsEntityModeCache=true;
} }
SetEntityMode(eFaces); SetEntityMode(eFaces);
} }
}else if(myControlActor == my3DActor) { else if(myControlActor == my3DActor) {
if (!myIsEntityModeCache){ if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode(); myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true; myIsEntityModeCache=true;
@ -1487,9 +1479,15 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
case eCoincidentNodes: case eCoincidentNodes:
myNodeExtActor->VisibilityOn(); myNodeExtActor->VisibilityOn();
break; break;
case eLength:
case eMultiConnection:
my1DActor->VisibilityOn();
break;
case eFreeEdges: case eFreeEdges:
case eFreeBorders: case eFreeBorders:
case eCoincidentElems1D: case eCoincidentElems1D:
case eLength2D:
case eMultiConnection2D:
my1DExtActor->VisibilityOn(); my1DExtActor->VisibilityOn();
break; break;
case eFreeFaces: case eFreeFaces:
@ -1503,40 +1501,32 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
case eCoincidentElems3D: case eCoincidentElems3D:
my3DExtActor->VisibilityOn(); my3DExtActor->VisibilityOn();
break; break;
case eLength2D:
case eMultiConnection2D:
my1DExtActor->VisibilityOn();
break;
default:; default:;
} }
if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells()) if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
myScalarBarActor->VisibilityOn(); myScalarBarActor->VisibilityOn();
} }
if(myRepresentation != ePoint)
myPickableActor->VisibilityOn(); myPickableActor->VisibilityOn();
else {
myNodeActor->VisibilityOn();
}
if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){ if ( GetRepresentation() != ePoint )
{
if(myEntityMode & e0DElements ){
my0DActor->VisibilityOn(); my0DActor->VisibilityOn();
} }
if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){ if(myEntityMode & eBallElem ){
myBallActor->VisibilityOn(); myBallActor->VisibilityOn();
} }
if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
if(myEntityMode & eEdges && GetRepresentation() != ePoint){
my1DActor->VisibilityOn(); my1DActor->VisibilityOn();
} }
if(myEntityMode & eFaces ){
if(myEntityMode & eFaces && GetRepresentation() != ePoint){
my2DActor->VisibilityOn(); my2DActor->VisibilityOn();
} }
if(myEntityMode & eVolumes ){
if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
my3DActor->VisibilityOn(); my3DActor->VisibilityOn();
} }
}
if(myNodeActor->GetPointsLabeled()){ if(myNodeActor->GetPointsLabeled()){
myNodeActor->VisibilityOn(); myNodeActor->VisibilityOn();
@ -1750,8 +1740,6 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
} }
myPickableActor = myBaseActor; myPickableActor = myBaseActor;
myNodeActor->SetVisibility(false);
myNodeExtActor->SetVisibility(false);
vtkProperty *aProp = NULL, *aBackProp = NULL; vtkProperty *aProp = NULL, *aBackProp = NULL;
vtkProperty *aPropVN = NULL, *aPropVR = NULL; vtkProperty *aPropVN = NULL, *aPropVR = NULL;
SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1); SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
@ -1759,7 +1747,6 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
switch (myRepresentation) { switch (myRepresentation) {
case ePoint: case ePoint:
myPickableActor = myNodeActor; myPickableActor = myNodeActor;
myNodeActor->SetVisibility(true);
aQuadraticMode = SMESH_Actor::eLines; aQuadraticMode = SMESH_Actor::eLines;
aProp = aBackProp = aPropVN = aPropVR = myNodeProp; aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
aReperesent = SMESH_DeviceActor::ePoint; aReperesent = SMESH_DeviceActor::ePoint;
@ -1777,6 +1764,8 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
break; break;
} }
if ( myRepresentation != ePoint )
{
my2DActor->SetProperty(aProp); my2DActor->SetProperty(aProp);
my2DActor->SetBackfaceProperty(aBackProp); my2DActor->SetBackfaceProperty(aBackProp);
my2DActor->SetRepresentation(aReperesent); my2DActor->SetRepresentation(aReperesent);
@ -1792,11 +1781,6 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
my3DActor->SetBackfaceProperty(aPropVR); my3DActor->SetBackfaceProperty(aPropVR);
my3DActor->SetRepresentation(aReperesent); my3DActor->SetRepresentation(aReperesent);
my1DExtActor->SetVisibility(false);
my2DExtActor->SetVisibility(false);
my3DExtActor->SetVisibility(false);
my0DActor->SetRepresentation(aReperesent); my0DActor->SetRepresentation(aReperesent);
myBallActor->SetRepresentation(aReperesent); myBallActor->SetRepresentation(aReperesent);
@ -1820,11 +1804,10 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
my1DActor->SetRepresentation(aReperesent); my1DActor->SetRepresentation(aReperesent);
my1DExtActor->SetRepresentation(aReperesent); my1DExtActor->SetRepresentation(aReperesent);
}
if(myIsPointsVisible) if(myIsPointsVisible)
myPickableActor = myNodeActor; myPickableActor = myNodeActor;
if(GetPointRepresentation())
myNodeActor->SetVisibility(true);
SetMapper(myPickableActor->GetMapper()); SetMapper(myPickableActor->GetMapper());
@ -1886,6 +1869,7 @@ void SMESH_ActorDef::UpdateHighlight()
} }
myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint); myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
myNodeActor->GetProperty()->Modified();
break; break;
} }
} }

View File

@ -198,7 +198,8 @@ void SMESH_CellLabelActor::RemoveFromRender(vtkRenderer* theRenderer)
SMESH_DeviceActor::RemoveFromRender(theRenderer); SMESH_DeviceActor::RemoveFromRender(theRenderer);
} }
void SMESH_CellLabelActor::UpdateLabels() { void SMESH_CellLabelActor::UpdateLabels()
{
if(myIsCellsLabeled) if(myIsCellsLabeled)
SetCellsLabeled(myIsCellsLabeled); SetCellsLabeled(myIsCellsLabeled);
} }
@ -207,7 +208,8 @@ void SMESH_CellLabelActor::UpdateLabels() {
void SMESH_CellLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject), void SMESH_CellLabelActor::ProcessEvents(vtkObject* vtkNotUsed(theObject),
unsigned long theEvent, unsigned long theEvent,
void* theClientData, void* theClientData,
void* vtkNotUsed(theCallData)) { void* vtkNotUsed(theCallData))
{
SMESH_CellLabelActor* self = reinterpret_cast<SMESH_CellLabelActor*>(theClientData); SMESH_CellLabelActor* self = reinterpret_cast<SMESH_CellLabelActor*>(theClientData);
if(self) if(self)
self->UpdateLabels(); self->UpdateLabels();

View File

@ -88,7 +88,7 @@ SMESH_DeviceActor
myIsShrunk = false; myIsShrunk = false;
myIsHighlited = false; myIsHighlited = false;
myRepresentation = eSurface; myRepresentation = SMESH_DeviceActor::EReperesent(-1);
myProperty = vtkProperty::New(); myProperty = vtkProperty::New();
myMapper = VTKViewer_PolyDataMapper::New(); myMapper = VTKViewer_PolyDataMapper::New();
@ -306,7 +306,7 @@ SMESH_DeviceActor
vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
// SetStoreIDMapping(true); // SetStoreIDMapping(true);
// myExtractUnstructuredGrid->Update(); myExtractUnstructuredGrid->Update();
vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput(); vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
aDataSet->ShallowCopy(aGrid); aDataSet->ShallowCopy(aGrid);
@ -619,7 +619,19 @@ unsigned long int
SMESH_DeviceActor SMESH_DeviceActor
::GetMTime() ::GetMTime()
{ {
// cout << this->myExtractUnstructuredGrid // cout << "DA " << this
// << " GF " << myGeomFilter;
// if ( this->Property )
// cout << " P " << this->Property->GetMTime();
// if ( this->BackfaceProperty != NULL )
// cout << " BP " << BackfaceProperty->GetMTime();
// if ( this->Texture != NULL )
// cout << " T " << this->Texture->GetMTime();
// cout << " U " << this->GetUserTransformMatrixMTime()
// << " M " << this->MTime.GetMTime() << endl;
// cout << "DA " << this
// << " GF " << myGeomFilter
// << " " << this->Superclass::GetMTime() // << " " << this->Superclass::GetMTime()
// << " " << myExtractGeometry->GetMTime() // << " " << myExtractGeometry->GetMTime()
// << " " << myExtractUnstructuredGrid->GetMTime() // << " " << myExtractUnstructuredGrid->GetMTime()
@ -745,6 +757,8 @@ void
SMESH_DeviceActor SMESH_DeviceActor
::SetRepresentation(EReperesent theMode) ::SetRepresentation(EReperesent theMode)
{ {
if ( myRepresentation == theMode )
return;
switch(theMode){ switch(theMode){
case ePoint: case ePoint:
myGeomFilter->SetInside(true); myGeomFilter->SetInside(true);