Commit b687b233 authored by bonnell's avatar bonnell

More double-precision support

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@18977 18c085ea-50e0-402c-830e-de6fd14e8384
parent 71ea731e
......@@ -1850,6 +1850,10 @@ GetDataMagnitudeRange(vtkDataSet *ds, double *exts, const char *vname,
//
// Mark C. Miller, Mon Jan 10 07:21:59 PST 2011
// Replaced isfinite with visitIsFinite.
//
// Kathleen Biagas, Wed Aug 8 09:26:51 PDT 2012
// Allow doubles.
//
// ****************************************************************************
void
......@@ -1887,27 +1891,43 @@ GetDataMajorEigenvalueRange(vtkDataSet *ds, double *exts, const char *vname,
return;
}
//
// We only know how to deal with floats.
// We only know how to deal with floats / doubles.
//
if (da->GetDataType() != VTK_FLOAT)
if (da->GetDataType() == VTK_FLOAT)
{
return;
}
float *ptr = (float *) da->GetVoidPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
if ((ghosts != NULL) && (ghosts[i] != '\0'))
continue;
double val = MajorEigenvalue(ptr);
if (!visitIsFinite(val))
continue;
float *ptr = (float *) da->GetVoidPointer(0);
for (int i = 0 ; i < nvals ; i++)
exts[0] = (exts[0] < val ? exts[0] : val);
exts[1] = (exts[1] > val ? exts[1] : val);
ptr+=ncomps;
}
}
else if (da->GetDataType() == VTK_DOUBLE)
{
if ((ghosts != NULL) && (ghosts[i] != '\0'))
continue;
double *ptr = (double *) da->GetVoidPointer(0);
for (int i = 0 ; i < nvals ; i++)
{
if ((ghosts != NULL) && (ghosts[i] != '\0'))
continue;
double val = MajorEigenvalue(ptr);
double val = MajorEigenvalue(ptr);
if (!visitIsFinite(val))
continue;
if (!visitIsFinite(val))
continue;
exts[0] = (exts[0] < val ? exts[0] : val);
exts[1] = (exts[1] > val ? exts[1] : val);
ptr+=ncomps;
exts[0] = (exts[0] < val ? exts[0] : val);
exts[1] = (exts[1] > val ? exts[1] : val);
ptr+=ncomps;
}
}
}
......
......@@ -52,6 +52,7 @@
#include <avtDatasetExaminer.h>
#include <avtExtents.h>
#include <vtkVisItUtility.h>
#include <ImproperUseException.h>
......@@ -162,6 +163,9 @@ avtProjectFilter::Equivalent(const AttributeGroup *a)
// Hank Childs, Tue Aug 3 09:28:35 PDT 2010
// Fix bug with project of cell-centered vectors.
//
// Kathleen Biagas, Wed Aug 8 17:31:54 PDT 2012
// Use templatized ProjectVectors.
//
// ****************************************************************************
vtkDataSet *
......@@ -197,7 +201,10 @@ avtProjectFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
vtkDataArray *arr = vectors->NewInstance();
arr->SetNumberOfComponents(3);
arr->Allocate(3*vectors->GetNumberOfTuples());
ProjectVectors(in_ds, out_ds, vectors, arr, false);
if (arr->GetDataType() == VTK_FLOAT)
ProjectVectors<float>(in_ds, out_ds, vectors, arr, false);
else if (arr->GetDataType() == VTK_DOUBLE)
ProjectVectors<double>(in_ds, out_ds, vectors, arr, false);
arr->SetName(vectors->GetName());
out_ds->GetPointData()->RemoveArray(vectors->GetName());
out_ds->GetPointData()->SetVectors(arr);
......@@ -209,7 +216,10 @@ avtProjectFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
vtkDataArray *arr = vectors->NewInstance();
arr->SetNumberOfComponents(3);
arr->Allocate(3*vectors->GetNumberOfTuples());
ProjectVectors(in_ds, out_ds, vectors, arr, true);
if (arr->GetDataType() == VTK_FLOAT)
ProjectVectors<float>(in_ds, out_ds, vectors, arr, true);
else if (arr->GetDataType() == VTK_DOUBLE)
ProjectVectors<double>(in_ds, out_ds, vectors, arr, true);
arr->SetName(vectors->GetName());
out_ds->GetCellData()->RemoveArray(vectors->GetName());
out_ds->GetCellData()->SetVectors(arr);
......@@ -399,6 +409,9 @@ avtProjectFilter::ProjectPoint(double &x,double &y,double &z)
// Jeremy Meredith, Fri Sep 10 16:16:12 PDT 2004
// Always convert to a curvilinear grid. The extra code wasn't even
// worth it because I expect no one will ever want to do it.
//
// Kathleen Biagas, Wed Aug 8 15:37:10 PDT 2012
// Preserve coordinate data type.
//
// ****************************************************************************
vtkPointSet *
......@@ -409,7 +422,7 @@ avtProjectFilter::ProjectRectilinearGrid(vtkRectilinearGrid *in_ds)
int numPts = dims[0]*dims[1]*dims[2];
vtkPoints *pts = vtkPoints::New();
vtkPoints *pts = vtkVisItUtility::NewPoints(in_ds);
pts->SetNumberOfPoints(numPts);
vtkDataArray *x = in_ds->GetXCoordinates();
......@@ -423,7 +436,7 @@ avtProjectFilter::ProjectRectilinearGrid(vtkRectilinearGrid *in_ds)
{
for (int i = 0 ; i < dims[0] ; i++)
{
float pt[3];
double pt[3];
pt[0] = x->GetComponent(i,0);
pt[1] = y->GetComponent(j,0);
pt[2] = z->GetComponent(k,0);
......@@ -473,7 +486,11 @@ avtProjectFilter::ProjectRectilinearGrid(vtkRectilinearGrid *in_ds)
// In the special case where we have a curvilinear mesh with dimensions
// 1xYxZ or Xx1xZ, then change the projected mesh to be XxYx1.
//
// Kathleen Biagas, Wed Aug 8 17:33:35 PDT 2012
// Preserve coordinate type.
//
// ****************************************************************************
vtkPointSet *
avtProjectFilter::ProjectPointSet(vtkPointSet *in_ds)
{
......@@ -484,14 +501,27 @@ avtProjectFilter::ProjectPointSet(vtkPointSet *in_ds)
int npoints = old_pts->GetNumberOfPoints();
// Make a new point array
vtkPoints *new_pts = old_pts->NewInstance();
vtkPoints *new_pts = vtkPoints::New(old_pts->GetDataType());
new_pts->DeepCopy(old_pts);
float *points = (float*)new_pts->GetVoidPointer(0); // Assume float
for (int i = 0 ; i < npoints ; i++)
if (old_pts->GetDataType() == VTK_FLOAT)
{
float *points = (float*)new_pts->GetVoidPointer(0);
for (int i = 0 ; i < npoints ; i++)
{
ProjectPoint(points[i*3+0],
points[i*3+1],
points[i*3+2]);
}
}
else if (old_pts->GetDataType() == VTK_DOUBLE)
{
ProjectPoint(points[i*3+0],
points[i*3+1],
points[i*3+2]);
double *points = (double*)new_pts->GetVoidPointer(0);
for (int i = 0 ; i < npoints ; i++)
{
ProjectPoint(points[i*3+0],
points[i*3+1],
points[i*3+2]);
}
}
out_ds->SetPoints(new_pts);
new_pts->Delete();
......@@ -548,8 +578,12 @@ avtProjectFilter::ProjectPointSet(vtkPointSet *in_ds)
// Kathleen Bonnell, Thu Dec 9 14:49:04 PST 2010
// Normalize the vector before projection in the AsDirection case.
//
// Kathleen Biagas, Wed Aug 8 17:36:03 PDT 2012
// Templatized to handle different data types.
//
// ****************************************************************************
void
template <class T> void
avtProjectFilter::ProjectVectors(vtkDataSet *old_ds,
vtkDataSet *new_ds,
vtkDataArray *in,
......@@ -560,8 +594,8 @@ avtProjectFilter::ProjectVectors(vtkDataSet *old_ds,
const double instantEpsInv = 1.e+5;
int nvectors = in->GetNumberOfTuples();
float *inptr = (float*)in->GetVoidPointer(0);
float *outptr = (float*)out->GetVoidPointer(0);
T *inptr = (T*)in->GetVoidPointer(0);
T *outptr = (T*)out->GetVoidPointer(0);
for (int i=0; i<nvectors; i++)
{
......
......@@ -103,6 +103,8 @@ class avtProjectFilter : public avtPluginDataTreeIterator
void ProjectPoint(double &x, double &y, double &z);
vtkPointSet *ProjectPointSet(vtkPointSet*);
vtkPointSet *ProjectRectilinearGrid(vtkRectilinearGrid*);
template <class T>
void ProjectVectors(vtkDataSet*,vtkDataSet*,
vtkDataArray*,vtkDataArray*,bool);
};
......
......@@ -665,6 +665,8 @@ avtReplicateFilter::OffsetDataArray(vtkDataArray *coords, double val)
// Note: taken largely from avtReflectFilter.C
//
// Modifications:
// Kathleen Biagas, Wed Aug 8 15:25:37 PDT 2012
// Ensure new vtkPoints object has same data type as input.
//
// ****************************************************************************
......@@ -675,7 +677,7 @@ avtReplicateFilter::ReplicatePointSet(vtkPointSet *ds, double offset[3])
out->ShallowCopy(ds);
vtkPoints *inPts = ds->GetPoints();
vtkPoints *outPts = vtkPoints::New();
vtkPoints *outPts = vtkPoints::New(inPts->GetDataType());
int nPts = inPts->GetNumberOfPoints();
outPts->SetNumberOfPoints(nPts);
......@@ -730,6 +732,8 @@ avtReplicateFilter::ReplicatePointSet(vtkPointSet *ds, double offset[3])
// Added support for shifting atoms to a unit cell at a different origin
// than the current one.
//
// Kathleen Biagas, Wed Aug 8 15:27:07 PDT 2012
// Ensure output vtkPoints has same data type as input.
//
// ****************************************************************************
static void
......@@ -845,7 +849,7 @@ avtReplicateFilter::ReplicateAndShiftUnitCellAtoms(vtkPolyData *in)
vtkPolyData *out = (vtkPolyData*)in->NewInstance();
vtkPointData *outPD = out->GetPointData();
vtkCellData *outCD = out->GetCellData();
vtkPoints *outPts = vtkPoints::New();
vtkPoints *outPts = vtkPoints::New(inPts->GetDataType());
vtkCellArray *outVerts = vtkCellArray::New();
vtkCellArray *outLines = vtkCellArray::New();
out->GetFieldData()->ShallowCopy(in->GetFieldData());
......
This diff is collapsed.
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