[Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0.

This commit is contained in:
apo 2005-03-22 10:32:59 +00:00
parent 7411bcf53c
commit 1eea5485d1
6 changed files with 162 additions and 54 deletions

View File

@ -68,6 +68,7 @@
#include <vtkMath.h>
#include <vtkPlane.h>
#include <vtkImplicitBoolean.h>
#include <vtkImplicitFunctionCollection.h>
#include "utilities.h"
@ -599,7 +600,8 @@ void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
}
void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled){
void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
{
vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
if(myIsCellsLabeled){
@ -818,18 +820,6 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
setName(theName);
myVisualObj = theVisualObj;
myNodeActor->myVisualObj = myVisualObj;
myBaseActor->myVisualObj = myVisualObj;
myHighlitableActor->myVisualObj = myVisualObj;
myNodeHighlitableActor->myVisualObj = myVisualObj;
my1DActor->myVisualObj = myVisualObj;
my1DExtActor->myVisualObj = myVisualObj;
my2DActor->myVisualObj = myVisualObj;
my3DActor->myVisualObj = myVisualObj;
myVisualObj->Update(theIsClear);
myNodeActor->Init(myVisualObj,myImplicitBoolean);
@ -1456,9 +1446,67 @@ int SMESH_ActorDef::GetObjDimension( const int theObjId )
return myVisualObj->GetElemDimension( theObjId );
}
bool
SMESH_ActorDef::
IsImplicitFunctionUsed() const
{
return myBaseActor->IsImplicitFunctionUsed();
}
vtkImplicitBoolean* SMESH_ActorDef::GetPlaneContainer(){
return myImplicitBoolean;
void
SMESH_ActorDef::
SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
{
myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
myNodeHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
}
vtkIdType
SMESH_ActorDef::
AddClippingPlane(vtkPlane* thePlane)
{
if(thePlane){
myImplicitBoolean->GetFunction()->AddItem(thePlane);
myCippingPlaneCont.push_back(thePlane);
if(!IsImplicitFunctionUsed())
SetImplicitFunctionUsed(true);
}
return myCippingPlaneCont.size();
}
void
SMESH_ActorDef::
RemoveAllClippingPlanes()
{
myImplicitBoolean->GetFunction()->RemoveAllItems();
myImplicitBoolean->GetFunction()->Modified(); // VTK bug
myCippingPlaneCont.clear();
SetImplicitFunctionUsed(false);
}
vtkIdType
SMESH_ActorDef::
GetNumberOfClippingPlanes()
{
return myCippingPlaneCont.size();
}
vtkPlane*
SMESH_ActorDef::
GetClippingPlane(vtkIdType theID)
{
if(theID >= myCippingPlaneCont.size())
return NULL;
return myCippingPlaneCont[theID].Get();
}

View File

@ -104,7 +104,10 @@ class SMESH_Actor: public SALOME_Actor
virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane) = 0;
virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane) = 0;
virtual vtkImplicitBoolean* GetPlaneContainer() = 0;
virtual void RemoveAllClippingPlanes() = 0;
virtual vtkIdType GetNumberOfClippingPlanes() = 0;
virtual vtkPlane* GetClippingPlane(vtkIdType theID) = 0;
virtual vtkIdType AddClippingPlane(vtkPlane* thePlane) = 0;
virtual TVisualObjPtr GetObject() = 0;

View File

@ -32,6 +32,28 @@
#include "SMESH_Actor.h"
#include "SMESH_Object.h"
#include <vtkSmartPointer.h>
template <class T>
class TVTKSmartPtr: public vtkSmartPointer<T>
{
public:
TVTKSmartPtr() {}
TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
if(r && theIsOwner)
r->Delete();
}
TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
vtkSmartPointer<T>::operator=(r);
if(r && theIsOwner)
r->Delete();
return *this;
}
TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
T* Get() const { return GetPointer();}
};
class vtkProperty;
class vtkShrinkFilter;
class vtkPolyDataMapper;
@ -153,7 +175,10 @@ class SMESH_ActorDef : public SMESH_Actor{
virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
virtual vtkImplicitBoolean* GetPlaneContainer();
virtual void RemoveAllClippingPlanes();
virtual vtkIdType GetNumberOfClippingPlanes();
virtual vtkPlane* GetClippingPlane(vtkIdType theID);
virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
virtual TVisualObjPtr GetObject() { return myVisualObj;}
@ -161,6 +186,9 @@ class SMESH_ActorDef : public SMESH_Actor{
virtual long GetControlsPrecision() const { return myControlsPrecision; }
protected:
void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
bool IsImplicitFunctionUsed() const;
TVisualObjPtr myVisualObj;
vtkTimeStamp* myTimeStamp;
@ -213,7 +241,9 @@ class SMESH_ActorDef : public SMESH_Actor{
vtkSelectVisiblePoints* myClsSelectVisiblePoints;
vtkImplicitBoolean* myImplicitBoolean;
typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
typedef std::vector<TPlanePtr> TCippingPlaneCont;
TCippingPlaneCont myCippingPlaneCont;
long myControlsPrecision;
SMESH_ActorDef();

View File

@ -21,10 +21,10 @@
//
//
//
// File : SMESH_Actor.cxx
// Author : Nicolas REJNERI
// File : SMESH_DeviceActor.cxx
// Author :
// Module : SMESH
// $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.7 2005/02/02 12:17:51 apo Exp $
// $Header$
#include "SMESH_DeviceActor.h"
@ -76,7 +76,6 @@ vtkStandardNewMacro(SMESH_DeviceActor);
SMESH_DeviceActor::SMESH_DeviceActor(){
if(MYDEBUG) MESSAGE("SMESH_DeviceActor");
myIsShrunk = false;
myIsShrinkable = false;
myRepresentation = eSurface;
@ -93,7 +92,9 @@ SMESH_DeviceActor::SMESH_DeviceActor(){
myShrinkFilter = vtkShrinkFilter::New();
myExtractGeometry = SMESH_ExtractGeometry::New();
myExtractGeometry->SetReleaseDataFlag(true);
myExtractGeometry->SetStoreMapping(true);
myIsImplicitFunctionUsed = false;
myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
myExtractUnstructuredGrid->SetStoreMapping(true);
@ -160,6 +161,23 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj,
}
void
SMESH_DeviceActor::
SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
{
if(myIsImplicitFunctionUsed == theIsImplicitFunctionUsed)
return;
int anId = 0;
if(theIsImplicitFunctionUsed)
myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
else
myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
}
void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
if(theGrid){
//myIsShrinkable = theGrid->GetNumberOfCells() > 10;
@ -172,7 +190,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
myExtractGeometry->SetInput(myMergeFilter->GetOutput());
int anId = 0;
myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
anId++; // 1
@ -524,8 +542,8 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
GetProperty()->SetRepresentation(1);
break;
default :
GetProperty()->SetRepresentation(theMode);
myGeomFilter->SetInside(false);
GetProperty()->SetRepresentation(theMode);
}
myRepresentation = theMode;
GetProperty()->Modified();
@ -552,14 +570,18 @@ int SMESH_DeviceActor::GetVisibility(){
int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID);
vtkIdType anID = theVtkID;
if(IsImplicitFunctionUsed())
anID = myExtractGeometry->GetNodeObjId(theVtkID);
vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; aRetID = "<<aRetID);
return aRetID;
}
float* SMESH_DeviceActor::GetNodeCoord(int theObjID){
vtkDataSet* aDataSet = myExtractGeometry->GetInput();
vtkDataSet* aDataSet = myMergeFilter->GetOutput();
vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
float* aCoord = aDataSet->GetPoint(anID);
if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
@ -571,12 +593,17 @@ int SMESH_DeviceActor::GetElemObjId(int theVtkID){
vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
if(anId < 0)
return -1;
vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId);
vtkIdType anId2 = anId;
if(IsImplicitFunctionUsed())
anId2 = myExtractGeometry->GetElemObjId(anId);
if(anId2 < 0)
return -1;
vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
if(anId3 < 0)
return -1;
vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
if(MYDEBUG)
MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);

View File

@ -106,6 +106,9 @@ class SMESH_DeviceActor: public vtkLODActor{
virtual void Render(vtkRenderer *, vtkMapper *);
void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
protected:
void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
@ -117,6 +120,7 @@ class SMESH_DeviceActor: public vtkLODActor{
EReperesent myRepresentation;
SMESH_ExtractGeometry* myExtractGeometry;
bool myIsImplicitFunctionUsed;
vtkMergeFilter* myMergeFilter;
SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid;

View File

@ -383,10 +383,6 @@ SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
}
//=======================================================================
// function : ClickOnApply()
// purpose :
//=======================================================================
void SMESHGUI_ClippingDlg::ClickOnApply()
{
if (!myActor)
@ -395,17 +391,13 @@ void SMESHGUI_ClippingDlg::ClickOnApply()
if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
QAD_WaitCursor wc;
vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
aCollection->RemoveAllItems();
aBoolean->Modified(); // VTK bug
aCollection->InitTraversal();
myActor->RemoveAllClippingPlanes();
SMESH::TPlanes::iterator anIter = myPlanes.begin();
for (;anIter != myPlanes.end();anIter++){
OrientedPlane* anOrientedPlane = OrientedPlane::New();
anOrientedPlane->ShallowCopy(anIter->GetPointer());
aCollection->AddItem(anOrientedPlane);
myActor->AddClippingPlane(anOrientedPlane);
anOrientedPlane->Delete();
}
@ -446,12 +438,12 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject();
myActor = SMESH::FindActorByEntry(IOS->getEntry());
if ( myActor ){
vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
aCollection->InitTraversal();
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
myPlanes.clear();
while(vtkImplicitFunction* aFunction = aCollection->GetNextItem()){
vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
for(; anId < anEnd; anId++){
if(vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)){
if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy());
SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
@ -460,6 +452,8 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
myPlanes.push_back(aTVTKPlane);
}
}
}
std::for_each(myPlanes.begin(),myPlanes.end(),
TSetVisiblity(PreviewCheckBox->isChecked()));
}
@ -634,7 +628,9 @@ void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRo
// function : SetCurrentPlaneParam
// purpose :
//=======================================================================
void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
void
SMESHGUI_ClippingDlg::
SetCurrentPlaneParam()
{
if(myPlanes.empty() || myIsSelectPlane)
return;