本文整理汇总了C++中MDWSDescription::getDimNames方法的典型用法代码示例。如果您正苦于以下问题:C++ MDWSDescription::getDimNames方法的具体用法?C++ MDWSDescription::getDimNames怎么用?C++ MDWSDescription::getDimNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDWSDescription
的用法示例。
在下文中一共展示了MDWSDescription::getDimNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createEmptyEventWS
void MDEventWSWrapper::createEmptyEventWS(const MDWSDescription &description) {
boost::shared_ptr<DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>>
ws = boost::shared_ptr<
DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>>(
new DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>());
auto numBins = description.getNBins();
size_t nBins(10); // HACK. this means we have 10 bins artificially. This can't
// be right.
// Give all the dimensions
for (size_t d = 0; d < nd; d++) {
if (!numBins.empty())
nBins = numBins[d];
Geometry::MDHistoDimension *dim = NULL;
if (d < 3 && description.isQ3DMode()) {
// We should have frame and scale information that we can use correctly
// for our Q dimensions.
auto mdFrame = description.getFrame(d);
dim = new Geometry::MDHistoDimension(
description.getDimNames()[d], description.getDimIDs()[d], *mdFrame,
Mantid::coord_t(description.getDimMin()[d]),
Mantid::coord_t(description.getDimMax()[d]), nBins);
} else {
Mantid::Geometry::GeneralFrame frame(description.getDimNames()[d],
description.getDimUnits()[d]);
dim = new Geometry::MDHistoDimension(
description.getDimNames()[d], description.getDimIDs()[d], frame,
Mantid::coord_t(description.getDimMin()[d]),
Mantid::coord_t(description.getDimMax()[d]), nBins);
}
ws->addDimension(Geometry::MDHistoDimension_sptr(dim));
}
ws->initialize();
m_Workspace = ws;
}
示例2: createEmptyMDWS
/** function creates empty MD event workspace with given parameters (workspace factory) and stores internal pointer to this workspace for further usage.
* IT ASLO SETS UP W-TRANSFORMATON. TODO: reconsile w-transfo with MD geometry.
*
*@param WSD the class which describes an MD workspace
*
*@returns shared pointer to the created workspace
*/
API::IMDEventWorkspace_sptr MDEventWSWrapper::createEmptyMDWS(const MDWSDescription &WSD)
{
if(WSD.nDimensions()<1||WSD.nDimensions()>MAX_N_DIM)
{
std::string ERR=" Number of requested MD dimensions: "+boost::lexical_cast<std::string>(WSD.nDimensions())+
" exceeds maximal number of MD dimensions: "+boost::lexical_cast<std::string>((int)MAX_N_DIM)+" instantiated during compilation\n";
throw(std::invalid_argument(ERR));
}
m_NDimensions = (int)WSD.nDimensions();
// call the particular function, which creates the workspace with n_dimensions
(this->*(wsCreator[m_NDimensions]))(WSD.getDimNames(),WSD.getDimIDs(),WSD.getDimUnits(),WSD.getDimMin(),WSD.getDimMax(),WSD.getNBins());
// set up the matrix, which convert momentums from Q in orthogonal crystal coordinate system and units of Angstrom^-1 to hkl or orthogonal hkl or whatevert
m_Workspace->setWTransf(WSD.m_Wtransf);
return m_Workspace;
}
示例3: Bm
/** Build meaningful dimension names for different conversion modes
* @param TargWSDescription the class-container to keep the dimension names and
dimension unints
* @param FrameID -- the ID describing the target transformation frame (lab,
sample, hkl)
* @param ScaleID -- the scale ID which define how the dimensions are scaled
*/
void MDWSTransform::setQ3DDimensionsNames(
MDWSDescription &TargWSDescription, CnvrtToMD::TargetFrame FrameID,
CnvrtToMD::CoordScaling ScaleID) const {
std::vector<Kernel::V3D> dimDirections;
// set default dimension names:
std::vector<std::string> dimNames = TargWSDescription.getDimNames();
// define B-matrix and Lattice parameters to one in case if no OrientedLattice
// is there
Kernel::DblMatrix Bm(3, 3, true);
std::vector<double> LatPar(3, 1);
if (TargWSDescription.hasLattice()) { // redefine B-matrix and Lattice
// parameters from real oriented lattice
// if there is one
auto spLatt = TargWSDescription.getLattice();
Bm = spLatt->getB();
for (int i = 0; i < 3; i++)
LatPar[i] = spLatt->a(i);
}
if (FrameID == CnvrtToMD::AutoSelect)
FrameID = findTargetFrame(TargWSDescription);
switch (FrameID) {
case (CnvrtToMD::LabFrame): {
dimNames[0] = "Q_lab_x";
dimNames[1] = "Q_lab_y";
dimNames[2] = "Q_lab_z";
TargWSDescription.setCoordinateSystem(Mantid::Kernel::QLab);
TargWSDescription.setFrame(Geometry::QLab::QLabName);
break;
}
case (CnvrtToMD::SampleFrame): {
dimNames[0] = "Q_sample_x";
dimNames[1] = "Q_sample_y";
dimNames[2] = "Q_sample_z";
TargWSDescription.setCoordinateSystem(Mantid::Kernel::QSample);
TargWSDescription.setFrame(Geometry::QSample::QSampleName);
break;
}
case (CnvrtToMD::HKLFrame): {
dimNames[0] = "H";
dimNames[1] = "K";
dimNames[2] = "L";
Kernel::MDUnit_uptr mdUnit(new Kernel::InverseAngstromsUnit);
TargWSDescription.setCoordinateSystem(Mantid::Kernel::HKL);
TargWSDescription.setFrame(Geometry::HKL::HKLName);
break;
}
default:
throw(std::invalid_argument(" Unknown or undefined Target Frame ID"));
}
dimDirections.resize(3);
dimDirections[0] = m_UProj;
dimDirections[1] = m_VProj;
dimDirections[2] = m_WProj;
if (ScaleID == OrthogonalHKLScale) {
std::vector<Kernel::V3D> uv(2);
uv[0] = m_UProj;
uv[1] = m_VProj;
dimDirections = Kernel::V3D::makeVectorsOrthogonal(uv);
}
// axis names:
if ((FrameID == CnvrtToMD::LabFrame) || (FrameID == CnvrtToMD::SampleFrame))
for (int i = 0; i < 3; i++)
TargWSDescription.setDimName(i, dimNames[i]);
else
for (int i = 0; i < 3; i++)
TargWSDescription.setDimName(
i, MDAlgorithms::makeAxisName(dimDirections[i], dimNames));
if (ScaleID == NoScaling) {
for (int i = 0; i < 3; i++)
TargWSDescription.setDimUnit(i, "A^-1");
}
if (ScaleID == SingleScale) {
double dMax(-1.e+32);
for (int i = 0; i < 3; i++)
dMax = (dMax > LatPar[i]) ? (dMax) : (LatPar[i]);
for (int i = 0; i < 3; i++)
TargWSDescription.setDimUnit(
i, "in " + MDAlgorithms::sprintfd(2 * M_PI / dMax, 1.e-3) + " A^-1");
}
if ((ScaleID == OrthogonalHKLScale) || (ScaleID == HKLScale)) {
// get the length along each of the axes
std::vector<double> len;
Kernel::V3D x;
x = Bm * dimDirections[0];
len.push_back(2 * M_PI * x.norm());
x = Bm * dimDirections[1];
//.........这里部分代码省略.........