本文整理汇总了C++中magnet::xml::Node::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::getAttribute方法的具体用法?C++ Node::getAttribute怎么用?C++ Node::getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magnet::xml::Node
的用法示例。
在下文中一共展示了Node::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
void
IStepped::operator<<(const magnet::xml::Node& XML)
{
if (strcmp(XML.getAttribute("Type"),"Stepped"))
M_throw() << "Attempting to load Stepped from non Stepped entry";
range.set_ptr(C2Range::getClass(XML,Sim));
try {
intName = XML.getAttribute("Name");
if (!XML.hasNode("Step"))
M_throw() << "No steppings defined for stepped potential "
<< intName;
for (magnet::xml::Node node = XML.fastGetNode("Step"); node.valid(); ++node)
steps.push_back(steppair(node.getAttribute("R").as<double>(),
node.getAttribute("E").as<double>()));
std::sort(steps.rbegin(), steps.rend());
IMultiCapture::loadCaptureMap(XML);
}
catch (boost::bad_lexical_cast &)
{
M_throw() << "Failed a lexical cast in CIStepped";
}
if (steps.empty())
M_throw() << "No steps defined in SteppedPotential Interaction with name "
<< getName();
}
示例2: is
void
LTriangleMesh::operator<<(const magnet::xml::Node& XML)
{
range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"), Sim));
_diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());
_e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
localName = XML.getAttribute("Name");
{//Load the vertex coordinates
std::istringstream is(XML.getNode("Vertices").getValue());
is.exceptions(std::ostringstream::badbit | std::ostringstream::failbit);
is.peek(); //Set the eof flag if needed
Vector tmp;
while (!is.eof())
{
is >> tmp[0];
if (is.eof()) M_throw() << "The vertex coordinates is not a multiple of 3";
is >> tmp[1];
if (is.eof()) M_throw() << "The vertex coordinates is not a multiple of 3";
is >> tmp[2];
_vertices.push_back(tmp * Sim->units.unitLength());
}
}
{//Load the triangle elements
std::istringstream is(XML.getNode("Elements").getValue());
is.exceptions(std::ostringstream::badbit | std::ostringstream::failbit);
is.peek(); //Set the eof flag if needed
TriangleElements tmp;
while (!is.eof())
{
is >> std::get<0>(tmp);
if (is.eof()) M_throw() << "The triangle elements are not a multiple of 3";
is >> std::get<1>(tmp);
if (is.eof()) M_throw() << "The triangle elements are not a multiple of 3";
is >> std::get<2>(tmp);
if ((std::get<0>(tmp) >= _vertices.size())
|| (std::get<1>(tmp) >= _vertices.size())
|| (std::get<2>(tmp) >= _vertices.size()))
M_throw() << "Triangle " << _elements.size() << " has an out of range vertex ID";
Vector normal
= (_vertices[std::get<1>(tmp)] - _vertices[std::get<0>(tmp)])
^ (_vertices[std::get<2>(tmp)] - _vertices[std::get<1>(tmp)]);
if (normal.nrm() == 0)
M_throw() << "Triangle " << _elements.size() << " has a zero normal!";
_elements.push_back(tmp);
}
}
}
示例3: fileOrdering
void
GVolumetricPotential::operator<<(const magnet::xml::Node& XML) {
globName = XML.getAttribute("Name");
_fileName = XML.getAttribute("RawFile");
_sampleBytes = XML.getAttribute("SampleBytes").as<size_t>();
//Load the dimensions of the data set (and its subset of data if
//only processing a smaller section)
auto XMLdim = XML.getNode("Dimensions");
_imageDimensions = std::array<size_t, 3>{{XMLdim.getAttribute("x").as<size_t>(), XMLdim.getAttribute("y").as<size_t>(), XMLdim.getAttribute("z").as<size_t>()}};
_offset = std::array<size_t, 3>{{0, 0, 0}};
if (XML.hasNode("Offset"))
{
auto XMLdim = XML.getNode("Offset");
_offset = std::array<size_t, 3>{{XMLdim.getAttribute("x").as<size_t>(), XMLdim.getAttribute("y").as<size_t>(), XMLdim.getAttribute("z").as<size_t>()}};
}
std::array<size_t, 3> sampleDimensions = _imageDimensions;
if (XML.hasNode("SampleDimensions"))
{
auto XMLdim = XML.getNode("SampleDimensions");
sampleDimensions = std::array<size_t, 3>{{XMLdim.getAttribute("x").as<size_t>(), XMLdim.getAttribute("y").as<size_t>(), XMLdim.getAttribute("z").as<size_t>()}};
}
Ordering fileOrdering(_imageDimensions);
std::vector<unsigned char> fileData(fileOrdering.size() * _sampleBytes);
dout << "Opening " << _fileName << std::endl;
std::ifstream file(_fileName.c_str(), std::ifstream::binary);
if (!file.good())
M_throw() << "Failed open the file " << _fileName;
dout << "Reading " << fileOrdering.size() * _sampleBytes << " bytes of data into memory" << std::endl;
file.read(reinterpret_cast<char*>(fileData.data()), fileOrdering.size() * _sampleBytes);
if (!file)
M_throw() << "Failed reading volumetric data (read " << file.gcount() << " bytes of an expected " << fileOrdering.size() * _sampleBytes << " from " << _fileName << ")";
file.close();
_ordering = Ordering(sampleDimensions);
_volumeData.resize(_ordering.size());
dout << "Resampling " << _ordering.size() << " bytes of data from the file into the simulation" << std::endl;
if (_sampleBytes == 1)
{
if (sampleDimensions == _imageDimensions)
std::swap(_volumeData, fileData);
else
for (size_t z = 0; z < sampleDimensions[2]; ++z)
for (size_t y = 0; y < sampleDimensions[1]; ++y)
{
size_t startindex = fileOrdering.toIndex(std::array<size_t, 3>{{_offset[0], y + _offset[1], z + _offset[2]}});
std::copy(fileData.begin() + startindex, fileData.begin() + startindex + sampleDimensions[0], _volumeData.begin() + _ordering.toIndex(std::array<size_t, 3>{{0, y, z}}));
}
}
else
M_throw() << "Do not have an optimised loader for resampling data yet";
dout << "Loading complete" << std::endl;
}
示例4: sqrt
void
LWall::operator<<(const magnet::xml::Node& XML)
{
range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"),Sim));
_diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());
if (_diameter->getMaxValue() == 0)
M_throw() << "Cannot have a wall with a diameter of zero";
_e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
sqrtT = 0;
if (XML.hasAttribute("Temperature"))
sqrtT = sqrt(XML.getAttribute("Temperature").as<double>()
* Sim->units.unitEnergy());
if (sqrtT < 0)
M_throw() << "Cannot use negative temperatures on a Wall";
magnet::xml::Node xBrowseNode = XML.getNode("Norm");
localName = XML.getAttribute("Name");
vNorm << xBrowseNode;
if (vNorm.nrm() == 0)
M_throw() << "The normal for the Local Wall named \"" << getName() << "\" has a length of 0. Cannot load";
vNorm /= vNorm.nrm();
xBrowseNode = XML.getNode("Origin");
vPosition << xBrowseNode;
vPosition *= Sim->units.unitLength();
}
示例5: catch
void
OPThermalDiffusionE::operator<<(const magnet::xml::Node& XML)
{
try
{
try {
species1name = std::string(XML.getAttribute("Species"));
} catch (std::exception& nex)
{
M_throw() << "The name of the Species must be specified"
<< nex.what();
}
if (XML.hasAttribute("Length"))
CorrelatorLength = XML.getAttribute("Length").as<size_t>();
if (XML.hasAttribute("dt"))
dt = Sim->dynamics.units().unitTime() *
XML.getAttribute("dt").as<double>();
if (XML.hasAttribute("t"))
dt = Sim->dynamics.units().unitTime() *
XML.getAttribute("t").as<double>() / CorrelatorLength;
}
catch (boost::bad_lexical_cast &)
{
M_throw() << "Failed a lexical cast in OPMutualDiffusion";
}
}
示例6: catch
void
ISquareWell::operator<<(const magnet::xml::Node& XML)
{
Interaction::operator<<(XML);
try {
_diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"),
Property::Units::Length());
_lambda = Sim->_properties.getProperty(XML.getAttribute("Lambda"),
Property::Units::Dimensionless());
_wellDepth = Sim->_properties.getProperty(XML.getAttribute("WellDepth"),
Property::Units::Energy());
if (XML.hasAttribute("Elasticity"))
_e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"),
Property::Units::Dimensionless());
else
_e = Sim->_properties.getProperty(1.0, Property::Units::Dimensionless());
intName = XML.getAttribute("Name");
ISingleCapture::loadCaptureMap(XML);
}
catch (boost::bad_lexical_cast &)
{
M_throw() << "Failed a lexical cast in ISquareWell";
}
}
示例7:
void
IDSMC::operator<<(const magnet::xml::Node& XML)
{
Interaction::operator<<(XML);
_length = Sim->_properties.getProperty(XML.getAttribute("Length"), Property::Units::Length());
_e = Sim->_properties.getProperty(XML.getAttribute("Elasticity"), Property::Units::Dimensionless());
ICapture::loadCaptureMap(XML);
}
示例8:
void
OPRGyration::operator<<(const magnet::xml::Node& XML)
{
if (XML.hasAttribute("BinWidthGyration"))
_binWidthGyration = XML.getAttribute("BinWidthGyration").as<double>();
if (XML.hasAttribute("BinWidthGyration"))
_binWidthNematic = XML.getAttribute("BinWidthGyration").as<double>();
}
示例9: TChain
shared_ptr<Topology>
Topology::getClass(const magnet::xml::Node& XML, dynamo::Simulation* Sim, size_t ID)
{
if (!strcmp(XML.getAttribute("Type"),"Chain"))
return shared_ptr<Topology>(new TChain(XML, Sim, ID));
else
M_throw() << XML.getAttribute("Type")
<< ", Unknown type of Topology encountered";
}
示例10:
void
SSleep::operator<<(const magnet::xml::Node& XML)
{
sysName = XML.getAttribute("Name");
_sleepVelocity = XML.getAttribute("SleepV").as<double>() * Sim->units.unitVelocity();
_sleepDistance = Sim->units.unitLength() * 0.01;
_sleepTime = Sim->units.unitTime() * 0.0001;
_range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"), Sim));
}
示例11: ParticleProperty
inline ParticleProperty(const magnet::xml::Node& node):
Property(Property::Units(node.getAttribute("Units").getValue())),
_name(node.getAttribute("Name").getValue())
{
//Move up to the particles nodes, and start loading the property values
for (magnet::xml::Node pNode = node.getParent().getParent()
.getNode("ParticleData").fastGetNode("Pt");
pNode.valid(); ++pNode)
_values.push_back(pNode.getAttribute(_name).as<double>());
}
示例12:
void
GFrancesco::operator<<(const magnet::xml::Node& XML)
{
globName = XML.getAttribute("Name");
const double MFT = XML.getAttribute("MFT").as<double>() * Sim->units.unitTime();
const double MFTstddev = XML.getAttribute("MFTstddev").as<double>() * Sim->units.unitTime();
_dist = std::normal_distribution<>(MFT, MFTstddev);
_vel = XML.getAttribute("Velocity").as<double>() * Sim->units.unitVelocity();
range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"), Sim));
}
示例13: catch
void
CSRingDSMC::operator<<(const magnet::xml::Node& XML)
{
if (strcmp(XML.getAttribute("Type"),"RingDSMC"))
M_throw() << "Attempting to load RingDSMC from a "
<< XML.getAttribute("Type") << " entry";
try {
tstep = XML.getAttribute("tStep").as<double>() * Sim->dynamics.units().unitTime();
chi12 = XML.getAttribute("Chi12").as<double>();
chi13 = XML.getAttribute("Chi13").as<double>();
sysName = XML.getAttribute("Name");
diameter = XML.getAttribute("Diameter").as<double>() * Sim->dynamics.units().unitLength();
e = XML.getAttribute("Inelasticity").as<double>();
d2 = diameter * diameter;
range1 = std::tr1::shared_ptr<CRange>(CRange::getClass(XML.getNode("Range1"), Sim));
if (XML.hasAttribute("MaxProbability12"))
maxprob12 = XML.getAttribute("MaxProbability12").as<double>();
if (XML.hasAttribute("MaxProbability13"))
maxprob13 = XML.getAttribute("MaxProbability13").as<double>();
}
catch (boost::bad_lexical_cast &)
{
M_throw() << "Failed a lexical cast in CGGlobal";
}
}
示例14:
void
BCLeesEdwards::operator<<(const magnet::xml::Node& XML)
{
if (XML.hasAttribute("DXD"))
_dxd = XML.getAttribute("DXD").as<double>();
_dxd *= Sim->units.unitLength();
if (XML.hasAttribute("Rate"))
_shearRate = XML.getAttribute("Rate").as<double>();
_shearRate /= Sim->units.unitTime();
}
示例15:
void
OPStructureImaging::operator<<(const magnet::xml::Node& XML)
{
if (!XML.hasAttribute("Structure"))
M_throw() << "You must specify the name of the structure to monitor for StructureImaging";
structureName = XML.getAttribute("Structure");
if (XML.hasAttribute("MaxImages"))
imageCount = XML.getAttribute("MaxImages").as<size_t>();
}