Skip to content

Commit

Permalink
refs #6449 Changed all MDBoxBase lists/iteratros from Base to IMDNode
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 5, 2013
1 parent 14f58bf commit 9ca26d6
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 183 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ set ( INC_FILES
inc/MantidAPI/IMDEventWorkspace.h
inc/MantidAPI/IMDHistoWorkspace.h
inc/MantidAPI/IMDIterator.h
inc/MantidAPI/IMDNode.h
inc/MantidAPI/IMDWorkspace.h
inc/MantidAPI/IMaskWorkspace.h
inc/MantidAPI/IPeak.h
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/IMDEventWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MultipleExperimentInfos.h"
#include "MantidAPI/Workspace.h"
#include "MantidAPI/IMDNode.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidGeometry/MDGeometry/MDDimensionExtents.h"
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
Expand Down Expand Up @@ -48,7 +49,7 @@ namespace API
virtual Mantid::API::BoxController_sptr getBoxController() = 0;
virtual Mantid::API::BoxController_const_sptr getBoxController() const = 0;

virtual void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t maxDepth, bool leafOnly)=0;
virtual void getBoxes(std::vector<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly)=0;

/// Helper method that makes a table workspace with some box data
virtual Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num) = 0;
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef MANTID_MDEVENTS_ISAVEABLE_H_
#define MANTID_MDEVENTS_ISAVEABLE_H_
#ifndef MANTID_KERNEL_ISAVEABLE_H_
#define MANTID_KERNEL_ISAVEABLE_H_

#include "MantidKernel/System.h"
#include <vector>
Expand Down Expand Up @@ -169,4 +169,4 @@ namespace Kernel
} // namespace Kernel
} // namespace Mantid

#endif /* MANTID_MDEVENTS_ISAVEABLE_H_ */
#endif /* MANTID_KERNEL_ISAVEABLE_H_ */
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDAlgorithms/src/BinMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace MDAlgorithms
MDImplicitFunction * function = this->getImplicitFunctionForChunk(chunkMin, chunkMax);

// Use getBoxes() to get an array with a pointer to each box
std::vector<Kernel::ISaveable *> boxes;
std::vector<API::IMDNode *> boxes;
// Leaf-only; no depth limit; with the implicit function passed to it.
ws->getBox()->getBoxes(boxes, 1000, true, function);

Expand Down
25 changes: 16 additions & 9 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace MDEvents

MDBox(Mantid::API::BoxController_sptr splitter, const size_t depth, const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector, int64_t boxSize=-1,int64_t boxID=-1);

MDBox(const MDBox<MDE,nd> & other);
MDBox(const MDBox<MDE,nd> & other,const Mantid::API::BoxController * otherBC=NULL);

virtual ~MDBox() {}

Expand All @@ -66,8 +66,13 @@ namespace MDEvents
*/
void setLoaded()
{
m_isLoaded=true;
m_isLoaded=true;
}

/// @return whether the box data (from disk) is loaded in memory.
bool getInMemory() const
{ return m_isLoaded; }


/// @return the amount of memory that the object takes up in the MRU.
virtual uint64_t getTotalDataSize() const
Expand Down Expand Up @@ -102,10 +107,6 @@ namespace MDEvents
{ throw std::runtime_error("MDBox cannot have children."); }


/// @return whether the box data (from disk) is loaded in memory.
bool getInMemory() const
{ return m_isLoaded; }


/// @return true if events were added to the box (using addEvent()) while the rest of the event list is cached to disk
bool isDataAdded() const
Expand Down Expand Up @@ -139,6 +140,13 @@ namespace MDEvents

std::vector< MDE > * getEventsCopy();

virtual void addEvent(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId);
virtual void addAndTraceEvent(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId,size_t index);
virtual void addEventUnsafe(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId);
//virtual size_t addEventsPart(const std::vector<coord_t> &coords,const signal_t *Signal,const signal_t *errorSq,const uint16_t *runIndex,const uint32_t *detectorId, const size_t start_at, const size_t stop_at);
//virtual size_t addEvents(const std::vector<signal_t> &sigErrSq,const std::vector<coord_t> &Coord,
// const std::vector<uint16_t> &runIndex=std::vector<uint16_t>(),const std::vector<uint32_t> &detectorId=std::vector<uint32_t>());
virtual size_t addEvents(const std::vector<signal_t> &sigErrSq,const std::vector<coord_t> &Coord,const std::vector<uint16_t> &runIndex,const std::vector<uint32_t> &detectorId);

