本文整理汇总了C++中simtk::xml::Element::insertNodeAfter方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::insertNodeAfter方法的具体用法?C++ Element::insertNodeAfter怎么用?C++ Element::insertNodeAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simtk::xml::Element
的用法示例。
在下文中一共展示了Element::insertNodeAfter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFromXMLNode
// Handle conversion from older format
void VisibleObject::updateFromXMLNode(SimTK::Xml::Element& aNode, int versionNumber)
{
SimTK::Array_<SimTK::String> oldGeometryFiles;
if ( versionNumber < XMLDocument::getLatestVersion()){
if (versionNumber<20101){
SimTK::Xml::element_iterator visPropIter = aNode.element_begin("VisibleProperties");
// Get geometry files and Preferences if any and set them into
if (visPropIter!=aNode.element_end()){
// Move display_prference, and show_axes nodes up to VisibleObject
SimTK::Xml::element_iterator prefIter = visPropIter->element_begin("display_preference");
if (prefIter!= visPropIter->element_end()){
SimTK::Xml::Node moveNode = visPropIter->removeNode(prefIter);
aNode.insertNodeAfter(aNode.element_end(), moveNode);
}
SimTK::Xml::element_iterator showAxesIter = visPropIter->element_begin("show_axes");
if (showAxesIter!=aNode.element_end()){
SimTK::Xml::Node moveNode = visPropIter->removeNode(showAxesIter);
aNode.insertNodeAfter(aNode.element_end(), moveNode);
}
}
SimTK::Xml::element_iterator geometryIter = aNode.element_begin("geometry_files");
string propValue="";
bool hasPieces=false;
if (geometryIter!= aNode.element_end()){
geometryIter->getValueAs(oldGeometryFiles);
}
}
}
Object::updateFromXMLNode(aNode, versionNumber);
if (oldGeometryFiles.size()>0){
for(unsigned i=0; i< oldGeometryFiles.size(); i++)
setGeometryFileName(i, oldGeometryFiles[i]);
}
}
示例2: updateFromXMLNode
/*virtual*/
void Marker::updateFromXMLNode(SimTK::Xml::Element& aNode, int versionNumber)
{
if (versionNumber < XMLDocument::getLatestVersion()){
if (versionNumber < 30501) {
// Parse name of Body under <body>node
SimTK::Xml::element_iterator bIter = aNode.element_begin("body");
SimTK::String bName = bIter->getValue();
// Create nodes for new layout
SimTK::Xml::Element connectorsElement("connectors");
SimTK::Xml::Element frameElement("Connector_PhysicalFrame_");
connectorsElement.insertNodeAfter(connectorsElement.node_end(), frameElement);
frameElement.setAttributeValue("name", "parent_frame");
SimTK::Xml::Element connecteeElement("connectee_name");
// Markers in pre-4.0 models are necessarily 1 level deep
// (model, markers), and Bodies were necessarily 1 level deep;
// here we create the correct relative path (accounting for sets
// being components).
bName = XMLDocument::updateConnecteePath30517("bodyset", bName);
connecteeElement.setValue(bName);
frameElement.insertNodeAfter(frameElement.node_end(), connecteeElement);
aNode.insertNodeAfter(bIter, connectorsElement);
aNode.eraseNode(bIter);
}
}
// Call base class now assuming _node has been corrected for current version
Super::updateFromXMLNode(aNode, versionNumber);
}
示例3: updateFromXMLNode
void Body::updateFromXMLNode(SimTK::Xml::Element& aNode, int versionNumber)
{
if (versionNumber < XMLDocument::getLatestVersion()) {
if (versionNumber < 30500) {
SimTK::Vec6 newInertia(1.0, 1.0, 1.0, 0., 0., 0.);
std::string inertiaComponents[] = { "inertia_xx", "inertia_yy", "inertia_zz", "inertia_xy", "inertia_xz", "inertia_yz" };
for (int i = 0; i < 6; ++i) {
SimTK::Xml::element_iterator iIter = aNode.element_begin(inertiaComponents[i]);
if (iIter != aNode.element_end()) {
newInertia[i] = iIter->getValueAs<double>();
aNode.removeNode(iIter);
}
}
std::ostringstream strs;
for (int i = 0; i < 6; ++i) {
strs << newInertia[i];
if (i < 5) strs << " ";
}
std::string strInertia = strs.str();
SimTK::Xml::Element inertiaNode("inertia", strInertia);
aNode.insertNodeAfter(aNode.element_end(), inertiaNode);
}
}
Super::updateFromXMLNode(aNode, versionNumber);
}
示例4: writeDefaultObjects
void XMLDocument::writeDefaultObjects(SimTK::Xml::Element& elmt)
{
if (_defaultObjects.getSize()==0) return;
// Make node for "defaults"
SimTK::Xml::Element defaultsElement("defaults");
elmt.insertNodeAfter(elmt.node_end(), defaultsElement);
for(int i=0; i < _defaultObjects.getSize(); i++){
_defaultObjects.get(i)->updateXMLNode(defaultsElement);
}
}
示例5: updateFromXMLNode
//_____________________________________________________________________________
// Override default implementation by object to intercept and fix the XML node
// underneath the model to match current version.
void Muscle::updateFromXMLNode(SimTK::Xml::Element& aNode, int versionNumber)
{
if ( versionNumber < XMLDocument::getLatestVersion()) {
if (Object::getDebugLevel()>=1)
cout << "Updating Muscle object to latest format..." << endl;
if (versionNumber <= 20301){
SimTK::Xml::element_iterator pathIter =
aNode.element_begin("GeometryPath");
if (pathIter != aNode.element_end()) {
XMLDocument::renameChildNode(*pathIter, "MusclePointSet", "PathPointSet");
XMLDocument::renameChildNode(*pathIter, "MuscleWrapSet", "PathWrapSet");
} else { // There was no GeometryPath, just MusclePointSet
SimTK::Xml::element_iterator musclePointSetIter = aNode.element_begin("MusclePointSet");
bool pathPointSetFound=false;
if (musclePointSetIter != aNode.element_end()){
XMLDocument::renameChildNode(aNode, "MusclePointSet", "PathPointSet");
pathPointSetFound=true;
}
bool pathWrapSetFound=false;
SimTK::Xml::element_iterator muscleWrapSetIter = aNode.element_begin("MuscleWrapSet");
if (muscleWrapSetIter != aNode.element_end()){
XMLDocument::renameChildNode(aNode, "MuscleWrapSet", "PathWrapSet");
pathWrapSetFound=true;
}
// Now create a "GeometryPath" node and move MusclePointSet & MuscleWrapSet under it
SimTK::Xml::Element myPathElement("GeometryPath");
SimTK::Xml::Node moveNode;
if (pathPointSetFound) {
SimTK::Xml::element_iterator pathPointSetIter = aNode.element_begin("PathPointSet");
moveNode = aNode.removeNode(pathPointSetIter);
myPathElement.insertNodeAfter(myPathElement.element_end(),moveNode);
}
if (pathWrapSetFound) {
SimTK::Xml::element_iterator pathWrapSetIter = aNode.element_begin("PathWrapSet");
moveNode = aNode.removeNode(pathWrapSetIter);
myPathElement.insertNodeAfter(myPathElement.element_end(),moveNode);
}
aNode.insertNodeAfter(aNode.element_end(), myPathElement);
}
XMLDocument::renameChildNode(aNode, "pennation_angle", "pennation_angle_at_optimal");
}
}
// Call base class now assuming aNode has been corrected for current version
Super::updateFromXMLNode(aNode, versionNumber);
}
示例6: updateFromXMLNode
/*virtual*/
void Marker::updateFromXMLNode(SimTK::Xml::Element& aNode, int versionNumber)
{
if (versionNumber < XMLDocument::getLatestVersion()){
if (versionNumber < 30501) {
// Parse name of Body under <body>node
SimTK::Xml::element_iterator bIter = aNode.element_begin("body");
SimTK::String bName = bIter->getValue();
// Create nodes for new layout
SimTK::Xml::Element connectorsElement("connectors");
SimTK::Xml::Element frameElement("Connector_PhysicalFrame_");
connectorsElement.insertNodeAfter(connectorsElement.node_end(), frameElement);
frameElement.setAttributeValue("name", "reference_frame");
SimTK::Xml::Element connecteeElement("connectee_name");
connecteeElement.setValue(bName);
frameElement.insertNodeAfter(frameElement.node_end(), connecteeElement);
aNode.insertNodeAfter(bIter, connectorsElement);
aNode.eraseNode(bIter);
}
}
// Call base class now assuming _node has been corrected for current version
Object::updateFromXMLNode(aNode, versionNumber);
}
示例7: updateFromXMLNode
//.........这里部分代码省略.........
// now append updated frames to the property list for
// both parent and child
XMLDocument::addPhysicalOffsetFrame30505_30517(aNode, parentFrameName+"_offset",
parentFrameName, location_in_parent, orientation_in_parent);
parentNameElt->setValue(parentFrameName + "_offset");
XMLDocument::addPhysicalOffsetFrame30505_30517(aNode, childFrameName + "_offset",
childFrameName, location_in_child, orientation_in_child);
childNameElt->setValue(childFrameName + "_offset");
}
// Version 30507 replaced Joint's CoordinateSet with a "coordinates"
// list property.
if (documentVersion < 30507) {
if (aNode.hasElement("CoordinateSet")) {
auto coordSetIter = aNode.element_begin("CoordinateSet");
if (coordSetIter->hasElement("objects")) {
auto coordIter = coordSetIter->getRequiredElement("objects")
.element_begin("Coordinate");
if (coordIter != aNode.element_end()) {
// A "CoordinateSet" element exists, it contains an
// "objects" element, and the "objects" element contains
// at least one "Coordinate" element.
// Create an element for the new layout.
Xml::Element coordinatesElement("coordinates");
// Copy all "Coordinate" elements from the old layout.
while (coordIter != aNode.element_end()) {
coordinatesElement.appendNode(coordIter->clone());
++coordIter;
}
// Insert new "coordinates" element.
aNode.insertNodeAfter(coordSetIter, coordinatesElement);
}
}
// Remove old "CoordinateSet" element.
aNode.eraseNode(coordSetIter);
}
}
// Version 30514 removed the user-facing "reverse" property from Joint.
// The parent and child frames are swapped if a "reverse" element is
// found and its value is "true".
if (documentVersion < 30514) {
auto reverseElt = aNode.element_begin("reverse");
if (reverseElt != aNode.element_end()) {
bool swapFrames = false;
reverseElt->getValue().tryConvertToBool(swapFrames);
if (swapFrames) {
std::string oldParentFrameName = "";
std::string oldChildFrameName = "";
// Find names of parent and child frames. If more than one
// "parent_frame" or "child_frame" element exists, keep the
// first one. The "parent_frame" and "child_frame" elements
// may be listed in either order.
SimTK::Xml::element_iterator connectorsNode =
aNode.element_begin("connectors");
SimTK::Xml::element_iterator connectorElt = connectorsNode->
element_begin("Connector_PhysicalFrame_");
SimTK::Xml::element_iterator connecteeNameElt;