mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
0021343: EDF 1930 SMESH: Huge memory occupation when assigning an hypothesis to a big model
This commit is contained in:
parent
d867e9b08b
commit
38b9ea6198
@ -17,16 +17,9 @@
|
|||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// SMESH OBJECT : interactive object for SMESH visualization
|
|
||||||
// File : SMESH_PreviewActorsCollection.cxx
|
|
||||||
// Author :
|
|
||||||
// Module : SMESH
|
|
||||||
//
|
|
||||||
#include "SMESH_PreviewActorsCollection.h"
|
#include "SMESH_PreviewActorsCollection.h"
|
||||||
|
|
||||||
#include "utilities.h"
|
#include <utilities.h>
|
||||||
|
|
||||||
#include "SALOME_InteractiveObject.hxx"
|
|
||||||
|
|
||||||
// OCC includes
|
// OCC includes
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
@ -39,14 +32,17 @@
|
|||||||
#include <vtkRenderer.h>
|
#include <vtkRenderer.h>
|
||||||
#include <vtkProperty.h>
|
#include <vtkProperty.h>
|
||||||
|
|
||||||
#include "VTKViewer_Actor.h"
|
#include <QSet>
|
||||||
|
|
||||||
#include "SVTK_DeviceActor.h"
|
// GEOM includes
|
||||||
#include "SALOME_Actor.h"
|
#include <GEOM_Actor.h>
|
||||||
|
|
||||||
// QT
|
// GUI includes
|
||||||
#include <QString>
|
#include <VTKViewer_Actor.h>
|
||||||
#include <QColor>
|
#include <SVTK_DeviceActor.h>
|
||||||
|
#include <SALOME_InteractiveObject.hxx>
|
||||||
|
#include <SUIT_ResourceMgr.h>
|
||||||
|
#include <SUIT_Session.h>
|
||||||
|
|
||||||
#ifdef _DEBUG_
|
#ifdef _DEBUG_
|
||||||
static int MYDEBUG = 0;
|
static int MYDEBUG = 0;
|
||||||
@ -54,38 +50,34 @@ static int MYDEBUG = 0;
|
|||||||
static int MYDEBUG = 0;
|
static int MYDEBUG = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
SMESH_PreviewActorsCollection::SMESH_PreviewActorsCollection() :
|
||||||
//vtkStandardNewMacro(SMESH_PreviewActorsCollection);
|
mySelector( 0 ), myRenderer( 0 ), myCurrentChunk( 0 ), myChunkSize( 0 ), myIsShown( true )
|
||||||
|
|
||||||
|
|
||||||
SMESH_PreviewActorsCollection
|
|
||||||
::SMESH_PreviewActorsCollection()
|
|
||||||
{
|
{
|
||||||
if(MYDEBUG) MESSAGE("SMESH_PreviewActorsCollection - "<<this);
|
if(MYDEBUG) MESSAGE("SMESH_PreviewActorsCollection - "<<this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SMESH_PreviewActorsCollection
|
SMESH_PreviewActorsCollection::~SMESH_PreviewActorsCollection()
|
||||||
::~SMESH_PreviewActorsCollection()
|
|
||||||
{
|
{
|
||||||
if(MYDEBUG) MESSAGE("~SMESH_PreviewActorsCollection - "<<this);
|
if(MYDEBUG) MESSAGE("~SMESH_PreviewActorsCollection - "<<this);
|
||||||
if (myRenderer)
|
clearActors();
|
||||||
RemoveFromRender(myRenderer);
|
|
||||||
|
|
||||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
|
||||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
|
||||||
if ( GEOM_Actor* anActor = iter.value() )
|
|
||||||
anActor->Delete();
|
|
||||||
myMapOfActors.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape, TopAbs_ShapeEnum theType, const QString& theEntry )
|
bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape,
|
||||||
|
TopAbs_ShapeEnum theType,
|
||||||
|
const QString& theEntry )
|
||||||
{
|
{
|
||||||
|
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
|
||||||
|
|
||||||
|
myType = theType;
|
||||||
|
myEntry = theEntry;
|
||||||
myMainShape = theShape;
|
myMainShape = theShape;
|
||||||
myMapOfActors.clear();
|
myMapOfActors.clear();
|
||||||
myMapOfShapes.Clear();
|
myMapOfShapes.Clear();
|
||||||
|
myIndices.clear();
|
||||||
|
myCurrentChunk = 0;
|
||||||
|
myChunkSize = mgr->integerValue( "SMESH", "preview_actor_chunk_size", 100 );
|
||||||
|
|
||||||
if ( theShape.IsNull() )
|
if ( theShape.IsNull() )
|
||||||
return false;
|
return false;
|
||||||
@ -95,65 +87,23 @@ bool SMESH_PreviewActorsCollection::Init( const TopoDS_Shape& theShape, TopAbs_S
|
|||||||
|
|
||||||
// get indexes of seleted elements
|
// get indexes of seleted elements
|
||||||
TopExp::MapShapes( theShape, myMapOfShapes );
|
TopExp::MapShapes( theShape, myMapOfShapes );
|
||||||
|
|
||||||
TopExp_Explorer exp( theShape, theType );
|
TopExp_Explorer exp( theShape, theType );
|
||||||
for ( ; exp.More(); exp.Next() ) {
|
QSet<int> indices;
|
||||||
int index = myMapOfShapes.FindIndex( exp.Current() );
|
for ( ; exp.More(); exp.Next() )
|
||||||
if ( index && !myMapOfActors.contains( index ) ) {
|
indices << myMapOfShapes.FindIndex( exp.Current() );
|
||||||
// create actor if the index is present
|
myIndices = indices.toList();
|
||||||
if ( GEOM_Actor* anActor = createActor( exp.Current().Oriented(TopAbs_FORWARD))) {
|
qSort(myIndices);
|
||||||
// Create new entry for actor
|
|
||||||
QString aString = theEntry;
|
|
||||||
aString += QString("_%1").arg( index ); // add index to actor entry
|
|
||||||
|
|
||||||
// Create interactive object
|
// show current chunk
|
||||||
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
showCurrentChunk();
|
||||||
anIO->setEntry( aString.toLatin1().constData() );
|
|
||||||
|
|
||||||
// Init Actor
|
return count() > 0;
|
||||||
anActor->SetVectorMode( theType==TopAbs_EDGE );
|
|
||||||
anActor->setIO( anIO );
|
|
||||||
anActor->SetSelector( mySelector );
|
|
||||||
anActor->SetPickable( true );
|
|
||||||
anActor->SetResolveCoincidentTopology( true );
|
|
||||||
|
|
||||||
// Add Actor to the Actors Map
|
|
||||||
myMapOfActors.insert(index, anActor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mySelector->ClearIObjects();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOM_Actor* SMESH_PreviewActorsCollection::createActor(const TopoDS_Shape& shape)
|
GEOM_Actor* SMESH_PreviewActorsCollection::createActor(const TopoDS_Shape& shape)
|
||||||
{
|
{
|
||||||
GEOM_Actor* actor = GEOM_Actor::New();
|
GEOM_Actor* actor = GEOM_Actor::New();
|
||||||
actor->SetShape( shape, 0, 0 );
|
actor->SetShape( shape, 0, 0 );
|
||||||
|
|
||||||
//Color Properties
|
|
||||||
/*
|
|
||||||
vtkProperty* aProp = vtkProperty::New();
|
|
||||||
vtkProperty* aHLProp = vtkProperty::New();
|
|
||||||
vtkProperty* aPHLProp = vtkProperty::New();
|
|
||||||
|
|
||||||
aProp->SetColor( 255, 0, 0);
|
|
||||||
actor->SetProperty(aProp);
|
|
||||||
|
|
||||||
aHLProp->SetColor( 255, 255, 255);
|
|
||||||
actor->SetHighlightProperty(aHLProp);
|
|
||||||
|
|
||||||
aPHLProp->SetColor( 155, 155, 155);
|
|
||||||
aPHLProp->SetLineWidth ( 3 );
|
|
||||||
aPHLProp->SetOpacity ( 0.75 );
|
|
||||||
actor->SetPreHighlightProperty(aPHLProp);
|
|
||||||
|
|
||||||
aProp->Delete();
|
|
||||||
aHLProp->Delete();
|
|
||||||
aPHLProp->Delete();
|
|
||||||
*/
|
|
||||||
|
|
||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,11 +122,14 @@ void SMESH_PreviewActorsCollection::AddToRender(vtkRenderer* theRenderer)
|
|||||||
myRenderer = theRenderer;
|
myRenderer = theRenderer;
|
||||||
|
|
||||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
for ( ; iter != myMapOfActors.end(); ++iter ) {
|
||||||
|
iter.value()->SetVisibility( myIsShown );
|
||||||
iter.value()->AddToRender( theRenderer );
|
iter.value()->AddToRender( theRenderer );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SMESH_PreviewActorsCollection::RemoveFromRender(vtkRenderer* theRenderer){
|
void SMESH_PreviewActorsCollection::RemoveFromRender(vtkRenderer* theRenderer)
|
||||||
|
{
|
||||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
for ( ; iter != myMapOfActors.end(); ++iter )
|
||||||
iter.value()->RemoveFromRender( theRenderer );
|
iter.value()->RemoveFromRender( theRenderer );
|
||||||
@ -187,20 +140,108 @@ void SMESH_PreviewActorsCollection::SetSelector(SVTK_Selector* theSelector)
|
|||||||
mySelector = theSelector;
|
mySelector = theSelector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_PreviewActorsCollection::HighlightAll( bool theHighlight ){
|
void SMESH_PreviewActorsCollection::HighlightAll( bool theHighlight )
|
||||||
|
{
|
||||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
for ( ; iter != myMapOfActors.end(); ++iter )
|
||||||
iter.value()->Highlight( theHighlight );
|
iter.value()->Highlight( theHighlight );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_PreviewActorsCollection::HighlightID( int index ){
|
void SMESH_PreviewActorsCollection::HighlightID( int index )
|
||||||
|
{
|
||||||
GEOM_Actor* anActor = GetActorByIndex( index );
|
GEOM_Actor* anActor = GetActorByIndex( index );
|
||||||
if ( anActor && !anActor->isHighlighted() )
|
if ( anActor && !anActor->isHighlighted() )
|
||||||
anActor->Highlight( true );
|
anActor->Highlight( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMESH_PreviewActorsCollection::SetShown( bool shown ){
|
void SMESH_PreviewActorsCollection::SetShown( bool shown )
|
||||||
|
{
|
||||||
|
myIsShown = shown;
|
||||||
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||||
for ( ; iter != myMapOfActors.end(); ++iter )
|
for ( ; iter != myMapOfActors.end(); ++iter )
|
||||||
iter.value()->SetVisibility( shown );
|
iter.value()->SetVisibility( shown );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SMESH_PreviewActorsCollection::count() const
|
||||||
|
{
|
||||||
|
return myIndices.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SMESH_PreviewActorsCollection::chunkSize() const
|
||||||
|
{
|
||||||
|
return myChunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SMESH_PreviewActorsCollection::currentChunk() const
|
||||||
|
{
|
||||||
|
return myCurrentChunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESH_PreviewActorsCollection::hasPrevious() const
|
||||||
|
{
|
||||||
|
return chunkSize() > 0 && currentChunk() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SMESH_PreviewActorsCollection::hasNext() const
|
||||||
|
{
|
||||||
|
return chunkSize() > 0 && (currentChunk()+1)*chunkSize() < count();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESH_PreviewActorsCollection::previous()
|
||||||
|
{
|
||||||
|
if ( !hasPrevious() ) return;
|
||||||
|
myCurrentChunk--;
|
||||||
|
showCurrentChunk();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESH_PreviewActorsCollection::next()
|
||||||
|
{
|
||||||
|
if ( !hasNext() ) return;
|
||||||
|
myCurrentChunk++;
|
||||||
|
showCurrentChunk();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESH_PreviewActorsCollection::showCurrentChunk()
|
||||||
|
{
|
||||||
|
clearActors();
|
||||||
|
int imin = currentChunk() * chunkSize();
|
||||||
|
int imax = std::min( (currentChunk()+1) * chunkSize(), count() );
|
||||||
|
for ( int i = imin; i < imax; i++ ) {
|
||||||
|
int index = myIndices[i];
|
||||||
|
if ( !index || myMapOfActors.contains( index ) ) continue;
|
||||||
|
TopoDS_Shape s = myMapOfShapes.FindKey( index );
|
||||||
|
if ( s.IsNull() ) continue;
|
||||||
|
// create actor if the index is present
|
||||||
|
if ( GEOM_Actor* anActor = createActor( s.Oriented(TopAbs_FORWARD))) {
|
||||||
|
// Create new entry for actor
|
||||||
|
QString entry = QString( "%1_%2" ).arg( myEntry ).arg( index );
|
||||||
|
// Create interactive object
|
||||||
|
Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
|
||||||
|
anIO->setEntry( entry.toLatin1().constData() );
|
||||||
|
// Init Actor
|
||||||
|
anActor->SetVectorMode( myType==TopAbs_EDGE );
|
||||||
|
anActor->setIO( anIO );
|
||||||
|
anActor->SetSelector( mySelector );
|
||||||
|
anActor->SetPickable( true );
|
||||||
|
anActor->SetResolveCoincidentTopology( true );
|
||||||
|
|
||||||
|
// Add Actor to the Actors Map
|
||||||
|
myMapOfActors.insert(index, anActor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mySelector->ClearIObjects();
|
||||||
|
if ( myRenderer )
|
||||||
|
AddToRender( myRenderer );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SMESH_PreviewActorsCollection::clearActors()
|
||||||
|
{
|
||||||
|
if (myRenderer)
|
||||||
|
RemoveFromRender(myRenderer);
|
||||||
|
|
||||||
|
QMap<int, GEOM_Actor*>::iterator iter = myMapOfActors.begin();
|
||||||
|
for ( ; iter != myMapOfActors.end(); ++iter )
|
||||||
|
if ( GEOM_Actor* anActor = iter.value() )
|
||||||
|
anActor->Delete();
|
||||||
|
myMapOfActors.clear();
|
||||||
|
}
|
||||||
|
@ -26,18 +26,18 @@
|
|||||||
#ifndef SMESH_PREVIEW_ACTOR_COLLECTION_H
|
#ifndef SMESH_PREVIEW_ACTOR_COLLECTION_H
|
||||||
#define SMESH_PREVIEW_ACTOR_COLLECTION_H
|
#define SMESH_PREVIEW_ACTOR_COLLECTION_H
|
||||||
|
|
||||||
#include "SMESH_Actor.h"
|
|
||||||
#include <GEOM_Actor.h>
|
|
||||||
#include "SMESH_Object.h"
|
#include "SMESH_Object.h"
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
#include <SMDS_SetIterator.hxx>
|
|
||||||
#include <TopAbs_ShapeEnum.hxx>
|
#include <TopAbs_ShapeEnum.hxx>
|
||||||
#include <TopTools_IndexedMapOfShape.hxx>
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
#include <QString>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class vtkRenderer;
|
class vtkRenderer;
|
||||||
class GEOM_Actor;
|
class GEOM_Actor;
|
||||||
|
class SVTK_Selector;
|
||||||
|
|
||||||
class SMESHOBJECT_EXPORT SMESH_PreviewActorsCollection
|
class SMESHOBJECT_EXPORT SMESH_PreviewActorsCollection
|
||||||
{
|
{
|
||||||
@ -61,15 +61,31 @@ class SMESHOBJECT_EXPORT SMESH_PreviewActorsCollection
|
|||||||
|
|
||||||
void SetShown( bool );
|
void SetShown( bool );
|
||||||
|
|
||||||
protected:
|
int count() const;
|
||||||
GEOM_Actor* createActor( const TopoDS_Shape& );
|
int chunkSize() const;
|
||||||
|
int currentChunk() const;
|
||||||
|
bool hasPrevious() const;
|
||||||
|
bool hasNext() const;
|
||||||
|
void previous();
|
||||||
|
void next();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
GEOM_Actor* createActor( const TopoDS_Shape& );
|
||||||
|
void showCurrentChunk();
|
||||||
|
void clearActors();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TopAbs_ShapeEnum myType;
|
||||||
|
QString myEntry;
|
||||||
TopoDS_Shape myMainShape;
|
TopoDS_Shape myMainShape;
|
||||||
SVTK_Selector* mySelector;
|
SVTK_Selector* mySelector;
|
||||||
vtkRenderer* myRenderer;
|
vtkRenderer* myRenderer;
|
||||||
TopTools_IndexedMapOfShape myMapOfShapes;
|
TopTools_IndexedMapOfShape myMapOfShapes;
|
||||||
QMap<int, GEOM_Actor*> myMapOfActors;
|
QMap<int, GEOM_Actor*> myMapOfActors;
|
||||||
|
QList<int> myIndices;
|
||||||
|
int myCurrentChunk;
|
||||||
|
int myChunkSize;
|
||||||
|
bool myIsShown;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user