Skip to content
Snippets Groups Projects
Commit 899b2b2d authored by Hahn, Steven's avatar Hahn, Steven
Browse files

Refs #12719. Refs #12932. Update field data for AxesGrid.

parent de76c80f
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
#include "MantidGeometry/MDGeometry/MDTypes.h"
#include <string>
#include <vector>
#include <array>
class vtkDataSet;
class vtkUnstructuredGrid;
......@@ -83,6 +83,7 @@ namespace VATES
Kernel::V3D m_basisY; ///< The Y direction basis vector
Kernel::V3D m_basisZ; ///< The Z direction basis vector
Kernel::SpecialCoordinateSystem m_coordType; ///< The coordinate system for the workspace
std::array<double, 6> m_boundingBox;
};
......
......@@ -17,9 +17,15 @@
#include <boost/scoped_ptr.hpp>
#include <vtkPVChangeOfBasisHelper.h>
#include <vtkFieldData.h>
#include <vtkDataSet.h>
namespace {
Mantid::Kernel::Logger g_log("MDHWLoadingPresenter");
}
namespace Mantid
{
namespace VATES
......@@ -185,10 +191,12 @@ namespace Mantid
*/
void MDHWLoadingPresenter::setAxisLabels(vtkDataSet *visualDataSet)
{
vtkFieldData* fieldData = visualDataSet->GetFieldData();
setAxisLabel("AxisTitleForX", axisLabels[0], fieldData);
setAxisLabel("AxisTitleForY", axisLabels[1], fieldData);
setAxisLabel("AxisTitleForZ", axisLabels[2], fieldData);
if (!vtkPVChangeOfBasisHelper::AddBasisNames(
visualDataSet, axisLabels[0].c_str(), axisLabels[1].c_str(),
axisLabels[2].c_str())) {
g_log.warning("The basis names could not be added to the field data of "
"the data set.\n");
}
}
/**
......
......@@ -13,12 +13,14 @@
#include <vtkFloatArray.h>
#include <vtkDoubleArray.h>
#include <vtkMatrix3x3.h>
#include "vtkVector.h"
#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataObject.h>
#include <vtkMatrix4x4.h>
#include <vtkSmartPointer.h>
#include <vtkPVChangeOfBasisHelper.h>
#include <boost/algorithm/string/find.hpp>
#include <stdexcept>
......@@ -26,9 +28,11 @@
using namespace Mantid;
namespace {
void addChangeOfBasisMatrixToFieldData(vtkDataObject *dataObject,
const MantidVec &u, const MantidVec &v,
const MantidVec &w) {
Mantid::Kernel::Logger g_log("vtkDataSetToNonOrthogonalDataSet");
void addChangeOfBasisMatrixToFieldData(
vtkDataObject *dataObject, const MantidVec &u, const MantidVec &v,
const MantidVec &w, const std::array<double, 6> &boundingBox) {
if (!dataObject) {
throw std::invalid_argument("Change of basis needs a vtkDataObject");
......@@ -44,21 +48,20 @@ void addChangeOfBasisMatrixToFieldData(vtkDataObject *dataObject,
}
vtkSmartPointer<vtkMatrix4x4> cobMatrix =
vtkSmartPointer<vtkMatrix4x4>::New();
cobMatrix->Identity();
std::copy(u.begin(), u.end(), cobMatrix->Element[0]);
std::copy(v.begin(), v.end(), cobMatrix->Element[1]);
std::copy(w.begin(), w.end(), cobMatrix->Element[2]);
cobMatrix->Transpose();
vtkNew<vtkDoubleArray> cobArray;
cobArray->SetName("ChangeOfBasisMatrix");
cobArray->SetNumberOfComponents(16);
cobArray->SetNumberOfTuples(1);
std::copy(&cobMatrix->Element[0][0], (&cobMatrix->Element[0][0]) + 16,
cobArray->GetPointer(0));
dataObject->GetFieldData()->AddArray(cobArray.GetPointer());
vtkPVChangeOfBasisHelper::GetChangeOfBasisMatrix(
vtkVector3d(&u[0]), vtkVector3d(&v[0]), vtkVector3d(&w[0]));
if (!vtkPVChangeOfBasisHelper::AddChangeOfBasisMatrixToFieldData(dataObject,
cobMatrix)) {
g_log.warning("The Change-of-Basis-Matrix could not be added to the field "
"data of the data set.\n");
}
if (!vtkPVChangeOfBasisHelper::AddBoundingBoxInBasis(dataObject,
&boundingBox[0])) {
g_log.warning("The bounding box could not be added to the field data of "
"the data set.\n");
}
}
}
......@@ -127,6 +130,14 @@ void vtkDataSetToNonOrthogonalDataSet::execute() {
if (boost::algorithm::find_first(wsType, "MDHistoWorkspace")) {
API::IMDHistoWorkspace_const_sptr infoWs =
boost::dynamic_pointer_cast<const API::IMDHistoWorkspace>(ws);
m_boundingBox[0] = infoWs->getDimension(0)->getMinimum();
m_boundingBox[1] = infoWs->getDimension(0)->getMaximum();
m_boundingBox[2] = infoWs->getDimension(1)->getMinimum();
m_boundingBox[3] = infoWs->getDimension(1)->getMaximum();
m_boundingBox[4] = infoWs->getDimension(2)->getMinimum();
m_boundingBox[5] = infoWs->getDimension(2)->getMaximum();
m_numDims = infoWs->getNumDims();
m_coordType = infoWs->getSpecialCoordinateSystem();
if (Kernel::HKL != m_coordType) {
......@@ -331,7 +342,8 @@ void vtkDataSetToNonOrthogonalDataSet::stripMatrix(Kernel::DblMatrix &mat) {
void vtkDataSetToNonOrthogonalDataSet::updateMetaData(vtkUnstructuredGrid *ugrid)
{
// Create and add the change of basis matrix
addChangeOfBasisMatrixToFieldData(ugrid, m_basisX, m_basisY, m_basisZ);
addChangeOfBasisMatrixToFieldData(ugrid, m_basisX, m_basisY, m_basisZ,
m_boundingBox);
}
} // namespace VATES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment