Salome HOME
Windows port
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index 337aba6483d5bceb36398e573d1c371553a48bbc..2a657eb34b87da6fb05ff0a9413aa0f1db403d74 100644 (file)
@@ -1,41 +1,40 @@
-//  SMESH OBJECT : interactive object for SMESH visualization
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  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 
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
+//  You should have received a copy of the GNU Lesser General Public
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH OBJECT : interactive object for SMESH visualization
 //  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 "SMESH_FaceOrientationFilter.h"
+#include "VTKViewer_CellLocationsArray.h"
 
-#include "SALOME_Transform.h"
-#include "SALOME_TransformFilter.h"
-#include "SALOME_PassThroughFilter.h"
-#include "SALOME_ExtractUnstructuredGrid.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 <vtkRenderer.h>
 
 #include "utilities.h"
 
@@ -75,9 +76,15 @@ using namespace std;
 vtkStandardNewMacro(SMESH_DeviceActor);
 
 
-SMESH_DeviceActor::SMESH_DeviceActor(){
-  myIsShrunk = false;
+SMESH_DeviceActor
+::SMESH_DeviceActor()
+{
+  if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
+
   myIsShrinkable = false;
+  myIsShrunk = false;
+  myIsHighlited = false;
+
   myRepresentation = eSurface;
 
   myProperty = vtkProperty::New();
@@ -91,69 +98,106 @@ SMESH_DeviceActor::SMESH_DeviceActor(){
 
   myShrinkFilter = vtkShrinkFilter::New();
 
+  myStoreClippingMapping = false;
+
   myExtractGeometry = SMESH_ExtractGeometry::New();
   myExtractGeometry->SetReleaseDataFlag(true);
-  myExtractGeometry->SetStoreMapping(true);
   myIsImplicitFunctionUsed = false;
 
-  myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
-  myExtractUnstructuredGrid->SetStoreMapping(true);
-
+  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());
+
+  // Orientation of faces
+  myIsFacesOriented = false;
+
+  vtkFloatingPointType anRGB[3] = { 1, 1, 1 };
+  SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
+
+  myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
+
+  myFaceOrientationDataMapper = vtkPolyDataMapper::New();
+  myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());
+
+  myFaceOrientation = vtkActor::New();
+  myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
+  myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
 }
 
 
-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();
   }
+
+  // Orientation of faces
+  myFaceOrientationFilter->Delete();
+
+  myFaceOrientationDataMapper->RemoveAllInputs();
+  myFaceOrientationDataMapper->Delete();
+
+  myFaceOrientation->Delete();
 }
 
 
