Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

Commit 210e2913 authored by ghweber's avatar ghweber
Browse files

Add the ability to extract and 'stack' multiple distribution function slices.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@27817 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8c17bedb
<?xml version="1.0"?>
<Plugin name="ExtractPointFunction2D" type="operator" label="Extract Point Function 2D" version="1.0" enabled="false" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" createExpression="true" exprInType="array" exprOutType="scalar" category="Analysis">
<Plugin name="ExtractPointFunction2D" type="operator" label="Extract Point Function 2D" version="1.0" enabled="false" mdspecificcode="false" engspecificcode="false" onlyengine="false" noengine="false" category="Analysis" createExpression="true" exprInType="array" exprOutType="scalar">
<Attribute name="ExtractPointFunction2DAttributes" purpose="Attributes for ExtractPointFunction2D" persistent="true" keyframe="true" exportAPI="" exportInclude="" codefile="ExtractPointFunction2DAttributes.code">
<Field name="I" label="I" type="int">
0
<Field name="I" label="I" type="intVector">
</Field>
<Field name="J" label="J" type="int">
0
<Field name="J" label="J" type="intVector">
</Field>
<Function name="ExtractPointFunction2DCommonPluginInfo::GetCreatedExpressions" user="false" member="true">
</Function>
......
......@@ -56,8 +56,6 @@
void ExtractPointFunction2DAttributes::Init()
{
I = 0;
J = 0;
ExtractPointFunction2DAttributes::SelectAll();
}
......@@ -466,9 +464,9 @@ ExtractPointFunction2DAttributes::SetFromNode(DataNode *parentNode)
DataNode *node;
if((node = searchNode->GetNode("I")) != 0)
SetI(node->AsInt());
SetI(node->AsIntVector());
if((node = searchNode->GetNode("J")) != 0)
SetJ(node->AsInt());
SetJ(node->AsIntVector());
}
///////////////////////////////////////////////////////////////////////////////
......@@ -476,14 +474,14 @@ ExtractPointFunction2DAttributes::SetFromNode(DataNode *parentNode)
///////////////////////////////////////////////////////////////////////////////
void
ExtractPointFunction2DAttributes::SetI(int I_)
ExtractPointFunction2DAttributes::SetI(const intVector &I_)
{
I = I_;
Select(ID_I, (void *)&I);
}
void
ExtractPointFunction2DAttributes::SetJ(int J_)
ExtractPointFunction2DAttributes::SetJ(const intVector &J_)
{
J = J_;
Select(ID_J, (void *)&J);
......@@ -493,18 +491,46 @@ ExtractPointFunction2DAttributes::SetJ(int J_)
// Get property methods
///////////////////////////////////////////////////////////////////////////////
int
const intVector &
ExtractPointFunction2DAttributes::GetI() const
{
return I;
}
int
intVector &
ExtractPointFunction2DAttributes::GetI()
{
return I;
}
const intVector &
ExtractPointFunction2DAttributes::GetJ() const
{
return J;
}
intVector &
ExtractPointFunction2DAttributes::GetJ()
{
return J;
}
///////////////////////////////////////////////////////////////////////////////
// Select property methods
///////////////////////////////////////////////////////////////////////////////
void
ExtractPointFunction2DAttributes::SelectI()
{
Select(ID_I, (void *)&I);
}
void
ExtractPointFunction2DAttributes::SelectJ()
{
Select(ID_J, (void *)&J);
}
///////////////////////////////////////////////////////////////////////////////
// Keyframing methods
///////////////////////////////////////////////////////////////////////////////
......@@ -555,8 +581,8 @@ ExtractPointFunction2DAttributes::GetFieldType(int index) const
{
switch (index)
{
case ID_I: return FieldType_int;
case ID_J: return FieldType_int;
case ID_I: return FieldType_intVector;
case ID_J: return FieldType_intVector;
default: return FieldType_unknown;
}
}
......@@ -581,8 +607,8 @@ ExtractPointFunction2DAttributes::GetFieldTypeName(int index) const
{
switch (index)
{
case ID_I: return "int";
case ID_J: return "int";
case ID_I: return "intVector";
case ID_J: return "intVector";
default: return "invalid index";
}
}
......
......@@ -84,14 +84,18 @@ public:
// Property selection methods
virtual void SelectAll();
void SelectI();
void SelectJ();
// Property setting methods
void SetI(int I_);
void SetJ(int J_);
void SetI(const intVector &I_);
void SetJ(const intVector &J_);
// Property getting methods
int GetI() const;
int GetJ() const;
const intVector &GetI() const;
intVector &GetI();
const intVector &GetJ() const;
intVector &GetJ();
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
......@@ -113,13 +117,13 @@ public:
};
private:
int I;
int J;
intVector I;
intVector J;
// Static class format string for type map.
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define EXTRACTPOINTFUNCTION2DATTRIBUTES_TMFS "ii"
#define EXTRACTPOINTFUNCTION2DATTRIBUTES_TMFS "i*i*"
#endif
......@@ -41,6 +41,8 @@ package llnl.visit.operators;
import llnl.visit.AttributeSubject;
import llnl.visit.CommunicationBuffer;
import llnl.visit.Plugin;
import java.lang.Integer;
import java.util.Vector;
// ****************************************************************************
// Class: ExtractPointFunction2DAttributes
......@@ -65,24 +67,36 @@ public class ExtractPointFunction2DAttributes extends AttributeSubject implement
{
super(ExtractPointFunction2DAttributes_numAdditionalAtts);
I = 0;
J = 0;
I = new Vector();
J = new Vector();
}
public ExtractPointFunction2DAttributes(int nMoreFields)
{
super(ExtractPointFunction2DAttributes_numAdditionalAtts + nMoreFields);
I = 0;
J = 0;
I = new Vector();
J = new Vector();
}
public ExtractPointFunction2DAttributes(ExtractPointFunction2DAttributes obj)
{
super(ExtractPointFunction2DAttributes_numAdditionalAtts);
I = obj.I;
J = obj.J;
int i;
I = new Vector();
for(i = 0; i < obj.I.size(); ++i)
{
Integer iv = (Integer)obj.I.elementAt(i);
I.addElement(new Integer(iv.intValue()));
}
J = new Vector();
for(i = 0; i < obj.J.size(); ++i)
{
Integer iv = (Integer)obj.J.elementAt(i);
J.addElement(new Integer(iv.intValue()));
}
SelectAll();
}
......@@ -99,38 +113,58 @@ public class ExtractPointFunction2DAttributes extends AttributeSubject implement
public boolean equals(ExtractPointFunction2DAttributes obj)
{
int i;
// Compare the elements in the I vector.
boolean I_equal = (obj.I.size() == I.size());
for(i = 0; (i < I.size()) && I_equal; ++i)
{
// Make references to Integer from Object.
Integer I1 = (Integer)I.elementAt(i);
Integer I2 = (Integer)obj.I.elementAt(i);
I_equal = I1.equals(I2);
}
// Compare the elements in the J vector.
boolean J_equal = (obj.J.size() == J.size());
for(i = 0; (i < J.size()) && J_equal; ++i)
{
// Make references to Integer from Object.
Integer J1 = (Integer)J.elementAt(i);
Integer J2 = (Integer)obj.J.elementAt(i);
J_equal = J1.equals(J2);
}
// Create the return value
return ((I == obj.I) &&
(J == obj.J));
return (I_equal &&
J_equal);
}
public String GetName() { return "ExtractPointFunction2D"; }
public String GetVersion() { return "1.0"; }
// Property setting methods
public void SetI(int I_)
public void SetI(Vector I_)
{
I = I_;
Select(0);
}
public void SetJ(int J_)
public void SetJ(Vector J_)
{
J = J_;
Select(1);
}
// Property getting methods
public int GetI() { return I; }
public int GetJ() { return J; }
public Vector GetI() { return I; }
public Vector GetJ() { return J; }
// Write and read methods.
public void WriteAtts(CommunicationBuffer buf)
{
if(WriteSelect(0, buf))
buf.WriteInt(I);
buf.WriteIntVector(I);
if(WriteSelect(1, buf))
buf.WriteInt(J);
buf.WriteIntVector(J);
}
public void ReadAtts(int index, CommunicationBuffer buf)
......@@ -138,10 +172,10 @@ public class ExtractPointFunction2DAttributes extends AttributeSubject implement
switch(index)
{
case 0:
SetI(buf.ReadInt());
SetI(buf.ReadIntVector());
break;
case 1:
SetJ(buf.ReadInt());
SetJ(buf.ReadIntVector());
break;
}
}
......@@ -149,14 +183,14 @@ public class ExtractPointFunction2DAttributes extends AttributeSubject implement
public String toString(String indent)
{
String str = new String();
str = str + intToString("I", I, indent) + "\n";
str = str + intToString("J", J, indent) + "\n";
str = str + intVectorToString("I", I, indent) + "\n";
str = str + intVectorToString("J", J, indent) + "\n";
return str;
}
// Attributes
private int I;
private int J;
private Vector I; // vector of Integer objects
private Vector J; // vector of Integer objects
}
......@@ -76,10 +76,38 @@ PyExtractPointFunction2DAttributes_ToString(const ExtractPointFunction2DAttribut
std::string str;
char tmpStr[1000];
SNPRINTF(tmpStr, 1000, "%sI = %d\n", prefix, atts->GetI());
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%sJ = %d\n", prefix, atts->GetJ());
str += tmpStr;
{ const intVector &I = atts->GetI();
SNPRINTF(tmpStr, 1000, "%sI = (", prefix);
str += tmpStr;
for(size_t i = 0; i < I.size(); ++i)
{
SNPRINTF(tmpStr, 1000, "%d", I[i]);
str += tmpStr;
if(i < I.size() - 1)
{
SNPRINTF(tmpStr, 1000, ", ");
str += tmpStr;
}
}
SNPRINTF(tmpStr, 1000, ")\n");
str += tmpStr;
}
{ const intVector &J = atts->GetJ();
SNPRINTF(tmpStr, 1000, "%sJ = (", prefix);
str += tmpStr;
for(size_t i = 0; i < J.size(); ++i)
{
SNPRINTF(tmpStr, 1000, "%d", J[i]);
str += tmpStr;
if(i < J.size() - 1)
{
SNPRINTF(tmpStr, 1000, ", ");
str += tmpStr;
}
}
SNPRINTF(tmpStr, 1000, ")\n");
str += tmpStr;
}
return str;
}
......@@ -97,12 +125,47 @@ ExtractPointFunction2DAttributes_SetI(PyObject *self, PyObject *args)
{
ExtractPointFunction2DAttributesObject *obj = (ExtractPointFunction2DAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
intVector &vec = obj->data->GetI();
PyObject *tuple;
if(!PyArg_ParseTuple(args, "O", &tuple))
return NULL;
if(PyTuple_Check(tuple))
{
vec.resize(PyTuple_Size(tuple));
for(int i = 0; i < PyTuple_Size(tuple); ++i)
{
PyObject *item = PyTuple_GET_ITEM(tuple, i);
if(PyFloat_Check(item))
vec[i] = int(PyFloat_AS_DOUBLE(item));
else if(PyInt_Check(item))
vec[i] = int(PyInt_AS_LONG(item));
else if(PyLong_Check(item))
vec[i] = int(PyLong_AsLong(item));
else
vec[i] = 0;
}
}
else if(PyFloat_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyFloat_AS_DOUBLE(tuple));
}
else if(PyInt_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyInt_AS_LONG(tuple));
}
else if(PyLong_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyLong_AsLong(tuple));
}
else
return NULL;
// Set the I in the object.
obj->data->SetI((int)ival);
// Mark the I in the object as modified.
obj->data->SelectI();
Py_INCREF(Py_None);
return Py_None;
......@@ -112,7 +175,11 @@ ExtractPointFunction2DAttributes_SetI(PyObject *self, PyObject *args)
ExtractPointFunction2DAttributes_GetI(PyObject *self, PyObject *args)
{
ExtractPointFunction2DAttributesObject *obj = (ExtractPointFunction2DAttributesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetI()));
// Allocate a tuple the with enough entries to hold the I.
const intVector &I = obj->data->GetI();
PyObject *retval = PyTuple_New(I.size());
for(size_t i = 0; i < I.size(); ++i)
PyTuple_SET_ITEM(retval, i, PyInt_FromLong(long(I[i])));
return retval;
}
......@@ -121,12 +188,47 @@ ExtractPointFunction2DAttributes_SetJ(PyObject *self, PyObject *args)
{
ExtractPointFunction2DAttributesObject *obj = (ExtractPointFunction2DAttributesObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
intVector &vec = obj->data->GetJ();
PyObject *tuple;
if(!PyArg_ParseTuple(args, "O", &tuple))
return NULL;
if(PyTuple_Check(tuple))
{
vec.resize(PyTuple_Size(tuple));
for(int i = 0; i < PyTuple_Size(tuple); ++i)
{
PyObject *item = PyTuple_GET_ITEM(tuple, i);
if(PyFloat_Check(item))
vec[i] = int(PyFloat_AS_DOUBLE(item));
else if(PyInt_Check(item))
vec[i] = int(PyInt_AS_LONG(item));
else if(PyLong_Check(item))
vec[i] = int(PyLong_AsLong(item));
else
vec[i] = 0;
}
}
else if(PyFloat_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyFloat_AS_DOUBLE(tuple));
}
else if(PyInt_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyInt_AS_LONG(tuple));
}
else if(PyLong_Check(tuple))
{
vec.resize(1);
vec[0] = int(PyLong_AsLong(tuple));
}
else
return NULL;
// Set the J in the object.
obj->data->SetJ((int)ival);
// Mark the J in the object as modified.
obj->data->SelectJ();
Py_INCREF(Py_None);
return Py_None;
......@@ -136,7 +238,11 @@ ExtractPointFunction2DAttributes_SetJ(PyObject *self, PyObject *args)
ExtractPointFunction2DAttributes_GetJ(PyObject *self, PyObject *args)
{
ExtractPointFunction2DAttributesObject *obj = (ExtractPointFunction2DAttributesObject *)self;
PyObject *retval = PyInt_FromLong(long(obj->data->GetJ()));
// Allocate a tuple the with enough entries to hold the J.
const intVector &J = obj->data->GetJ();
PyObject *retval = PyTuple_New(J.size());
for(size_t i = 0; i < J.size(); ++i)
PyTuple_SET_ITEM(retval, i, PyInt_FromLong(long(J[i])));
return retval;
}
......
......@@ -176,10 +176,10 @@ QvisExtractPointFunction2DWindow::UpdateWindow(bool doAll)
switch(i)
{
case ExtractPointFunction2DAttributes::ID_I:
I->setText(IntToQString(atts->GetI()));
I->setText(IntsToQString(atts->GetI()));
break;
case ExtractPointFunction2DAttributes::ID_J:
J->setText(IntToQString(atts->GetJ()));
J->setText(IntsToQString(atts->GetJ()));
break;
}
}
......@@ -209,13 +209,13 @@ QvisExtractPointFunction2DWindow::GetCurrentValues(int which_widget)
// Do I
if(which_widget == ExtractPointFunction2DAttributes::ID_I || doAll)
{
int val;
if(LineEditGetInt(I, val))
intVector val;
if(LineEditGetInts(I, val))
atts->SetI(val);
else
{
ResettingError(tr("I"),
IntToQString(atts->GetI()));
IntsToQString(atts->GetI()));
atts->SetI(atts->GetI());
}
}
......@@ -223,13 +223,13 @@ QvisExtractPointFunction2DWindow::GetCurrentValues(int which_widget)
// Do J
if(which_widget == ExtractPointFunction2DAttributes::ID_J || doAll)
{
int val;
if(LineEditGetInt(J, val))
intVector val;
if(LineEditGetInts(J, val))
atts->SetJ(val);
else
{
ResettingError(tr("J"),
IntToQString(atts->GetJ()));
IntsToQString(atts->GetJ()));
atts->SetJ(atts->GetJ());
}
}
......
......@@ -44,6 +44,11 @@
#include <float.h>
#ifdef PARALLEL
#include <avtParallel.h>
#include <mpi.h>
#endif
#include <vtkCellData.h>
#include <vtkDataArray.h>
#include <vtkDoubleArray.h>
......@@ -51,6 +56,8 @@
#include <vtkIntArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkDataSetWriter.h>
// ****************************************************************************
// Method: avtExtractPointFunction2DFilter constructor
//
......@@ -170,17 +177,11 @@ avtExtractPointFunction2DFilter::PreExecute(void)
spatialExtents[5] = 0;
}
// ****************************************************************************
// Method: avtExtractPointFunction2DFilter::ExecuteData
// Method: avtExtractPointFunction2DFilter::Execute
//
// Purpose:
// Sends the specified input and output through the ExtractPointFunction2D filter.
//
// Arguments:
// in_dr The input data representation.
//
// Returns: The output data representation.
// Extracts the point function in a localtion (or a list of locations)
//
// Programmer: ghweber -- generated by xml2avt
// Creation: Tue Jun 4 10:46:56 PDT 2013
......@@ -195,134 +196,239 @@ avtExtractPointFunction2DFilter::PreExecute(void)
//
// ****************************************************************************
avtDataRepresentation *
avtExtractPointFunction2DFilter::ExecuteData(avtDataRepresentation *in_dr)
void
avtExtractPointFunction2DFilter::Execute()
{
//
// Get the VTK data set.
//
vtkDataSet *in_ds = in_dr->GetDataVTK();
// Ensure that we are working on rectilinear grid
vtkRectilinearGrid *rgrid = dynamic_cast<vtkRectilinearGrid*>(in_ds);
if (!rgrid)
// Check consistency
if (atts.GetI().size() != atts.