本文整理汇总了C++中typenameMDEventWorkspace::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ typenameMDEventWorkspace::getName方法的具体用法?C++ typenameMDEventWorkspace::getName怎么用?C++ typenameMDEventWorkspace::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenameMDEventWorkspace
的用法示例。
在下文中一共展示了typenameMDEventWorkspace::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFakeUniformData
void FakeMDEventData::addFakeUniformData(
typename MDEventWorkspace<MDE, nd>::sptr ws) {
std::vector<double> params = getProperty("UniformParams");
if (params.empty())
return;
bool randomEvents = true;
if (params[0] < 0) {
randomEvents = false;
params[0] = -params[0];
}
if (params.size() == 1) {
if (randomEvents) {
for (size_t d = 0; d < nd; ++d) {
params.push_back(ws->getDimension(d)->getMinimum());
params.push_back(ws->getDimension(d)->getMaximum());
}
} else // regular events
{
size_t nPoints = size_t(params[0]);
double Vol = 1;
for (size_t d = 0; d < nd; ++d)
Vol *= (ws->getDimension(d)->getMaximum() -
ws->getDimension(d)->getMinimum());
if (Vol == 0 || Vol > std::numeric_limits<float>::max())
throw std::invalid_argument(
" Domain ranges are not defined properly for workspace: " +
ws->getName());
double dV = Vol / double(nPoints);
double delta0 = std::pow(dV, 1. / double(nd));
for (size_t d = 0; d < nd; ++d) {
double min = ws->getDimension(d)->getMinimum();
params.push_back(min * (1 + FLT_EPSILON) - min + FLT_EPSILON);
double extent = ws->getDimension(d)->getMaximum() - min;
size_t nStrides = size_t(extent / delta0);
if (nStrides < 1)
nStrides = 1;
params.push_back(extent / static_cast<double>(nStrides));
}
}
}
if ((params.size() != 1 + nd * 2))
throw std::invalid_argument(
"UniformParams: needs to have ndims*2+1 arguments ");
if (randomEvents)
addFakeRandomData<MDE, nd>(params, ws);
else
addFakeRegularData<MDE, nd>(params, ws);
ws->splitBox();
Kernel::ThreadScheduler *ts = new ThreadSchedulerFIFO();
ThreadPool tp(ts);
ws->splitAllIfNeeded(ts);
tp.joinAll();
ws->refreshCache();
}
示例2: doCreate
void vtkSplatterPlotFactory::doCreate(typename MDEventWorkspace<MDE, nd>::sptr ws) const
{
bool VERBOSE = true;
CPUTimer tim;
// Acquire a scoped read-only lock to the workspace (prevent segfault
// from algos modifying ws)
ReadLock lock(*ws);
// Find out how many events to plot, and the percentage of the largest
// boxes to use.
size_t totalPoints = ws->getNPoints();
size_t numPoints = m_numPoints;
if (numPoints > totalPoints)
{
numPoints = totalPoints;
}
double percent_to_use = m_percentToUse;
// Fail safe limits on fraction of boxes to use
if (percent_to_use <= 0)
{
percent_to_use = 5;
}
if (percent_to_use > 100)
{
percent_to_use = 100;
}
// First we get all the boxes, up to the given depth; with or wo the
// slice function
std::vector<API::IMDNode *> boxes;
if (this->slice)
{
ws->getBox()->getBoxes(boxes, 1000, true, this->sliceImplicitFunction);
}
else
{
ws->getBox()->getBoxes(boxes, 1000, true);
}
if (VERBOSE)
{
std::cout << tim << " to retrieve the "<< boxes.size() << " boxes down."<< std::endl;
}
std::string new_name = ws->getName();
if (new_name != m_wsName || m_buildSortedList)
{
m_wsName = new_name;
m_buildSortedList = false;
m_sortedBoxes.clear();
// get list of boxes with signal > 0 and sort
// the list in order of decreasing signal
for (size_t i = 0; i < boxes.size(); i++)
{
MDBox<MDE,nd> * box = dynamic_cast<MDBox<MDE,nd> *>(boxes[i]);
if (box)
{
size_t newPoints = box->getNPoints();
if (newPoints > 0)
{
m_sortedBoxes.push_back(box);
}
}
}
if (VERBOSE)
{
std::cout << "START SORTING" << std::endl;
}
std::sort(m_sortedBoxes.begin(), m_sortedBoxes.end(),
CompareNormalizedSignal);
if (VERBOSE)
{
std::cout << "DONE SORTING" << std::endl;
}
}
size_t num_boxes_to_use = static_cast<size_t>(percent_to_use * static_cast<double>(m_sortedBoxes.size()) / 100.0);
if (num_boxes_to_use >= m_sortedBoxes.size())
{
num_boxes_to_use = m_sortedBoxes.size()-1;
}
// restrict the number of points to the
// number of points in boxes being used
size_t total_points_available = 0;
for (size_t i = 0; i < num_boxes_to_use; i++)
{
size_t newPoints = m_sortedBoxes[i]->getNPoints();
total_points_available += newPoints;
}
if (numPoints > total_points_available)
{
numPoints = total_points_available;
}
size_t points_per_box = 0;
//.........这里部分代码省略.........