本文整理汇总了C++中magnet::xml::Node::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::getNode方法的具体用法?C++ Node::getNode怎么用?C++ Node::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类magnet::xml::Node
的用法示例。
在下文中一共展示了Node::getNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: catch
void
LOscillatingPlate::operator<<(const magnet::xml::Node& XML)
{
range = shared_ptr<Range>(Range::getClass(XML,Sim));
try {
e = XML.getAttribute("Elasticity").as<double>();
nhat << XML.getNode("Norm");
nhat /= nhat.nrm();
rw0 << XML.getNode("Origin");
rw0 *= Sim->dynamics.units().unitLength();
if (XML.hasAttribute("StrongPlate"))
strongPlate = XML.getAttribute("StrongPlate").as<double>();
omega0 = XML.getAttribute("Omega0").as<double>() / Sim->dynamics.units().unitTime();
sigma = XML.getAttribute("Sigma").as<double>() * Sim->dynamics.units().unitLength();
delta = XML.getAttribute("Delta").as<double>() * Sim->dynamics.units().unitLength();
mass = XML.getAttribute("Mass").as<double>() * Sim->dynamics.units().unitMass();
timeshift = XML.getAttribute("TimeShift").as<double>() * Sim->dynamics.units().unitTime();
localName = XML.getAttribute("Name");
}
catch (boost::bad_lexical_cast &)
{
M_throw() << "Failed a lexical cast in LOscillatingPlate";
}
}
示例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:
void
ISWSequence::operator<<(const magnet::xml::Node& XML)
{
Interaction::operator<<(XML);
_diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"),
Property::Units::Length());
_lambda = Sim->_properties.getProperty(XML.getAttribute("Lambda"),
Property::Units::Dimensionless());
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");
ICapture::loadCaptureMap(XML);
//Load the sequence
sequence.clear();
std::set<size_t> letters;
for (magnet::xml::Node node = XML.getNode("Sequence").fastGetNode("Element");
node.valid(); ++node)
{
if (node.getAttribute("seqID").as<size_t>() != sequence.size())
M_throw() << "Sequence of letters not in order, missing element " << sequence.size();
size_t letter = node.getAttribute("Letter").as<size_t>();
letters.insert(letter);
sequence.push_back(letter);
}
//Initialise all the well depths to 1.0
alphabet.resize(letters.size());
for (std::vector<double>& vec : alphabet)
vec.resize(letters.size(), 0.0);
for (magnet::xml::Node node = XML.getNode("Alphabet").fastGetNode("Word");
node.valid(); ++node)
{
alphabet
.at(node.getAttribute("Letter1").as<size_t>())
.at(node.getAttribute("Letter2").as<size_t>())
= node.getAttribute("Depth").as<double>();
alphabet
.at(node.getAttribute("Letter2").as<size_t>())
.at(node.getAttribute("Letter1").as<size_t>())
= node.getAttribute("Depth").as<double>();
}
}
示例6: part
void
Liouvillean::loadParticleXMLData(const magnet::xml::Node& XML)
{
dout << "Loading Particle Data" << std::endl;
bool outofsequence = false;
for (magnet::xml::Node node = XML.getNode("ParticleData").fastGetNode("Pt");
node.valid(); ++node)
{
if (!node.hasAttribute("ID")
|| node.getAttribute("ID").as<size_t>() != Sim->particleList.size())
outofsequence = true;
Particle part(node, Sim->particleList.size());
part.getVelocity() *= Sim->dynamics.units().unitVelocity();
part.getPosition() *= Sim->dynamics.units().unitLength();
Sim->particleList.push_back(part);
}
if (outofsequence)
dout << "Particle ID's out of sequence!\n"
<< "This can result in incorrect capture map loads etc.\n"
<< "Erase any capture maps in the configuration file so they are regenerated." << std::endl;
Sim->N = Sim->particleList.size();
dout << "Particle count " << Sim->N << std::endl;
if (XML.getNode("ParticleData").hasAttribute("OrientationData"))
{
orientationData.resize(Sim->N);
size_t i(0);
for (magnet::xml::Node node = XML.getNode("ParticleData").fastGetNode("Pt");
node.valid(); ++node, ++i)
{
orientationData[i].orientation << node.getNode("U");
orientationData[i].angularVelocity << node.getNode("O");
double oL = orientationData[i].orientation.nrm();
if (!(oL > 0.0))
M_throw() << "Particle ID " << i
<< " orientation vector is zero!";
//Makes the vector a unit vector
orientationData[i].orientation /= oL;
}
}
}
示例7: IDPairRangePair
IDPairRangePair(const magnet::xml::Node& XML, const dynamo::Simulation* Sim)
{
magnet::xml::Node subRangeXML = XML.getNode("IDRange");
range1 = shared_ptr<IDRange>(IDRange::getClass(subRangeXML, Sim));
++subRangeXML;
range2 = shared_ptr<IDRange>(IDRange::getClass(subRangeXML, Sim));
}
示例8: catch
void
CSUmbrella::operator<<(const magnet::xml::Node& XML)
{
if (strcmp(XML.getAttribute("Type"),"Umbrella"))
M_throw() << "Attempting to load Umbrella from a "
<< XML.getAttribute("Type") << " entry";
try {
sysName = XML.getAttribute("Name");
a = XML.getAttribute("a").as<double>()
* Sim->dynamics.units().unitEnergy()
/ Sim->dynamics.units().unitArea();
b = XML.getAttribute("b").as<double>()
* Sim->dynamics.units().unitLength();
delU = XML.getAttribute("delU").as<double>() * Sim->dynamics.units().unitEnergy();
range1.set_ptr(CRange::getClass(XML.getNode("Range1"), Sim));
range2.set_ptr(CRange::getClass(XML.getNode("Range2"), Sim));
if (XML.hasAttribute("currentulevel"))
{
ulevel = XML.getAttribute("currentulevel").as<size_t>();
ulevelset = true;
}
}
catch (boost::bad_lexical_cast &)
{ M_throw() << "Failed a lexical cast in CSUmbrella"; }
}
示例9: 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";
}
}
示例10:
void
SysUmbrella::operator<<(const magnet::xml::Node& XML)
{
sysName = XML.getAttribute("Name");
magnet::xml::Node rangeNode = XML.getNode("IDRange");
range1 = shared_ptr<IDRange>(IDRange::getClass(rangeNode, Sim));
++rangeNode;
range2 = shared_ptr<IDRange>(IDRange::getClass(rangeNode, Sim));
_potential = Potential::getClass(XML.getNode("Potential"));
_lengthScale = XML.getAttribute("LengthScale").as<double>() * Sim->units.unitLength();
_energyScale = XML.getAttribute("EnergyScale").as<double>() * Sim->units.unitEnergy();
if (XML.hasAttribute("CurrentStep"))
_stepID = XML.getAttribute("CurrentStep").as<size_t>();
}
示例11:
C2RPair::C2RPair(const magnet::xml::Node& XML, const dynamo::SimData* Sim)
{
if (strcmp(XML.getAttribute("Range"), "Pair"))
M_throw() << "Attempting to load a pair from a non pair";
range1 = shared_ptr<Range>(Range::getClass(XML.getNode("Range1"), Sim));
range2 = shared_ptr<Range>(Range::getClass(XML.getNode("Range2"), Sim));
}
示例12: Vector
void
LBoundary::operator<<(const magnet::xml::Node& XML)
{
range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"),Sim));
localName = XML.getAttribute("Name");
_oscillationData._origin << XML.getNode("Origin");
_oscillationData._origin *= Sim->units.unitLength();
_diameter = Sim->_properties.getProperty(XML.getAttribute("Diameter"), Property::Units::Length());
if (_diameter->getMaxValue() == 0)
M_throw() << "Cannot have a boundary with a diameter of zero";
_oscillationData._amplitude = Vector();
_oscillationData._freq = 0;
_oscillationData._t_shift = 0;
const size_t data_count = XML.hasNode("Amplitude") + XML.hasAttribute("Frequency") + XML.hasAttribute("Phase");
if ((data_count != 3) && (data_count != 0))
M_throw() << "For oscillating walls you must have an Amplitude, Frequency, and Phase specified."
<< XML.getPath();
if (data_count == 3) {
_oscillationData._freq = XML.getAttribute("Frequency").as<double>() / Sim->units.unitTime();
_oscillationData._t_shift = XML.getAttribute("Phase").as<double>() * Sim->units.unitTime();
_oscillationData._amplitude << XML.getNode("Amplitude");
_oscillationData._amplitude *= Sim->units.unitLength();
}
_kT = 0;
if (XML.hasAttribute("kT")) {
if (data_count == 3)
M_throw() << "Cannot have both a thermalised wall and a oscillating wall"
<< XML.getPath();
_kT = XML.getAttribute("kT").as<double>() * Sim->units.unitEnergy();
}
if (_kT < 0)
M_throw() << "Temperature is less than zero" << XML.getPath();
for (magnet::xml::Node node = XML.findNode("Object"); node.valid(); ++node)
_objects.push_back(boundary::Object::getClass(node, Sim, _oscillationData));
if (_objects.empty())
M_throw() << "Boundary Locals must have at least one Object.\n" << XML.getPath();
}
示例13:
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));
}
示例14:
void
LOscillatingPlate::operator<<(const magnet::xml::Node& XML)
{
range = shared_ptr<IDRange>(IDRange::getClass(XML.getNode("IDRange"),Sim));
e = XML.getAttribute("Elasticity").as<double>();
nhat << XML.getNode("Norm");
nhat /= nhat.nrm();
rw0 << XML.getNode("Origin");
rw0 *= Sim->units.unitLength();
if (XML.hasAttribute("StrongPlate"))
strongPlate = XML.getAttribute("StrongPlate").as<double>();
omega0 = XML.getAttribute("Omega0").as<double>() / Sim->units.unitTime();
sigma = XML.getAttribute("Sigma").as<double>() * Sim->units.unitLength();
delta = XML.getAttribute("Delta").as<double>() * Sim->units.unitLength();
mass = XML.getAttribute("Mass").as<double>() * Sim->units.unitMass();
timeshift = XML.getAttribute("TimeShift").as<double>() * Sim->units.unitTime();
localName = XML.getAttribute("Name");
}
示例15:
Particle::Particle(const magnet::xml::Node& XML, unsigned long nID):
_ID(nID),
_peculiarTime(0.0),
_state(DEFAULT)
{
if (XML.hasAttribute("Static")) clearState(DYNAMIC);
_pos << XML.getNode("P");
_vel << XML.getNode("V");
}