1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*=========================================================================
Program: Visualization Toolkit
Module: TestGenericCell.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.
=========================================================================*/
#include "vtkGenericCell.h"
#include "vtkHigherOrderHexahedron.h"
#include "vtkHigherOrderQuadrilateral.h"
#include "vtkHigherOrderWedge.h"
#include "vtkMath.h"
#include "vtkSmartPointer.h"
#include "vtkTestErrorObserver.h"
int TestGenericCell(int, char*[])
{
int rval = 0;
auto cell = vtkSmartPointer<vtkGenericCell>::New();
auto errorObserver = vtkSmartPointer<vtkTest::ErrorObserver>::New();
cell->AddObserver(vtkCommand::ErrorEvent, errorObserver);
for (int i = 0; i < VTK_NUMBER_OF_CELL_TYPES; ++i)
{
cell->SetCellType(i);
if (cell->RequiresInitialization())
{
cell->Initialize();
}
int numPts = cell->GetNumberOfPoints();
int numEdges = cell->GetNumberOfEdges();
int numFaces = cell->GetNumberOfFaces();
cell->Print(cout);
double center[3];
int a = cell->GetParametricCenter(center);
(void)a;
double* pcoords = cell->GetParametricCoords();
if (cell->GetCellType() != VTK_EMPTY_CELL && cell->GetCellType() != VTK_POLY_VERTEX // FIXME
&& cell->GetCellType() != VTK_POLY_LINE // FIXME
&& cell->GetCellType() != VTK_TRIANGLE_STRIP // FIXME
&& cell->GetCellType() != VTK_POLYGON // FIXME
&& cell->GetCellType() != VTK_CONVEX_POINT_SET // FIXME
&& cell->GetCellType() != VTK_POLYHEDRON) // FIXME
{
double m[3] = { 0., 0., 0. };
// We add all the points since
// Those on the corner points indeed define the parametric center
// The dof node (center mid-points) by definition have the same parametric center
// and taking into account the center point only add a 0 vector to the sum
// therefore we do not need to differentiate corner from the rest in this sum:
for (int j = 0; j < numPts; ++j)
{
double* point = pcoords + 3 * j;
m[0] += point[0];
m[1] += point[1];
m[2] += point[2];
}
if (numPts)
{
m[0] /= numPts;
m[1] /= numPts;
m[2] /= numPts;
if (fabs(center[0] - m[0]) > 1e-6 || fabs(center[1] - m[1]) > 1e-6 ||
fabs(center[2] - m[2]) > 1e-6)
{
cerr << "Cell: " << i << endl;
cerr << "Center: " << center[0] << "," << center[1] << "," << center[2] << endl;
cerr << "M : " << m[0] << "," << m[1] << "," << m[2] << endl;
++rval;
}
}
}
int p = cell->IsPrimaryCell();
(void)p;
int cellDim = cell->GetCellDimension();
(void)cellDim;
int l = cell->IsLinear();
(void)l;
for (int e = 0; e < numEdges; ++e)
{
vtkCell* c = cell->GetEdge(e);
c->Print(cout);
}
for (int f = 0; f < numFaces; ++f)
{
vtkCell* c = cell->GetFace(f);
c->Print(cout);
}
if (cell->GetCellType() != i && cell->GetCellType() != VTK_EMPTY_CELL)
{
++rval;
}
}
return rval;
}
|