Salome HOME
Color Number (Color Group) parameter is returned for compatibility
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index 79d20d81305011bed2749e846300d01dc4f6029a..8a7341b4913e6006ae2cd1d7954d49b06d598a02 100644 (file)
 //  License along with this library; if not, write to the Free Software 
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
 // 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
-//  File   : SMESH_Actor.cxx
-//  Author : Nicolas REJNERI
+//  File   : SMESH_DeviceActor.cxx
+//  Author : 
 //  Module : SMESH
 //  $Header$
 
 
 #include "SMESH_DeviceActor.h"
 #include "SMESH_ExtractGeometry.h"
+#include "SMESH_ControlsDef.hxx"
+#include "SMESH_ActorUtils.h"
+#include "VTKViewer_CellLocationsArray.h"
 
-#include "SALOME_Transform.h"
-#include "SALOME_TransformFilter.h"
-#include "SALOME_PassThroughFilter.h"
-#include "SALOME_ExtractUnstructuredGrid.h"
-
-#include "utilities.h"
+#include <VTKViewer_Transform.h>
+#include <VTKViewer_TransformFilter.h>
+#include <VTKViewer_ExtractUnstructuredGrid.h>
 
 // VTK Includes
 #include <vtkObjectFactory.h>
 
 #include <vtkCell.h>
 #include <vtkIdList.h>
-#include <vtkIntArray.h>
 #include <vtkCellArray.h>
 #include <vtkUnsignedCharArray.h>
 
 #include <vtkImplicitBoolean.h>
+#include <vtkPassThroughFilter.h>
+
+#include "utilities.h"
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
 #else
 static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
 #endif
 
 using namespace std;
@@ -75,8 +75,11 @@ using namespace std;
 vtkStandardNewMacro(SMESH_DeviceActor);
 
 
