Commit 43be0f19 authored by David Thompson's avatar David Thompson

Merge branch 'catalyst-slice-multimesh' into 'master'

Accept a mesh name in Catalyst slices.

See merge request !95
parents e3be0f3f 337c2652
#include "CatalystSlice.h"
#include "CatalystUtilities.h"
#include <Timer.h>
#include <Error.h>
#include <vtkCPDataDescription.h>
#include <vtkCPInputDataDescription.h>
......@@ -41,6 +42,7 @@ public:
std::string ColorArrayName;
bool AutoCenter;
bool UseLogScale;
std::string Mesh;
double ColorRange[2];
bool AutoColorRange;
......@@ -219,6 +221,13 @@ CatalystSlice::~CatalystSlice()
delete this->Internals;
}
//----------------------------------------------------------------------------
void CatalystSlice::SetInputMesh(const std::string& meshName)
{
vtkInternals& internals = (*this->Internals);
internals.Mesh = meshName;
}
//----------------------------------------------------------------------------
void CatalystSlice::SetSliceOrigin(double x, double y, double z)
{
......@@ -264,9 +273,25 @@ void CatalystSlice::SetImageParameters(const std::string& filename, int width, i
//----------------------------------------------------------------------------
int CatalystSlice::RequestDataDescription(vtkCPDataDescription* dataDesc)
{
dataDesc->GetInputDescription(0)->GenerateMeshOn();
dataDesc->GetInputDescription(0)->AllFieldsOn();
return 1;
vtkInternals& internals = (*this->Internals);
auto dd = internals.Mesh.empty() ?
dataDesc->GetInputDescription(0) :
dataDesc->GetInputDescriptionByName(internals.Mesh.c_str());
if (dd)
{
dd->GenerateMeshOn();
dd->AllFieldsOn();
return 1;
}
if (internals.Mesh.empty())
{
SENSEI_ERROR("Unable to obtain default dataset");
}
else
{
SENSEI_ERROR("Unable to obtain dataset \"" << internals.Mesh.c_str() << "\"");
}
return 0;
}
//----------------------------------------------------------------------------
......@@ -274,9 +299,16 @@ int CatalystSlice::CoProcess(vtkCPDataDescription* dataDesc)
{
timer::MarkEvent mark("catalyst::slice");
vtkInternals& internals = (*this->Internals);
internals.UpdatePipeline(dataDesc->GetInputDescription(0)->GetGrid(),
dataDesc->GetTimeStep(), dataDesc->GetTime());
return 1;
auto dd = internals.Mesh.empty() ?
dataDesc->GetInputDescription(0) :
dataDesc->GetInputDescriptionByName(internals.Mesh.c_str());
if (dd)
{
internals.UpdatePipeline(dd->GetGrid(),
dataDesc->GetTimeStep(), dataDesc->GetTime());
return 1;
}
return 0;
}
//----------------------------------------------------------------------------
......
......@@ -13,6 +13,9 @@ public:
vtkTypeMacro(CatalystSlice, vtkCPPipeline);
void PrintSelf(ostream& os, vtkIndent indent) override;
/// @brief Set the mesh on which the slice should operate.
void SetInputMesh(const std::string& meshName);
/// @brief Set slice plane origin.
void SetSliceOrigin(double x, double y, double z);
......
......@@ -333,6 +333,10 @@ int ConfigurableAnalysis::InternalsType::AddCatalyst(pugi::xml_node node)
vtkNew<CatalystSlice> slice;
double tmp[3];
if (node.attribute("mesh"))
{
slice->SetInputMesh(node.attribute("mesh").value());
}
if (node.attribute("slice-normal") &&
(std::sscanf(node.attribute("slice-normal").value(),
"%lg,%lg,%lg", &tmp[0], &tmp[1], &tmp[2]) == 3))
......
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