From 16ebf90e08571ea8c25db107e3e88a6d5fe116b0 Mon Sep 17 00:00:00 2001 From: Afeef Date: Thu, 1 Apr 2021 13:19:09 +0200 Subject: [PATCH] Use old routines for nonlinear cells (quadratic 1D and 2D): This should fix arc visulization for quadratic elements --- src/VTKViewer/VTKViewer_GeometryFilter.cxx | 108 +++++++++++++++------ src/VTKViewer/VTKViewer_GeometryFilter.h | 3 +- 2 files changed, 80 insertions(+), 31 deletions(-) diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.cxx b/src/VTKViewer/VTKViewer_GeometryFilter.cxx index f2c3292d4..e715f0b57 100644 --- a/src/VTKViewer/VTKViewer_GeometryFilter.cxx +++ b/src/VTKViewer/VTKViewer_GeometryFilter.cxx @@ -50,6 +50,9 @@ #include #include #include +#include +#include +#include #include #include @@ -144,6 +147,18 @@ static inline bool toShowEdge( vtkIdType id1, vtkIdType id2, vtkIdType cellId, v return ( cells[iCell] == cellId ); } +//------------------------------------------------------------------------------ +// Excluded faces are defined here. +struct vtkExcludedFaces +{ + vtkStaticCellLinksTemplate* Links; + vtkExcludedFaces() + : Links(nullptr) + { + } + ~vtkExcludedFaces() { delete this->Links; } +}; + int VTKViewer_GeometryFilter ::RequestData( @@ -152,36 +167,79 @@ VTKViewer_GeometryFilter vtkInformationVector *outputVector) { - if (delegateToVtk) - { - int serror = vtkGeometryFilter::RequestData(request, inputVector , outputVector); - return serror; - } - else - { - // get the info objects - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation *outInfo = outputVector->GetInformationObject(0); + // get the info objects + vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the input and ouptut + vtkDataSet *input = vtkDataSet::SafeDownCast( + inInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkPolyData *output = vtkPolyData::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); - // get the input and ouptut - vtkDataSet *input = vtkDataSet::SafeDownCast( - inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPolyData *output = vtkPolyData::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkIdType numCells=input->GetNumberOfCells(); + vtkIdType numPts = input->GetNumberOfPoints(); - vtkIdType numCells=input->GetNumberOfCells(); + if (numPts == 0 || numCells == 0) + { + return 0; + } - if (numCells == 0) + if (delegateToVtk) + { + FastMode = false; + Merging = true; + + // get the info objects excluded faces + vtkInformation* excInfo = inputVector[1]->GetInformationObject(0); + + vtkExcludedFaces exc; // Will delete exc->Links when goes out of scope + if (excInfo) { - return 0; + vtkPolyData* excFaces = vtkPolyData::SafeDownCast(excInfo->Get(vtkDataObject::DATA_OBJECT())); + vtkCellArray* excPolys = excFaces->GetPolys(); + if (excPolys->GetNumberOfCells() > 0) + { + exc.Links = new vtkStaticCellLinksTemplate; + exc.Links->ThreadedBuildLinks(numPts, excPolys->GetNumberOfCells(), excPolys); + } } + switch (input->GetDataObjectType()) + { + case VTK_POLY_DATA: + return this->vtkGeometryFilter::PolyDataExecute(input, output, &exc); + case VTK_UNSTRUCTURED_GRID: + { + vtkUnstructuredGrid* inputUnstrctured = static_cast(input); + bool Contains1D2DQuads = false; + if ( vtkUnsignedCharArray* types = inputUnstrctured->GetCellTypesArray() ) + { + std::set quad1D2DTypes; + quad1D2DTypes.insert( VTK_QUADRATIC_EDGE ); + quad1D2DTypes.insert( VTK_QUADRATIC_TRIANGLE ); + quad1D2DTypes.insert( VTK_BIQUADRATIC_TRIANGLE ); + quad1D2DTypes.insert( VTK_QUADRATIC_QUAD ); + quad1D2DTypes.insert( VTK_BIQUADRATIC_QUAD ); + quad1D2DTypes.insert( VTK_QUADRATIC_POLYGON ); + for ( int i = 0; i < types->GetNumberOfTuples() && !Contains1D2DQuads; ++i ) + Contains1D2DQuads = quad1D2DTypes.count( types->GetValue(i) ); + } + if ( Contains1D2DQuads ) + return this->UnstructuredGridExecute(input, output, outInfo); + else + return this->vtkGeometryFilter::UnstructuredGridExecute(input, output, nullptr, &exc); + } + } + + return this->vtkGeometryFilter::DataSetExecute(input, output, &exc); + } + else // !delegateToVtk + { if (input->GetDataObjectType() == VTK_UNSTRUCTURED_GRID){ return this->UnstructuredGridExecute(input, output, outInfo); }else return Superclass::RequestData(request,inputVector,outputVector); - - return 1; } } @@ -191,15 +249,6 @@ VTKViewer_GeometryFilter vtkPolyData *output, vtkInformation */*outInfo*/) { - - if (delegateToVtk) - { - FastMode = true; - Merging = true; - int serror = vtkGeometryFilter::UnstructuredGridExecute( dataSetInput, output); - return serror; - } - else{ vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput; vtkCellArray *Connectivity = input->GetCells(); // Check input @@ -1241,7 +1290,6 @@ VTKViewer_GeometryFilter } return 1; - } } void diff --git a/src/VTKViewer/VTKViewer_GeometryFilter.h b/src/VTKViewer/VTKViewer_GeometryFilter.h index 8c1d44188..16f3dd219 100644 --- a/src/VTKViewer/VTKViewer_GeometryFilter.h +++ b/src/VTKViewer/VTKViewer_GeometryFilter.h @@ -35,6 +35,7 @@ #endif class vtkUnstructuredGrid; +struct vtkExcludedFaces; /*! \brief This class used same as vtkGeometryFilter. See documentation on VTK for more information. */ @@ -125,7 +126,7 @@ protected: */ ~VTKViewer_GeometryFilter(); - virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override; //special cases for performance -- 2.39.2