From 577764e46d3e8ddd9cf3e425491a90d5a5081d6e Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 13 Mar 2020 19:37:51 +0300 Subject: [PATCH] Fix crash at switching off faces of shrunk 3D mesh --- src/VTKViewer/VTKViewer_ConvexTool.cxx | 3 +-- src/VTKViewer/VTKViewer_GeometryFilter.cxx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/VTKViewer/VTKViewer_ConvexTool.cxx b/src/VTKViewer/VTKViewer_ConvexTool.cxx index 41a3b3b39..3a3d8050b 100644 --- a/src/VTKViewer/VTKViewer_ConvexTool.cxx +++ b/src/VTKViewer/VTKViewer_ConvexTool.cxx @@ -107,9 +107,8 @@ VTKViewer_Triangulator myPoints->Modified(); // the VTK bug vtkIdType aNumPts; - vtkIdType const *tmp(nullptr); + vtkIdType const *tmp(myPointIds); theInput->GetCellPoints(theCellId, aNumPts, tmp); - std::copy(tmp,tmp+aNumPts,myPointIds); if ( aNumPts > 0 ) { double anAbsoluteCoord[3]; myPoints->SetNumberOfPoints(aNumPts); diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index 592b74377..6dba69fd7 100644 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -28,7 +28,6 @@ #include "VTKViewer_ConvexTool.h" #include "VTKViewer_ArcBuilder.h" -#include #include #include #include @@ -42,13 +41,15 @@ #include #include #include +#include +#include #include #include #include #include +#include #include #include -#include #include #include @@ -118,25 +119,24 @@ VTKViewer_GeometryFilter static inline bool toShowEdge( vtkIdType id1, vtkIdType id2, vtkIdType cellId, vtkUnstructuredGrid* input ) { // return true if the given cell is the 1st among cells including the edge - vtkCellLinks * links = static_cast(input->GetCellLinks()); + vtkStaticCellLinks * links = static_cast(input->GetCellLinks()); if ( !links ) { input->BuildLinks(); - links = static_cast(input->GetCellLinks()); + links = static_cast(input->GetCellLinks()); } if ( id1 < id2 ) std::swap( id1, id2 ); vtkIdType *cells = links->GetCells( id1 ); // among cells, look for a cell including the edge - vtkIdType *cellPts, npts, iCell = 0; + vtkIdType npts, iCell = 0; + vtkIdType const *cellPts; bool found = false; while ( !found ) { if ( cells[iCell] == cellId ) return true; - vtkIdType const *tmp(nullptr); - input->GetCellPoints( cells[iCell], npts, tmp ); - std::copy(tmp, tmp+npts, cellPts); + input->GetCellPoints( cells[iCell], npts, cellPts ); for ( vtkIdType i = 0; i < npts && !found; ++i ) found = ( cellPts[i] == id2 ); iCell += ( !found ); -- 2.39.2