[bos #42217][EDF 28921] Horseshoe with bodyfitting. Added vtkTriangleFilter to prevent concave polygons render artifacts.

This commit is contained in:
Konstantin Leontev 2024-08-12 12:42:04 +01:00
parent dda7e97469
commit a8ab49d0b3
3 changed files with 22 additions and 3 deletions

View File

@ -43,6 +43,7 @@
#include <vtkObjectFactory.h> #include <vtkObjectFactory.h>
#include <vtkShrinkFilter.h> #include <vtkShrinkFilter.h>
#include <vtkShrinkPolyData.h> #include <vtkShrinkPolyData.h>
#include <vtkTriangleFilter.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkPolyData.h> #include <vtkPolyData.h>
@ -109,6 +110,7 @@ SMESH_DeviceActor
myMergeFilter = vtkMergeFilter::New(); myMergeFilter = vtkMergeFilter::New();
myGeomFilter = VTKViewer_GeometryFilter::New(); myGeomFilter = VTKViewer_GeometryFilter::New();
myTriangleFilter = vtkTriangleFilter::New();
myTransformFilter = VTKViewer_TransformFilter::New(); myTransformFilter = VTKViewer_TransformFilter::New();
@ -153,6 +155,7 @@ SMESH_DeviceActor
myFaceOrientation->Delete(); myFaceOrientation->Delete();
myGeomFilter->Delete(); myGeomFilter->Delete();
myTriangleFilter->Delete();
myTransformFilter->Delete(); myTransformFilter->Delete();
@ -251,9 +254,10 @@ SMESH_DeviceActor
anId++; // 3 anId++; // 3
myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
myTriangleFilter->SetInputConnection(myGeomFilter->GetOutputPort());
anId++; // 4 anId++; // 4
myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() ); myPassFilter[ anId ]->SetInputConnection( myTriangleFilter->GetOutputPort() );
myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() ); myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
anId++; // 5 anId++; // 5

View File

@ -46,6 +46,7 @@ class vtkLookupTable;
class vtkImplicitBoolean; class vtkImplicitBoolean;
class vtkPassThrough; class vtkPassThrough;
class vtkPlaneCollection; class vtkPlaneCollection;
class vtkTriangleFilter;
class VTKViewer_Transform; class VTKViewer_Transform;
class VTKViewer_TransformFilter; class VTKViewer_TransformFilter;
@ -182,6 +183,7 @@ class SMESHOBJECT_EXPORT SMESH_DeviceActor: public vtkLODActor{
bool myStoreClippingMapping; bool myStoreClippingMapping;
VTKViewer_GeometryFilter *myGeomFilter; VTKViewer_GeometryFilter *myGeomFilter;
vtkTriangleFilter* myTriangleFilter = nullptr;
VTKViewer_TransformFilter *myTransformFilter; VTKViewer_TransformFilter *myTransformFilter;
std::vector<vtkPassThrough*> myPassFilter; std::vector<vtkPassThrough*> myPassFilter;

View File

@ -70,6 +70,8 @@
#include <vtkPolyDataMapper.h> #include <vtkPolyDataMapper.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkCellData.h> #include <vtkCellData.h>
#include <vtkTriangleFilter.h>
#include <vtkGeometryFilter.h>
// Qt includes // Qt includes
#include <QComboBox> #include <QComboBox>
@ -108,6 +110,8 @@ namespace SMESH
SALOME_Actor* myFaceOrientation; SALOME_Actor* myFaceOrientation;
vtkPolyDataMapper* myFaceOrientationDataMapper; vtkPolyDataMapper* myFaceOrientationDataMapper;
SMESH_FaceOrientationFilter* myFaceOrientationFilter; SMESH_FaceOrientationFilter* myFaceOrientationFilter;
vtkSmartPointer<vtkGeometryFilter> myGeometryFilter = nullptr;
vtkSmartPointer<vtkTriangleFilter> myTriangleFilter = nullptr;
public: public:
TElementSimulation (SalomeApp_Application* theApplication) TElementSimulation (SalomeApp_Application* theApplication)
@ -120,9 +124,15 @@ namespace SMESH
myGrid = vtkUnstructuredGrid::New(); myGrid = vtkUnstructuredGrid::New();
myGeometryFilter = vtkSmartPointer<vtkGeometryFilter>::New();
myGeometryFilter->SetInputData(myGrid);
myTriangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
myTriangleFilter->SetInputConnection(myGeometryFilter->GetOutputPort());
// Create and display actor // Create and display actor
myMapper = vtkDataSetMapper::New(); myMapper = vtkDataSetMapper::New();
myMapper->SetInputData(myGrid); myMapper->SetInputConnection(myTriangleFilter->GetOutputPort());
myPreviewActor = SALOME_Actor::New(); myPreviewActor = SALOME_Actor::New();
myPreviewActor->PickableOff(); myPreviewActor->PickableOff();
@ -148,7 +158,7 @@ namespace SMESH
// Orientation of faces // Orientation of faces
myFaceOrientationFilter = SMESH_FaceOrientationFilter::New(); myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
myFaceOrientationFilter->SetInputData(myGrid); myFaceOrientationFilter->SetInputConnection(myTriangleFilter->GetOutputPort());
myFaceOrientationDataMapper = vtkPolyDataMapper::New(); myFaceOrientationDataMapper = vtkPolyDataMapper::New();
myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort()); myFaceOrientationDataMapper->SetInputConnection(myFaceOrientationFilter->GetOutputPort());
@ -209,6 +219,9 @@ namespace SMESH
myGrid->InsertNextCell(theType,anIds); myGrid->InsertNextCell(theType,anIds);
anIds->Delete(); anIds->Delete();
myGeometryFilter->Update();
myTriangleFilter->Update();
myGrid->Modified(); myGrid->Modified();
SetVisibility(true, theActor->GetFacesOriented(), false); SetVisibility(true, theActor->GetFacesOriented(), false);