-void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){
-  if (myStoreMapping == theStoreMapping)
-    return;
-  myStoreMapping = theStoreMapping;
-  myGeomFilter->SetStoreMapping( myStoreMapping );
-  Modified();
+void
+SMESH_DeviceActor
+::SetStoreGemetryMapping(bool theStoreMapping)
+{
+  myGeomFilter->SetStoreMapping(theStoreMapping);
+  SetStoreClippingMapping(theStoreMapping);
 }
 
 
-void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, 
-                            vtkImplicitBoolean* theImplicitBoolean)
+void
+SMESH_DeviceActor
+::SetStoreClippingMapping(bool theStoreMapping)
+{
+  myStoreClippingMapping = theStoreMapping;
+  myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
+  SetStoreIDMapping(theStoreMapping);
+}
+
+
+void
+SMESH_DeviceActor
+::SetStoreIDMapping(bool theStoreMapping)
+{
+  myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
+}
+
+
+void 
+SMESH_DeviceActor
+::Init(TVisualObjPtr theVisualObj, 
+       vtkImplicitBoolean* theImplicitBoolean)
 {
   myVisualObj = theVisualObj;
   myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
@@ -162,12 +206,9 @@ void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj,
 
 
 void
-SMESH_DeviceActor::
-SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
+SMESH_DeviceActor
+::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
 {
-  if(myIsImplicitFunctionUsed == theIsImplicitFunctionUsed)
-    return;
-
   int anId = 0;
   if(theIsImplicitFunctionUsed)
     myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
@@ -175,10 +216,14 @@ SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
     myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
     
   myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
+  SetStoreClippingMapping(myStoreClippingMapping);
 }
 
 
-void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
+void
+SMESH_DeviceActor
+::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
+{
   if(theGrid){
     //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
     myIsShrinkable = true;
@@ -190,11 +235,10 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
     myExtractGeometry->SetInput(myMergeFilter->GetOutput());
 
     int anId = 0;
-    myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
+    SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
     myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
     
     anId++; // 1
-    myGeomFilter->SetStoreMapping( myStoreMapping );
     myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 2
@@ -203,17 +247,13 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
 
     anId++; // 3
     myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
-    myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
 
     anId++; // 4
     myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
     myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
-    myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
-    myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 5
     myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
-    myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
 
     vtkLODActor::SetMapper( myMapper );
     Modified();
@@ -221,25 +261,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();
@@ -270,6 +322,7 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
     aScalars->Delete();
        
     theLookupTable->SetRange(aScalars->GetRange());
+    theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
     theLookupTable->Build();
     
     myMergeFilter->SetScalars(aDataSet);
@@ -279,15 +332,16 @@ void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
   theScalarBarActor->SetVisibility(anIsInitialized);
 }
 
-void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                         SMESH_DeviceActor* theDeviceActor,
-                                         vtkScalarBarActor* theScalarBarActor,
-                                         vtkLookupTable* theLookupTable)
+void
+SMESH_DeviceActor
+::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
+                   vtkScalarBarActor* theScalarBarActor,
+                   vtkLookupTable* theLookupTable)
 {
   bool anIsInitialized = theFunctor;
   myExtractUnstructuredGrid->ClearRegisteredCells();
   myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
-  myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll);
+  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
   myVisualObj->UpdateFunctor(theFunctor);
 
   using namespace SMESH::Controls;
@@ -334,7 +388,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 );
       
@@ -394,7 +448,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 );
       
@@ -419,22 +473,25 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
   theScalarBarActor->SetVisibility(anIsInitialized);
 }
 
-void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
-                                         SMESH_DeviceActor* theDeviceActor)
+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);
+  if ( dynamic_cast<FreeBorders*>(theFunctor.get()) ||
+       dynamic_cast<FreeFaces*>(theFunctor.get()) ) {
+    Predicate* aFreePredicate = dynamic_cast<Predicate*>(theFunctor.get());
+    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
     vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
     for( vtkIdType i = 0; i < aNbCells; i++ ){
       vtkIdType anObjId = myVisualObj->GetElemObjId(i);
-      if(aFreeBorders->IsSatisfy(anObjId))
+      if(aFreePredicate->IsSatisfy(anObjId))
        myExtractUnstructuredGrid->RegisterCell(i);
     }
     if(!myExtractUnstructuredGrid->IsCellsRegistered())
@@ -475,7 +532,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 );
     
@@ -487,29 +544,51 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
 
     SetUnstructuredGrid(aDataSet);
     aDataSet->Delete();
+  }else if(FreeNodes* aFreeNodes = dynamic_cast<FreeNodes*>(theFunctor.get())){
+    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+    vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+    vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
+    for( vtkIdType i = 0; i < aNbNodes; i++ ){
+      vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
+      if(aFreeNodes->IsSatisfy(anObjId))
+       myExtractUnstructuredGrid->RegisterCell(i);
+    }
+    if(!myExtractUnstructuredGrid->IsCellsRegistered())
+      myExtractUnstructuredGrid->RegisterCell(-1);
+    SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
   }
 }
 
 
 
 
-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());
   mTime = max(mTime,myMergeFilter->GetMTime());
   mTime = max(mTime,myGeomFilter->GetMTime());
   mTime = max(mTime,myTransformFilter->GetMTime());
+  mTime = max(mTime,myFaceOrientationFilter->GetMTime());
   return mTime;
 }
 
 
-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() )
   {
@@ -519,7 +598,10 @@ void SMESH_DeviceActor::SetShrink() {
   }
 }
 
