Skip to content

Commit

Permalink
refs #6315 fix problems with transforming rebinning filter.
Browse files Browse the repository at this point in the history
Was not working with 4 Dims.
  • Loading branch information
OwenArnold committed Jan 7, 2013
1 parent 4fc2438 commit 572366b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@
number_of_elements="1"
default_values="1">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<IntVectorProperty
name="In Original Coods"
command="SetInOriginalCoords"
number_of_elements="1"
default_values="0">
<BooleanDomain name="bool"/>
</IntVectorProperty>
<DoubleVectorProperty
name="InputMinThreshold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,6 @@ void vtkRebinningTransformOperator::SetThresholdRangeStrategyIndex(std::string s
}
}

void vtkRebinningTransformOperator::SetInOriginalCoords(bool inOriginalCoords)
{
if(inOriginalCoords != m_bTransformVis)
{
m_bTransformVis = inOriginalCoords;
this->Modified();
}
}

const char* vtkRebinningTransformOperator::GetInputGeometryXML()
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class VTK_EXPORT vtkRebinningTransformOperator : public vtkUnstructuredGridAlgor
void SetOrigin(double originX, double originY, double originZ);
void SetForceOrthogonal(bool value);
void SetOutputHistogramWS(bool value);
void SetInOriginalCoords(bool inOriginalCoords);

const char* GetInputGeometryXML();
void SetThresholdRangeStrategyIndex(std::string selectedStrategyIndex);
Expand Down Expand Up @@ -170,8 +169,6 @@ class VTK_EXPORT vtkRebinningTransformOperator : public vtkUnstructuredGridAlgor
double m_lengthB3;
/// Do we force the basis vectors to be orthogonal?
bool m_ForceOrthogonal;
/// Flag indicating that visual results should be transformed into the original coordinate frame.
bool m_bTransformVis;
/// Flag indicating that a histogram workspace should be provided.
bool m_bOutputHistogramWS;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace Mantid

void persistReductionKnowledge(vtkDataSet* out_ds, const RebinningKnowledgeSerializer& xmlGenerator, const char* id);
std::string extractFormattedPropertyFromDimension(Mantid::Geometry::IMDDimension_sptr dimension) const;
std::string extractFormattedPropertyFromDimension(const Mantid::Kernel::VMD& basis, double length, Mantid::Geometry::IMDDimension_sptr dimension) const;
std::string extractFormattedPropertyFromDimension(const Mantid::Kernel::V3D& basis, const size_t totalNDims, double length, Mantid::Geometry::IMDDimension_sptr dimension) const;
void addFunctionKnowledge();

///Parser used to process input vtk to extract metadata.
Expand Down
44 changes: 36 additions & 8 deletions Code/Mantid/Vates/VatesAPI/src/MDEWRebinningPresenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <vtkPlane.h>

using namespace Mantid::API;
using namespace Mantid::Kernel;

