Salome HOME
Fix: Bug PAL7970 Broken control Lengh2D after Free Borders
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index 16ead487f9ab8927d92b2ab06f8760ff1018caf6..52a34f63de2b65db6217214395cb0576727e404e 100644 (file)
@@ -24,7 +24,7 @@
 //  File   : SMESH_Actor.cxx
 //  Author : Nicolas REJNERI
 //  Module : SMESH
-//  $Header$Header$
+//  $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.7 2005/02/02 12:17:51 apo Exp $
 
 
 #include "SMESH_DeviceActor.h"
@@ -162,15 +162,14 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
     //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
     myIsShrinkable = true;
 
-    myExtractGeometry->SetInput(theGrid);
+    myExtractUnstructuredGrid->SetInput(theGrid);
 
-    myExtractUnstructuredGrid->SetInput(myExtractGeometry->GetOutput());
     myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
-    
-    theGrid = static_cast<vtkUnstructuredGrid*>(myMergeFilter->GetOutput());
+
+    myExtractGeometry->SetInput(myMergeFilter->GetOutput());
 
     int anId = 0;
-    myPassFilter[ anId ]->SetInput( theGrid );
+    myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
     myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
     
     anId++; // 1
@@ -233,16 +232,14 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
     if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
       for(vtkIdType i = 0; i < aNbCells; i++){
        vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
-       vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId);
-       vtkIdType anObjId = myVisualObj->GetElemObjId(anId2);
+       vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
        double aValue = aNumericalFunctor->GetValue(anObjId);
        aScalars->SetValue(i,aValue);
       }
     }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
       for(vtkIdType i = 0; i < aNbCells; i++){
        vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
-       vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId);
-       vtkIdType anObjId = myVisualObj->GetElemObjId(anId2);
+       vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
        bool aValue = aPredicate->IsSatisfy(anObjId);
        aScalars->SetValue(i,aValue);
       }
@@ -267,14 +264,16 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
                                          vtkLookupTable* theLookupTable)
 {
   bool anIsInitialized = theFunctor;
+  myExtractUnstructuredGrid->ClearRegisteredCells();
+  myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
+  myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll);
+  myVisualObj->UpdateFunctor(theFunctor);
 
   using namespace SMESH::Controls;
   if (anIsInitialized){
     if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
       SMESH::Controls::Length2D::TValues aValues;
 
-      myVisualObj->UpdateFunctor(theFunctor);
-
       aLength2D->GetValues(aValues);
       vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
       vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
@@ -337,8 +336,6 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
     else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
       SMESH::Controls::MultiConnection2D::MValues aValues;
 
-      myVisualObj->UpdateFunctor(theFunctor);
-
       aMultiConnection2D->GetValues(aValues);
       vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
       vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
@@ -361,8 +358,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
       anIdList->SetNumberOfIds(2);
       
       MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
-      int i = 0;
-      for(vtkIdType aVtkId; anIter != aValues.end(); anIter++,i++){
+      for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
        const MultiConnection2D::Value& aValue = (*anIter).first;
        int aNode[2] = {
          myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
@@ -373,7 +369,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
          anIdList->SetId( 1, aNode[1] );
          aConnectivity->InsertNextCell( anIdList );
          aCellTypesArray->InsertNextValue( VTK_LINE );
-         aScalars->SetValue(i,(*anIter).second);
+         aScalars->SetValue(aVtkId,(*anIter).second);
        }
       }