-SMESH_DeviceActor::SMESH_DeviceActor(){
-  if(MYDEBUG) MESSAGE("SMESH_DeviceActor");
+SMESH_DeviceActor
+::SMESH_DeviceActor()
+{
+  if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
+
   myIsShrunk = false;
   myIsShrinkable = false;
   myRepresentation = eSurface;
@@ -92,64 +95,83 @@ SMESH_DeviceActor::SMESH_DeviceActor(){
 
   myShrinkFilter = vtkShrinkFilter::New();
 
-  myExtractGeometry = SMESH_ExtractGeometry::New();
-  myExtractGeometry->SetStoreMapping(true);
+  myStoreClippingMapping = false;
 
-  myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
-  myExtractUnstructuredGrid->SetStoreMapping(true);
+  myExtractGeometry = SMESH_ExtractGeometry::New();
+  myExtractGeometry->SetReleaseDataFlag(true);
+  myIsImplicitFunctionUsed = false;
 
+  myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
+    
   myMergeFilter = vtkMergeFilter::New();
 
-  myStoreMapping = false;
-  myGeomFilter = SALOME_GeometryFilter::New();
+  myGeomFilter = VTKViewer_GeometryFilter::New();
 
-  myTransformFilter = SALOME_TransformFilter::New();
+  myTransformFilter = VTKViewer_TransformFilter::New();
 
   for(int i = 0; i < 6; i++)
-    myPassFilter.push_back(SALOME_PassThroughFilter::New());
+    myPassFilter.push_back(vtkPassThroughFilter::New());
 }
 
 
-SMESH_DeviceActor::~SMESH_DeviceActor(){
-  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor");
+SMESH_DeviceActor
+::~SMESH_DeviceActor()
+{
+  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
+
   myProperty->Delete();
 
-  myMapper->RemoveAllInputs();
   myMapper->Delete();
 
-  myShrinkFilter->UnRegisterAllOutputs();
   myShrinkFilter->Delete();
 
-  myExtractUnstructuredGrid->UnRegisterAllOutputs();
   myExtractUnstructuredGrid->Delete();
 
-  myMergeFilter->UnRegisterAllOutputs();
   myMergeFilter->Delete();
 
-  myGeomFilter->UnRegisterAllOutputs();
   myGeomFilter->Delete();
 
-  myExtractGeometry->UnRegisterAllOutputs();
   myExtractGeometry->Delete();
 
-  myTransformFilter->UnRegisterAllOutputs();
   myTransformFilter->Delete();
 
   for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
-    myPassFilter[i]->UnRegisterAllOutputs(); 
     myPassFilter[i]->Delete();
   }
 }
 
 
-void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){
-  myStoreMapping = theStoreMapping;
-  Modified();
+void
+SMESH_DeviceActor
+::SetStoreGemetryMapping(bool theStoreMapping)
+{
+  myGeomFilter->SetStoreMapping(theStoreMapping);
+  SetStoreClippingMapping(theStoreMapping);
+}
+
+
+void
+SMESH_DeviceActor
+::SetStoreClippingMapping(bool theStoreMapping)
+{
+  myStoreClippingMapping = theStoreMapping;
+  myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
+  SetStoreIDMapping(theStoreMapping);
 }
 
 
-void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, 
-                            vtkImplicitBoolean* theImplicitBoolean)
+void
+SMESH_DeviceActor
+::SetStoreIDMapping(bool theStoreMapping)
+{
+  myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
+}
+
+
+void 
+SMESH_DeviceActor
+::Init(TVisualObjPtr theVisualObj, 
+       vtkImplicitBoolean* theImplicitBoolean)
 {
   myVisualObj = theVisualObj;
   myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
@@ -157,24 +179,40 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj,
 }
 
 
-void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
+void
+SMESH_DeviceActor
+::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
+{
+  int anId = 0;
+  if(theIsImplicitFunctionUsed)
+    myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
+  else
+    myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
+    
+  myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
+  SetStoreClippingMapping(myStoreClippingMapping);
+}
+
+
+void
+SMESH_DeviceActor
+::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
+{
   if(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 );
+    SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
     myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
     
     anId++; // 1
-    myGeomFilter->SetStoreMapping( myStoreMapping );
     myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 2
@@ -201,25 +239,37 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
 }
 
 
-SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){
+VTKViewer_ExtractUnstructuredGrid* 
+SMESH_DeviceActor
+::GetExtractUnstructuredGrid()
+{
   return myExtractUnstructuredGrid;
 }
 
 
-vtkUnstructuredGrid* SMESH_DeviceActor::GetUnstructuredGrid(){
+vtkUnstructuredGrid* 
+SMESH_DeviceActor
+::GetUnstructuredGrid()
+{
   myExtractUnstructuredGrid->Update();
   return myExtractUnstructuredGrid->GetOutput();
 }
 
 
-void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                      vtkScalarBarActor* theScalarBarActor,
-                                      vtkLookupTable* theLookupTable)
+void
+SMESH_DeviceActor
+::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
+                vtkScalarBarActor* theScalarBarActor,
+                vtkLookupTable* theLookupTable)
 {
   bool anIsInitialized = theFunctor;
   if(anIsInitialized){
     vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+
+    SetStoreIDMapping(true);
+    myExtractUnstructuredGrid->Update();
     vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
+
     aDataSet->ShallowCopy(aGrid);
     
     vtkDoubleArray *aScalars = vtkDoubleArray::New();
@@ -233,16 +283,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);
       }
@@ -252,6 +300,7 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
     aScalars->Delete();
        
     theLookupTable->SetRange(aScalars->GetRange());
+    theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
     theLookupTable->Build();
     
     myMergeFilter->SetScalars(aDataSet);
@@ -261,23 +310,163 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
   theScalarBarActor->SetVisibility(anIsInitialized);
 }
 
