Salome HOME
[Bug PAL7444] display mesh takes a lot of more memory in 2.1.0 than in 2.0.0.
[modules/smesh.git] / src / OBJECT / SMESH_Actor.cxx
index 47967a9a52e4499b5d14ea53e00aea3377f1db86..f3794ec5e452b2a9a4d6209efc4c288feeede871 100644 (file)
@@ -68,6 +68,7 @@
 #include <vtkMath.h>
 #include <vtkPlane.h>
 #include <vtkImplicitBoolean.h>
 #include <vtkMath.h>
 #include <vtkPlane.h>
 #include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunctionCollection.h>
 
 #include "utilities.h"
 
 
 #include "utilities.h"
 
@@ -239,9 +240,10 @@ SMESH_ActorDef::SMESH_ActorDef(){
   myBaseActor->SetUserMatrix(aMatrix);
   myBaseActor->SetStoreMapping(true);
   myBaseActor->GetProperty()->SetOpacity(0.0);
   myBaseActor->SetUserMatrix(aMatrix);
   myBaseActor->SetStoreMapping(true);
   myBaseActor->GetProperty()->SetOpacity(0.0);
+  myBaseActor->myGeomFilter->SetInside(true);
 
   myPickableActor = myBaseActor;
 
   myPickableActor = myBaseActor;
-
+  
   myHighlightProp = vtkProperty::New();
   myHighlightProp->SetAmbient(1.0);
   myHighlightProp->SetDiffuse(0.0);
   myHighlightProp = vtkProperty::New();
   myHighlightProp->SetAmbient(1.0);
   myHighlightProp->SetDiffuse(0.0);
@@ -598,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){
   vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
   myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
   if(myIsCellsLabeled){
@@ -734,8 +737,6 @@ void SMESH_ActorDef::SetControlMode(eControl theMode){
        my1DExtActor->SetExtControlMode(aFunctor,myControlActor);
        break;
       case eLength2D:
        my1DExtActor->SetExtControlMode(aFunctor,myControlActor);
        break;
       case eLength2D:
-       my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
-       break;
       case eMultiConnection2D:
        my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
        break;
       case eMultiConnection2D:
        my1DExtActor->SetExtControlMode(aFunctor,myControlActor,myScalarBarActor,myLookupTable);
        break;
@@ -819,18 +820,6 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
   setName(theName);
 
   myVisualObj = 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);
   myVisualObj->Update(theIsClear);
 
   myNodeActor->Init(myVisualObj,myImplicitBoolean);
@@ -1064,8 +1053,10 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
       my3DActor->VisibilityOn();
     }
     
       my3DActor->VisibilityOn();
     }
     
-    if(myIsPointsLabeled) 
+    if(myIsPointsLabeled){ 
       myPointLabels->VisibilityOn();
       myPointLabels->VisibilityOn();
+      myNodeActor->VisibilityOn();
+    }
 
     if(myIsCellsLabeled) 
       myCellsLabels->VisibilityOn();
 
     if(myIsCellsLabeled) 
       myCellsLabels->VisibilityOn();
@@ -1085,11 +1076,46 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume))
     theMode &= ~eVolumes;
 
   if(!myVisualObj->GetNbEntities(SMDSAbs_Volume))
     theMode &= ~eVolumes;
 
-  if(!theMode)
-    return;
+  if(!theMode){
+    if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
+      theMode |= eEdges;
+
+    if(myVisualObj->GetNbEntities(SMDSAbs_Face))
+      theMode |= eFaces;
+
+    if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
+      theMode |= eVolumes;
+  }
 
   myEntityMode = theMode;
 
   myEntityMode = theMode;
+  SALOME_ExtractUnstructuredGrid* aFilter = NULL;
+  aFilter = myBaseActor->GetExtractUnstructuredGrid();
+  aFilter->ClearRegisteredCellsWithType();
+  aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
+  
+  if(myEntityMode & eEdges){
+    if (MYDEBUG) MESSAGE("EDGES");
+    aFilter->RegisterCellsWithType(VTK_LINE);
+  }
 
 
+  if(myEntityMode & eFaces){
+    if (MYDEBUG) MESSAGE("FACES");
+    aFilter->RegisterCellsWithType(VTK_TRIANGLE);
+    aFilter->RegisterCellsWithType(VTK_POLYGON);
+    aFilter->RegisterCellsWithType(VTK_QUAD);
+  }
+
+  if(myEntityMode & eVolumes){
+    if (MYDEBUG) MESSAGE("VOLUMES");
+    aFilter->RegisterCellsWithType(VTK_TETRA);
+    aFilter->RegisterCellsWithType(VTK_VOXEL);
+    aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+    aFilter->RegisterCellsWithType(VTK_WEDGE);
+    aFilter->RegisterCellsWithType(VTK_PYRAMID);
+    aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+  }
+  aFilter->Update();
+  if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
   SetVisibility(GetVisibility(),false);
 }
 
   SetVisibility(GetVisibility(),false);
 }
 
@@ -1136,7 +1162,7 @@ void SMESH_ActorDef::SetRepresentation(int theMode){
   case ePoint:
     myPickableActor = myNodeActor;
     myNodeActor->SetVisibility(true);
   case ePoint:
     myPickableActor = myNodeActor;
     myNodeActor->SetVisibility(true);
-
+    
     aProp = aBackProp = myNodeProp;
     aReperesent = SMESH_DeviceActor::ePoint;
     break;
     aProp = aBackProp = myNodeProp;
     aReperesent = SMESH_DeviceActor::ePoint;
     break;
@@ -1290,6 +1316,7 @@ void SMESH_ActorDef::Update(){
   if(myIsCellsLabeled){
     SetCellsLabeled(myIsCellsLabeled);
   }
   if(myIsCellsLabeled){
     SetCellsLabeled(myIsCellsLabeled);
   }
+  SetEntityMode(GetEntityMode());
   SetVisibility(GetVisibility());
   
   myTimeStamp->Modified();
   SetVisibility(GetVisibility());
   
   myTimeStamp->Modified();
@@ -1419,9 +1446,67 @@ int SMESH_ActorDef::GetObjDimension( const int theObjId )
   return myVisualObj->GetElemDimension( 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();
 }
 
 
 }