From 7b09f5b72c15b7fdc3d000ed486d98a157faaba0 Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 26 Sep 2008 12:00:26 +0000 Subject: [PATCH] Orientation of faces is added for new elements' preview (remark for issue 0017291: EDF 591 SMESH : Visualization of the orientation of the normal vector of the mesh faces) --- src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx | 38 ++++++++++++++++++- .../SMESHGUI_AddQuadraticElementDlg.cxx | 38 ++++++++++++++++++- 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 415f32f6f..bccdc505e 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -34,6 +34,7 @@ #include #include +#include #include // SALOME GUI inclues @@ -59,6 +60,7 @@ #include #include #include +#include #include // Qt includes @@ -90,6 +92,10 @@ namespace SMESH vtkDataSetMapper* myMapper; vtkUnstructuredGrid* myGrid; + SALOME_Actor* myFaceOrientation; + vtkPolyDataMapper* myFaceOrientationDataMapper; + SMESH_FaceOrientationFilter* myFaceOrientationFilter; + public: TElementSimulation (SalomeApp_Application* theApplication) { @@ -124,6 +130,26 @@ namespace SMESH aBackProp->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", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); + anOrientationProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + myFaceOrientation->SetProperty( anOrientationProp ); + anOrientationProp->Delete(); + + myVTKViewWindow->AddActor(myFaceOrientation); } typedef std::vector TVTKIds; @@ -171,13 +197,14 @@ namespace SMESH myGrid->Modified(); - SetVisibility(true); + SetVisibility(true, theActor->GetFacesOriented()); } - void SetVisibility (bool theVisibility) + void SetVisibility (bool theVisibility, bool theShowOrientation = false) { myPreviewActor->SetVisibility(theVisibility); + myFaceOrientation->SetVisibility(theShowOrientation); RepaintCurrentView(); } @@ -186,12 +213,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(); } }; diff --git a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx index cc2e4b16f..0571ed4dc 100644 --- a/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddQuadraticElementDlg.cxx @@ -34,6 +34,7 @@ #include #include +#include #include // SALOME GUI includes @@ -63,6 +64,7 @@ #include #include #include +#include #include #include @@ -155,6 +157,10 @@ namespace SMESH vtkFloatingPointType myRGB[3], myBackRGB[3]; + SALOME_Actor* myFaceOrientation; + vtkPolyDataMapper* myFaceOrientationDataMapper; + SMESH_FaceOrientationFilter* myFaceOrientationFilter; + public: TElementSimulation (SalomeApp_Application* theApplication) { @@ -188,6 +194,26 @@ namespace SMESH 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", myRGB[0], myRGB[1], myRGB[2], QColor( 255, 255, 255 ) ); + anOrientationProp->SetColor( myRGB[0], myRGB[1], myRGB[2] ); + myFaceOrientation->SetProperty( anOrientationProp ); + anOrientationProp->Delete(); + + myVTKViewWindow->AddActor(myFaceOrientation); } typedef std::vector TVTKIds; @@ -262,7 +288,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 +299,10 @@ namespace SMESH } - void SetVisibility (bool theVisibility) + void SetVisibility (bool theVisibility, bool theShowOrientation = false) { myPreviewActor->SetVisibility(theVisibility); + myFaceOrientation->SetVisibility(theShowOrientation); RepaintCurrentView(); } @@ -284,12 +311,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(); -- 2.30.2