+void
+SMESH_DeviceActor
+::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
+                   vtkScalarBarActor* theScalarBarActor,
+                   vtkLookupTable* theLookupTable)
+{
+  bool anIsInitialized = theFunctor;
+  myExtractUnstructuredGrid->ClearRegisteredCells();
+  myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
+  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
+  myVisualObj->UpdateFunctor(theFunctor);
 
-void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                         SMESH_DeviceActor* theDeviceActor)
+  using namespace SMESH::Controls;
+  if (anIsInitialized){
+    if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
+      SMESH::Controls::Length2D::TValues aValues;
+
+      aLength2D->GetValues(aValues);
+      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+
+      aDataSet->SetPoints(aGrid->GetPoints());
+      
+      vtkIdType aNbCells = aValues.size();
+      
+      vtkDoubleArray *aScalars = vtkDoubleArray::New();
+      aScalars->SetNumberOfComponents(1);
+      aScalars->SetNumberOfTuples(aNbCells);
+
+      vtkIdType aCellsSize = 3*aNbCells;
+      vtkCellArray* aConnectivity = vtkCellArray::New();
+      aConnectivity->Allocate( aCellsSize, 0 );
+      
+      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+      aCellTypesArray->SetNumberOfComponents( 1 );
+      aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+      
+      vtkIdList *anIdList = vtkIdList::New();
+      anIdList->SetNumberOfIds(2);
+      
+      Length2D::TValues::const_iterator anIter = aValues.begin();
+      for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
+       const Length2D::Value& aValue = *anIter;
+       int aNode[2] = {
+         myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+         myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+       };
+       if(aNode[0] >= 0 && aNode[1] >= 0){
+         anIdList->SetId( 0, aNode[0] );
+         anIdList->SetId( 1, aNode[1] );
+         aConnectivity->InsertNextCell( anIdList );
+         aCellTypesArray->InsertNextValue( VTK_LINE );
+         aScalars->SetValue(aVtkId,aValue.myLength);
+       }
+      }
+      
+      VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
+      aCellLocationsArray->SetNumberOfComponents( 1 );
+      aCellLocationsArray->SetNumberOfTuples( aNbCells );
+      
+      aConnectivity->InitTraversal();
+      for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+       aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+      
+      aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+      SetUnstructuredGrid(aDataSet);
+
+      aDataSet->GetCellData()->SetScalars(aScalars);
+      aScalars->Delete();
+      
+      theLookupTable->SetRange(aScalars->GetRange());
+      theLookupTable->Build();
+      
+      myMergeFilter->SetScalars(aDataSet);
+      aDataSet->Delete();
+    }
+    else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
+      SMESH::Controls::MultiConnection2D::MValues aValues;
+
+      aMultiConnection2D->GetValues(aValues);
+      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+      aDataSet->SetPoints(aGrid->GetPoints());
+      
+      vtkIdType aNbCells = aValues.size();
+      vtkDoubleArray *aScalars = vtkDoubleArray::New();
+      aScalars->SetNumberOfComponents(1);
+      aScalars->SetNumberOfTuples(aNbCells);
+
+      vtkIdType aCellsSize = 3*aNbCells;
+      vtkCellArray* aConnectivity = vtkCellArray::New();
+      aConnectivity->Allocate( aCellsSize, 0 );
+      
+      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+      aCellTypesArray->SetNumberOfComponents( 1 );
+      aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
+      
+      vtkIdList *anIdList = vtkIdList::New();
+      anIdList->SetNumberOfIds(2);
+      
+      MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
+      for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
+       const MultiConnection2D::Value& aValue = (*anIter).first;
+       int aNode[2] = {
+         myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+         myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+       };
+       if(aNode[0] >= 0 && aNode[1] >= 0){
+         anIdList->SetId( 0, aNode[0] );
+         anIdList->SetId( 1, aNode[1] );
+         aConnectivity->InsertNextCell( anIdList );
+         aCellTypesArray->InsertNextValue( VTK_LINE );
+         aScalars->SetValue(aVtkId,(*anIter).second);
+       }
+      }
+      
+      VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
+      aCellLocationsArray->SetNumberOfComponents( 1 );
+      aCellLocationsArray->SetNumberOfTuples( aNbCells );
+      
+      aConnectivity->InitTraversal();
+      for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+       aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
+      
+      aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
+      SetUnstructuredGrid(aDataSet);
+
+      aDataSet->GetCellData()->SetScalars(aScalars);
+      aScalars->Delete();
+      
+      theLookupTable->SetRange(aScalars->GetRange());
+      theLookupTable->Build();
+      
+      myMergeFilter->SetScalars(aDataSet);
+      aDataSet->Delete();
+    }
+  }
+  GetMapper()->SetScalarVisibility(anIsInitialized);
+  theScalarBarActor->SetVisibility(anIsInitialized);
+}
+
+void
+SMESH_DeviceActor
+::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
 {
   myExtractUnstructuredGrid->ClearRegisteredCells();
   myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
-  myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll);
+  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
   myVisualObj->UpdateFunctor(theFunctor);
 
   using namespace SMESH::Controls;
   if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){
-    myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding);
-    myExtractUnstructuredGrid->ClearRegisteredCells();
-    vtkUnstructuredGrid* aGrid = theDeviceActor->GetUnstructuredGrid();
+    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+    vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
     for( vtkIdType i = 0; i < aNbCells; i++ ){
-      vtkIdType anObjId = theDeviceActor->GetElemObjId(i);
+      vtkIdType anObjId = myVisualObj->GetElemObjId(i);
       if(aFreeBorders->IsSatisfy(anObjId))
        myExtractUnstructuredGrid->RegisterCell(i);
     }
