Commit 4a25e5c6 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot

Merge topic '16777_tessellator_fixes'

67a46781 BUG #16777: Pass cell data in vtkTessellatorFilter.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: David Thompson's avatarDavid Thompson <david.thompson@kitware.com>
Merge-request: !1667
parents f40851c1 67a46781
Pipeline #19181 running with stage
......@@ -6,49 +6,44 @@
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
#include "vtkActor2D.h"
#include "vtkActor.h"
#include "vtkCellData.h"
#include "vtkCell.h"
#include "vtkCellTypes.h"
#include "vtkCommand.h"
#include "vtkDataArray.h"
#include "vtkDataSet.h"
#include "vtkDataSetMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShrinkFilter.h"
#include "vtkCellTypes.h"
#include "vtkLabeledDataMapper.h"
#include "vtkEdgeSubdivisionCriterion.h"
#include "vtkGlyph3D.h"
#include "vtkIdList.h"
#include "vtkIdTypeArray.h"
#include "vtkLabeledDataMapper.h"
#include "vtkObjectFactory.h"
#include "vtkPNGWriter.h"
#include "vtkPointData.h"
#include "vtkPoints.h"
#include "vtkPNGWriter.h"
#include "vtkTextActor.h"
#include "vtkGlyph3D.h"
#include "vtkSphereSource.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor2D.h"
#include "vtkProperty.h"
#include "vtkRandomAttributeGenerator.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkShrinkFilter.h"
#include "vtkSphereSource.h"
#include "vtkStreamingTessellator.h"
#include "vtkTessellatorFilter.h"
#include "vtkTestUtilities.h"
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
#include "vtkToolkits.h"
#include "vtkUnstructuredGrid.h"
#include "vtkXMLUnstructuredGridReader.h"
#include "vtkWindowToImageFilter.h"
#include "vtkStreamingTessellator.h"
#include "vtkEdgeSubdivisionCriterion.h"
#include "vtkXMLUnstructuredGridReader.h"
#include <algorithm>
#include "vtkObjectFactory.h"
#include "vtkIdList.h"
#include "vtkDataArray.h"
#include "vtkPointData.h"
#include "vtkCellData.h"
#include "vtkCell.h"
#include "vtkDataSet.h"
using std::copy;
#undef ONLY_WIRE
......@@ -3638,7 +3633,6 @@ int TestTessellator( int argc, char* argv[] )
}
#endif // VTK_CHECK_RESULTS
#ifdef VTK_DATA_ROOT
// Test vtkTessellatorFilter and vtkDataSetEdgeSubdivisionCriterion if we have a dataset to use
char* fname = vtkTestUtilities::ExpandDataFileName( argc, argv, "Data/quadraticTetra01.vtu" );
if ( fname )
......@@ -3646,10 +3640,15 @@ int TestTessellator( int argc, char* argv[] )
vtkXMLUnstructuredGridReader* rdr = vtkXMLUnstructuredGridReader::New();
rdr->SetFileName( fname );
delete [] fname ;
rdr->Update();
// Add filter to generate some scalar data.
vtkRandomAttributeGenerator* rag = vtkRandomAttributeGenerator::New();
rag->SetInputConnection(rdr->GetOutputPort());
rag->SetGenerateCellScalars(1);
rag->SetGenerateCellVectors(1);
vtkTessellatorFilter* tf = vtkTessellatorFilter::New();
tf->SetInputConnection( rdr->GetOutputPort() );
tf->SetInputConnection( rag->GetOutputPort() );
tf->MergePointsOn();
tf->Update();
......@@ -3662,10 +3661,16 @@ int TestTessellator( int argc, char* argv[] )
tf->MergePointsOff();
tf->Update();
if (tf->GetOutput()->GetCellData()->GetNumberOfArrays() != 2)
{
std::cerr << "ERROR: Failed to pass through cell data!\n";
vtkTessellatorError = 1;
}
rdr->Delete();
rag->Delete();
tf->Delete();
}
#endif // VTK_DATA_ROOT
return vtkTessellatorError;
}
......@@ -37,6 +37,19 @@
vtkStandardNewMacro(vtkTessellatorFilter);
namespace
{
void vtkCopyTuples(
vtkDataSetAttributes* inDSA, vtkIdType inId,
vtkDataSetAttributes* outDSA, vtkIdType beginId, vtkIdType endId)
{
for (vtkIdType cc=beginId; cc < endId; ++cc)
{
outDSA->CopyData(inDSA, inId, cc);
}
}
}
// ========================================
// vtkCommand subclass for reporting progress of merge filter
class vtkProgressCommand : public vtkCommand
......@@ -403,6 +416,8 @@ void vtkTessellatorFilter::SetupOutput(
this->Subdivider->PassField( a, array->GetNumberOfComponents(), this->Tessellator );
++attrib;
}
output->GetCellData()->CopyAllocate(input->GetCellData(), input->GetNumberOfCells());
}
void vtkTessellatorFilter::MergeOutputPoints( vtkUnstructuredGrid* input, vtkUnstructuredGrid* output )
......@@ -478,7 +493,6 @@ void vtkTessellatorFilter::MergeOutputPoints( vtkUnstructuredGrid* input, vtkUns
delete [] ptMap;
cellPoints->Delete();
output->Squeeze();
}
void vtkTessellatorFilter::Teardown()
......@@ -1093,10 +1107,10 @@ int vtkTessellatorFilter::RequestData(
vtkDataSet* mesh = vtkDataSet::SafeDownCast(
inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkUnstructuredGrid* tmpOut;
vtkSmartPointer<vtkUnstructuredGrid> tmpOut;
if ( this->MergePoints )
{
tmpOut = vtkUnstructuredGrid::New();
tmpOut = vtkSmartPointer<vtkUnstructuredGrid>::New();
}
else
{
......@@ -1129,7 +1143,10 @@ int vtkTessellatorFilter::RequestData(
progCells += deltaProg;
for ( ; (cell < progCells) && (cell < numCells); ++cell )
{
const vtkIdType nextOutCellId = this->OutputMesh->GetNumberOfCells();
this->Subdivider->SetCellId( cell );
vtkCell* cp = this->Subdivider->GetCell(); // We set the cell ID, get the vtkCell pointer
int np = cp->GetCellType();
double* pcoord = cp->GetParametricCoords();
......@@ -1466,6 +1483,11 @@ int vtkTessellatorFilter::RequestData(
// do nothing
break;
}
// Copy cell data.
vtkCopyTuples(mesh->GetCellData(), cell,
this->OutputMesh->GetCellData(),
nextOutCellId, this->OutputMesh->GetNumberOfCells());
}
this->UpdateProgress( (double)( progress / 100. ) );
}
......@@ -1473,14 +1495,14 @@ int vtkTessellatorFilter::RequestData(
if ( this->MergePoints )
{
this->MergeOutputPoints( tmpOut, output );
tmpOut->Delete();
}
output->Squeeze();
this->Teardown();
return 1;
}
//----------------------------------------------------------------------------
int vtkTessellatorFilter::FillInputPortInformation(
int vtkNotUsed(port), vtkInformation* info )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment