本文整理汇总了C++中typenameMDEventWorkspace::get方法的典型用法代码示例。如果您正苦于以下问题:C++ typenameMDEventWorkspace::get方法的具体用法?C++ typenameMDEventWorkspace::get怎么用?C++ typenameMDEventWorkspace::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenameMDEventWorkspace
的用法示例。
在下文中一共展示了typenameMDEventWorkspace::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doCreate
void vtkMDHexFactory::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);
// 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, m_maxDepth, true,
this->sliceImplicitFunction.get());
else
ws->getBox()->getBoxes(boxes, m_maxDepth, true);
vtkIdType numBoxes = boxes.size();
vtkIdType imageSizeActual = 0;
if (VERBOSE)
std::cout << tim << " to retrieve the " << numBoxes
<< " boxes down to depth " << m_maxDepth << '\n';
// Create 8 points per box.
vtkNew<vtkPoints> points;
vtkFloatArray *pointsArray = vtkFloatArray::FastDownCast(points->GetData());
float *pointsPtr = pointsArray->WritePointer(0, numBoxes * 8 * 3);
// One scalar per box
vtkNew<vtkFloatArray> signals;
signals->SetName(ScalarName.c_str());
signals->SetNumberOfComponents(1);
float *signalsPtr = signals->WritePointer(0, numBoxes);
// To cache the signal
std::vector<float> signalCache(numBoxes, 0);
// True for boxes that we will use
// We do not use vector<bool> here because of the parallelization below
// Simultaneous access to different elements of vector<bool> is not safe
auto useBox = Mantid::Kernel::make_unique<bool[]>(numBoxes);
memset(useBox.get(), 0, sizeof(bool) * numBoxes);
// Create the data set (will outlive this object - output of create)
auto visualDataSet = vtkSmartPointer<vtkUnstructuredGrid>::New();
this->dataSet = visualDataSet;
visualDataSet->Allocate(numBoxes);
vtkNew<vtkIdList> hexPointList;
hexPointList->SetNumberOfIds(8);
auto hexPointList_ptr = hexPointList->WritePointer(0, 8);
NormFuncIMDNodePtr normFunction =
makeMDEventNormalizationFunction(m_normalizationOption, ws.get());
// This can be parallelized
// cppcheck-suppress syntaxError
PRAGMA_OMP( parallel for schedule (dynamic) )
for (int ii = 0; ii < int(boxes.size()); ii++) {
// Get the box here
size_t i = static_cast<size_t>(ii);
API::IMDNode *box = boxes[i];
Mantid::signal_t signal_normalized = (box->*normFunction)();
if (std::isfinite(signal_normalized)) {
// Cache the signal and using of it
signalCache[i] = static_cast<float>(signal_normalized);
useBox[i] = true;
// Get the coordinates.
size_t numVertexes = 0;
std::unique_ptr<coord_t[]> coords;
// If slicing down to 3D, specify which dimensions to keep.
if (this->slice) {
coords = std::unique_ptr<coord_t[]>(
box->getVertexesArray(numVertexes, 3, this->sliceMask.get()));
} else {
coords =
std::unique_ptr<coord_t[]>(box->getVertexesArray(numVertexes));
}
if (numVertexes == 8) {
std::copy_n(coords.get(), 24, std::next(pointsPtr, i * 24));
}
} else {
useBox[i] = false;
}
} // For each box
if (VERBOSE)
std::cout << tim << " to create the necessary points.\n";
// Add points
visualDataSet->SetPoints(points.GetPointer());
for (size_t i = 0; i < boxes.size(); i++) {
if (useBox[i]) {
// The bare point ID
vtkIdType pointId = i * 8;
//.........这里部分代码省略.........