-void SMESH_DeviceActor::UnShrink() {
+void
+SMESH_DeviceActor
+::UnShrink() 
+{
   if ( !myIsShrunk ) return;
   if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
   {    
@@ -531,37 +613,82 @@ void SMESH_DeviceActor::UnShrink() {
 }
 
 
-void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
+void
+SMESH_DeviceActor
+::SetFacesOriented(bool theIsFacesOriented) 
+{
+  if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() )
+  {
+    myIsFacesOriented = theIsFacesOriented;
+    if( theIsFacesOriented )
+      myFaceOrientationFilter->SetInput( aDataSet );
+    UpdateFaceOrientation();
+  }
+}
+
+void
+SMESH_DeviceActor
+::UpdateFaceOrientation()
+{
+  bool aShowFaceOrientation = myIsFacesOriented;
+  aShowFaceOrientation &= GetVisibility();
+  aShowFaceOrientation &= myRepresentation == eSurface;
+  myFaceOrientation->SetVisibility(aShowFaceOrientation);
+}
+
+
+void
+SMESH_DeviceActor
+::SetRepresentation(EReperesent theMode)
+{
   switch(theMode){
   case ePoint:
     myGeomFilter->SetInside(true);
+    myGeomFilter->SetWireframeMode(false);
     GetProperty()->SetRepresentation(0);
     break;
+  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 :
+  case eSurface:
     myGeomFilter->SetInside(false);
+    myGeomFilter->SetWireframeMode(false);
     GetProperty()->SetRepresentation(theMode);
   }
   myRepresentation = theMode;
+  UpdateFaceOrientation();
   GetProperty()->Modified();
   myMapper->Modified();
   Modified();
 }
 
 
-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);
   }
+  UpdateFaceOrientation();
 }
 
 
-int SMESH_DeviceActor::GetVisibility(){
+int
+SMESH_DeviceActor
+::GetVisibility()
+{
   if(!GetUnstructuredGrid()->GetNumberOfCells()){
     vtkLODActor::SetVisibility(false);
   }
@@ -569,27 +696,53 @@ int SMESH_DeviceActor::GetVisibility(){
 }
 
 
-int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
+void
+SMESH_DeviceActor
+::AddToRender(vtkRenderer* theRenderer)
+{
+  theRenderer->AddActor(this);
+  theRenderer->AddActor(myFaceOrientation);
+}
+
+void
+SMESH_DeviceActor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
+  theRenderer->RemoveActor(this);
+  theRenderer->RemoveActor(myFaceOrientation);
+}
+
+
+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){
+vtkFloatingPointType* 
+SMESH_DeviceActor
+::GetNodeCoord(int theObjID)
+{
   vtkDataSet* aDataSet = myMergeFilter->GetOutput();
   vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
-  float* aCoord = aDataSet->GetPoint(anID);
+  vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
   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;
@@ -610,41 +763,58 @@ int SMESH_DeviceActor::GetElemObjId(int theVtkID){
   return aRetID;
 }
 
-vtkCell* SMESH_DeviceActor::GetElemCell(int theObjID){
+vtkCell* 
+SMESH_DeviceActor
+::GetElemCell(int theObjID)
+{
   vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
   vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
-  vtkCell* aCell = aDataSet->GetCell(aGridID);
+  vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
   if(MYDEBUG) 
     MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
   return aCell;
 }
 
 
-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);
@@ -655,8 +825,38 @@ 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;
 }
 
+/*!
+ * On/Off representation 2D quadratic element as arked polygon
+ */
+void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
+  myGeomFilter->SetQuadraticArcMode(theFlag);
+}
+
+/*!
+ * Return true if 2D quadratic element displayed as arked polygon
+ */
+bool SMESH_DeviceActor::GetQuadraticArcMode(){
+  return myGeomFilter->GetQuadraticArcMode();
+}
+/*!
+ * Set Max angle for representation 2D quadratic element as arked polygon
+ */
+void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){
+  myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
+}
+
+/*!
+ * Return Max angle of the representation 2D quadratic element as arked polygon
+ */
+vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){
+  return myGeomFilter->GetQuadraticArcAngle();
+}