Skip to content
Snippets Groups Projects
Commit 5669d2b7 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'fix_extract_grid'


d5ef995f Handle extracting outer faces.

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: default avatarBerk Geveci <berk.geveci@kitware.com>
Merge-request: !2765
parents 80d36e98 d5ef995f
Branches master
No related tags found
No related merge requests found
......@@ -478,6 +478,14 @@ void vtkExtractStructuredGridHelper::CopyCellData(int inExt[6], int outExt[6],
int outCellExt[6];
vtkStructuredData::GetCellExtentFromPointExtent(outExt,outCellExt);
// clamp outCellExt using inpCellExt. This is needed for the case where outExt
// is the outer face of the dataset along any of the dimensions.
for (int dim = 0; dim < 3; ++dim)
{
EMIN(outCellExt, dim) = std::min(EMAX(inpCellExt, dim), EMIN(outCellExt, dim));
EMAX(outCellExt, dim) = std::min(EMAX(inpCellExt, dim), EMAX(outCellExt, dim));
}
// Lists for batching copy operations:
vtkNew<vtkIdList> srcIds;
vtkNew<vtkIdList> dstIds;
......
......@@ -19,12 +19,13 @@
#include "vtkDoubleArray.h"
#include "vtkExtractRectilinearGrid.h"
#include "vtkMathUtilities.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkPointDataToCellData.h"
#include "vtkRectilinearGrid.h"
#include "vtkRectilinearGridWriter.h"
#include "vtkStructuredData.h"
// C/C++ includes
#include <cassert>
#include <cmath>
......@@ -142,6 +143,13 @@ void GenerateGrid( vtkRectilinearGrid* grid, int ext[6] )
xyz->SetTuple(pntIdx, grid->GetPoint(pntIdx) );
} // END for all points
grid->GetPointData()->AddArray( xyz );
vtkNew<vtkPointDataToCellData> pd2cd;
pd2cd->PassPointDataOn();
pd2cd->SetInputDataObject(grid);
pd2cd->Update();
grid->ShallowCopy(pd2cd->GetOutputDataObject(0));
xyz->Delete();
}
......@@ -176,6 +184,16 @@ int TestExtractRectilinearGrid( int argc, char* argv[])
rc += CheckGrid( subGrid );
// Let's extract outer face too.
int sub_ext2[6] = { 49, 49, 0, 49, 0, 0 };
extractFilter->SetVOI(sub_ext2);
extractFilter->SetSampleRate(1, 1, 1);
extractFilter->IncludeBoundaryOff();
extractFilter->Update();
subGrid = extractFilter->GetOutput();
rc += CheckGrid(subGrid);
extractFilter->Delete();
grid->Delete();
return( rc );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment