Salome HOME
0019941: EDF 766 SMESH : Max length hypothesis
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_AddQuadraticElementDlg.cxx
index cc2e4b16f8e59d1521f38ad64402d01d5da3763a..1c3106e735eb3c1ed149aceebfa603bd56d8d136 100644 (file)
@@ -1,29 +1,29 @@
-// SMESH SMESHGUI : GUI for SMESH component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+//  Copyright (C) 2003-2007  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 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. 
+//  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 
+//  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
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// SMESH SMESHGUI : GUI for SMESH component
 // File   : SMESHGUI_AddMeshElementDlg.cxx
 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
-//
-
 // SMESH includes
+//
 #include "SMESHGUI_AddQuadraticElementDlg.h"
 
 #include "SMESHGUI.h"
@@ -34,6 +34,7 @@
 
 #include <SMESH_Actor.h>
 #include <SMESH_ActorUtils.h>
+#include <SMESH_FaceOrientationFilter.h>
 #include <SMDS_Mesh.hxx>
 
 // SALOME GUI includes
@@ -63,6 +64,7 @@
 #include <vtkIdList.h>
 #include <vtkUnstructuredGrid.h>
 #include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
 #include <vtkCellType.h>
 
@@ -88,7 +90,7 @@
 
 namespace SMESH
 {
-  void ReverseConnectivity( std::vector<int> & ids, int type )
+  void ReverseConnectivity( std::vector<vtkIdType> & ids, int type )
   {
     // for reverse connectivity of other types keeping the first id, see
     // void SMESH_VisualObjDef::buildElemPrs() in SMESH_Object.cxx:900
@@ -136,7 +138,7 @@ namespace SMESH
       reverse( ids.begin(), ids.end() );
     }
     else {
-      std::vector<int> aRevIds( ids.size() );
+      std::vector<vtkIdType> aRevIds( ids.size() );
       for ( int i = 0; i < ids.size(); i++)
         aRevIds[ i ] = ids[ conn[ i ]];
       ids = aRevIds;
@@ -153,7 +155,11 @@ namespace SMESH
     vtkUnstructuredGrid* myGrid;
     //vtkProperty* myBackProp, *myProp;
 
-    vtkFloatingPointType myRGB[3], myBackRGB[3];
+    //vtkFloatingPointType myRGB[3], myBackRGB[3];
+
+    SALOME_Actor* myFaceOrientation;
+    vtkPolyDataMapper* myFaceOrientationDataMapper;
+    SMESH_FaceOrientationFilter* myFaceOrientationFilter;
 
   public:
     TElementSimulation (SalomeApp_Application* theApplication)
@@ -176,18 +182,39 @@ namespace SMESH
       myPreviewActor->SetMapper(myMapper);
 
       vtkProperty* myProp = vtkProperty::New();
-      GetColor( "SMESH", "fill_color", myRGB[0], myRGB[1], myRGB[2], QColor( 0, 170, 255 ) );
-      myProp->SetColor( myRGB[0], myRGB[1], myRGB[2] );
+      vtkFloatingPointType aRGB[3], aBackRGB[3];
+      GetColor( "SMESH", "fill_color", aRGB[0], aRGB[1], aRGB[2], QColor( 0, 170, 255 ) );
+      myProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
       myPreviewActor->SetProperty( myProp );
       myProp->Delete();
 
       vtkProperty* myBackProp = vtkProperty::New();
-      GetColor( "SMESH", "backface_color", myBackRGB[0], myBackRGB[1], myBackRGB[2], QColor( 0, 0, 255 ) );
-      myBackProp->SetColor( myBackRGB[0], myBackRGB[1], myBackRGB[2] );
+      GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) );
+      myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] );
       myPreviewActor->SetBackfaceProperty( myBackProp );
       myBackProp->Delete();
 
       myVTKViewWindow->AddActor(myPreviewActor);
+
+      // Orientation of faces
+      myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
+      myFaceOrientationFilter->SetInput(myGrid);
+
+      myFaceOrientationDataMapper = vtkPolyDataMapper::New();
+      myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());
+
+      myFaceOrientation = SALOME_Actor::New();
+      myFaceOrientation->PickableOff();
+      myFaceOrientation->VisibilityOff();
+      myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
+
+      vtkProperty* anOrientationProp = vtkProperty::New();
+      GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) );
+      anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
+      myFaceOrientation->SetProperty( anOrientationProp );
+      anOrientationProp->Delete();
+
+      myVTKViewWindow->AddActor(myFaceOrientation);
     }
 
     typedef std::vector<vtkIdType> TVTKIds;
@@ -262,7 +289,7 @@ namespace SMESH
 
       myPreviewActor->GetMapper()->Update();
       myPreviewActor->SetRepresentation( theMode );
-      SetVisibility(true);
+      SetVisibility(true, theActor->GetFacesOriented());
 
       // restore normal orientation
       if ( aType == VTK_CONVEX_POINT_SET ) {
@@ -273,9 +300,10 @@ namespace SMESH
     }
 
 
-    void SetVisibility (bool theVisibility)
+    void SetVisibility (bool theVisibility, bool theShowOrientation = false)
     {
       myPreviewActor->SetVisibility(theVisibility);
+      myFaceOrientation->SetVisibility(theShowOrientation);
       RepaintCurrentView();
     }
 
@@ -284,12 +312,19 @@ namespace SMESH
     {
       if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
        myVTKViewWindow->RemoveActor(myPreviewActor);
+       myVTKViewWindow->RemoveActor(myFaceOrientation);
       }
       myPreviewActor->Delete();
+      myFaceOrientation->Delete();
 
       myMapper->RemoveAllInputs();
       myMapper->Delete();
 
+      myFaceOrientationFilter->Delete();
+
+      myFaceOrientationDataMapper->RemoveAllInputs();
+      myFaceOrientationDataMapper->Delete();
+
       myGrid->Delete();
 
 //       myProp->Delete();
@@ -631,7 +666,7 @@ void SMESHGUI_AddQuadraticElementDlg::ClickOnApply()
 
   BusyLocker lock( myBusy );
 
-  std::vector<int> anIds;
+  std::vector<vtkIdType> anIds;
 
   switch (myType) {
   case QUAD_EDGE: