From a8ab49d0b35b94d81513cd41029a610512d34405 Mon Sep 17 00:00:00 2001 From: Konstantin Leontev Date: Mon, 12 Aug 2024 12:42:04 +0100 Subject: [PATCH] [bos #42217][EDF 28921] Horseshoe with bodyfitting. Added vtkTriangleFilter to prevent concave polygons render artifacts. --- src/OBJECT/SMESH_DeviceActor.cxx | 6 +++++- src/OBJECT/SMESH_DeviceActor.h | 2 ++ src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx | 17 +++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index be17fe3c3..fafd40aef 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,7 @@ SMESH_DeviceActor myMergeFilter = vtkMergeFilter::New(); myGeomFilter = VTKViewer_GeometryFilter::New(); + myTriangleFilter = vtkTriangleFilter::New(); myTransformFilter = VTKViewer_TransformFilter::New(); @@ -153,6 +155,7 @@ SMESH_DeviceActor myFaceOrientation->Delete(); myGeomFilter->Delete(); + myTriangleFilter->Delete(); myTransformFilter->Delete(); @@ -251,9 +254,10 @@ SMESH_DeviceActor anId++; // 3 myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); + myTriangleFilter->SetInputConnection(myGeomFilter->GetOutputPort()); anId++; // 4 - myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() ); + myPassFilter[ anId ]->SetInputConnection( myTriangleFilter->GetOutputPort() ); myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); anId++; // 5 diff --git a/src/OBJECT/SMESH_DeviceActor.h b/src/OBJECT/SMESH_DeviceActor.h index c8f17d254..f9a131f70 100644 --- a/src/OBJECT/SMESH_DeviceActor.h +++ b/src/OBJECT/SMESH_DeviceActor.h @@ -46,6 +46,7 @@ class vtkLookupTable; class vtkImplicitBoolean; class vtkPassThrough; class vtkPlaneCollection; +class vtkTriangleFilter; class VTKViewer_Transform; class VTKViewer_TransformFilter; @@ -182,6 +183,7 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{ bool myStoreClippingMapping; VTKViewer_GeometryFilter *myGeomFilter; + vtkTriangleFilter* myTriangleFilter = nullptr; VTKViewer_TransformFilter *myTransformFilter; std::vector myPassFilter; diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 7d38aa510..a1af7d572 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -70,6 +70,8 @@ #include #include #include +#include +#include // Qt includes #include @@ -108,6 +110,8 @@ namespace SMESH SALOME_Actor* myFaceOrientation; vtkPolyDataMapper* myFaceOrientationDataMapper; SMESH_FaceOrientationFilter* myFaceOrientationFilter; + vtkSmartPointer myGeometryFilter = nullptr; + vtkSmartPointer myTriangleFilter = nullptr; public: TElementSimulation (SalomeApp_Application* theApplication) @@ -120,9 +124,15 @@ namespace SMESH myGrid = vtkUnstructuredGrid::New(); + myGeometryFilter = vtkSmartPointer::New(); + myGeometryFilter->SetInputData(myGrid); + + myTriangleFilter = vtkSmartPointer::New(); + myTriangleFilter->SetInputConnection(myGeometryFilter->GetOutputPort()); + // Create and display actor myMapper = vtkDataSetMapper::New(); - myMapper->SetInputData(myGrid); + myMapper->SetInputConnection(myTriangleFilter->GetOutputPort()); myPreviewActor = SALOME_Actor::New(); myPreviewActor->PickableOff(); @@ -148,7 +158,7 @@ namespace SMESH // Orientation of faces myFaceOrientationFilter = SMESH_FaceOrientationFilter::New(); - myFaceOrientationFilter->SetInputData(myGrid); + myFaceOrientationFilter->SetInputConnection(myTriangleFilter->GetOutputPort()); myFaceOrientationDataMapper = vtkPolyDataMapper::New(); myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort()); @@ -209,6 +219,9 @@ namespace SMESH myGrid->InsertNextCell(theType,anIds); anIds->Delete(); + myGeometryFilter->Update(); + myTriangleFilter->Update(); + myGrid->Modified(); SetVisibility(true, theActor->GetFacesOriented(), false); -- 2.39.2