Skip to content

Commit

Permalink
refs #4201 Moved splitBox and boxController methods
Browse files Browse the repository at this point in the history
from wsWrapper to IMDEventWorkspace interface
  • Loading branch information
abuts committed Jan 6, 2012
1 parent f2e4ec5 commit 0ea2270
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 45 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDEventWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ namespace API
virtual void estimateResolution() = 0;
/// get number of dimensions contained in initialized MD workspace
virtual size_t getNumDims()const=0;
/// split box function;
virtual void splitBox()=0;
//
virtual void refreshCache()=0;

/// Split all boxes that exceed the split threshold.
virtual void splitAllIfNeeded(Kernel::ThreadScheduler * ts) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ namespace MDAlgorithms
template<Q_state Q, AnalMode MODE, CnvrtUnits CONV,XCoordType XTYPE>
struct COORD_TRANSFORMER;

//
class DLLExport ConvertToMDEvents : public MDEvents::BoxControllerSettingsAlgorithm
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void ConvertToMDEvents::processQNDEWS()
int32_t det_id = det_loc.det_id[wi];

const DataObjects::EventList & el = pEventWS->getEventList(ic);
size_t numEvents = (int64_t)el.getNumberEvents();
//size_t numEvents = el.getNumberEvents();


const MantidVec& X = el.dataX();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class DLLExport MDEventWSWrapper
//****> the methods below provide the equivalent of vftable for MDEvent workspace write interface.
// It should probably be moved to that interface if no substantial performance loss is identified (and seems there are no)
/// to access to splitBox method of multidimensional workspace
void splitBox(){boxSplitter[n_dimensions]();}
void splitBox(){workspace->splitBox();}
/** returns the MDevent ws box controller for access and modifications */
Mantid::API::BoxController_sptr getBoxController(){return workspace->getBoxController();}
/// refresh cash on md event workspace
void refreshCache(){ cashRefresher[n_dimensions]();}
void refreshCache(){workspace->refreshCache();}
private:
/// maximal nuber of dimensions, currently supported by the class;
static const size_t MAX_N_DIM=8;
Expand Down Expand Up @@ -101,12 +101,7 @@ class DLLExport MDEventWSWrapper
std::vector<fpVoidMethod> wsCreator;
/// vector holding function pointers to the code, which adds diffrent dimension number events to the workspace
std::vector<fpVoidMethod> mdEvSummator;
/// vecor holding pointers to the box splitting code
std::vector<fpVoidMethod> boxSplitter;
/// vecor holding pointers to the box splitting code
std::vector<fpVoidMethod> cashRefresher;

/// helper function to create empty MDEventWorkspace with nd dimensions
/// helper function to create empty MDEventWorkspace with nd dimensions
template<size_t nd>
void createEmptyEventWS(void)
{
Expand Down Expand Up @@ -154,27 +149,7 @@ class DLLExport MDEventWSWrapper
//tp.joinAll();

}
/// template to access boxSplit method on MD workspace
template<size_t nd>
void split_Box(){
MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *const pWs = dynamic_cast<MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *>(this->workspace.get());
if(!pWs){
g_log.error()<<"MDEventWSWrapper: can not cast worspace pointer into pointer to proper target workspace\n";
throw(std::bad_cast());
}
pWs->splitBox();
}
/// template to access refresh cash method on MD workspace
template<size_t nd>
void refresh_Cache(){
MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *const pWs = dynamic_cast<MDEvents::MDEventWorkspace<MDEvents::MDEvent<nd>,nd> *>(this->workspace.get());
if(!pWs){
g_log.error()<<"MDEventWSWrapper: can not cast worspace pointer into pointer to proper target workspace\n";
throw(std::bad_cast());
}
pWs->refreshCache();
}


/// function called if the workspace has not been initated;
void throwNotInitiatedError();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ namespace MDEvents
/// Set the number of bins in each dimension to something corresponding to the estimated resolution of the finest binning
void estimateResolution();

void splitAllIfNeeded(Kernel::ThreadScheduler * ts);
virtual void splitAllIfNeeded(Kernel::ThreadScheduler * ts);

virtual void splitBox();

virtual void refreshCache();
//------------------------ (END) IMDEventWorkspace Methods -----------------------------------------

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

void splitBox();

void refreshCache();


void addEvent(const MDE & event);

size_t addEvents(const std::vector<MDE> & events);
Expand Down
12 changes: 2 additions & 10 deletions Code/Mantid/Framework/MDEvents/src/MDEventWSWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ class LOOP{
pH->wsCreator.push_back(boost::bind(std::mem_fun(&MDEventWSWrapper::createEmptyEventWS<i>),pH));
pH->mdEvSummator.push_back(boost::bind(std::mem_fun(&MDEventWSWrapper::add_MDData<i>),pH));

// vftable definition
pH->boxSplitter.push_back(boost::bind(std::mem_fun(&MDEventWSWrapper::split_Box<i>),pH));
pH->cashRefresher.push_back(boost::bind(std::mem_fun(&MDEventWSWrapper::refresh_Cache<i>),pH));

}
};
template<>
Expand All @@ -104,18 +100,14 @@ class LOOP<0>{
fpVoidMethod fp = (boost::bind(std::mem_fun(&MDEventWSWrapper::throwNotInitiatedError),pH));
pH->wsCreator.push_back(fp);
pH->mdEvSummator.push_back(fp);
pH->boxSplitter.push_back(fp);
pH->cashRefresher.push_back(fp);
}
}
};

MDEventWSWrapper::MDEventWSWrapper():n_dimensions(0)
{
wsCreator.reserve(MAX_N_DIM+1);
mdEvSummator.reserve(MAX_N_DIM+1);
boxSplitter.reserve(MAX_N_DIM+1);
cashRefresher.reserve(MAX_N_DIM+1);
LOOP<MAX_N_DIM>::EXEC(this);
LOOP<MAX_N_DIM>::EXEC(this);
}


Expand Down

0 comments on commit 0ea2270

Please sign in to comment.