Commit 289f6813 authored by Mathieu Malaterre's avatar Mathieu Malaterre
Browse files

BUG: Fix Bug #1597 - Inconsistency in face orders of vtkWedge and...

BUG: Fix Bug #1597 - Inconsistency in face orders of vtkWedge and vtkQuadraticWedge. Also add a test to verify this nightly
parent 4b3989e1
......@@ -2,6 +2,7 @@ SET(KIT Filtering)
#
# Create a test lists
CREATE_TEST_SOURCELIST(Tests ${KIT}CxxTests.cxx
quadCellConsistency.cxx
otherColorTransferFunction.cxx
EXTRA_INCLUDE vtkSuppressCrtDbgWarning.h
FUNCTION vtkSuppressCrtDbgWarning
......
/*=========================================================================
Program: Visualization Toolkit
Module: quadCellConsistency.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.
=========================================================================*/
// .NAME
// .SECTION Description
// this program tests the consistency of face/edge ids between linear and quadratic cells
#include "vtkLine.h"
#include "vtkQuadraticEdge.h"
#include "vtkTriangle.h"
#include "vtkQuadraticTriangle.h"
#include "vtkQuad.h"
#include "vtkQuadraticQuad.h"
#include "vtkTetra.h"
#include "vtkQuadraticTetra.h"
#include "vtkHexahedron.h"
#include "vtkQuadraticHexahedron.h"
#include "vtkPyramid.h"
#include "vtkQuadraticPyramid.h"
#include "vtkWedge.h"
#include "vtkQuadraticWedge.h"
void InitializeCell(vtkCell *cell)
{
// Default initialize the cell ids to 0,1,2 ... n
int n = cell->GetNumberOfPoints();
for(int i=0; i<n; i++)
{
cell->GetPointIds()->SetId(i, i);
}
}
// Check that corner points id match quad ones for each edges
int CompareCellEdges(vtkCell *linear, vtkCell *quadratic)
{
int dif;
int sum = 0;
int nEdges = linear->GetNumberOfEdges();
for(int edge = 0; edge < nEdges; edge++)
{
vtkCell *lEdge = linear->GetEdge(edge);
vtkCell *qEdge = quadratic->GetEdge(edge);
int n = lEdge->GetNumberOfPoints();
// Check that the points of the linear cell match the one from the quadratic one
for( int i=0; i<n; i++)
{
dif = lEdge->GetPointIds()->GetId(i) - qEdge->GetPointIds()->GetId(i);
sum += dif;
}
}
return sum;
}
// Check that corner points id match quad ones for each faces
int CompareCellFaces(vtkCell *linear, vtkCell *quadratic)
{
int dif;
int sum = 0;
int nFaces = linear->GetNumberOfFaces();
for(int face = 0; face < nFaces; face++)
{
vtkCell *lFace = linear->GetFace(face);
vtkCell *qFace = quadratic->GetFace(face);
int n = lFace->GetNumberOfPoints();
// Check that the points of the linear cell match the one from the quadratic one
for( int i=0; i<n; i++)
{
dif = lFace->GetPointIds()->GetId(i) - qFace->GetPointIds()->GetId(i);
sum += dif;
}
}
return sum;
}
int quadCellConsistency(int, char *[])
{
int ret = 0;
// Line / vtkQuadraticEdge:
vtkLine *edge = vtkLine::New();
vtkQuadraticEdge *qedge = vtkQuadraticEdge::New();
InitializeCell(edge);
InitializeCell(qedge);
ret += CompareCellEdges(edge, qedge);
ret += CompareCellFaces(edge, qedge);
edge->Delete();
qedge->Delete();
// Triangles:
vtkTriangle *tri = vtkTriangle::New();
vtkQuadraticTriangle *qtri = vtkQuadraticTriangle::New();
InitializeCell(tri);
InitializeCell(qtri);
ret += CompareCellEdges(tri, qtri);
ret += CompareCellFaces(tri, qtri);
tri->Delete();
qtri->Delete();
// Quad
vtkQuad *quad = vtkQuad::New();
vtkQuadraticQuad *qquad = vtkQuadraticQuad::New();
InitializeCell(quad);
InitializeCell(qquad);
ret += CompareCellEdges(quad, qquad);
ret += CompareCellFaces(quad, qquad);
quad->Delete();
qquad->Delete();
// Tetra
vtkTetra *tetra = vtkTetra::New();
vtkQuadraticTetra *qtetra = vtkQuadraticTetra::New();
InitializeCell(tetra);
InitializeCell(qtetra);
ret += CompareCellEdges(tetra, qtetra);
ret += CompareCellFaces(tetra, qtetra);
tetra->Delete();
qtetra->Delete();
// Hexhedron
vtkHexahedron *hex = vtkHexahedron::New();
vtkQuadraticHexahedron *qhex = vtkQuadraticHexahedron::New();
InitializeCell(hex);
InitializeCell(qhex);
ret += CompareCellEdges(hex, qhex);
ret += CompareCellFaces(hex, qhex);
hex->Delete();
qhex->Delete();
// Pyramid
vtkPyramid *pyr= vtkPyramid::New();
vtkQuadraticPyramid *qpyr = vtkQuadraticPyramid::New();
InitializeCell(pyr);
InitializeCell(qpyr);
ret += CompareCellEdges(pyr, qpyr);
ret += CompareCellFaces(pyr, qpyr);
pyr->Delete();
qpyr->Delete();
// Wedge cells
vtkWedge *wedge = vtkWedge::New();
vtkQuadraticWedge *qwedge = vtkQuadraticWedge::New();
InitializeCell(wedge);
InitializeCell(qwedge);
ret += CompareCellEdges(wedge, qwedge);
ret += CompareCellFaces(wedge, qwedge);
wedge->Delete();
qwedge->Delete();
return ret;
}
......@@ -24,7 +24,7 @@
#include "vtkPoints.h"
#include "vtkQuad.h"
vtkCxxRevisionMacro(vtkHexahedron, "1.3");
vtkCxxRevisionMacro(vtkHexahedron, "1.4");
vtkStandardNewMacro(vtkHexahedron);
static const double VTK_DIVERGED = 1.e6;
......@@ -33,17 +33,12 @@ static const double VTK_DIVERGED = 1.e6;
// Construct the hexahedron with eight points.
vtkHexahedron::vtkHexahedron()
{
int i;
this->Points->SetNumberOfPoints(8);
this->PointIds->SetNumberOfIds(8);
for (i = 0; i < 8; i++)
for (int i = 0; i < 8; i++)
{
this->Points->SetPoint(i, 0.0, 0.0, 0.0);
}
for (i = 0; i < 8; i++)
{
this->PointIds->SetId(i,0);
}
this->Line = vtkLine::New();
......
......@@ -38,13 +38,10 @@ class vtkUnstructuredGrid;
class VTK_FILTERING_EXPORT vtkPyramid : public vtkCell3D
{
public:
static vtkPyramid *New();
vtkTypeRevisionMacro(vtkPyramid,vtkCell3D);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Create an instance of this class.
static vtkPyramid *New();
// Description:
// See vtkCell3D API for description of these methods.
virtual void GetEdgePoints(int edgeId, int* &pts);
......
......@@ -20,23 +20,21 @@
#include "vtkDoubleArray.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkQuadraticEdge, "1.2");
vtkCxxRevisionMacro(vtkQuadraticEdge, "1.3");
vtkStandardNewMacro(vtkQuadraticEdge);
//----------------------------------------------------------------------------
// Construct the line with two points.
vtkQuadraticEdge::vtkQuadraticEdge()
{
this->Line = vtkLine::New();
int i;
this->Points->SetNumberOfPoints(3);
this->PointIds->SetNumberOfIds(3);
for (i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
this->Points->SetPoint(i, 0.0, 0.0, 0.0);
this->PointIds->SetId(i,0);
}
this->Line = vtkLine::New();
}
//----------------------------------------------------------------------------
......
......@@ -27,7 +27,7 @@
#include "vtkQuadraticQuad.h"
#include "vtkQuadraticTriangle.h"
vtkCxxRevisionMacro(vtkQuadraticPyramid, "1.4");
vtkCxxRevisionMacro(vtkQuadraticPyramid, "1.5");
vtkStandardNewMacro(vtkQuadraticPyramid);
//----------------------------------------------------------------------------
......@@ -86,7 +86,7 @@ static int LinearPyramids[10][5] = { {0,5,13,8,9},
{7,12,11,13,0},
{8,9,12,13,0} };
static int PyramidFaces[5][8] = { {0,1,2,3,5,6,7,8},
static int PyramidFaces[5][8] = { {0,3,2,1,8,7,6,5},
{0,1,4,5,10,9,0,0},
{1,2,4,6,11,10,0,0},
{2,3,4,7,12,11,0,0},
......
......@@ -26,7 +26,7 @@
#include "vtkQuadraticQuad.h"
#include "vtkQuadraticTriangle.h"
vtkCxxRevisionMacro(vtkQuadraticWedge, "1.2");
vtkCxxRevisionMacro(vtkQuadraticWedge, "1.3");
vtkStandardNewMacro(vtkQuadraticWedge);
//----------------------------------------------------------------------------
......@@ -81,15 +81,15 @@ static int LinearWedges[8][6] = { {0,6,8,12,15,17},
{15,13,16,9,4,10},
{17,16,14,11,10,5} };
static int WedgeFaces[5][8] = { {0,3,4,1,12,9,13,6},
static int WedgeFaces[5][8] = { {0,1,2,6,7,8,0,0},
{3,5,4,11,10,9,0,0},
{0,3,4,1,12,9,13,6},
{1,4,5,2,13,10,14,7},
{2,5,3,0,14,11,12,8},
{0,1,2,6,7,8,0,0},
{3,5,4,11,10,9,0,0}};
{2,5,3,0,14,11,12,8}};
static int WedgeEdges[9][3] = { {0,1,6}, {1,2,7}, {0,2,8},
{0,3,12},{1,4,13},{2,5,14},
{3,4,9}, {4,5,10}, {3,5,11} };
static int WedgeEdges[9][3] = { {0,1,6}, {1,2,7}, {2,0,8},
{3,4,9}, {4,5,10}, {5,3,11},
{0,3,12},{1,4,13}, {2,5,14} };
static double MidPoints[3][3] = { {0.5,0.0,0.5},
{0.5,0.5,0.5},
......
......@@ -26,23 +26,18 @@
#include "vtkPolygon.h"
#include "vtkQuadric.h"
vtkCxxRevisionMacro(vtkTriangle, "1.3");
vtkCxxRevisionMacro(vtkTriangle, "1.4");
vtkStandardNewMacro(vtkTriangle);
//----------------------------------------------------------------------------
// Construct the triangle with three points.
vtkTriangle::vtkTriangle()
{
int i;
this->Points->SetNumberOfPoints(3);
this->PointIds->SetNumberOfIds(3);
for (i = 0; i < 3; i++)
for (int i = 0; i < 3; i++)
{
this->Points->SetPoint(i, 0.0, 0.0, 0.0);
}
for (i = 0; i < 3; i++)
{
this->PointIds->SetId(i,0);
}
this->Line = vtkLine::New();
......@@ -462,12 +457,7 @@ void vtkTriangle::Contour(double value, vtkDataArray *cellScalars,
// coordinates.
vtkCell *vtkTriangle::GetEdge(int edgeId)
{
int edgeIdPlus1 = edgeId + 1;
if (edgeIdPlus1 > 2)
{
edgeIdPlus1 = 0;
}
int edgeIdPlus1 = (edgeId > 1 ? 0 : (edgeId+1) );
// load point id's
this->Line->PointIds->SetId(0,this->PointIds->GetId(edgeId));
......
......@@ -34,10 +34,6 @@ public:
vtkTypeRevisionMacro(vtkTriangle,vtkCell);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Create a new cell and copy this triangle's information into the
// cell. Returns a pointer to the new cell created.
// Description:
// Get the edge specified by edgeId (range 0 to 2) and return that edge's
// coordinates.
......
......@@ -25,7 +25,7 @@
#include "vtkTriangle.h"
#include "vtkUnstructuredGrid.h"
vtkCxxRevisionMacro(vtkWedge, "1.3");
vtkCxxRevisionMacro(vtkWedge, "1.4");
vtkStandardNewMacro(vtkWedge);
static const double VTK_DIVERGED = 1.e6;
......@@ -482,9 +482,7 @@ int *vtkWedge::GetFaceArray(int faceId)
//----------------------------------------------------------------------------
vtkCell *vtkWedge::GetFace(int faceId)
{
int *verts;
verts = faces[faceId];
int *verts = faces[faceId];
if ( verts[3] != -1 ) // quad cell
{
......
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