Skip to content

Commit

Permalink
refs #6449 Streamlined MDNode interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 5, 2013
1 parent 64bbabf commit 9ce1484
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 50 deletions.
139 changes: 139 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#ifndef IMD_NODE_H_
#define IMD_NODE_H_

#include <vector>
#include "MantidKernel/ThreadScheduler.h"
#include "MantidKernel/INode.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidAPI/BoxController.h"

namespace Mantid
{
namespace API
{

class IMDNode : public Kernel::INode
{
public:
virtual Kernel::ISaveable *const getISaveable(){return NULL;}
virtual Kernel::ISaveable *const getISaveable()const{return NULL;}
//---------------- ISAVABLE
/// @return the amount of memory that the object takes up in the MRU.
virtual uint64_t getTotalDataSize() const=0;

virtual size_t getDataMemorySize()const=0;

virtual void clearDataFromMemory()=0;
//-------------------------------------------------------------
/// 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;

/// get box controller
virtual Mantid::API::BoxController *getBoxController() const=0;

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

// -------------------------------- Parents/Children-Related -------------------------------------------
/// Avoid rtti
virtual bool isBox()const=0;
/// 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 IMDNode * getChild(size_t index) = 0;

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

/// Return a pointer to the parent box
virtual void setParent(IMDNode * parent)=0;

/// Return a pointer to the parent box
virtual IMDNode * getParent()=0;


/// Return a pointer to the parent box (const)
virtual const IMDNode * getParent() const = 0;

// -------------------------------- 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<coor> & getEventsCopy() = 0;
/// Add a single event
virtual void addEvent(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId) = 0;
// add a single event and set pointer to the box which needs splitting (if one actually need)
virtual void addAndTraceEvent(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId,size_t index) = 0;

/// Add a single event, with no mutex locking
virtual void addEventUnsafe(const std::vector<coord_t> &point, signal_t Signal, signal_t errorSq,uint16_t runIndex,uint32_t detectorId) = 0;

/// Add several events, within a given range
//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)=0;
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;

/// Add several events, within a given range, with no bounds checking
//virtual size_t addEventsPartUnsafe(const std::vector<MDE> & events, const size_t start_at, const size_t stop_at);
//size_t addEventsUnsafe(const std::vector<MDE> & events);

/** Perform centerpoint binning of events
* @param bin :: MDBin object giving the limits of events to accept.
* @param fullyContained :: optional bool array sized [nd] of which dimensions are known to be fully contained (for MDSplitBox)
*/
//virtual void centerpointBin(MDBin<MDE,nd> & bin, bool * fullyContained) const = 0;

/// General binning method for any shape.
//virtual void generalBin(MDBin<MDE,nd> & bin, Mantid::Geometry::MDImplicitFunction & function) const = 0;

/** Sphere (peak) integration */
virtual void integrateSphere(Mantid::API::CoordTransform & radiusTransform, const coord_t radiusSquared, signal_t & signal, signal_t & errorSquared) const = 0;

/** 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;

// box-related
/** Split sub-boxes, if this is possible and neede for this box */
virtual void splitAllIfNeeded(Mantid::Kernel::ThreadScheduler * /*ts*/ = NULL)=0;


/** Recalculate signal etc. */
virtual void refreshCache(Kernel::ThreadScheduler * /*ts*/ = NULL)=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=0;


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




};

}
}

#endif
46 changes: 46 additions & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/INode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef INODE_H_
#define INODE_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/ISaveable.h"

namespace Mantid
{
namespace Kernel
{
/** Helper class providing interface to ISAveable
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport INode
{
public:
virtual ISaveable *const getISaveable()=0;
virtual ISaveable *const getISaveable()const=0;
virtual ~INode(){};
};
}
}

#endif
21 changes: 2 additions & 19 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,6 @@ namespace MDEvents

/// Load the data which are not in memory yet and merge them with the data in memory;
virtual void load();
/** Method sets the attribite which tells that data were loaded in memory.
Usually one should not use this method as load operation sets this attribute by itself
but in some specific situations where the data were loaded from extermal source and exchanged with the box and the
data file position in new place is known this attribute should be set to true manually, to not allowing attempt to download
data again (see mergeMD files where target box data were loaded from the external source and been added to the box
*/
void setLoaded()
{
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.
Expand All @@ -81,6 +66,7 @@ namespace MDEvents
(because it might be cached to disk) or the size on disk (because you might have called AddEvents) */
virtual size_t getDataMemorySize()const
{ return data.size();}
/** teturns true if it is box*/
virtual bool isBox()const{return true;}
//-----------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -198,10 +184,7 @@ namespace MDEvents
/// Mutex for modifying the event list
Mantid::Kernel::Mutex dataMutex;

/// True when the events, which were saved before have been loaded up from disk. Load sets it true and memory clean-up resets it to false
mutable bool m_isLoaded;

/// Flag indicating that masking has been applied.
/// Flag indicating that masking has been applied.
bool m_bIsMasked;

public:
Expand Down
28 changes: 0 additions & 28 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDBoxBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ namespace MDEvents
virtual void load()
{ }

/// @return the amount of memory that the object takes up in the MRU.
virtual uint64_t getTotalDataSize() const
{ return 0; }
virtual size_t getDataMemorySize()const
{return 0;}

virtual void clearDataFromMemory()
{// no data so no operations
}
// -------------------------------- Parents/Children-Related -------------------------------------------
/// Return a pointer to the parent box
void setParent(MDBoxBase<MDE,nd> * parent)
Expand Down Expand Up @@ -375,25 +366,6 @@ namespace MDEvents
m_inverseVolume = invVolume;
}

#ifdef MDBOX_TRACK_CENTROID
//-----------------------------------------------------------------------------------------------
/** Return the centroid of the box.
* @param d :: index of the dimension to return.
*/
coord_t getCentroid(size_t d) const
{
return m_centroid[d];
}

//-----------------------------------------------------------------------------------------------
/** Return the centroid array of the box.
*/
const coord_t * getCentroid() const
{
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 Down
3 changes: 0 additions & 3 deletions Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/MDGridBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ namespace MDEvents

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

// void getBoxes(std::vector<MDBoxBase<MDE,nd> *> & 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<API::IMDNode *> & boxes, size_t maxDepth, bool leafOnly, Mantid::Geometry::MDImplicitFunction * function);

const MDBoxBase<MDE,nd> * getBoxAtCoord(const coord_t * coords) const;
Expand Down

0 comments on commit 9ce1484

Please sign in to comment.