Salome HOME
Fix for '54311: Ugly representation in the VTK Viewer after creation of the ParaView...
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index 2d632782db5c1fce6ee104e5c18d72eeed2fb0b6..cfe6159a2c0e7e4484c444878060473940d275f2 100644 (file)
@@ -37,6 +37,7 @@
 #include <VTKViewer_Transform.h>
 #include <VTKViewer_TransformFilter.h>
 #include <VTKViewer_ExtractUnstructuredGrid.h>
 #include <VTKViewer_Transform.h>
 #include <VTKViewer_TransformFilter.h>
 #include <VTKViewer_ExtractUnstructuredGrid.h>
+#include <VTKViewer_Actor.h>
 
 // VTK Includes
 #include <vtkObjectFactory.h>
 
 // VTK Includes
 #include <vtkObjectFactory.h>
@@ -88,14 +89,14 @@ SMESH_DeviceActor
   myIsShrunk = false;
   myIsHighlited = false;
 
   myIsShrunk = false;
   myIsHighlited = false;
 
-  myRepresentation = eSurface;
+  myRepresentation = SMESH_DeviceActor::EReperesent(-1);
 
   myProperty = vtkProperty::New();
   myMapper = VTKViewer_PolyDataMapper::New();
   myPlaneCollection = vtkPlaneCollection::New();
 
 
   myProperty = vtkProperty::New();
   myMapper = VTKViewer_PolyDataMapper::New();
   myPlaneCollection = vtkPlaneCollection::New();
 
-  vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
-                                                                 myPolygonOffsetUnits);
+  VTKViewer_Actor::GetDefaultPolygonOffsetParameters(myPolygonOffsetFactor,
+                                                     myPolygonOffsetUnits);
 
   myMapper->UseLookupTableScalarRangeOn();
   myMapper->SetColorModeToMapScalars();
 
   myMapper->UseLookupTableScalarRangeOn();
   myMapper->SetColorModeToMapScalars();
@@ -142,7 +143,7 @@ SMESH_DeviceActor
   if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
 
   myMapper->Delete();
   if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
 
   myMapper->Delete();
-  myPlaneCollection->Delete();
+  // myPlaneCollection->Delete(); -- it is vtkSmartPointer
   myProperty->Delete();
 
   myExtractGeometry->Delete();
   myProperty->Delete();
 
   myExtractGeometry->Delete();
@@ -172,7 +173,8 @@ SMESH_DeviceActor
 ::SetStoreGemetryMapping(bool theStoreMapping)
 {
   myGeomFilter->SetStoreMapping(theStoreMapping);
 ::SetStoreGemetryMapping(bool theStoreMapping)
 {
   myGeomFilter->SetStoreMapping(theStoreMapping);
-  SetStoreClippingMapping(theStoreMapping);
+  // for optimization, switch the mapping explicitly in each filter/algorithm
+  //SetStoreClippingMapping(theStoreMapping);
 }
 
 
 }
 
 
@@ -182,7 +184,10 @@ SMESH_DeviceActor
 {
   myStoreClippingMapping = theStoreMapping;
   myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
 {
   myStoreClippingMapping = theStoreMapping;
   myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
-  SetStoreIDMapping(theStoreMapping);
+  // EAP, 23315
+  // Mapping in myExtractUnstructuredGrid and myGeomFilter is ON in the pickable DeviceActor only.
+  // To show labels, the mapping is computed explicitly via myExtractUnstructuredGrid->BuildOut2InMap();
+  //SetStoreIDMapping(theStoreMapping);
 }
 
 
 }
 
 
@@ -301,7 +306,7 @@ SMESH_DeviceActor
   if(anIsInitialized){
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
 
   if(anIsInitialized){
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
 
-    SetStoreIDMapping(true);
+    // SetStoreIDMapping(true);
     myExtractUnstructuredGrid->Update();
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
 
     myExtractUnstructuredGrid->Update();
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
 
@@ -318,7 +323,9 @@ SMESH_DeviceActor
     using namespace SMESH::Controls;
     if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
     {
     using namespace SMESH::Controls;
     if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
     {
-      for(vtkIdType i = 0; i < aNbCells; i++){
+      myExtractUnstructuredGrid->BuildOut2InMap();
+      for(vtkIdType i = 0; i < aNbCells; i++)
+      {
         vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
         vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
         double aValue = aNumericalFunctor->GetValue(anObjId);
         vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
         vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
         double aValue = aNumericalFunctor->GetValue(anObjId);
@@ -334,7 +341,9 @@ SMESH_DeviceActor
     }
     else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
     {
     }
     else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
     {
-      for(vtkIdType i = 0; i < aNbCells; i++){
+      myExtractUnstructuredGrid->BuildOut2InMap();
+      for(vtkIdType i = 0; i < aNbCells; i++)
+      {
         vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
         vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
         bool aValue = aPredicate->IsSatisfy(anObjId);
         vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
         vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
         bool aValue = aPredicate->IsSatisfy(anObjId);
@@ -607,11 +616,23 @@ SMESH_DeviceActor
 
 
 
 
 
 
-unsigned long int
+vtkMTimeType
 SMESH_DeviceActor
 ::GetMTime()
 {
 SMESH_DeviceActor
 ::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()
   //      << " " << myExtractGeometry->GetMTime()
   //      << " " << myExtractUnstructuredGrid->GetMTime()
   //      << " " << this->Superclass::GetMTime()
   //      << " " << myExtractGeometry->GetMTime()
   //      << " " << myExtractUnstructuredGrid->GetMTime()
@@ -620,7 +641,7 @@ SMESH_DeviceActor
   //      << " " << myTransformFilter->GetMTime()
   //      << " " << myFaceOrientationFilter->GetMTime() << endl;
 
   //      << " " << myTransformFilter->GetMTime()
   //      << " " << myFaceOrientationFilter->GetMTime() << endl;
 
-  unsigned long mTime = this->Superclass::GetMTime();
+  vtkMTimeType mTime = this->Superclass::GetMTime();
   mTime = max(mTime,myExtractGeometry->GetMTime());
   mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
   mTime = max(mTime,myMergeFilter->GetMTime());
   mTime = max(mTime,myExtractGeometry->GetMTime());
   mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
   mTime = max(mTime,myMergeFilter->GetMTime());
@@ -737,6 +758,8 @@ void
 SMESH_DeviceActor
 ::SetRepresentation(EReperesent theMode)
 {
 SMESH_DeviceActor
 ::SetRepresentation(EReperesent theMode)
 {
+  if ( myRepresentation == theMode )
+    return;
   switch(theMode){
   case ePoint:
     myGeomFilter->SetInside(true);
   switch(theMode){
   case ePoint:
     myGeomFilter->SetInside(true);