void addEvent(const MDE & Evnt);
void addAndTraceEvent(const MDE & point,size_t index);
Expand Down Expand Up @@ -167,10 +175,10 @@ namespace MDEvents
void loadNexus(::NeXus::File * file, bool setLoaded=true);

void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t /*maxDepth*/, bool /*leafOnly*/);
void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t /*maxDepth*/, bool /*leafOnly*/);
void getBoxes(std::vector<API::IMDNode *> & boxes, size_t /*maxDepth*/, bool /*leafOnly*/);

void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);
void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);
void getBoxes(std::vector<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);

void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset);

Expand Down Expand Up @@ -211,7 +219,6 @@ namespace MDEvents




}//namespace MDEvents

}//namespace Mantid
Expand Down
75 changes: 14 additions & 61 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MDBOXBASE_H_

#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/IMDNode.h"
#include "MantidGeometry/MDGeometry/MDDimensionExtents.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidKernel/ISaveable.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ namespace MDEvents
*
* */
TMDE_CLASS
class DLLExport MDBoxBase : public Mantid::Kernel::ISaveable
class DLLExport MDBoxBase : public Mantid::API::IMDNode
{
public:

Expand All @@ -50,22 +51,11 @@ namespace MDEvents

MDBoxBase(const std::vector<Mantid::Geometry::MDDimensionExtents<coord_t> > & extentsVector);

MDBoxBase(const MDBoxBase<MDE,nd> & box);
MDBoxBase(const MDBoxBase<MDE,nd> & box,const Mantid::API::BoxController * otherBC=NULL);

/// Destructor
virtual ~MDBoxBase() {}

/// Get number of dimensions
virtual size_t getNumDims() const = 0;

/// Getter for the masking
virtual bool getIsMasked() const = 0;

///Setter for masking the box
virtual void mask() = 0;

///Setter for unmasking the box
virtual void unmask() = 0;

// ----------------------------- ISaveable Methods ------------------------------------------------------

Expand Down Expand Up @@ -101,23 +91,8 @@ namespace MDEvents
virtual void clearDataFromMemory()
{// no data so no operations
}
// TODO: Kill it
virtual bool isBox()const{throw std::runtime_error("Non-overloaded boxBase is invoked "); return false;}
// -------------------------------- Parents/Children-Related -------------------------------------------
/// Get the total # of unsplit MDBoxes contained.
virtual size_t getNumMDBoxes() const = 0;


/// Get the # of children MDBoxBase'es (non-recursive)
virtual size_t getNumChildren() const = 0;

/// Return the indexth child MDBoxBase.
virtual MDBoxBase<MDE,nd> * getChild(size_t index) = 0;

/// Sets the children from a vector of children
virtual void setChildren(const std::vector<MDBoxBase<MDE,nd> *> & boxes, const size_t indexStart, const size_t indexEnd) = 0;

/// Return a pointer to the parent box
/// Return a pointer to the parent box
void setParent(MDBoxBase<MDE,nd> * parent)
{ m_parent = parent; }

Expand All @@ -130,20 +105,11 @@ namespace MDEvents
{ return m_parent; }

/// Fill a vector with all the boxes up to a certain depth
virtual void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly) = 0;
virtual void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t maxDepth, bool leafOnly) = 0;
//virtual void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly) = 0;

/// Fill a vector with all the boxes up to a certain depth
virtual void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function) = 0;
virtual void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function) = 0;

/** Split sub-boxes, if this is possible and neede for this box */
virtual void splitAllIfNeeded(Mantid::Kernel::ThreadScheduler * /*ts*/ = NULL)
{ /* Do nothing by default. */ }
//virtual void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function) = 0;

/** Recalculate signal etc. */
virtual void refreshCache(Kernel::ThreadScheduler * /*ts*/ = NULL)
{ /* Do nothing by default. */ }

/// Returns the lowest-level box at the given coordinates
virtual const MDBoxBase<MDE,nd> * getBoxAtCoord(const coord_t * /*coords*/) const
Expand All @@ -164,15 +130,8 @@ namespace MDEvents

// -------------------------------- Events-Related -------------------------------------------

