Commit f7b8187f authored by allens's avatar allens

add spatial bounds to the meta data

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@14349 18c085ea-50e0-402c-830e-de6fd14e8384
parent 1bab95d9
......@@ -62,6 +62,10 @@ void avtMeshMetaData::Init()
meshCoordType = AVT_XY;
cellOrigin = 0;
spatialDimension = 3;
hasSpatialBounds = false;
spatialBounds[0] = 0;
spatialBounds[1] = 0;
spatialBounds[2] = 0;
topologicalDimension = 3;
xLabel = "X-Axis";
yLabel = "Y-Axis";
......@@ -151,6 +155,11 @@ void avtMeshMetaData::Copy(const avtMeshMetaData &obj)
meshCoordType = obj.meshCoordType;
cellOrigin = obj.cellOrigin;
spatialDimension = obj.spatialDimension;
hasSpatialBounds = obj.hasSpatialBounds;
spatialBounds[0] = obj.spatialBounds[0];
spatialBounds[1] = obj.spatialBounds[1];
spatialBounds[2] = obj.spatialBounds[2];
topologicalDimension = obj.topologicalDimension;
xUnits = obj.xUnits;
yUnits = obj.yUnits;
......@@ -358,6 +367,11 @@ avtMeshMetaData::operator = (const avtMeshMetaData &obj)
bool
avtMeshMetaData::operator == (const avtMeshMetaData &obj) const
{
// Compare the spatialBounds arrays.
bool spatialBounds_equal = true;
for(int i = 0; i < 3 && spatialBounds_equal; ++i)
spatialBounds_equal = (spatialBounds[i] == obj.spatialBounds[i]);
// Compare the minSpatialExtents arrays.
bool minSpatialExtents_equal = true;
for(int i = 0; i < 3 && minSpatialExtents_equal; ++i)
......@@ -391,6 +405,8 @@ avtMeshMetaData::operator == (const avtMeshMetaData &obj) const
(meshCoordType == obj.meshCoordType) &&
(cellOrigin == obj.cellOrigin) &&
(spatialDimension == obj.spatialDimension) &&
(hasSpatialBounds == obj.hasSpatialBounds) &&
spatialBounds_equal &&
(topologicalDimension == obj.topologicalDimension) &&
(xUnits == obj.xUnits) &&
(yUnits == obj.yUnits) &&
......@@ -579,6 +595,8 @@ avtMeshMetaData::SelectAll()
Select(ID_meshCoordType, (void *)&meshCoordType);
Select(ID_cellOrigin, (void *)&cellOrigin);
Select(ID_spatialDimension, (void *)&spatialDimension);
Select(ID_hasSpatialBounds, (void *)&hasSpatialBounds);
Select(ID_spatialBounds, (void *)spatialBounds, 3);
Select(ID_topologicalDimension, (void *)&topologicalDimension);
Select(ID_xUnits, (void *)&xUnits);
Select(ID_yUnits, (void *)&yUnits);
......@@ -635,6 +653,7 @@ avtMeshMetaData::SelectAll()
// Method: avtMeshMetaData constructor
//
// Arguments:
// bounds Strunctured mesh bounds as < max_i, max_j, max_k>.
// extents Mesh extents as <min_x, max_x, min_y, max_y, min_z, max_z>.
// s The name of the mesh.
// nb The number of blocks.
......@@ -707,7 +726,8 @@ avtMeshMetaData::SelectAll()
//
// ****************************************************************************
avtMeshMetaData::avtMeshMetaData(const double *extents, std::string s, int nb,
avtMeshMetaData::avtMeshMetaData(const int *bounds, const double *extents,
std::string s, int nb,
int bo, int co, int go, int sd, int td,
avtMeshType mt)
: AttributeSubject(avtMeshMetaData::TypeMapFormatString)
......@@ -728,6 +748,7 @@ avtMeshMetaData::avtMeshMetaData(const double *extents, std::string s, int nb,
numGroups = 0;
containsExteriorBoundaryGhosts = false;
SetExtents(extents);
SetBounds(bounds);
}
// ****************************************************************************
......@@ -827,6 +848,7 @@ avtMeshMetaData::avtMeshMetaData(std::string s, int nb, int bo, int co, int go,
meshType = mt;
containsExteriorBoundaryGhosts = false;
SetExtents(0);
SetBounds(0);
}
// ****************************************************************************
......@@ -883,6 +905,47 @@ avtMeshMetaData::UnsetExtents()
hasSpatialExtents = false;
}
// ****************************************************************************
// Method: avtMeshMetaData::SetBounds
//
// Purpose:
// Sets the bounds of the mesh.
//
// Arguments:
// bounds Mesh bounds as < i_max, j_max, k_max>.
//
// Programmer: Hank Childs
// Creation: August 30, 2000
//
// ****************************************************************************
void
avtMeshMetaData::SetBounds(const int *bounds)
{
if (bounds == NULL)
{
hasSpatialBounds = false;
for (int i = 0 ; i < std::min(spatialDimension, 3) ; i++)
{
spatialBounds[i] = 0.0;
}
}
else
{
hasSpatialBounds = true;
for (int i = 0 ; i < std::min(spatialDimension, 3) ; i++)
{
spatialBounds[i] = bounds[i];
}
}
}
void
avtMeshMetaData::UnsetBounds()
{
hasSpatialBounds = false;
}
// ****************************************************************************
// Method: avtMeshMetaData::Print
//
......@@ -1081,6 +1144,26 @@ avtMeshMetaData::Print(ostream &out, int indent) const
Indent(out, indent);
out << "Spatial Dimension = " << spatialDimension << endl;
if (hasSpatialBounds)
{
Indent(out, indent);
out << "Bounds are: (";
for (int j = 0 ; j < std::min(spatialDimension, 3) ; j++)
{
out << spatialBounds[j];
if(j < spatialDimension-1)
out << ", ";
}
out << ")" << endl;
}
else
{
Indent(out, indent);
out << "The spatial bounds are not set." << endl;
}
Indent(out, indent);
out << "Topological Dimension = " << topologicalDimension << endl;
if (hasSpatialExtents)
......
Function: avtMeshMetaData2
Declaration: avtMeshMetaData(const double *, std::string, int, int, int, int, int, int, avtMeshType);
Declaration: avtMeshMetaData(const int *, const double *, std::string, int, int, int, int, int, int, avtMeshType);
Definition:
// ****************************************************************************
// Method: avtMeshMetaData constructor
//
// Arguments:
// bounds Strunctured mesh bounds as < max_i, max_j, max_k>.
// extents Mesh extents as <min_x, max_x, min_y, max_y, min_z, max_z>.
// s The name of the mesh.
// nb The number of blocks.
......@@ -77,7 +78,8 @@ Definition:
//
// ****************************************************************************
avtMeshMetaData::avtMeshMetaData(const double *extents, std::string s, int nb,
avtMeshMetaData::avtMeshMetaData(const int *bounds, const double *extents,
std::string s, int nb,
int bo, int co, int go, int sd, int td,
avtMeshType mt)
: AttributeSubject(avtMeshMetaData::TypeMapFormatString)
......@@ -98,6 +100,7 @@ avtMeshMetaData::avtMeshMetaData(const double *extents, std::string s, int nb,
numGroups = 0;
containsExteriorBoundaryGhosts = false;
SetExtents(extents);
SetBounds(bounds);
}
Function: avtMeshMetaData3
......@@ -200,6 +203,7 @@ avtMeshMetaData::avtMeshMetaData(std::string s, int nb, int bo, int co, int go,
meshType = mt;
containsExteriorBoundaryGhosts = false;
SetExtents(0);
SetBounds(0);
}
Function: SetExtents
......@@ -262,6 +266,53 @@ avtMeshMetaData::UnsetExtents()
hasSpatialExtents = false;
}
Function: SetBounds
Declaration: void SetBounds(const int *);
Definition:
// ****************************************************************************
// Method: avtMeshMetaData::SetBounds
//
// Purpose:
// Sets the bounds of the mesh.
//
// Arguments:
// bounds Mesh bounds as < i_max, j_max, k_max>.
//
// Programmer: Hank Childs
// Creation: August 30, 2000
//
// ****************************************************************************
void
avtMeshMetaData::SetBounds(const int *bounds)
{
if (bounds == NULL)
{
hasSpatialBounds = false;
for (int i = 0 ; i < std::min(spatialDimension, 3) ; i++)
{
spatialBounds[i] = 0.0;
}
}
else
{
hasSpatialBounds = true;
for (int i = 0 ; i < std::min(spatialDimension, 3) ; i++)
{
spatialBounds[i] = bounds[i];
}
}
}
Function: UnsetBounds
Declaration: void UnsetBounds();
Definition:
void
avtMeshMetaData::UnsetBounds()
{
hasSpatialBounds = false;
}
Function: Print
Declaration: void Print(ostream &, int = 0) const;
Definition:
......@@ -463,6 +514,26 @@ avtMeshMetaData::Print(ostream &out, int indent) const
Indent(out, indent);
out << "Spatial Dimension = " << spatialDimension << endl;
if (hasSpatialBounds)
{
Indent(out, indent);
out << "Bounds are: (";
for (int j = 0 ; j < std::min(spatialDimension, 3) ; j++)
{
out << spatialBounds[j];
if(j < spatialDimension-1)
out << ", ";
}
out << ")" << endl;
}
else
{
Indent(out, indent);
out << "The spatial bounds are not set." << endl;
}
Indent(out, indent);
out << "Topological Dimension = " << topologicalDimension << endl;
if (hasSpatialExtents)
......
......@@ -90,10 +90,12 @@ public:
virtual void SelectAll();
// User-defined methods
avtMeshMetaData(const double *, std::string, int, int, int, int, int, int, avtMeshType);
avtMeshMetaData(const int *, const double *, std::string, int, int, int, int, int, int, avtMeshType);
avtMeshMetaData(std::string, int, int, int, int, int, int, avtMeshType);
void SetExtents(const double *);
void UnsetExtents();
void SetBounds(const int *);
void UnsetBounds();
void Print(ostream &, int = 0) const;
void SetAMRInfo(const std::string &levelName, const std::string &patchName, int origin,const std::vector<int> &patchesPerLevel);
......@@ -106,6 +108,8 @@ public:
ID_meshCoordType,
ID_cellOrigin,
ID_spatialDimension,
ID_hasSpatialBounds,
ID_spatialBounds,
ID_topologicalDimension,
ID_xUnits,
ID_yUnits,
......@@ -155,6 +159,8 @@ public:
avtMeshCoordType meshCoordType;
int cellOrigin;
int spatialDimension;
bool hasSpatialBounds;
int spatialBounds[3];
int topologicalDimension;
std::string xUnits;
std::string yUnits;
......@@ -199,6 +205,6 @@ private:
static const char *TypeMapFormatString;
static const private_tmfs_t TmfsStruct;
};
#define AVTMESHMETADATA_TMFS "ssbiiiiissssssbDDiisss*aiissi*i*bibbbbibFFbDibbi"
#define AVTMESHMETADATA_TMFS "ssbiiiibIissssssbDDiisss*aiissi*i*bibbbbibFFbDibbi"
#endif
......@@ -20,6 +20,14 @@
<Field name="spatialDimension" label="Spatial dimension" type="int" access="public">
3
</Field>
<Field name="hasSpatialBounds" label="Has spatial bounds" type="bool" access="public">
false
</Field>
<Field name="spatialBounds" label="Spatial bounds" type="intArray" length="3" access="public">
0.000000
0.000000
0.000000
</Field>
<Field name="topologicalDimension" label="Topological dimension" type="int" access="public">
3
</Field>
......@@ -164,6 +172,10 @@
</Function>
<Function name="UnsetExtents" user="true" member="true">
</Function>
<Function name="SetBounds" user="true" member="true">
</Function>
<Function name="UnsetBounds" user="true" member="true">
</Function>
<Function name="Print" user="true" member="true">
</Function>
<Function name="SetAMRInfo" user="true" member="true">
......
......@@ -310,6 +310,7 @@ avtFileFormat::SetCache(avtVariableCache *c)
// origin The origin of the block numbers. (optional, = 0)
// spatial The spatial dimension of the mesh. (optional, = 3)
// topo The topological dimension of the mesh. (optional, = 3)
// bounds The bounds of the mesh. (optional)
//
// Programmer: Hank Childs
// Creation: February 23, 2001
......@@ -331,7 +332,8 @@ avtFileFormat::SetCache(avtVariableCache *c)
void
avtFileFormat::AddMeshToMetaData(avtDatabaseMetaData *md, string name,
avtMeshType type, const double *extents,
int blocks, int origin, int spatial, int topo)
int blocks, int origin, int spatial, int topo,
const int* bounds)
{
if (type == AVT_POINT_MESH)
topo = 0;
......@@ -345,6 +347,16 @@ avtFileFormat::AddMeshToMetaData(avtDatabaseMetaData *md, string name,
mesh->topologicalDimension = topo;
mesh->blockTitle = "blocks";
mesh->blockPieceName = "block";
if (bounds != NULL)
{
mesh->SetBounds(bounds);
mesh->hasSpatialBounds = true;
}
else
{
mesh->hasSpatialBounds = false;
}
if (extents != NULL)
{
mesh->SetExtents(extents);
......
......@@ -267,7 +267,7 @@ class DATABASE_API avtFileFormat
void AddMeshToMetaData(avtDatabaseMetaData *, std::string,
avtMeshType, const double * = NULL, int = 1,
int = 0, int = 3, int = 3);
int = 0, int = 3, int = 3, const int * = NULL);
void AddScalarVarToMetaData(avtDatabaseMetaData *, std::string,
std::string, avtCentering,
const double * = NULL,
......
......@@ -388,10 +388,15 @@ avtH5NimrodFileFormat::PopulateDatabaseMetaData (avtDatabaseMetaData * md,
int spatial_dimension = ndims;
int topological_dimension = ndims;
double *extents = NULL;
int bounds[3];
bounds[0] = grid_dims[0];
bounds[1] = grid_dims[1];
bounds[2] = grid_dims[2];
AddMeshToMetaData (md, "Mesh", AVT_CURVILINEAR_MESH, extents, nblocks,
block_origin, spatial_dimension, topological_dimension);
block_origin, spatial_dimension, topological_dimension,
bounds);
for (int idx = 0; idx < nscalarvars; idx++)
{
......@@ -399,7 +404,7 @@ avtH5NimrodFileFormat::PopulateDatabaseMetaData (avtDatabaseMetaData * md,
string varname = scalarvarnames[idx];
// AVT_NODECENT, AVT_ZONECENT, AVT_UNKNOWN_CENT
avtCentering cent = AVT_NODECENT;
AddScalarVarToMetaData (md, varname, mesh_for_this_var, cent);
AddScalarVarToMetaData (md, varname, mesh_for_this_var, cent, extents);
}
for (int idx = 0; idx < nvectorvars; idx++)
{
......@@ -408,7 +413,7 @@ avtH5NimrodFileFormat::PopulateDatabaseMetaData (avtDatabaseMetaData * md,
// AVT_NODECENT, AVT_ZONECENT, AVT_UNKNOWN_CENT
avtCentering cent = AVT_NODECENT;
AddVectorVarToMetaData (md, varname, mesh_for_this_var, cent,
vectorvardims[idx]);
vectorvardims[idx], extents);
}
md->SetCyclesAreAccurate(true);
......
......@@ -2044,7 +2044,8 @@ avtSiloFileFormat::ReadQuadmeshes(DBfile *dbfile,
extents_to_use = extents;
}
avtMeshMetaData *mmd = new avtMeshMetaData(extents_to_use,
avtMeshMetaData *mmd = new avtMeshMetaData(NULL,
extents_to_use,
name_w_dir, 1, 0,
qm->origin, 0,
qm->ndims, qm->ndims,
......@@ -2156,7 +2157,9 @@ avtSiloFileFormat::ReadUcdmeshes(DBfile *dbfile,
#endif
#endif
avtMeshMetaData *mmd = new avtMeshMetaData(extents_to_use, name_w_dir,
avtMeshMetaData *mmd = new avtMeshMetaData(NULL,
extents_to_use,
name_w_dir,
1, 0, um->origin, 0, um->ndims, tdims,
AVT_UNSTRUCTURED_MESH);
if (um->units[0] != NULL)
......@@ -2397,7 +2400,9 @@ avtSiloFileFormat::ReadCSGmeshes(DBfile *dbfile,
extents_to_use = extents;
}
avtMeshMetaData *mmd = new avtMeshMetaData(extents_to_use, name_w_dir,
avtMeshMetaData *mmd = new avtMeshMetaData(NULL,
extents_to_use,
name_w_dir,
csgm->zones->nzones, 0, csgm->origin, 0,
csgm->ndims, csgm->ndims, AVT_CSG_MESH);
if (csgm->units[0] != NULL)
......@@ -5496,7 +5501,8 @@ avtSiloFileFormat::AddCSGMultimesh(const char *const dirname,
{
char *name_w_dir = GenerateName(dirname, multimesh_name, topDir.c_str());
avtMeshMetaData *mmd = new avtMeshMetaData(extents_to_use, name_w_dir,
avtMeshMetaData *mmd = new avtMeshMetaData(NULL,
extents_to_use, name_w_dir,
nregions, 0, 0, 0, ndims, ndims, AVT_CSG_MESH);
mmd->blockTitle = "regions";
......
This diff is collapsed.
......@@ -153,6 +153,27 @@ PyavtMeshMetaData_ToString(const avtMeshMetaData *atts, const char *prefix)
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%sspatialDimension = %d\n", prefix, atts->spatialDimension);
str += tmpStr;
if(atts->hasSpatialBounds)
SNPRINTF(tmpStr, 1000, "%shasSpatialBounds = 1\n", prefix);
else
SNPRINTF(tmpStr, 1000, "%shasSpatialBounds = 0\n", prefix);
str += tmpStr;
{ const int *spatialBounds = atts->spatialBounds;
SNPRINTF(tmpStr, 1000, "%sspatialBounds = (", prefix);
str += tmpStr;
for(int i = 0; i < 3; ++i)
{
SNPRINTF(tmpStr, 1000, "%d", spatialBounds[i]);
str += tmpStr;
if(i < 2)
{
SNPRINTF(tmpStr, 1000, ", ");
str += tmpStr;
}
}
SNPRINTF(tmpStr, 1000, ")\n");
str += tmpStr;
}
SNPRINTF(tmpStr, 1000, "%stopologicalDimension = %d\n", prefix, atts->topologicalDimension);
str += tmpStr;
SNPRINTF(tmpStr, 1000, "%sxUnits = \"%s\"\n", prefix, atts->xUnits.c_str());
......@@ -607,6 +628,84 @@ avtMeshMetaData_GetSpatialDimension(PyObject *self, PyObject *args)
return retval;
}
/*static*/ PyObject *
avtMeshMetaData_SetHasSpatialBounds(PyObject *self, PyObject *args)
{
avtMeshMetaDataObject *obj = (avtMeshMetaDataObject *)self;
int ival;
if(!PyArg_ParseTuple(args, "i", &ival))
return NULL;
// Set the hasSpatialBounds in the object.
obj->data->hasSpatialBounds = (ival != 0);
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
avtMeshMetaData_GetHasSpatialBounds(PyObject *self, PyObject *args)
{
avtMeshMetaDataObject *obj = (avtMeshMetaDataObject *)self;
PyObject *retval = PyInt_FromLong(obj->data->hasSpatialBounds?1L:0L);
return retval;
}
/*static*/ PyObject *
avtMeshMetaData_SetSpatialBounds(PyObject *self, PyObject *args)
{
avtMeshMetaDataObject *obj = (avtMeshMetaDataObject *)self;
int *ivals = obj->data->spatialBounds;
if(!PyArg_ParseTuple(args, "iii", &ivals[0], &ivals[1], &ivals[2]))
{
PyObject *tuple;
if(!PyArg_ParseTuple(args, "O", &tuple))
return NULL;
if(PyTuple_Check(tuple))
{
if(PyTuple_Size(tuple) != 3)
return NULL;
PyErr_Clear();
for(int i = 0; i < PyTuple_Size(tuple); ++i)
{
PyObject *item = PyTuple_GET_ITEM(tuple, i);
if(PyFloat_Check(item))
ivals[i] = int(PyFloat_AS_DOUBLE(item));
else if(PyInt_Check(item))
ivals[i] = int(PyInt_AS_LONG(item));
else if(PyLong_Check(item))
ivals[i] = int(PyLong_AsDouble(item));
else
ivals[i] = 0;
}
}
else
return NULL;
}
// Mark the spatialBounds in the object as modified.
obj->data->SelectAll();
Py_INCREF(Py_None);
return Py_None;
}
/*static*/ PyObject *
avtMeshMetaData_GetSpatialBounds(PyObject *self, PyObject *args)
{
avtMeshMetaDataObject *obj = (avtMeshMetaDataObject *)self;
// Allocate a tuple the with enough entries to hold the spatialBounds.
PyObject *retval = PyTuple_New(3);
const int *spatialBounds = obj->data->spatialBounds;
for(int i = 0; i < 3; ++i)
PyTuple_SET_ITEM(retval, i, PyInt_FromLong(long(spatialBounds[i])));
return retval;
}
/*static*/ PyObject *
avtMeshMetaData_SetTopologicalDimension(PyObject *self, PyObject *args)
{
......@@ -1800,6 +1899,10 @@ PyMethodDef PyavtMeshMetaData_methods[AVTMESHMETADATA_NMETH] = {
{"GetCellOrigin", avtMeshMetaData_GetCellOrigin, METH_VARARGS},
{"SetSpatialDimension", avtMeshMetaData_SetSpatialDimension, METH_VARARGS},
{"GetSpatialDimension", avtMeshMetaData_GetSpatialDimension, METH_VARARGS},
{"SetHasSpatialBounds", avtMeshMetaData_SetHasSpatialBounds, METH_VARARGS},
{"GetHasSpatialBounds", avtMeshMetaData_GetHasSpatialBounds, METH_VARARGS},
{"SetSpatialBounds", avtMeshMetaData_SetSpatialBounds, METH_VARARGS},
{"GetSpatialBounds", avtMeshMetaData_GetSpatialBounds, METH_VARARGS},
{"SetTopologicalDimension", avtMeshMetaData_SetTopologicalDimension, METH_VARARGS},
{"GetTopologicalDimension", avtMeshMetaData_GetTopologicalDimension, METH_VARARGS},
{"SetXUnits", avtMeshMetaData_SetXUnits, METH_VARARGS},
......@@ -1942,6 +2045,10 @@ PyavtMeshMetaData_getattr(PyObject *self, char *name)
return avtMeshMetaData_GetCellOrigin(self, NULL);
if(strcmp(name, "spatialDimension") == 0)
return avtMeshMetaData_GetSpatialDimension(self, NULL);
if(strcmp(name, "hasSpatialBounds") == 0)
return avtMeshMetaData_GetHasSpatialBounds(self, NULL);
if(strcmp(name, "spatialBounds") == 0)
return avtMeshMetaData_GetSpatialBounds(self, NULL);
if(strcmp(name, "topologicalDimension") == 0)
return avtMeshMetaData_GetTopologicalDimension(self, NULL);
if(strcmp(name, "xUnits") == 0)
......@@ -2070,6 +2177,10 @@ PyavtMeshMetaData_setattr(PyObject *self, char *name, PyObject *args)
obj = avtMeshMetaData_SetCellOrigin(self, tuple);
else if(strcmp(name, "spatialDimension") == 0)
obj = avtMeshMetaData_SetSpatialDimension(self, tuple);
else if(strcmp(name, "hasSpatialBounds") == 0)
obj = avtMeshMetaData_SetHasSpatialBounds(self, tuple);
else if(strcmp(name, "spatialBounds") == 0)
obj = avtMeshMetaData_SetSpatialBounds(self, tuple);
else if(strcmp(name, "topologicalDimension") == 0)
obj = avtMeshMetaData_SetTopologicalDimension(self, tuple);
else if(strcmp(name, "xUnits") == 0)
......
......@@ -45,7 +45,7 @@
//
// Functions exposed to the VisIt module.
//
#define AVTMESHMETADATA_NMETH 92
#define AVTMESHMETADATA_NMETH 96
void VISITPY_API PyavtMeshMetaData_StartUp(avtMeshMetaData *subj, void *data);
void VISITPY_API PyavtMeshMetaData_CloseDown();
VISITPY_API PyMethodDef * PyavtMeshMetaData_GetMethodTable(int *nMethods);
......
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