Commit 6739e88d authored by Andrew Bauer's avatar Andrew Bauer

Converting const char* to std::string for consistency.

parent 7c29a0d4
......@@ -127,12 +127,15 @@ vtkDataObject* DataAdaptor::GetBlockMesh(int gid)
}
//-----------------------------------------------------------------------------
bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* arrayname)
bool DataAdaptor::AddArray(vtkDataObject* mesh, int association,
const std::string& arrayname)
{
#ifndef NDEBUG
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS ||
arrayname == NULL || strcmp(arrayname, "data") != 0)
arrayname != "data")
{
return false;
}
#endif
bool retVal = false;
DInternals& internals = (*this->Internals);
......@@ -146,10 +149,10 @@ bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* arr
vtkSmartPointer<vtkImageData>& blockMesh = internals.BlockMesh[cc];
if (vtkCellData* cd = (blockMesh? blockMesh->GetCellData(): NULL))
{
if (cd->GetArray(arrayname) == NULL)
if (cd->GetArray(arrayname.c_str()) == NULL)
{
vtkFloatArray* fa = vtkFloatArray::New();
fa->SetName(arrayname);
fa->SetName(arrayname.c_str());
fa->SetArray(internals.Data[cc], blockMesh->GetNumberOfCells(), 1);
cd->SetScalars(fa);
cd->SetActiveScalars("data");
......
......@@ -28,10 +28,10 @@ public:
void SetBlockData(int gid, float* data);
virtual vtkDataObject* GetMesh(bool structure_only=false);
virtual bool AddArray(vtkDataObject* mesh, int association, const char* arrayname);
virtual bool AddArray(vtkDataObject* mesh, int association, const std::string& arrayname);
virtual unsigned int GetNumberOfArrays(int) { return 1; }
virtual const char* GetArrayName(int, unsigned int index)
{ return index==0? "data" : NULL; }
virtual std::string GetArrayName(int association, unsigned int index)
{ return index==0? "data" : std::string(); }
virtual void ReleaseData();
protected:
......
......@@ -86,9 +86,9 @@ vtkDataObject* DataAdaptor::GetMesh(bool vtkNotUsed(structure_only))
}
//-----------------------------------------------------------------------------
bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* name)
bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const std::string& name)
{
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS || name == NULL)
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS || name.empty())
{
return false;
}
......@@ -107,7 +107,7 @@ bool DataAdaptor::AddArray(vtkDataObject* mesh, int association, const char* nam
{
vtkSmartPointer<vtkDoubleArray>& vtkarray = this->Arrays[iterV->first];
vtkarray = vtkSmartPointer<vtkDoubleArray>::New();
vtkarray->SetName(name);
vtkarray->SetName(name.c_str());
const vtkIdType size = (this->CellExtent[1] - this->CellExtent[0] + 1) *
(this->CellExtent[3] - this->CellExtent[2] + 1) *
(this->CellExtent[5] - this->CellExtent[4] + 1);
......@@ -127,11 +127,11 @@ unsigned int DataAdaptor::GetNumberOfArrays(int association)
}
//-----------------------------------------------------------------------------
const char* DataAdaptor::GetArrayName(int association, unsigned int index)
std::string DataAdaptor::GetArrayName(int association, unsigned int index)
{
if (association != vtkDataObject::FIELD_ASSOCIATION_CELLS)
{
return NULL;
return "";
}
unsigned int count = 0;
for (VariablesType::iterator iter=this->Variables.begin(), max=this->Variables.end();
......@@ -139,10 +139,10 @@ const char* DataAdaptor::GetArrayName(int association, unsigned int index)
{
if (count==index)
{
return iter->first.c_str();
return iter->first;
}
}
return NULL;
return "";
}
//-----------------------------------------------------------------------------
......
......@@ -36,9 +36,9 @@ public:
void ClearArrays();
virtual vtkDataObject* GetMesh(bool structure_only=false);
virtual bool AddArray(vtkDataObject* mesh, int association, const char* arrayname);
virtual bool AddArray(vtkDataObject* mesh, int association, const std::string& arrayname);
virtual unsigned int GetNumberOfArrays(int association);
virtual const char* GetArrayName(int association, unsigned int index);
virtual std::string GetArrayName(int association, unsigned int index);
virtual void ReleaseData();
protected:
......
......@@ -190,9 +190,9 @@ Autocorrelation::~Autocorrelation()
}
//-----------------------------------------------------------------------------
void Autocorrelation::Initialize(MPI_Comm world,
size_t window,
int association, const char* arrayname, size_t kmax)
void Autocorrelation::Initialize(
MPI_Comm world, size_t window, int association,
std::string& arrayname, size_t kmax)
{
timer::MarkEvent mark("autocorrelation::initialize");
AInternals& internals = (*this->Internals);
......@@ -214,7 +214,7 @@ bool Autocorrelation::Execute(DataAdaptor* data)
const char* arrayname = internals.ArrayName.c_str();
vtkDataObject* mesh = data->GetMesh(/*structure-only*/ true);
if (!data->AddArray(mesh, association, arrayname))
if (!data->AddArray(mesh, association, internals.ArrayName))
{
return false;
}
......
......@@ -3,6 +3,7 @@
#include "AnalysisAdaptor.h"
#include <mpi.h>
#include <string>
namespace sensei
{
......@@ -29,8 +30,9 @@ public:
/// @param arrayname together with \c association, identifies the array to
/// compute autocorrelation for.
/// @param k_max number of strongest autocorrelations to report
void Initialize(MPI_Comm world,
size_t window, int association, const char* arrayname, size_t k_max);
void Initialize(
MPI_Comm world, size_t window, int association,
std::string& arrayname, size_t k_max);
virtual bool Execute(DataAdaptor* data);
protected:
......
......@@ -194,10 +194,11 @@ public:
return -1;
vtkNew<Autocorrelation> adaptor;
std::string arrayname = node.attribute("array").value();
adaptor->Initialize(comm,
node.attribute("window")? node.attribute("window").as_int() : 10,
this->GetAssociation(node.attribute("association")),
node.attribute("array").value(),
arrayname,
node.attribute("k-max")? node.attribute("k-max").as_int() : 3);
this->Analyses.push_back(adaptor.GetPointer());
......
......@@ -4,6 +4,8 @@
#include "vtkObjectBase.h"
#include "vtkSetGet.h" // needed for vtkTypeMacro.
#include <string>
class vtkAbstractArray;
class vtkDataObject;
class vtkInformation;
......@@ -47,7 +49,7 @@ public:
/// vtkDataObject::FieldAssociations or vtkDataObject::AttributeTypes.
/// @return true if array was added (or already added), false is request array
/// is not available.
virtual bool AddArray(vtkDataObject* mesh, int association, const char* arrayname) = 0;
virtual bool AddArray(vtkDataObject* mesh, int association, const std::string& arrayname) = 0;
/// @brief Return the number of field arrays available.
///
......@@ -69,7 +71,7 @@ public:
/// @param index index for the array. Must be less than value returned
/// GetNumberOfArrays().
/// @return name of the array.
virtual const char* GetArrayName(int association, unsigned int index) = 0;
virtual std::string GetArrayName(int association, unsigned int index) = 0;
/// @brief Release data allocated for the current timestep.
///
......
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