@@ -304,7 +493,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
     anIdList->SetNumberOfIds(2);
     
     FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
-    for(vtkIdType aVtkId; anIter != aBorders.end(); anIter++){
+    for(; anIter != aBorders.end(); anIter++){
       const FreeEdges::Border& aBorder = *anIter;
       int aNode[2] = {
        myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
@@ -319,7 +508,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
       }
     }
     
-    vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+    VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
     aCellLocationsArray->SetNumberOfComponents( 1 );
     aCellLocationsArray->SetNumberOfTuples( aNbCells );
     
@@ -331,11 +520,16 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
 
     SetUnstructuredGrid(aDataSet);
     aDataSet->Delete();
-  }    
+  }
 }
 
 
-unsigned long int SMESH_DeviceActor::GetMTime(){
+
+
+unsigned long int 
+SMESH_DeviceActor
+::GetMTime()
+{
   unsigned long mTime = this->Superclass::GetMTime();
   mTime = max(mTime,myExtractGeometry->GetMTime());
   mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
@@ -346,12 +540,18 @@ unsigned long int SMESH_DeviceActor::GetMTime(){
 }
 
 
-void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){
+void
+SMESH_DeviceActor
+::SetTransform(VTKViewer_Transform* theTransform)
+{
   myTransformFilter->SetTransform(theTransform);
 }
 
 
-void SMESH_DeviceActor::SetShrink() {
+void
+SMESH_DeviceActor
+::SetShrink() 
+{
   if ( !myIsShrinkable ) return;
   if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
   {
@@ -361,7 +561,10 @@ void SMESH_DeviceActor::SetShrink() {
   }
 }
 
-void SMESH_DeviceActor::UnShrink() {
+void
+SMESH_DeviceActor
+::UnShrink() 
+{
   if ( !myIsShrunk ) return;
   if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
   {    
@@ -373,19 +576,30 @@ void SMESH_DeviceActor::UnShrink() {
 }
 
 
-void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ 
+void
+SMESH_DeviceActor
+::SetRepresentation(EReperesent theMode)
+{
   switch(theMode){
-  case ePoint: 
+  case ePoint:
     myGeomFilter->SetInside(true);
+    myGeomFilter->SetWireframeMode(false);
     GetProperty()->SetRepresentation(0);
     break;
-  case eInsideframe: 
+  case eWireframe:
+    myGeomFilter->SetInside(false);
+    myGeomFilter->SetWireframeMode(true);
+    GetProperty()->SetRepresentation(theMode);
+    break;
+  case eInsideframe:
     myGeomFilter->SetInside(true);
+    myGeomFilter->SetWireframeMode(true);
     GetProperty()->SetRepresentation(1);
     break;
-  default :
-    GetProperty()->SetRepresentation(theMode);
+  case eSurface:
     myGeomFilter->SetInside(false);
+    myGeomFilter->SetWireframeMode(false);
+    GetProperty()->SetRepresentation(theMode);
   }
   myRepresentation = theMode;
   GetProperty()->Modified();
@@ -394,8 +608,13 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
 }
 
 
-void SMESH_DeviceActor::SetVisibility(int theMode){
-  if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){
+void
+SMESH_DeviceActor
+::SetVisibility(int theMode)
+{
+  if(!myExtractUnstructuredGrid->GetInput() || 
+     GetUnstructuredGrid()->GetNumberOfCells())
+  {
     vtkLODActor::SetVisibility(theMode);
   }else{
     vtkLODActor::SetVisibility(false);
@@ -403,7 +622,10 @@ void SMESH_DeviceActor::SetVisibility(int theMode){
 }
 
 
-int SMESH_DeviceActor::GetVisibility(){
+int
+SMESH_DeviceActor
+::GetVisibility()
+{
   if(!GetUnstructuredGrid()->GetNumberOfCells()){
     vtkLODActor::SetVisibility(false);
   }
@@ -411,40 +633,61 @@ int SMESH_DeviceActor::GetVisibility(){
 }
 
 
-int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
-  vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID);
+int
+SMESH_DeviceActor
+::GetNodeObjId(int theVtkID)
+{
+  vtkIdType anID = theVtkID;
+
+  if(IsImplicitFunctionUsed())
+    anID = myExtractGeometry->GetNodeObjId(theVtkID);
+
   vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
-  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; aRetID = "<<aRetID);
+  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
   return aRetID;
 }
 
-float* SMESH_DeviceActor::GetNodeCoord(int theObjID){
-  vtkDataSet* aDataSet = myExtractGeometry->GetInput();
+vtkFloatingPointType* 
+SMESH_DeviceActor
+::GetNodeCoord(int theObjID)
+{
+  vtkDataSet* aDataSet = myMergeFilter->GetOutput();
   vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
-  float* aCoord = aDataSet->GetPoint(anID);
+  vtkFloatingPointType* aCoord = aDataSet->GetPoint(anID);
   if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
   return aCoord;
 }
 
 
-int SMESH_DeviceActor::GetElemObjId(int theVtkID){
+int
+SMESH_DeviceActor
+::GetElemObjId(int theVtkID)
+{
   vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
   if(anId < 0) 
     return -1;
-  vtkIdType anId2 = myExtractUnstructuredGrid->GetInputId(anId);
+
+  vtkIdType anId2 = anId;
+  if(IsImplicitFunctionUsed())
+    anId2 = myExtractGeometry->GetElemObjId(anId);
   if(anId2 < 0) 
     return -1;
-  vtkIdType anId3 = myExtractGeometry->GetElemObjId(anId2);
+
+  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);
+     MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
   return aRetID;
 }
 
-vtkCell* SMESH_DeviceActor::GetElemCell(int theObjID){
-  vtkDataSet* aDataSet = myExtractGeometry->GetInput();
+vtkCell* 
+SMESH_DeviceActor
+::GetElemCell(int theObjID)
+{
+  vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
   vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
   vtkCell* aCell = aDataSet->GetCell(aGridID);
   if(MYDEBUG) 
@@ -453,31 +696,45 @@ vtkCell* SMESH_DeviceActor::GetElemCell(int theObjID){
 }
 
 
-float SMESH_DeviceActor::GetShrinkFactor(){
+vtkFloatingPointType 
+SMESH_DeviceActor
+::GetShrinkFactor()
+{
   return myShrinkFilter->GetShrinkFactor();
 }
 
-void SMESH_DeviceActor::SetShrinkFactor(float theValue){
+void
+SMESH_DeviceActor
+::SetShrinkFactor(vtkFloatingPointType theValue)
+{
   theValue = theValue > 0.1? theValue: 0.8;
   myShrinkFilter->SetShrinkFactor(theValue);
   Modified();
 }
 
 
-void SMESH_DeviceActor::SetHighlited(bool theIsHighlited){
+void
+SMESH_DeviceActor
+::SetHighlited(bool theIsHighlited)
+{
+  if ( myIsHighlited == theIsHighlited )
+    return;
   myIsHighlited = theIsHighlited;
   Modified();
 }
 
-void SMESH_DeviceActor::Render(vtkRenderer *ren, vtkMapper* m){
+void
+SMESH_DeviceActor
+::Render(vtkRenderer *ren, vtkMapper* m)
+{
   int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
-  float aStoredFactor, aStoredUnit; 
+  vtkFloatingPointType aStoredFactor, aStoredUnit; 
   vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
 
   vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
-  float aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
+  vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
   if(myIsHighlited){
-    static float EPS = .01;
+    static vtkFloatingPointType EPS = .01;
     aUnits *= (1.0-EPS);
   }
   vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
@@ -488,7 +745,11 @@ void SMESH_DeviceActor::Render(vtkRenderer *ren, vtkMapper* m){
 }
 
 
-void SMESH_DeviceActor::SetPolygonOffsetParameters(float factor, float units){
+void
+SMESH_DeviceActor
+::SetPolygonOffsetParameters(vtkFloatingPointType factor, 
+                            vtkFloatingPointType units)
+{
   myPolygonOffsetFactor = factor;
   myPolygonOffsetUnits = units;
 }