Commit 088397fe authored by bonnell's avatar bonnell

Added logic so that avtActualExtentsFilter can get data extents for nodal data...

Added logic so that avtActualExtentsFilter can get data extents for nodal data from connected nodes only.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23379 18c085ea-50e0-402c-830e-de6fd14e8384
parent 37e4e51b
......@@ -86,10 +86,16 @@ using std::vector;
using std::string;
using namespace std;
void GetDataScalarRange(vtkDataSet *, double *, const char *, bool);
void GetDataMagnitudeRange(vtkDataSet *, double *, const char *, bool);
void GetDataMajorEigenvalueRange(vtkDataSet *, double *, const char *, bool);
// ****************************************************************************
//
// Kathleen Biagas, Wed May 28 17:27:33 MST 2014
// Added another bool arg with default to false, specifies whether to
// only consider connected nodes.
//
// ****************************************************************************
void GetDataScalarRange(vtkDataSet *, double *, const char *, bool, bool = false);
void GetDataMagnitudeRange(vtkDataSet *, double *, const char *, bool, bool = false);
void GetDataMajorEigenvalueRange(vtkDataSet *, double *, const char *, bool, bool = false);
// ****************************************************************************
......@@ -283,6 +289,9 @@ CGetSpatialExtents(avtDataRepresentation &data, void *info, bool &success)
// Hank Childs, Wed Oct 10 16:03:59 PDT 2007
// Add argument for whether or not we should ignore ghost zones.
//
// Kathleen Biagas, Wed May 28 17:27:33 MST 2014
// Added connectedNodesOnly.
//
// ****************************************************************************
void
......@@ -296,6 +305,7 @@ CGetDataExtents(avtDataRepresentation &data, void *g, bool &success)
GetVariableRangeArgs *gvra = (GetVariableRangeArgs *) g;
double *dde = gvra->extents;
const char *vname = gvra->varname;
bool cNO = gvra->connectedNodesOnly;
vtkDataArray *da = NULL;
if (ds->GetPointData()->GetArray(vname) != NULL)
......@@ -310,11 +320,11 @@ CGetDataExtents(avtDataRepresentation &data, void *g, bool &success)
double range[2] = {+DBL_MAX, -DBL_MAX};
bool ignoreGhost = false; // legacy behavior
if (dim == 1)
GetDataScalarRange(ds, range, vname, ignoreGhost);
GetDataScalarRange(ds, range, vname, ignoreGhost, cNO);
else if (dim <= 3)
GetDataMagnitudeRange(ds, range, vname, ignoreGhost);
GetDataMagnitudeRange(ds, range, vname, ignoreGhost, cNO);
else if (dim == 9)
GetDataMajorEigenvalueRange(ds, range, vname, ignoreGhost);
GetDataMajorEigenvalueRange(ds, range, vname, ignoreGhost, cNO);
//
// If we have gotten extents from another data rep, then merge the
......@@ -1326,6 +1336,10 @@ GetDataRange(vtkDataSet *ds, double *de, const char *vname,
// Fix uninitialized memory read that can lead to possible infinite
// recursion when there is no valid data in the array.
//
// Kathleen Biagas, Wed May 28 17:29:48 MST 2014
// Added 'GetNodalScalarRangeViaCells' to be used when data is nodal
// and 'onlyConnectedNodes' is requested.
//
// ****************************************************************************
template <class T> static bool
......@@ -1378,15 +1392,75 @@ GetScalarRange(T *buf, int n, double *exts, unsigned char *ghosts,
return setOne;
}
// KSB:
// This method determines nodal range of connected nodes by looking at cells and using
// their point ids. Involves duplicate comparisons, but in initial testing, the
// alternative is slower. (Step through points, if # cells a node is connected to > 0,
// consider the point). I think it is 'ds->GetPointCells' that is the slowdown.
template <class T> static bool
GetNodalScalarRangeViaCells(T *buf, int n, double *exts, bool checkFinite, vtkDataSet *ds)
{
T min;
T max;
bool setOne = false;
vtkIdType nCells = ds->GetNumberOfCells();
vtkIdList *ptIds = vtkIdList::New();
for (vtkIdType cellId = 0; cellId < nCells; ++cellId)
{
ds->GetCellPoints(cellId, ptIds);
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); i++)
{
vtkIdType id = ptIds->GetId(i);
if (checkFinite)
if (! visitIsFinite(buf[id]))
continue;
if (!setOne)
{
min = buf[id];
max = buf[id];
setOne = true;
continue;
}
if (buf[id] < min)
{
min = buf[id];
}
else if (buf[id] > max)
{
max = buf[id];
}
}
ptIds->Reset();
}
if (setOne)
{
if (! visitIsFinite(min) || ! visitIsFinite(max))
return GetNodalScalarRangeViaCells(buf, n, exts, true, ds);
else
{
exts[0] = (double) min;
exts[1] = (double) max;
}
}
ptIds->Delete();
return setOne;
}
void
GetDataScalarRange(vtkDataSet *ds, double *exts, const char *vname,
bool ignoreGhost)
bool ignoreGhost, bool connectedNodesOnly)
{
vtkDataArray *da = NULL;
unsigned char *ghosts = NULL;
bool nodalData = false;
if (ds->GetPointData()->GetArray(vname))
{
da = ds->GetPointData()->GetArray(vname);
nodalData = true;
}
else
{
......@@ -1405,15 +1479,27 @@ GetDataScalarRange(vtkDataSet *ds, double *exts, const char *vname,
int nvals = da->GetNumberOfTuples();
exts[0] = +FLT_MAX;
exts[1] = -FLT_MAX;
exts[0] = +DBL_MAX;
exts[1] = -DBL_MAX;
bool checkForFiniteByDefault = false;
switch (da->GetDataType())
if (!(connectedNodesOnly && nodalData))
{
vtkTemplateAliasMacro(GetScalarRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, exts, ghosts, checkForFiniteByDefault));
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetScalarRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, exts, ghosts, checkForFiniteByDefault));
}
}
else
{
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetNodalScalarRangeViaCells(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, exts, checkForFiniteByDefault, ds));
}
}
}
......@@ -1513,8 +1599,8 @@ GetDataAllComponentsRange(vtkDataSet *ds, double *exts, const char *vname,
for (int comp=0; comp<ncomps; comp++)
{
double *compexts = &(exts[2*comp]);
compexts[0] = +FLT_MAX;
compexts[1] = -FLT_MAX;
compexts[0] = +DBL_MAX;
compexts[1] = -DBL_MAX;
switch (da->GetDataType())
{
......@@ -1575,6 +1661,10 @@ GetDataAllComponentsRange(vtkDataSet *ds, double *exts, const char *vname,
// Hank Childs, Thu Sep 23 14:06:57 PDT 2010
// Use the original pointer when doing a recursive call.
//
// Kathleen Biagas, Wed May 28 17:29:48 MST 2014
// Added 'GetNodalMagnitudeRangeViaCells' to be used when data is nodal
// and 'onlyConnectedNodes' is requested.
//
// ****************************************************************************
template <class T> static void
......@@ -1608,7 +1698,7 @@ GetMagnitudeRange(T *buf, int n, int ncomps, double *exts,
if (! visitIsFinite(exts[0]) || ! visitIsFinite(exts[1]))
{
exts[0] = +FLT_MAX;
exts[0] = +DBL_MAX;
exts[1] = 0;
return GetMagnitudeRange(buf_orig, n, ncomps, exts, ghosts, true);
}
......@@ -1617,18 +1707,64 @@ GetMagnitudeRange(T *buf, int n, int ncomps, double *exts,
exts[1] = sqrt(exts[1]);
}
template <class T> static void
GetNodalMagnitudeRangeViaCells(T *buf, int n, int ncomps, double *exts,
bool checkFinite, vtkDataSet *ds)
{
vtkIdType nCells = ds->GetNumberOfCells();
vtkIdList *ptIds = vtkIdList::New();
for (vtkIdType cellId = 0; cellId < nCells; ++cellId)
{
ds->GetCellPoints(cellId, ptIds);
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); i++)
{
vtkIdType id = ptIds->GetId(i);
double mag = 0.0;
for (int j = 0; j < ncomps; j++)
mag += buf[id+j] * buf[id+j];
if (checkFinite)
if (! visitIsFinite(mag))
continue;
if (mag < exts[0])
{
exts[0] = mag;
}
else if (mag > exts[1])
{
exts[1] = mag;
}
}
}
if (! visitIsFinite(exts[0]) || ! visitIsFinite(exts[1]))
{
exts[0] = +DBL_MAX;
exts[1] = 0;
return GetNodalMagnitudeRangeViaCells(buf, n, ncomps, exts, true, ds);
}
exts[0] = sqrt(exts[0]);
exts[1] = sqrt(exts[1]);
}
void
GetDataMagnitudeRange(vtkDataSet *ds, double *exts, const char *vname,
bool ignoreGhost)
bool ignoreGhost, bool connectedNodesOnly)
{
exts[0] = +FLT_MAX;
exts[0] = +DBL_MAX;
exts[1] = 0;
vtkDataArray *da = NULL;
unsigned char *ghosts = NULL;
bool nodalData = false;
if (ds->GetPointData()->GetArray(vname))
{
da = ds->GetPointData()->GetArray(vname);
nodalData = true;
}
else
{
......@@ -1649,11 +1785,23 @@ GetDataMagnitudeRange(vtkDataSet *ds, double *exts, const char *vname,
int ncomps = da->GetNumberOfComponents();
bool checkForFiniteByDefault = false;
switch (da->GetDataType())
if (!(connectedNodesOnly && nodalData))
{
vtkTemplateAliasMacro(GetMagnitudeRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, ghosts, checkForFiniteByDefault));
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetMagnitudeRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, ghosts, checkForFiniteByDefault));
}
}
else
{
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetNodalMagnitudeRangeViaCells(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, checkForFiniteByDefault, ds));
}
}
}
......@@ -1697,6 +1845,10 @@ GetDataMagnitudeRange(vtkDataSet *ds, double *exts, const char *vname,
// Kathleen Biagas, Wed Aug 8 09:26:51 PDT 2012
// Allow doubles.
//
// Kathleen Biagas, Wed May 28 17:29:48 MST 2014
// Added 'GetNodalMajorEigenalueRangeViaCells' to be used when data is nodal
// and 'onlyConnectedNodes' is requested.
//
// ****************************************************************************
template <class T> static double
......@@ -1750,15 +1902,41 @@ GetMajorEigenvalueRange(T *ptr, int n, int ncomps, double *exts,
}
}
template <class T> static void
GetNodalMajorEigenvalueRangeViaCells(T *ptr, int n, int ncomps, double *exts,
vtkDataSet *ds)
{
vtkIdType nCells = ds->GetNumberOfCells();
vtkIdList *ptIds = vtkIdList::New();
for (vtkIdType cellId = 0; cellId < nCells; ++cellId)
{
ds->GetCellPoints(cellId, ptIds);
for (vtkIdType i = 0; i < ptIds->GetNumberOfIds(); i++)
{
vtkIdType id = ptIds->GetId(i);
double val = MajorEigenvalueT(&ptr[id*ncomps]);
if (!visitIsFinite(val))
continue;
exts[0] = (exts[0] < val ? exts[0] : val);
exts[1] = (exts[1] > val ? exts[1] : val);
}
}
}
void
GetDataMajorEigenvalueRange(vtkDataSet *ds, double *exts, const char *vname,
bool ignoreGhost)
bool ignoreGhost, bool connectedNodesOnly)
{
vtkDataArray *da = NULL;
unsigned char *ghosts = NULL;
bool nodalData = false;
if (ds->GetPointData()->GetArray(vname))
{
da = ds->GetPointData()->GetArray(vname);
nodalData = true;
}
else
{
......@@ -1784,11 +1962,23 @@ GetDataMajorEigenvalueRange(vtkDataSet *ds, double *exts, const char *vname,
{
return;
}
switch (da->GetDataType())
if (! (connectedNodesOnly && nodalData))
{
vtkTemplateAliasMacro(GetMajorEigenvalueRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, ghosts ));
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetMajorEigenvalueRange(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, ghosts ));
}
}
else
{
switch (da->GetDataType())
{
vtkTemplateAliasMacro(GetNodalMajorEigenvalueRangeViaCells(
static_cast<VTK_TT*>(da->GetVoidPointer(0)),
nvals, ncomps, exts, ds ));
}
}
}
......@@ -1861,7 +2051,7 @@ CFindMaximum(avtDataRepresentation &data, void *arg, bool &success)
}
int nS = s->GetNumberOfTuples();
double localMax = -FLT_MAX;
double localMax = -DBL_MAX;
int ind = -1;
for (int i = 0 ; i < nS ; i++)
{
......@@ -1967,7 +2157,7 @@ CFindMinimum(avtDataRepresentation &data, void *arg, bool &success)
}
int nS = s->GetNumberOfTuples();
double localMin = FLT_MAX;
double localMin = DBL_MAX;
int ind = -1;
for (int i = 0 ; i < nS ; i++)
{
......
......@@ -138,6 +138,9 @@ class vtkDataArray;
// Kathleen Biagas, Mon Jan 28 10:06:01 PST 2013
// Remove no longer used method CUpdateData.
//
// Kathleen Biagas, Wed May 28 17:25:57 MST 2014
// Added connectedNodesOnly to GetVariableRangeArgs.
//
// ****************************************************************************
//
......@@ -238,6 +241,7 @@ typedef struct
{
double *extents;
const char *varname;
bool connectedNodesOnly;
} GetVariableRangeArgs;
typedef struct
......
......@@ -313,11 +313,15 @@ avtDatasetExaminer::GetSpatialExtents(std::vector<avtDataTree_p> &l,double *se)
// Hank Childs, Fri Jun 9 13:25:31 PDT 2006
// Remove unused variable
//
// Kathleen Biagas, Wed May 28 17:38:40 MST 2014
// Added connectedNodesOnly.
//
// ****************************************************************************
bool
avtDatasetExaminer::GetDataExtents(avtDataset_p &ds, double *de,
const char *varname)
const char *varname,
bool connectedNodesOnly)
{
if (*ds == NULL || *(ds->GetDataTree()) == NULL)
return false;
......@@ -336,6 +340,7 @@ avtDatasetExaminer::GetDataExtents(avtDataset_p &ds, double *de,
GetVariableRangeArgs gvra;
gvra.varname = varname;
gvra.extents = de;
gvra.connectedNodesOnly = connectedNodesOnly;
if (*dataTree != NULL)
{
dataTree->Traverse(CGetDataExtents, (void *) &gvra, foundExtents);
......
......@@ -87,6 +87,10 @@ class vtkDataArray;
// Hank Childs, Fri May 21 11:22:21 CDT 2010
// Added CalculateHistogram.
//
// Kathleen Biagas, Wed May 28 17:37:30 MST 2014
// Added 'connecteNodesOnly' to GetDataExtents. Meant to be set to true
// if actual extents are desired.
//
// ****************************************************************************
class PIPELINE_API avtDatasetExaminer
......@@ -103,7 +107,8 @@ class PIPELINE_API avtDatasetExaminer
static bool GetSpatialExtents(std::vector<avtDataTree_p> &,
double *);
static bool GetDataExtents(avtDataset_p &, double *,
const char * = NULL);
const char * = NULL,
bool connectedNodesOnly=false);
static void FindMinimum(avtDataset_p &, double *, double &);
static void FindMaximum(avtDataset_p &, double *, double &);
static bool FindZone(avtDataset_p &, int, int, double *);
......
......@@ -39,6 +39,7 @@ list of changes in release 2.7.</p>
<li>The internal launcher was modified so that VisIt would work on systems where the OpenGL libraries were located in the LD_LIBRARY_PATH.</li>
<li>The VisItSetMPICommunicator() function in libsim was fixed.</li>
<li>Datalevel comparison wizard was fixed so that it doesn't create expressions with nested <>.</li>
<li>Fixed a bug with Pseudocolor plot not using the correct data extents when Material selection appled and 'Current Plot' option chosen.</li>
</ul>
<p><b><font size="4">Enhancements in version 2.7.3</font></b></p>
......
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