[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 <vtkShrinkFilter.h>
#include <vtkShrinkPolyData.h>
#include <vtkTriangleFilter.h>
#include <vtkProperty.h>
#include <vtkPolyData.h>
@ -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

View File

@ -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<vtkPassThrough*> myPassFilter;

View File

@ -70,6 +70,8 @@
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkCellData.h>
#include <vtkTriangleFilter.h>
#include <vtkGeometryFilter.h>
// Qt includes
#include <QComboBox>
@ -108,6 +110,8 @@ namespace SMESH
SALOME_Actor* myFaceOrientation;
vtkPolyDataMapper* myFaceOrientationDataMapper;
SMESH_FaceOrientationFilter* myFaceOrientationFilter;
vtkSmartPointer<vtkGeometryFilter> myGeometryFilter = nullptr;
vtkSmartPointer<vtkTriangleFilter> myTriangleFilter = nullptr;
public:
TElementSimulation (SalomeApp_Application* theApplication)
@ -120,9 +124,15 @@ namespace SMESH
myGrid = vtkUnstructuredGrid::New();
myGeometryFilter = vtkSmartPointer<vtkGeometryFilter>::New();
myGeometryFilter->SetInputData(myGrid);
myTriangleFilter = vtkSmartPointer<vtkTriangleFilter>::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);