namespace Mantid
{
Expand Down Expand Up @@ -244,12 +245,26 @@ namespace Mantid
@param dimension : dimension to extract property value for.
@return true available, false otherwise.
*/
std::string MDEWRebinningPresenter::extractFormattedPropertyFromDimension(const Mantid::Kernel::VMD& basis, double length, Mantid::Geometry::IMDDimension_sptr dimension) const
std::string MDEWRebinningPresenter::extractFormattedPropertyFromDimension(const Mantid::Kernel::V3D& basis, const size_t totalNDims, double length, Mantid::Geometry::IMDDimension_sptr dimension) const
{
UNUSED_ARG(length);

MantidVec localBasis(3);
localBasis[0] = basis.X();
localBasis[1] = basis.Y();
localBasis[2] = basis.Z();
size_t nAdditionalDimensions = totalNDims - 3;
if(nAdditionalDimensions >= 1)
{
for(size_t i = 0; i < nAdditionalDimensions; ++i)
{
localBasis.push_back(0);
}
}

std::string units = dimension->getUnits();
std::string id = dimension->getDimensionId();
return boost::str(boost::format("%s, %s, %s") %id %units %basis.toString(",") );
return boost::str(boost::format("%s, %s, %s") %id %units %VMD(localBasis).toString(",") );
}

/**
Expand Down Expand Up @@ -283,7 +298,7 @@ namespace Mantid
if(m_view->getApplyClip())
{
using namespace Mantid::Kernel;

const size_t totalNDims = sourceGeometry.getAllDimensions().size();
V3D b3 = m_b1.cross_prod(m_b2);
binningAlg->setPropertyValue("Translation", VMD(m_origin).toString(",") );
binningAlg->setProperty("AxisAligned", false);
Expand All @@ -292,28 +307,41 @@ namespace Mantid
std::vector<double> OutputExtents;
if(sourceGeometry.hasXDimension())
{
binningAlg->setPropertyValue("BasisVector0", extractFormattedPropertyFromDimension(VMD(m_b1), m_lengthB1, sourceGeometry.getXDimension()));
binningAlg->setPropertyValue("BasisVector0", extractFormattedPropertyFromDimension(m_b1, totalNDims, m_lengthB1, sourceGeometry.getXDimension()));
OutputExtents.push_back(0);
OutputExtents.push_back(m_lengthB1);
OutputBins.push_back(int(sourceGeometry.getXDimension()->getNBins()));
}
if(sourceGeometry.hasYDimension())
{
binningAlg->setPropertyValue("BasisVector1", extractFormattedPropertyFromDimension(VMD(m_b2), m_lengthB2, sourceGeometry.getYDimension()));
binningAlg->setPropertyValue("BasisVector1", extractFormattedPropertyFromDimension(m_b2, totalNDims, m_lengthB2, sourceGeometry.getYDimension()));
OutputExtents.push_back(0);
OutputExtents.push_back(m_lengthB2);
OutputBins.push_back(int(sourceGeometry.getYDimension()->getNBins()));
}
if(sourceGeometry.hasZDimension())
{
binningAlg->setPropertyValue("BasisVector2", extractFormattedPropertyFromDimension(VMD(b3), m_lengthB3, sourceGeometry.getZDimension()));
binningAlg->setPropertyValue("BasisVector2", extractFormattedPropertyFromDimension(b3, totalNDims, m_lengthB3, sourceGeometry.getZDimension()));
OutputExtents.push_back(0);
OutputExtents.push_back(m_lengthB3);
OutputBins.push_back(int(sourceGeometry.getYDimension()->getNBins()));
}
if(sourceGeometry.hasTDimension())
{
binningAlg->setPropertyValue("BasisVector3", "");
// Create a basis vector parallel to the current time vector.
auto dimT = sourceGeometry.getTDimension();
std::string units = dimT->getUnits();
std::string id = dimT->getDimensionId();
std::string formattedTInput = boost::str(boost::format("%s, %s, 0,0,0,1") %id %units);
binningAlg->setPropertyValue("BasisVector3", formattedTInput);

// Set up extents and bins for this dimension.
OutputExtents.push_back(dimT->getMinimum());
OutputExtents.push_back(dimT->getMaximum());
OutputBins.push_back(int(dimT->getNBins()));

// Overwrite the translation.
binningAlg->setPropertyValue("Translation", boost::str(boost::format("%s, 0") %VMD(m_origin).toString(",")) );
}
binningAlg->setProperty("OutputExtents", OutputExtents);
binningAlg->setProperty("OutputBins", OutputBins);
Expand All @@ -335,7 +363,7 @@ namespace Mantid
}
if(sourceGeometry.hasTDimension())
{
binningAlg->setPropertyValue("AlignedDim3", extractFormattedPropertyFromDimension(sourceGeometry.getTDimension()));
binningAlg->setPropertyValue("AlignedDim3", extractFormattedPropertyFromDimension(sourceGeometry.getTDimension()));
}
}

Expand Down

0 comments on commit 572366b

Please sign in to comment.