Commit 52ae0f57 authored by hrchilds's avatar hrchilds
Browse files

Add support for surface normals on 2D rectilinear grids in 3D space.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12604 18c085ea-50e0-402c-830e-de6fd14e8384
parent e4729377
......@@ -44,8 +44,10 @@
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkRectilinearGrid.h>
#include <vtkVisItPolyDataNormals.h>
#include <ExpressionException.h>
......@@ -101,11 +103,21 @@ avtSurfaceNormalExpression::~avtSurfaceNormalExpression()
// Programmer: Hank Childs
// Creation: September 22, 2005
//
// Modifications:
//
// Hank Childs, Fri Sep 24 10:18:38 PDT 2010
// Add support for rectilinear grids.
//
// ****************************************************************************
vtkDataArray *
avtSurfaceNormalExpression::DeriveVariable(vtkDataSet *in_ds)
{
if (in_ds->GetDataObjectType() == VTK_RECTILINEAR_GRID)
{
return RectilinearDeriveVariable((vtkRectilinearGrid *) in_ds);
}
if (in_ds->GetDataObjectType() != VTK_POLY_DATA)
{
EXCEPTION2(ExpressionException, outputVariableName, "The Surface normal expression "
......@@ -149,3 +161,64 @@ avtSurfaceNormalExpression::DeriveVariable(vtkDataSet *in_ds)
}
// ****************************************************************************
// Method: avtSurfaceNormalExpression::RectilinearDeriveVariable
//
// Purpose:
// A method that does special handling for rectilinear generation.
//
// Programmer: Hank Childs
// Creation: September 24, 2010
//
// ****************************************************************************
vtkDataArray *
avtSurfaceNormalExpression::RectilinearDeriveVariable(vtkRectilinearGrid *rgrid)
{
int dims[3];
rgrid->GetDimensions(dims);
int nMatch = 0;
bool doX = (dims[0] == 1);
if (doX)
nMatch++;
bool doY = (dims[1] == 1);
if (doY)
nMatch++;
bool doZ = (dims[2] == 1);
if (doZ)
nMatch++;
if (nMatch == 0)
{
EXCEPTION2(ExpressionException, outputVariableName, "Can not determine "
"surface normals for a 3D data set.");
}
if (nMatch > 1)
{
EXCEPTION2(ExpressionException, outputVariableName, "Can not determine "
"surface normals for lines and vertices.");
}
vtkFloatArray *n = vtkFloatArray::New();
n->SetNumberOfComponents(3);
int ntuples = (isPoint ? rgrid->GetNumberOfPoints()
: rgrid->GetNumberOfCells());
n->SetNumberOfTuples(ntuples);
float norm[3] = { 0, 0, 0 };
if (doX)
norm[0] = 1.0;
if (doY)
norm[1] = 1.0;
if (doZ)
norm[2] = 1.0;
float *ptr = n->GetPointer(0);
for (int i = 0 ; i < ntuples ; i++)
{
*ptr++ = norm[0];
*ptr++ = norm[1];
*ptr++ = norm[2];
}
return n;
}
......@@ -46,6 +46,7 @@
#include <avtSingleInputExpressionFilter.h>
class vtkDataArray;
class vtkRectilinearGrid;
// ****************************************************************************
......@@ -57,6 +58,11 @@ class vtkDataArray;
// Programmer: Hank Childs
// Creation: September 22, 2005
//
// Modifications:
//
// Hank Childs, Fri Sep 24 10:18:38 PDT 2010
// Add a method for rectilinear generation.
//
// ****************************************************************************
class EXPRESSION_API avtSurfaceNormalExpression
......@@ -77,6 +83,7 @@ class EXPRESSION_API avtSurfaceNormalExpression
virtual vtkDataArray *DeriveVariable(vtkDataSet *);
virtual bool IsPointVariable(void) { return isPoint; };
virtual int GetVariableDimension(void) { return 3; };
vtkDataArray *RectilinearDeriveVariable(vtkRectilinearGrid *);
};
......
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