Commit 4fc9dc3f authored by Yuanxin Liu's avatar Yuanxin Liu Committed by Code Review

Merge topic 'fix-reflection-filter-bug-0012734' into master

9596c0b1 fix bug 0012734
parents 9122889f 9596c0b1
......@@ -48,6 +48,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
TestQuadRotationalExtrusion.cxx
TestQuadRotationalExtrusionMultiBlock.cxx
TestRectilinearGridToPointSet.cxx
TestReflectionFilter.cxx
TestRotationalExtrusion.cxx
TestSelectEnclosedPoints.cxx
TestTessellatedBoxSource.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestReflectionFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This tests vtkReflectionFilter
#include <vtkSmartPointer.h>
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellType.h>
#include <vtkIdList.h>
#include <vtkReflectionFilter.h>
#include <iostream>
#include <assert.h>
#define AssertMacro(b) if(!(b)){std::cerr <<"Failed to reflect pyramid"<<std::endl;return EXIT_FAILURE;}
int TestReflectionFilter(int, char *[])
{
vtkSmartPointer<vtkUnstructuredGrid> pyramid = vtkSmartPointer<vtkUnstructuredGrid>::New();
{
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(-1,-1,-1);
points->InsertNextPoint( 1,-1,-1);
points->InsertNextPoint( 1, 1,-1);
points->InsertNextPoint(-1, 1,-1);
points->InsertNextPoint(0,0,1);
pyramid->SetPoints(points);
}
vtkNew<vtkIdList> verts;
verts->InsertNextId(0);
verts->InsertNextId(1);
verts->InsertNextId(2);
verts->InsertNextId(3);
verts->InsertNextId(4);
pyramid->InsertNextCell(VTK_PYRAMID,verts.GetPointer());
for(int i=0; i<2; i++)
{
vtkSmartPointer<vtkReflectionFilter> reflectionFilter = vtkSmartPointer<vtkReflectionFilter>::New();
reflectionFilter->SetInput(pyramid.GetPointer());
i==0? reflectionFilter->CopyInputOff() : reflectionFilter->CopyInputOn();
reflectionFilter->SetPlaneToZMin();
reflectionFilter->Update();
vtkUnstructuredGrid* pyramid1 = vtkUnstructuredGrid::SafeDownCast(reflectionFilter->GetOutput());
vtkNew<vtkIdList> cellIds;
if(i==0)
{
AssertMacro(pyramid1->GetNumberOfCells()==1);
}
else
{
AssertMacro(pyramid1->GetNumberOfCells()==2);
}
pyramid1->GetCellPoints(i, cellIds.GetPointer());
int apex = cellIds->GetId(4);
int offset = i==0? 0 : 5;
AssertMacro(apex==4+offset);
for(int j=0; j<4; j++)
{
int next = cellIds->GetId((j+1)%4);
int nextExpected = (cellIds->GetId(j)-offset+3)%4+offset;
AssertMacro(next ==nextExpected);
}
}
return EXIT_SUCCESS;
}
......@@ -344,6 +344,31 @@ int vtkReflectionFilter::RequestDataInternal(
cellId = output->InsertNextCell(cellType, cellPts);
cellPts->Delete();
}
else if (cellType == VTK_PYRAMID && vtkUnstructuredGrid::SafeDownCast(input))
{
if(numCellPts != 5)
{
vtkErrorMacro("Pyramid cell must have exactly 5 points")
}
int four = numCellPts-1;
cellPts = cell->GetPointIds();
newCellPts = new vtkIdType[numCellPts];
for (j = four-1; j >= 0; j--)
{
newCellPts[four-1-j] = cellPts->GetId(j);
if (this->CopyInput)
{
newCellPts[four-1-j] += numPts;
}
}
newCellPts[four] = cellPts->GetId(four);
if (this->CopyInput)
{
newCellPts[four] += numPts;
}
cellId = output->InsertNextCell(cellType, numCellPts, newCellPts);
delete [] newCellPts;
}
else
{
cellPts = cell->GetPointIds();
......
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