Commit c0f03983 authored by hrchilds's avatar hrchilds

Remove empty bins with data binning curves.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@19940 18c085ea-50e0-402c-830e-de6fd14e8384
parent 49318084
......@@ -102,6 +102,9 @@
<Field name="outputType" label="Output Type" type="enum" subtype="OutputType">
OutputOnBins
</Field>
<Field name="removeEmptyValFromCurve" label="Remove bins with emptyVal from curves?" type="bool">
true
</Field>
<Function name="CreateConstructionAtts" user="true" member="true">
</Function>
<Function name="DataBinningCommonPluginInfo::GetCreatedExpressions" user="false" member="true">
......
......@@ -199,3 +199,4 @@ DataBinningViewerPluginInfo::InitializeOperatorAtts(AttributeSubject *atts,
else if (strstr(varname, "operators/DataBinning/3D") != NULL)
binning->SetNumDimensions(DataBinningAttributes::Three);
}
......@@ -154,6 +154,7 @@ public:
void SetVarForReduction(const std::string &varForReduction_);
void SetEmptyVal(double emptyVal_);
void SetOutputType(OutputType outputType_);
void SetRemoveEmptyValFromCurve(bool removeEmptyValFromCurve_);
// Property getting methods
NumDimensions GetNumDimensions() const;
......@@ -184,6 +185,7 @@ public:
std::string &GetVarForReduction();
double GetEmptyVal() const;
OutputType GetOutputType() const;
bool GetRemoveEmptyValFromCurve() const;
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -251,6 +253,7 @@ public:
ID_varForReduction,
ID_emptyVal,
ID_outputType,
ID_removeEmptyValFromCurve,
ID__LAST
};
......@@ -279,11 +282,12 @@ private:
std::string varForReduction;
double emptyVal;
int outputType;
bool removeEmptyValFromCurve;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define DATABINNINGATTRIBUTES_TMFS "iisbddiisbddiisbddiiisdi"
#define DATABINNINGATTRIBUTES_TMFS "iisbddiisbddiisbddiiisdib"
#endif
......@@ -59,7 +59,7 @@ import llnl.visit.Plugin;
public class DataBinningAttributes extends AttributeSubject implements Plugin
{
private static int DataBinningAttributes_numAdditionalAtts = 24;
private static int DataBinningAttributes_numAdditionalAtts = 25;
// Enum values
public final static int REDUCTIONOPERATOR_AVERAGE = 0;
......@@ -116,6 +116,7 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
varForReduction = new String("");
emptyVal = 0;
outputType = OUTPUTTYPE_OUTPUTONBINS;
removeEmptyValFromCurve = true;
}
public DataBinningAttributes(int nMoreFields)
......@@ -146,6 +147,7 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
varForReduction = new String("");
emptyVal = 0;
outputType = OUTPUTTYPE_OUTPUTONBINS;
removeEmptyValFromCurve = true;
}
public DataBinningAttributes(DataBinningAttributes obj)
......@@ -176,6 +178,7 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
varForReduction = new String(obj.varForReduction);
emptyVal = obj.emptyVal;
outputType = obj.outputType;
removeEmptyValFromCurve = obj.removeEmptyValFromCurve;
SelectAll();
}
......@@ -216,7 +219,8 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
(reductionOperator == obj.reductionOperator) &&
(varForReduction.equals(obj.varForReduction)) &&
(emptyVal == obj.emptyVal) &&
(outputType == obj.outputType));
(outputType == obj.outputType) &&
(removeEmptyValFromCurve == obj.removeEmptyValFromCurve));
}
public String GetName() { return "DataBinning"; }
......@@ -367,6 +371,12 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
Select(23);
}
public void SetRemoveEmptyValFromCurve(boolean removeEmptyValFromCurve_)
{
removeEmptyValFromCurve = removeEmptyValFromCurve_;
Select(24);
}
// Property getting methods
public int GetNumDimensions() { return numDimensions; }
public int GetDim1BinBasedOn() { return dim1BinBasedOn; }
......@@ -392,6 +402,7 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
public String GetVarForReduction() { return varForReduction; }
public double GetEmptyVal() { return emptyVal; }
public int GetOutputType() { return outputType; }
public boolean GetRemoveEmptyValFromCurve() { return removeEmptyValFromCurve; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
......@@ -444,6 +455,8 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
buf.WriteDouble(emptyVal);
if(WriteSelect(23, buf))
buf.WriteInt(outputType);
if(WriteSelect(24, buf))
buf.WriteBool(removeEmptyValFromCurve);
}
public void ReadAtts(int index, CommunicationBuffer buf)
......@@ -522,6 +535,9 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
case 23:
SetOutputType(buf.ReadInt());
break;
case 24:
SetRemoveEmptyValFromCurve(buf.ReadBool());
break;
}
}
......@@ -615,6 +631,7 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
if(outputType == OUTPUTTYPE_OUTPUTONINPUTMESH)
str = str + "OUTPUTTYPE_OUTPUTONINPUTMESH";
str = str + "\n";
str = str + boolToString("removeEmptyValFromCurve", removeEmptyValFromCurve, indent) + "\n";
return str;
}
......@@ -644,5 +661,6 @@ public class DataBinningAttributes extends AttributeSubject implements Plugin
private String varForReduction;
private double emptyVal;
private int outputType;
private boolean removeEmptyValFromCurve;
}
......@@ -281,6 +281,11 @@ PyDataBinningAttributes_ToString(const DataBinningAttributes *atts, const char *
break;
}
if(atts->GetRemoveEmptyValFromCurve())
SNPRINTF(tmpStr, 1000, "%sremoveEmptyValFromCurve = 1\n", prefix);
else
SNPRINTF(tmpStr, 1000, "%sremoveEmptyValFromCurve = 0\n", prefix);
str += tmpStr;
return str;
}
......@@ -934,6 +939,30 @@ DataBinningAttributes_GetOutputType(PyObject *self, PyObject *args)
return retval;
}
/*static*/ PyObject *
DataBinningAttributes_SetRemoveEmptyValFromCurve(PyObject *self, PyObject *args)
{
DataBinningAttributesObject *obj = (DataBinningAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the removeEmptyValFromCurve in the object.
obj->data->SetRemoveEmptyValFromCurve(ival != 0);
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
DataBinningAttributes_GetRemoveEmptyValFromCurve(PyObject *self, PyObject *args)
{
DataBinningAttributesObject *obj = (DataBinningAttributesObject *)self;
PyObject *retval = PyInt_FromLong(obj->data->GetRemoveEmptyValFromCurve()?1L:0L);
return retval;
}
PyMethodDef PyDataBinningAttributes_methods[DATABINNINGATTRIBUTES_NMETH] = {
......@@ -986,6 +1015,8 @@ PyMethodDef PyDataBinningAttributes_methods[DATABINNINGATTRIBUTES_NMETH] = {
{"GetEmptyVal", DataBinningAttributes_GetEmptyVal, METH_VARARGS},
{"SetOutputType", DataBinningAttributes_SetOutputType, METH_VARARGS},
{"GetOutputType", DataBinningAttributes_GetOutputType, METH_VARARGS},
{"SetRemoveEmptyValFromCurve", DataBinningAttributes_SetRemoveEmptyValFromCurve, METH_VARARGS},
{"GetRemoveEmptyValFromCurve", DataBinningAttributes_GetRemoveEmptyValFromCurve, METH_VARARGS},
{NULL, NULL}
};
......@@ -1125,6 +1156,8 @@ PyDataBinningAttributes_getattr(PyObject *self, char *name)
if(strcmp(name, "OutputOnInputMesh") == 0)
return PyInt_FromLong(long(DataBinningAttributes::OutputOnInputMesh));
if(strcmp(name, "removeEmptyValFromCurve") == 0)
return DataBinningAttributes_GetRemoveEmptyValFromCurve(self, NULL);
return Py_FindMethod(PyDataBinningAttributes_methods, self, name);
}
......@@ -1187,6 +1220,8 @@ PyDataBinningAttributes_setattr(PyObject *self, char *name, PyObject *args)
obj = DataBinningAttributes_SetEmptyVal(self, tuple);
else if(strcmp(name, "outputType") == 0)
obj = DataBinningAttributes_SetOutputType(self, tuple);
else if(strcmp(name, "removeEmptyValFromCurve") == 0)
obj = DataBinningAttributes_SetRemoveEmptyValFromCurve(self, tuple);
if(obj != NULL)
Py_DECREF(obj);
......
......@@ -44,7 +44,7 @@
//
// Functions exposed to the VisIt module.
//
#define DATABINNINGATTRIBUTES_NMETH 50
#define DATABINNINGATTRIBUTES_NMETH 52
void PyDataBinningAttributes_StartUp(DataBinningAttributes *subj, void *data);
void PyDataBinningAttributes_CloseDown();
PyMethodDef * PyDataBinningAttributes_GetMethodTable(int *nMethods);
......
......@@ -127,6 +127,9 @@ QvisDataBinningWindow::~QvisDataBinningWindow()
// Hank Childs, Mon Jul 16 17:13:53 PDT 2012
// Add support for outputs on the mesh or the bins.
//
// Hank Childs, Fri Jan 4 11:49:36 PST 2013
// Remove unused bins for curves.
//
// ****************************************************************************
void
......@@ -372,6 +375,11 @@ QvisDataBinningWindow::CreateWindowContents()
this, SLOT(emptyValProcessText()));
rtLayout->addWidget(emptyVal, 2,1);
removeEmptyBins = new QCheckBox(tr("Remove bins with no data (curves only)"), central);
rtLayout->addWidget(removeEmptyBins, 3, 0);
connect(removeEmptyBins, SIGNAL(toggled(bool)),
this, SLOT(removeEmptyBinsToggled(bool)));
QGroupBox *outputGroup = new QGroupBox(central);
outputGroup->setTitle(tr("Output"));
mainLayout->addWidget(outputGroup);
......@@ -416,6 +424,9 @@ QvisDataBinningWindow::CreateWindowContents()
// Hank Childs, Mon Jul 16 17:13:53 PDT 2012
// Add support for outputs on the mesh or the bins.
//
// Hank Childs, Fri Jan 4 11:49:36 PST 2013
// Remove unused bins for curves.
//
// ****************************************************************************
void
......@@ -691,6 +702,9 @@ QvisDataBinningWindow::UpdateWindow(bool doAll)
case DataBinningAttributes::ID_emptyVal:
emptyVal->setText(DoubleToQString(atts->GetEmptyVal()));
break;
case DataBinningAttributes::ID_removeEmptyValFromCurve:
removeEmptyBins->setChecked(atts->GetRemoveEmptyValFromCurve());
break;
case DataBinningAttributes::ID_dim1BinBasedOn:
if (atts->GetDim1BinBasedOn() == DataBinningAttributes::Variable)
dim1Var->setEnabled(true);
......@@ -1155,3 +1169,9 @@ QvisDataBinningWindow::dim3SpecifyRangeToggled(bool v)
}
void
QvisDataBinningWindow::removeEmptyBinsToggled(bool v)
{
atts->SetRemoveEmptyValFromCurve(v);
Apply();
}
......@@ -74,6 +74,9 @@ class QvisVariableButton;
// Hank Childs, Sun Jul 31 16:01:41 PDT 2011
// Add support for binning based on spatial dimensions.
//
// Hank Childs, Fri Jan 4 11:49:36 PST 2013
// Remove unused bins for curves.
//
// ****************************************************************************
class QvisDataBinningWindow : public QvisOperatorWindow
......@@ -115,6 +118,7 @@ class QvisDataBinningWindow : public QvisOperatorWindow
void reductionOperatorClicked(int val);
void varForReductionChanged(const QString &varName);
void emptyValProcessText();
void removeEmptyBinsToggled(bool);
private:
QWidget *numDimensions;
QComboBox *numDimensionsCombo;
......@@ -171,6 +175,7 @@ class QvisDataBinningWindow : public QvisOperatorWindow
QLabel *reductionOperatorLabel;
QLabel *varForReductionLabel;
QLabel *emptyValLabel;
QCheckBox *removeEmptyBins;
QButtonGroup *outputButtonGroup;
DataBinningAttributes *atts;
......
......@@ -46,6 +46,7 @@
#include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <vtkPointData.h>
#include <vtkRectilinearGrid.h>
#include <avtCallback.h>
#include <avtDataBinning.h>
......@@ -142,6 +143,77 @@ avtDataBinningFilter::Equivalent(const AttributeGroup *a)
}
// ****************************************************************************
// Function: RemoveUndefinedPointsFromCurve
//
// Purpose:
// Removes all bins from a 1D vtkRectilinearGrid that have the "emptyVal".
//
// Programmer: Hank Childs
// Creation: January 4, 2013
//
// ****************************************************************************
void
RemoveUndefinedPointsFromCurve(vtkDataSet *ds, double emptyVal)
{
int i;
// Make sure we have a valid mesh
if (ds->GetDataObjectType() != VTK_RECTILINEAR_GRID)
return;
vtkRectilinearGrid *rg = (vtkRectilinearGrid *) ds;
int dims[3];
rg->GetDimensions(dims);
if (dims[0] <= 1 || dims[1] != 1 || dims[2] != 1)
return;
// Get the scalars
vtkDataArray *v = rg->GetPointData()->GetScalars();
if (v == NULL)
return;
// See how many match
int nvals = v->GetNumberOfTuples();
int numValid = 0;
for (i = 0 ; i < nvals ; i++)
{
if (v->GetTuple1(i) != emptyVal)
numValid++;
}
if (numValid == nvals)
return;
dims[0] = numValid;
rg->SetDimensions(dims);
vtkDataArray *oldX = rg->GetXCoordinates();
vtkDataArray *newX = vtkDataArray::CreateDataArray(oldX->GetDataType());
newX->SetNumberOfTuples(numValid);
vtkDataArray *newV = vtkDataArray::CreateDataArray(v->GetDataType());
newV->SetNumberOfTuples(numValid);
int curIdx = 0;
for (i = 0 ; i < nvals ; i++)
{
if (v->GetTuple1(i) != emptyVal)
{
newV->SetTuple1(curIdx, v->GetTuple1(i));
newX->SetTuple1(curIdx, oldX->GetTuple1(i));
curIdx++;
}
}
v->SetName("nameWeGiveSoWeCanRemoveIt");
rg->GetPointData()->RemoveArray("nameWeGiveSoWeCanRemoveIt");
rg->GetPointData()->SetScalars(newV);
newV->Delete();
rg->SetXCoordinates(newX);
newX->Delete();
}
// ****************************************************************************
// Method: avtDataBinningFilter::Execute
//
......@@ -171,6 +243,9 @@ avtDataBinningFilter::Equivalent(const AttributeGroup *a)
// Hank Childs, Mon Jul 16 17:22:00 PDT 2012
// Add support for outputing on the input mesh.
//
// Hank Childs, Fri Jan 4 11:49:36 PST 2013
// Remove unused bins for curves.
//
// ****************************************************************************
void
......@@ -253,6 +328,10 @@ avtDataBinningFilter::Execute(void)
if (PAR_Rank() == 0)
{
vtkDataSet *ds = d->CreateGrid();
bool isCurve = (atts.GetNumDimensions() == DataBinningAttributes::One);
bool removeUndefined = atts.GetRemoveEmptyValFromCurve();
if (isCurve && removeUndefined)
RemoveUndefinedPointsFromCurve(ds, atts.GetEmptyVal());
if (atts.GetNumDimensions() == DataBinningAttributes::One)
ds->GetPointData()->GetScalars()->SetName(varname.c_str());
else
......
......@@ -42,7 +42,7 @@ enhancements and bug-fixes that were added to this release.</p>
<a name="Advanced_Features"></a>
<p><b><font size="4">Advanced features added in version 2.7</font></b></p>
<ul>
<li></li>
<li>The DataBinning operator now automatically discards bins that have no data when creating curves.</li>
<li></li>
<li></li>
<li></li>
......
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