Commit 2b75a941 authored by hrchilds's avatar hrchilds

Update from August 13, 2003

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@57 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8383a49c
......@@ -115,6 +115,11 @@ Scanner::GetCharType(const char c)
// Programmer: Jeremy Meredith
// Creation: April 5, 2002
//
// Modifications:
//
// Hank Childs, Wed Aug 13 09:36:22 PDT 2003
// Take out the quotes around string constants.
//
// ****************************************************************************
Token *
Scanner::GetAcceptToken(const Pos &pos, const std::string &parsed, int state)
......@@ -122,7 +127,8 @@ Scanner::GetAcceptToken(const Pos &pos, const std::string &parsed, int state)
switch (state)
{
case 2:
return new StringConst(pos, parsed);
// Remove the quotes on either side of the string.
return new StringConst(pos, parsed.substr(1, parsed.size()-2));
case 3:
return new Character(pos, parsed);
case 5:
......
......@@ -221,6 +221,10 @@ avtDatabase::GetOutput(const char *var, int ts)
// Hank Childs, Fri Aug 1 21:54:08 PDT 2003
// Add support for curves.
//
// Hank Childs, Wed Aug 13 11:17:58 PDT 2003
// No longer assume that requesting a material means that we are doing
// material interface reconstruction.
//
// ****************************************************************************
void
......@@ -326,12 +330,6 @@ avtDatabase::PopulateDataObjectInformation(avtDataObject_p &dob,
atts.GetEffectiveDataExtents()->Set(extents);
}
const avtMaterialMetaData *matmd = GetMetaData()->GetMaterial(var);
if (matmd != NULL)
{
validity.InvalidateZones();
}
const avtCurveMetaData *cmd = GetMetaData()->GetCurve(var);
if (cmd != NULL)
{
......
......@@ -2247,10 +2247,10 @@ avtGenericDatabase::GetMIR(int domain, const char *varname, int timestep,
// so that it can do the material selection as we read.
//
// Arguments:
// var The variable name.
// dom The domain.
// silr The SIL restriction.
// mnames A place to put the list of material names.
// dom The domain.
// forceMIROn A boolean saying whether we should force MIR on.
// silr The SIL restriction.
// mnames A place to put the list of material names.
//
// Returns: true if we need to perform material selection, false otherwise.
//
......@@ -2263,10 +2263,14 @@ avtGenericDatabase::GetMIR(int domain, const char *varname, int timestep,
// Use the SIL restriction traverser since SIL restriction routines were
// antiquated.
//
// Hank Childs, Wed Aug 13 08:09:20 PDT 2003
// Do not longer key off type, instead use a flag that has been explicitly
// set.
//
// ****************************************************************************
bool
avtGenericDatabase::PrepareMaterialSelect(const char *var, int dom,
avtGenericDatabase::PrepareMaterialSelect(int dom, bool forceMIROn,
avtSILRestrictionTraverser &trav, vector<string> &mnames)
{
//
......@@ -2277,9 +2281,10 @@ avtGenericDatabase::PrepareMaterialSelect(const char *var, int dom,
mnames = trav.GetMaterials(dom, needMatSel);
//
// If we want a material plot, we must do material selection.
// If we were told to do material interface reconstruction, we should do
// it, regardless of SIL.
//
needMatSel |= (GetMetaData()->DetermineVarType(var) == AVT_MATERIAL);
needMatSel |= forceMIROn;
return needMatSel;
}
......@@ -2409,7 +2414,9 @@ avtGenericDatabase::ReadDataset(avtDatasetCollection &ds, vector<int> &domains,
{
vector<string> labels;
vector<string> matnames;
bool doSelect = PrepareMaterialSelect(var, domains[i], trav, matnames);
bool forceMIR = spec->MustDoMaterialInterfaceReconstruction();
bool doSelect = PrepareMaterialSelect(domains[i], forceMIR, trav,
matnames);
int nmats = matnames.size();
vtkDataSet *single_ds = NULL;
......@@ -3436,6 +3443,10 @@ avtGenericDatabase::CreateStructuredIndices(avtDatasetCollection &dsc,
// Hank Childs, Wed Jun 18 09:34:38 PDT 2003
// Added a stage for needing node numbers.
//
// Hank Childs, Wed Aug 13 08:09:20 PDT 2003
// We should do MIR if we are told to by the data spec, not if the type of
// variable is material.
//
// ****************************************************************************
int
......@@ -3454,7 +3465,7 @@ avtGenericDatabase::NumStagesForFetch(avtDataSpecification_p spec)
bool needMatSel = false;
const char *var = spec->GetVariable();
needMatSel |= (GetMetaData()->DetermineVarType(var) == AVT_MATERIAL);
needMatSel |= spec->MustDoMaterialInterfaceReconstruction();
if (!needMatSel)
{
for (int i = 0 ; i < domains.size() ; i++)
......
......@@ -201,7 +201,7 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
void AddOriginalCellsArray(vtkDataSet *, const int);
void AddOriginalNodesArray(vtkDataSet *, const int);
bool PrepareMaterialSelect(const char *, int,
bool PrepareMaterialSelect(int, bool,
avtSILRestrictionTraverser &,
std::vector<std::string> &);
avtDataTree_p MaterialSelect(vtkDataSet *, avtMaterial *,
......
......@@ -182,13 +182,16 @@ avtExpressionFilter::PostExecute(void)
// ****************************************************************************
vtkDataSet *
avtExpressionFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
avtExpressionFilter::ExecuteData(vtkDataSet *in_ds, int index,
std::string label)
{
int i, j;
//
// Start off by having the derived type calculate the derived variable.
//
currentDomainsLabel = label;
currentDomainsIndex = index;
vtkDataArray *dat = DeriveVariable(in_ds);
dat->SetName(outputVariableName);
......
......@@ -6,12 +6,16 @@
#define AVT_EXPRESSION_FILTER_H
#include <expression_exports.h>
#include <string>
#include <avtStreamer.h>
class vtkDataArray;
class ArgsExpr;
class ExprPipelineState;
// ****************************************************************************
// Class: avtExpressionFilter
//
......@@ -23,10 +27,15 @@ class ExprPipelineState;
// Creation: June 7, 2002
//
// Modifications:
// Sean Ahern, Fri Jun 13 11:18:07 PDT 2003
// Added the virtual function NumVariableArguments that lets an
// expression declare how many of its arguments are variables.
//
// Sean Ahern, Fri Jun 13 11:18:07 PDT 2003
// Added the virtual function NumVariableArguments that lets an
// expression declare how many of its arguments are variables.
//
// Hank Childs, Tue Aug 12 10:34:02 PDT 2003
// Store the domain label and index when deriving a variable. Certain
// filters need this information.
//
// ****************************************************************************
class EXPRESSION_API avtExpressionFilter : public avtStreamer
......@@ -44,6 +53,8 @@ class EXPRESSION_API avtExpressionFilter : public avtStreamer
protected:
char *outputVariableName;
std::string currentDomainsLabel;
int currentDomainsIndex;
virtual bool IsPointVariable();
......
// ************************************************************************* //
// avtMatvfFilter.C //
// avtMatvfFilter.C //
// ************************************************************************* //
#include <Token.h>
#include <EngineExprNode.h>
#include <avtMatvfFilter.h>
#include <DebugStream.h>
#include <ExpressionException.h>
#include <math.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkUnsignedIntArray.h>
#include <Token.h>
#include <EngineExprNode.h>
#include <avtMaterial.h>
#include <avtMetaData.h>
#include <DebugStream.h>
#include <ExpressionException.h>
#include <ImproperUseException.h>
// ****************************************************************************
......@@ -29,33 +36,148 @@
// Programmer: Sean Ahern
// Creation: Tue Mar 18 23:19:39 America/Los_Angeles 2003
//
// Modifications:
//
// Hank Childs, Tue Aug 12 10:21:49 PDT 2003
// Wrote the code to actually find the material volume fractions (the
// previous code was just a place-holder).
//
// ****************************************************************************
vtkDataArray *
avtMatvfFilter::DeriveVariable(vtkDataSet *in_ds)
{
vtkFloatArray *arr = vtkFloatArray::New();
int ncells = in_ds->GetNumberOfCells();
arr->SetNumberOfTuples(ncells);
int i, j;
for (int i = 0 ; i < ncells ; i++)
int ncells = in_ds->GetNumberOfCells();
//
// The 'currentDomainsIndex' is a data member of the base class that is
// set to be the id of the current domain right before DeriveVariable is
// called. We need that index to make sure we are getting the right mat.
//
avtMaterial *mat = GetMetaData()->GetMaterial(currentDomainsIndex);
if (mat == NULL)
{
// Set the tuple to the value of the material fraction at that cell.
//vtkCell *cell = in_ds->GetCell(i);
//float matfv = (float)GetMatvf(cell);
//arr->SetTuple1(i, matfv);
arr->SetTuple1(i, 1337);
debug1 << "Could not find a material object." << endl;
vtkFloatArray *dummy = vtkFloatArray::New();
dummy->SetNumberOfTuples(ncells);
for (i = 0 ; i < ncells ; i++)
dummy->SetTuple1(i, 0.);
return dummy;
}
cerr << "avtMatvfFilter: materials" << endl;
for(int i=0;i<materials.size();i++)
//
// Note that we are setting up vf_for_orig_cells based on the number of
// zones in the original dataset -- this may or may not be the number
// of cells in the input, depending on whether or not we did MIR.
//
vtkFloatArray *vf_for_orig_cells = vtkFloatArray::New();
vf_for_orig_cells = vtkFloatArray::New();
int norigcells = mat->GetNZones();
vf_for_orig_cells->SetNumberOfTuples(norigcells);
//
// Try to match up the materials in the avtMaterial object with the
// materials requested by the users. Some of the materials requested
// by the user may not be there. This is probably okay -- there are
// tricks played by the avtMaterial object where it throws out
// materials that are not used in that domain.
//
int nmats = mat->GetNMaterials();
std::vector<bool> useMat(nmats, false);
for (i = 0 ; i < nmats ; i++)
{
cerr << " " << materials[i] << endl;
std::string currentMat = mat->GetMaterials()[i];
for (j = 0 ; j < materials.size() ; j++)
{
if (currentMat == materials[j])
useMat[i] = true;
}
}
//
// Walk through the material data structure and calculate the volume
// fraction for each cell.
//
const int *matlist = mat->GetMatlist();
const int *mixmat = mat->GetMixMat();
const float *mixvf = mat->GetMixVF();
const int *mix_next = mat->GetMixNext();
for (i = 0 ; i < norigcells ; i++)
{
float vf = 0.;
if (matlist[i] >= 0)
{
vf = (useMat[matlist[i]] ? 1. : 0.);
}
else
{
vf = 0.;
int start = -matlist[i]-1;
for (j = start ; j < mix_next[start] ; j++)
{
if (useMat[mixmat[j]])
vf += mixvf[j];
}
}
vf_for_orig_cells->SetTuple1(i, vf);
}
bool zonesMatchMaterialObject = GetInput()->GetInfo().GetValidity().
GetZonesPreserved();
vtkFloatArray *rv = NULL;
if (zonesMatchMaterialObject)
{
//
// We have the volume fractions for the original cells and we are
// operating on the original cells -- we're done.
//
rv = vf_for_orig_cells;
rv->Register(NULL); // Because vf_for_orig_cells will be deleted later.
// Sanity check.
if (norigcells != ncells)
EXCEPTION0(ImproperUseException);
}
else
{
//
// We have the volume fractions for the original cells, but the
// original cells have been modified -- most likely by MIR. Use
// their original indexing to determine the volume fractions.
//
rv = vtkFloatArray::New();
rv->SetNumberOfTuples(ncells);
return arr;
vtkUnsignedIntArray *ids = (vtkUnsignedIntArray *)
in_ds->GetCellData()->GetArray("avtOriginalCellNumbers");
if (ids == NULL)
{
EXCEPTION0(ImproperUseException);
}
int ncomps = ids->GetNumberOfComponents();
unsigned int *ptr = ids->GetPointer(0);
for (i = 0 ; i < ncells ; i++)
{
//
// The id's are poorly arranged. There may be one or two
// components -- always with zones, sometimes with domains.
// The zones are always the last --> ncomps-1 st component.
//
unsigned int id = ptr[ncomps*i + (ncomps-1)];
rv->SetTuple1(i, vf_for_orig_cells->GetTuple1(id));
}
}
// This was essentially a temporary for us.
vf_for_orig_cells->Delete();
return rv;
}
// ****************************************************************************
// Method: avtMatvfFilter::ProcessArguments
//
......
// ************************************************************************* //
// avtMatvfFilter.h //
// avtMatvfFilter.h //
// ************************************************************************* //
#ifndef AVT_MATVF_FILTER_H
......@@ -31,7 +31,7 @@ class EXPRESSION_API avtMatvfFilter : public avtSingleInputExpressionFilter
virtual const char *GetType(void) { return "avtMatvfFilter"; };
virtual const char *GetDescription(void)
{return "Assigning random #.";};
{return "Calculating Material VF";};
virtual void ProcessArguments(ArgsExpr*, ExprPipelineState *);
protected:
......
......@@ -160,6 +160,39 @@ avtMetaData::GetExternalFacelist(int domain)
}
// ****************************************************************************
// Method: avtMetaData::GetMaterial
//
// Purpose:
// Gets an avtMaterial object.
//
// Returns: The material for the dataset, if one exists.
//
// Programmer: Hank Childs
// Creation: August 12, 2003
//
// ****************************************************************************
avtMaterial *
avtMetaData::GetMaterial(int domain)
{
VoidRefList list;
cerr << "asking for domain " << domain << endl;
avtPipelineSpecification_p spec = GetPipelineSpecification(domain);
source->GetMaterialAuxiliaryData(AUXILIARY_DATA_MATERIAL, NULL, spec,list);
if (list.nList == 0)
{
return NULL;
}
if (list.nList != 1)
{
EXCEPTION0(ImproperUseException);
}
return (avtMaterial *) *(list.list[0]);
}
// ****************************************************************************
// Method: avtMetaData::GetPipelineSpecification
//
......
......@@ -4,13 +4,14 @@
#ifndef AVT_META_DATA_H
#define AVT_META_DATA_H
#include <pipeline_exports.h>
#include <pipeline_exports.h>
#include <avtPipelineSpecification.h>
class avtFacelist;
class avtIntervalTree;
class avtMaterial;
class avtTerminatingSource;
......@@ -38,6 +39,9 @@ class avtTerminatingSource;
// Jeremy Meredith, Thu Dec 13 16:00:29 PST 2001
// Removed GetMaterial since it was never used.
//
// Hank Childs, Tue Aug 12 10:27:25 PDT 2003
// Added GetMaterial for matvf expressions.
//
// ****************************************************************************
class PIPELINE_API avtMetaData
......@@ -50,6 +54,7 @@ class PIPELINE_API avtMetaData
avtIntervalTree *GetSpatialExtents(void);
avtFacelist *GetExternalFacelist(int);
avtMaterial *GetMaterial(int);
protected:
avtTerminatingSource *source;
......
......@@ -59,6 +59,9 @@ using std::vector;
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Added needNodes.
//
// Hank Childs, Tue Aug 12 17:27:32 PDT 2003
// Added mustDoMIR.
//
// ****************************************************************************
avtDataSpecification::avtDataSpecification(const char *var, int ts,
......@@ -69,6 +72,7 @@ avtDataSpecification::avtDataSpecification(const char *var, int ts,
needNodes = false;
useGhostZones = true;
needInternalSurfaces = false;
mustDoMIR = false;
needBoundarySurfaces = false;
needValidFaceConnectivity = false;
needStructuredIndices = false;
......@@ -129,6 +133,9 @@ avtDataSpecification::avtDataSpecification(const char *var, int ts,
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Added needNodes.
//
// Hank Childs, Tue Aug 12 17:27:32 PDT 2003
// Added mustDoMIR.
//
// ****************************************************************************
avtDataSpecification::avtDataSpecification(const char *var, int ts, int ch)
......@@ -136,6 +143,7 @@ avtDataSpecification::avtDataSpecification(const char *var, int ts, int ch)
mayRequireZones = false;
needZones = false;
needNodes = false;
mustDoMIR = false;
useGhostZones = true;
needInternalSurfaces = false;
needBoundarySurfaces = false;
......@@ -298,6 +306,9 @@ avtDataSpecification::avtDataSpecification(avtDataSpecification_p spec)
// Jeremy Meredith, Tue Jun 10 13:21:32 PDT 2003
// Added needBoundarySurfaces.
//
// Hank Childs, Tue Aug 12 17:27:32 PDT 2003
// Added mustDoMIR.
//
// ****************************************************************************
avtDataSpecification &
......@@ -323,6 +334,7 @@ avtDataSpecification::operator=(const avtDataSpecification &spec)
}
mayRequireZones = spec.mayRequireZones;
mustDoMIR = spec.mustDoMIR;
useGhostZones = spec.useGhostZones;
needZones = spec.needZones;
needNodes = spec.needNodes;
......@@ -391,6 +403,9 @@ avtDataSpecification::operator=(const avtDataSpecification &spec)
// Hank Childs, Wed Jun 18 09:20:16 PDT 2003
// Compare needNodes.
//
// Hank Childs, Tue Aug 12 17:27:32 PDT 2003
// Added mustDoMIR.
//
// ****************************************************************************
bool
......@@ -424,6 +439,11 @@ avtDataSpecification::operator==(const avtDataSpecification &ds)
return false;
}
if (mustDoMIR != ds.mustDoMIR)
{
return false;
}
if (mayRequireZones != ds.mayRequireZones)
{
return false;
......
......@@ -83,6 +83,9 @@ typedef ref_ptr<avtDataSpecification> avtDataSpecification_p;
// Jeremy Meredith, Thu Jun 12 08:47:03 PDT 2003
// Added option for boundary surfaces.
//
// Hank Childs, Tue Aug 12 17:27:32 PDT 2003
// Added explicit flag for forcing material interface reconstruction.
//
// ****************************************************************************
class PIPELINE_API avtDataSpecification
......@@ -116,6 +119,13 @@ class PIPELINE_API avtDataSpecification
GetSecondaryVariables(void)
{ return secondaryVariables; };
bool MustDoMaterialInterfaceReconstruction(void)
{ return mustDoMIR; };
void ForceMaterialInterfaceReconstructionOn(void)
{ mustDoMIR = true; };
void ForceMaterialInterfaceReconstructionOff(void)
{ mustDoMIR = false; };
bool NeedInternalSurfaces(void)
{ return needInternalSurfaces; };
void TurnInternalSurfacesOn(void)
......@@ -193,6 +203,7 @@ class PIPELINE_API avtDataSpecification
bool needNodes;
bool mayRequireZones;
bool useGhostZones;
bool mustDoMIR;
bool needInternalSurfaces;
bool needBoundarySurfaces;
bool needValidFaceConnectivity;
......
......@@ -5,7 +5,7 @@
#include <avtVertexNormalsFilter.h>
#include <vtkPolyData.h>
#include <vtkPolyDataNormals.h>
#include <vtkVisItPolyDataNormals.h>
#include <avtDataset.h>
......@@ -47,6 +47,10 @@
// Disabled consistency checking because (1) it has bugs, (2) it is slow,
// and (3) we are careful enough about cell orderings that we don't need it.
//
// Jeremy Meredith, Wed Aug 13 18:13:14 PDT 2003
// Made it use the new VisIt poly data normals filter. Allowed
// cell normals as well as just point normals.
//
// ****************************************************************************
vtkDataSet *
......@@ -80,10 +84,14 @@ avtVertexNormalsFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
return in_ds;
}
vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
vtkVisItPolyDataNormals *normals = vtkVisItPolyDataNormals::New();
normals->SetInput(pd);
normals->SetFeatureAngle(45.);
normals->ConsistencyOff();
if (pointNormals)
normals->SetNormalTypeToPoint();
else
normals->SetNormalTypeToCell();
normals->SetSplitting(true);
normals->Update();
vtkPolyData *out_ds = normals->GetOutput();
......
......@@ -20,23 +20,28 @@
// Creation: December 31, 2001
//
// Modifications:
//
// Hank Childs, Tue Sep 10 15:17:21 PDT 2002
// Removed data members to conform with new memory management paradigm.
//
// Jeremy Meredith, Tue Aug 12 10:55:35 PDT 2003
// Added ability to have cell normals.
//
// ****************************************************************************
class PIPELINE_API avtVertexNormalsFilter : public avtStreamer
{
public:
avtVertexNormalsFilter() {;};
avtVertexNormalsFilter() { pointNormals=false;};
virtual ~avtVertexNormalsFilter() {;};
virtual const char *GetType(void) { return "avtVertexNormalsFilter"; };
virtual const char *GetDescription(void)
{ return "Calculating normals"; };
void SetPointNormals(bool pn) { pointNormals = pn; }
protected:
bool pointNormals;
virtual vtkDataSet *ExecuteData(vtkDataSet *, int, std::string);
};
......
......@@ -616,6 +616,10 @@ avtPlot::CombinedExecute(avtDataObject_p input, avtPipelineSpecification_p spec,
// Hank Childs, Fri Jul 25 21:21:08 PDT 2003
// Rename relevantPointsFilter to condenseDatasetFilter.
//
// Jeremy Meredith, Wed Aug 13 18:11:45 PDT 2003
// Made it use always use the normals filter, but only
// do cell normals if we don't want them averaged to the nodes.
//
// ****************************************************************************
avtDataObject_p
......@@ -664,13 +668,19 @@ avtPlot::ReduceGeometry(avtDataObject_p curDS)
//
// Only create vertex normals if we don't have zone-centered data.
// Otherwise, create cell normals.
//
if (rv->GetInfo().GetAttributes().GetCentering() != AVT_ZONECENT &&
!rv->GetInfo().GetValidity().NormalsAreInappropriate())
{
vertexNormalsFilter->SetInput(rv);
rv = vertexNormalsFilter->GetOutput();
vertexNormalsFilter->SetPointNormals(true);
}
else
{
vertexNormalsFilter->SetPointNormals(false);
}
vertexNormalsFilter->SetInput(rv);
rv = vertexNormalsFilter->GetOutput();
avtDataAttributes &outAtts = rv->GetInfo().GetAttributes();
if (outAtts.GetTopologicalDimension() != TargetTopologicalDimension())
......
......@@ -22,6 +22,7 @@
class avtDatasetToDatasetFilter;
class avtSmoothPolyDataFilter;
class avtVertexNormalsFilter;
class AttributeGroup;
class WindowAttributes;
......@@ -119,6 +120,10 @@ class WindowAttributes;
// Kathleen Bonnell, Tue Mar 25 11:18:43 PST 2003
// Renamed GetTransformedPoints to RequiresReExecuteForQuery.
//
// Jeremy Meredith, Wed Aug 13 16:33:21 PDT 2003
// Made the vertex normals filter be a pointer to the subclass so I could
// access methods not in avtDatasetToDatasetFilter.
//
// ****************************************************************************
class PLOTTER_API avtPlot
......@@ -174,7 +179,7 @@ class PLOTTER_API avtPlot
avtDatasetToDatasetFilter *ghostZoneAndFacelistFilter;
avtDatasetToDatasetFilter *compactTreeFilter;
avtDatasetToDatasetFilter *currentExtentFilter;
avtDatasetToDatasetFilter *vertexNormalsFilter;
avtVertexNormalsFilter *vertexNormalsFilter;
avtSmoothPolyDataFilter *smooth;
avtSILRestriction_p silr;
char *varname;
......
#include <MaterialEncoder.h>
#include <avtMaterial.h>
//
// Template function for memory reallocation.
//
template <class T>
T *remake(T *ptr, int oldsize, int size)
{