/// Clear all contained data
virtual void clear() = 0;

/// Get total number of points
virtual uint64_t getNPoints() const = 0;

/// Return a copy of contained events
virtual std::vector< MDE > * getEventsCopy() = 0;

/// Add a single event
virtual void addEvent(const MDE & point) = 0;
// add a single event and set pointer to the box which needs splitting (if one actually need)
Expand Down Expand Up @@ -204,24 +163,18 @@ namespace MDEvents
/** Find the centroid around a sphere */
virtual void centroidSphere(Mantid::API::CoordTransform & radiusTransform, const coord_t radiusSquared, coord_t * centroid, signal_t & signal) const = 0;


// -------------------------------------------------------------------------------------------
/** Cache the centroid of this box and all sub-boxes. */
virtual void refreshCentroid(Kernel::ThreadScheduler * /*ts*/ = NULL) {} //= 0;

virtual void calculateCentroid(coord_t * /*centroid*/) const {};

// -------------------------------------------------------------------------------------------
/// @return the box controller saved.
Mantid::API::BoxController_sptr getBoxController() const
Mantid::API::BoxController *getBoxController() const
{ return m_BoxController; }

/** Set the box controller used.
* @param controller :: Mantid::API::BoxController_sptr
* @param controller :: Mantid::API::BoxController *
*/
virtual void setBoxController(Mantid::API::BoxController_sptr controller)
virtual void setBoxController(Mantid::API::BoxController *controller)
{ m_BoxController = controller; }


//-----------------------------------------------------------------------------------------------
/** Set the extents of this box.
* @param dim :: index of dimension
Expand All @@ -238,7 +191,7 @@ namespace MDEvents

extents[dim].setExtents(min,max);
// volume has to be recalculated as extents have changed;
//this->calcVolume();
this->calcVolume();
}
/** Set the extents of this box.
* @param min :: min edge of the dimension
Expand Down Expand Up @@ -440,7 +393,7 @@ namespace MDEvents
return m_centroid;
}
#endif

virtual size_t addEvents(const std::vector<signal_t> &sigErrSq,const std::vector<coord_t> &Coord,const std::vector<uint16_t> &runIndex,const std::vector<uint32_t> &detectorId)=0;
protected:
/** Array of MDDimensionStats giving the extents and
* other stats on the box dimensions.
Expand All @@ -463,13 +416,13 @@ namespace MDEvents
coord_t m_inverseVolume;

/// The box splitting controller, shared with all boxes in the hierarchy
Mantid::API::BoxController_sptr m_BoxController;
Mantid::API::BoxController *m_BoxController;

/// Recursion depth
size_t m_depth;

/// Pointer to the parent of this box. NULL if no parent.
MDBoxBase<MDE,nd> * m_parent;
Mantid::API::IMDNode * m_parent;

#ifdef MDBOX_TRACK_CENTROID
/** The centroid (weighted center of mass) of the events in this MDBox.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace MDEvents

const std::string &getBCXMLdescr()const {return m_bcXMLDescr;}

std::vector<Kernel::ISaveable *> &getBoxes(){return m_Boxes;}
std::vector<API::IMDNode *> &getBoxes(){return m_Boxes;}

// TODO: this does not have to be a template-> refactoring needed.
template<typename MDE,size_t nd>
Expand Down Expand Up @@ -64,7 +64,7 @@ namespace MDEvents
/// Start/end children IDs
std::vector<int> m_BoxChildren;

std::vector<Kernel::ISaveable *> m_Boxes;
std::vector<API::IMDNode *> m_Boxes;

std::string m_bcXMLDescr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace MDEvents
size_t m_max;

/// Vector of all the boxes that will be iterated.
std::vector<Kernel::ISaveable *> m_boxes;
std::vector<API::IMDNode *> m_boxes;

/// Box currently pointed to
MDBoxBase<MDE,nd>* m_current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace MDEvents

Mantid::API::ITableWorkspace_sptr makeBoxTable(size_t start, size_t num);

virtual void getBoxes(std::vector<Kernel::ISaveable *> & boxes, size_t maxDepth, bool leafOnly)
virtual void getBoxes(std::vector<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly)
{
this->getBox()->getBoxes(boxes,maxDepth,leafOnly);
}
Expand Down

0 comments on commit 9ca26d6

Please sign in to comment.