97 template <IDX_t IDX, when_t when>
101 ASSERT(args.size() == 1 + 1 + 1);
116 unsigned uLabel = unsigned((*arg1)());
118 const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
121 <<
"(" << uLabel <<
"): "
122 "unable to find StructNode(" << uLabel <<
")"
158 template <IDX_t IDX, when_t when>
162 ASSERT(args.size() == 1 + 2 + 1);
182 unsigned uLabel1 = unsigned((*arg1)());
183 unsigned uLabel2 = unsigned((*arg2)());
185 const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
188 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
189 "unable to find StructNode(" << uLabel1 <<
")"
194 const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
197 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
198 "unable to find StructNode(" << uLabel2 <<
")"
234 template <IDX_t IDX, when_t when>
238 ASSERT(args.size() == 1 + 2 + 1);
258 unsigned uLabel1 = unsigned((*arg1)());
259 unsigned uLabel2 = unsigned((*arg2)());
261 const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
264 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
265 "unable to find StructNode(" << uLabel1 <<
")"
270 const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
273 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
274 "unable to find StructNode(" << uLabel2 <<
")"
291 if (dd <= std::numeric_limits<doublereal>::epsilon()) {
293 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
311 template <IDX_t IDX, when_t when>
315 ASSERT(args.size() == 1 + 1 + 1);
330 unsigned uLabel = unsigned((*arg1)());
332 const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
335 <<
"(" << uLabel <<
"): "
336 "unable to find StructNode(" << uLabel <<
")"
368 template <IDX_t IDX, when_t when>
372 ASSERT(args.size() == 1 + 2 + 1);
392 unsigned uLabel1 = unsigned((*arg1)());
393 unsigned uLabel2 = unsigned((*arg2)());
395 const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
398 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
399 "unable to find StructNode(" << uLabel1 <<
")"
404 const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
407 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
408 "unable to find StructNode(" << uLabel2 <<
")"
440 template <IDX_t IDX, when_t when>
444 ASSERT(args.size() == 1 + 1 + 1);
459 unsigned uLabel = unsigned((*arg1)());
461 const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
464 <<
"(" << uLabel <<
"): "
465 "unable to find StructNode(" << uLabel <<
")"
501 template <IDX_t IDX, when_t when>
505 ASSERT(args.size() == 1 + 2 + 1);
525 unsigned uLabel1 = unsigned((*arg1)());
526 unsigned uLabel2 = unsigned((*arg2)());
528 const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
531 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
532 "unable to find StructNode(" << uLabel1 <<
")"
537 const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
540 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
541 "unable to find StructNode(" << uLabel2 <<
")"
577 template <IDX_t IDX, when_t when>
581 ASSERT(args.size() == 1 + 1 + 1);
596 unsigned uLabel = unsigned((*arg1)());
598 const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
601 <<
"(" << uLabel <<
"): "
602 "unable to find StructNode(" << uLabel <<
")"
638 template <IDX_t IDX, when_t when>
642 ASSERT(args.size() == 1 + 2 + 1);
662 unsigned uLabel1 = unsigned((*arg1)());
663 unsigned uLabel2 = unsigned((*arg2)());
665 const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
668 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
669 "unable to find StructNode(" << uLabel1 <<
")"
674 const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
677 <<
"(" << uLabel1 <<
"," << uLabel2 <<
"): "
678 "unable to find StructNode(" << uLabel2 <<
")"
718 ASSERT(args.size() == 1 + 2 + 2);
737 ASSERT((*arg_label)() >= 0);
739 unsigned uLabel = unsigned((*arg_label)());
744 pDC = (*arg_dm)()->GetMBDynParser().GetDrive(uLabel);
746 silent_cerr(
"model::drive(" << uLabel <<
") not available"
753 silent_cerr(
"model::drivep(" << uLabel <<
") not differentiable"
768 *out = pDC->
dGetP(val);
771 *out = pDC->
dGet(val);
783 ASSERT(args.size() == 1 + 2 + 1);
798 int order = (*arg2)();
804 if (order < 0 || order > 1) {
805 silent_cerr(
"model::sf invalid derivative order " << order << std::endl);
810 *out = (*(*sf)())(v);
815 silent_cerr(
"model::sf "
816 "order=" << order <<
" only allowed "
817 "with differentiable scalar functions"
834 ASSERT(args.size() == 1 + 2 + 4);
846 unsigned int idx = 0;
857 int iLabel = (*arg_label)();
861 std::string v = (*arg_val)();
872 silent_cerr(
"model::node: invalid node label " << iLabel << std::endl);
875 unsigned uLabel = unsigned(iLabel);
879 silent_cerr(
"model::node: unable to find " <<
psNodeNames[type] <<
"(" << uLabel <<
")" << std::endl);
885 silent_cerr(
"model::node: " <<
psNodeNames[type] <<
"(" << dynamic_cast<const Node *>(pNode)->GetLabel() <<
"): invalid private data \"" << v <<
"\"" << std::endl);
890 (*arg_ptr)() = pNode;
910 std::string v = (*arg_val)();
918 silent_cerr(
"model::node: " <<
psNodeNames[type] <<
"(" << dynamic_cast<const Node *>(pNode)->GetLabel() <<
"): invalid private data \"" << v <<
"\"" << std::endl);
932 template <
bool unique>
936 ASSERT(args.size() == 1 + 2 - unique + 4);
938 static const unsigned int out_idx = 0;
939 static const unsigned int val_idx = 2 - (unique ? 1 : 0);
940 static const unsigned int type_idx = 3 - (unique ? 1 : 0);
941 static const unsigned int ptr_idx = 4 - (unique ? 1 : 0);
942 static const unsigned int idx_idx = 5 - (unique ? 1 : 0);
943 static const unsigned int dm_idx = 6 - (unique ? 1 : 0);
949 unsigned int idx = 0;
959 bool bLabelConst(
true);
961 static const unsigned int label_idx = 1;
966 int iLabel = (*arg_label)();
968 silent_cerr(
"model::element: invalid element label " << iLabel << std::endl);
971 uLabel = unsigned(iLabel);
978 std::string v = (*arg_val)();
993 silent_cerr(
"model::element: unable to find " <<
psElemNames[type] << std::endl);
996 silent_cerr(
"model::element: unable to find " <<
psElemNames[type] <<
"(" << uLabel <<
")" << std::endl);
1001 idx = pElem->iGetPrivDataIdx(v.c_str());
1004 silent_cerr(
"model::element: " <<
psElemNames[type] <<
": invalid private data \"" << v <<
"\"" << std::endl);
1007 silent_cerr(
"model::element: " <<
psElemNames[type] <<
"(" << dynamic_cast<const Elem *>(pElem)->GetLabel() <<
"): invalid private data \"" << v <<
"\"" << std::endl);
1012 if (unique || bLabelConst) {
1013 (*arg_ptr)() = pElem;
1033 std::string v = (*arg_val)();
1042 silent_cerr(
"model::element: " <<
psElemNames[type] <<
": invalid private data \"" << v <<
"\"" << std::endl);
1045 silent_cerr(
"model::element: " <<
psElemNames[type] <<
"(" << dynamic_cast<const Elem *>(pElem)->GetLabel() <<
"): invalid private data \"" << v <<
"\"" << std::endl);
1063 ASSERT(args.size() == 1 + 1 + 2);
1072 const std::string& name = (*arg_name)();
1081 silent_cerr(
"model::current(" << name <<
") not defined" << std::endl);
1085 *out = value.GetReal();
1097 f->
fname =
"position";
1099 f->
args.resize(1 + 1 + 1);
1103 f->
f = position<NORM, CURR>;
1106 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1107 silent_cerr(
"model namespace: "
1108 "unable to insert handler "
1109 "for function " << f->
fname << std::endl);
1115 f->
fname =
"position2";
1117 f->
args.resize(1 + 1 + 1);
1121 f->
f = position<SQUARE, CURR>;
1124 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1125 silent_cerr(
"model namespace: "
1126 "unable to insert handler "
1127 "for function " << f->
fname << std::endl);
1133 f->
fname =
"xposition";
1135 f->
args.resize(1 + 1 + 1);
1139 f->
f = position<IDX1, CURR>;
1142 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1143 silent_cerr(
"model namespace: "
1144 "unable to insert handler "
1145 "for function " << f->
fname << std::endl);
1151 f->
fname =
"yposition";
1153 f->
args.resize(1 + 1 + 1);
1157 f->
f = position<IDX2, CURR>;
1160 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1161 silent_cerr(
"model namespace: "
1162 "unable to insert handler "
1163 "for function " << f->
fname << std::endl);
1169 f->
fname =
"zposition";
1171 f->
args.resize(1 + 1 + 1);
1175 f->
f = position<IDX3, CURR>;
1178 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1179 silent_cerr(
"model namespace: "
1180 "unable to insert handler "
1181 "for function " << f->
fname << std::endl);
1187 f->
fname =
"distance";
1189 f->
args.resize(1 + 2 + 1);
1194 f->
f = distance<NORM, CURR>;
1197 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1198 silent_cerr(
"model namespace: "
1199 "unable to insert handler "
1200 "for function " << f->
fname << std::endl);
1206 f->
fname =
"distance2";
1208 f->
args.resize(1 + 2 + 1);
1213 f->
f = distance<SQUARE, CURR>;
1216 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1217 silent_cerr(
"model namespace: "
1218 "unable to insert handler "
1219 "for function " << f->
fname << std::endl);
1225 f->
fname =
"xdistance";
1227 f->
args.resize(1 + 2 + 1);
1232 f->
f = distance<IDX1, CURR>;
1235 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1236 silent_cerr(
"model namespace: "
1237 "unable to insert handler "
1238 "for function " << f->
fname << std::endl);
1244 f->
fname =
"ydistance";
1246 f->
args.resize(1 + 2 + 1);
1251 f->
f = distance<IDX2, CURR>;
1254 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1255 silent_cerr(
"model namespace: "
1256 "unable to insert handler "
1257 "for function " << f->
fname << std::endl);
1263 f->
fname =
"zdistance";
1265 f->
args.resize(1 + 2 + 1);
1270 f->
f = distance<IDX3, CURR>;
1273 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1274 silent_cerr(
"model namespace: "
1275 "unable to insert handler "
1276 "for function " << f->
fname << std::endl);
1282 f->
fname =
"xunitvec";
1284 f->
args.resize(1 + 2 + 1);
1289 f->
f = unitvec<IDX1, CURR>;
1292 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1293 silent_cerr(
"model namespace: "
1294 "unable to insert handler "
1295 "for function " << f->
fname << std::endl);
1301 f->
fname =
"yunitvec";
1303 f->
args.resize(1 + 2 + 1);
1308 f->
f = unitvec<IDX2, CURR>;
1311 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1312 silent_cerr(
"model namespace: "
1313 "unable to insert handler "
1314 "for function " << f->
fname << std::endl);
1320 f->
fname =
"zunitvec";
1322 f->
args.resize(1 + 2 + 1);
1327 f->
f = unitvec<IDX3, CURR>;
1330 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1331 silent_cerr(
"model namespace: "
1332 "unable to insert handler "
1333 "for function " << f->
fname << std::endl);
1341 f->
args.resize(1 + 1 + 1);
1345 f->
f = angle<NORM, CURR>;
1348 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1349 silent_cerr(
"model namespace: "
1350 "unable to insert handler "
1351 "for function " << f->
fname << std::endl);
1357 f->
fname =
"xangle";
1359 f->
args.resize(1 + 1 + 1);
1363 f->
f = angle<IDX1, CURR>;
1366 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1367 silent_cerr(
"model namespace: "
1368 "unable to insert handler "
1369 "for function " << f->
fname << std::endl);
1375 f->
fname =
"yangle";
1377 f->
args.resize(1 + 1 + 1);
1381 f->
f = angle<IDX2, CURR>;
1384 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1385 silent_cerr(
"model namespace: "
1386 "unable to insert handler "
1387 "for function " << f->
fname << std::endl);
1393 f->
fname =
"zangle";
1395 f->
args.resize(1 + 1 + 1);
1399 f->
f = angle<IDX3, CURR>;
1402 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1403 silent_cerr(
"model namespace: "
1404 "unable to insert handler "
1405 "for function " << f->
fname << std::endl);
1411 f->
fname =
"anglerel";
1413 f->
args.resize(1 + 2 + 1);
1418 f->
f = anglerel<NORM, CURR>;
1421 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1422 silent_cerr(
"model namespace: "
1423 "unable to insert handler "
1424 "for function " << f->
fname << std::endl);
1430 f->
fname =
"xanglerel";
1432 f->
args.resize(1 + 2 + 1);
1437 f->
f = anglerel<IDX1, CURR>;
1440 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1441 silent_cerr(
"model namespace: "
1442 "unable to insert handler "
1443 "for function " << f->
fname << std::endl);
1449 f->
fname =
"yanglerel";
1451 f->
args.resize(1 + 2 + 1);
1456 f->
f = anglerel<IDX2, CURR>;
1459 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1460 silent_cerr(
"model namespace: "
1461 "unable to insert handler "
1462 "for function " << f->
fname << std::endl);
1468 f->
fname =
"zanglerel";
1470 f->
args.resize(1 + 2 + 1);
1475 f->
f = anglerel<IDX3, CURR>;
1478 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1479 silent_cerr(
"model namespace: "
1480 "unable to insert handler "
1481 "for function " << f->
fname << std::endl);
1487 f->
fname =
"velocity";
1489 f->
args.resize(1 + 1 + 1);
1493 f->
f = velocity<NORM, CURR>;
1496 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1497 silent_cerr(
"model namespace: "
1498 "unable to insert handler "
1499 "for function " << f->
fname << std::endl);
1505 f->
fname =
"velocity2";
1507 f->
args.resize(1 + 1 + 1);
1511 f->
f = velocity<SQUARE, CURR>;
1514 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1515 silent_cerr(
"model namespace: "
1516 "unable to insert handler "
1517 "for function " << f->
fname << std::endl);
1523 f->
fname =
"xvelocity";
1525 f->
args.resize(1 + 1 + 1);
1529 f->
f = velocity<IDX1, CURR>;
1532 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1533 silent_cerr(
"model namespace: "
1534 "unable to insert handler "
1535 "for function " << f->
fname << std::endl);
1541 f->
fname =
"yvelocity";
1543 f->
args.resize(1 + 1 + 1);
1547 f->
f = velocity<IDX2, CURR>;
1550 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1551 silent_cerr(
"model namespace: "
1552 "unable to insert handler "
1553 "for function " << f->
fname << std::endl);
1559 f->
fname =
"zvelocity";
1561 f->
args.resize(1 + 1 + 1);
1565 f->
f = velocity<IDX3, CURR>;
1568 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1569 silent_cerr(
"model namespace: "
1570 "unable to insert handler "
1571 "for function " << f->
fname << std::endl);
1579 f->
args.resize(1 + 2 + 1);
1584 f->
f = vrel<NORM, CURR>;
1587 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1588 silent_cerr(
"model namespace: "
1589 "unable to insert handler "
1590 "for function " << f->
fname << std::endl);
1598 f->
args.resize(1 + 2 + 1);
1603 f->
f = vrel<SQUARE, CURR>;
1606 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1607 silent_cerr(
"model namespace: "
1608 "unable to insert handler "
1609 "for function " << f->
fname << std::endl);
1617 f->
args.resize(1 + 2 + 1);
1622 f->
f = vrel<IDX1, CURR>;
1625 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1626 silent_cerr(
"model namespace: "
1627 "unable to insert handler "
1628 "for function " << f->
fname << std::endl);
1636 f->
args.resize(1 + 2 + 1);
1641 f->
f = vrel<IDX2, CURR>;
1644 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1645 silent_cerr(
"model namespace: "
1646 "unable to insert handler "
1647 "for function " << f->
fname << std::endl);
1655 f->
args.resize(1 + 2 + 1);
1660 f->
f = vrel<IDX3, CURR>;
1663 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1664 silent_cerr(
"model namespace: "
1665 "unable to insert handler "
1666 "for function " << f->
fname << std::endl);
1672 f->
fname =
"angvel";
1674 f->
args.resize(1 + 1 + 1);
1678 f->
f = angvel<NORM, CURR>;
1681 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1682 silent_cerr(
"model namespace: "
1683 "unable to insert handler "
1684 "for function " << f->
fname << std::endl);
1690 f->
fname =
"angvel2";
1692 f->
args.resize(1 + 1 + 1);
1696 f->
f = angvel<SQUARE, CURR>;
1699 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1700 silent_cerr(
"model namespace: "
1701 "unable to insert handler "
1702 "for function " << f->
fname << std::endl);
1708 f->
fname =
"xangvel";
1710 f->
args.resize(1 + 1 + 1);
1714 f->
f = angvel<IDX1, CURR>;
1717 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1718 silent_cerr(
"model namespace: "
1719 "unable to insert handler "
1720 "for function " << f->
fname << std::endl);
1726 f->
fname =
"yangvel";
1728 f->
args.resize(1 + 1 + 1);
1732 f->
f = angvel<IDX2, CURR>;
1735 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1736 silent_cerr(
"model namespace: "
1737 "unable to insert handler "
1738 "for function " << f->
fname << std::endl);
1744 f->
fname =
"zangvel";
1746 f->
args.resize(1 + 1 + 1);
1750 f->
f = angvel<IDX3, CURR>;
1753 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1754 silent_cerr(
"model namespace: "
1755 "unable to insert handler "
1756 "for function " << f->
fname << std::endl);
1762 f->
fname =
"angvrel";
1764 f->
args.resize(1 + 2 + 1);
1769 f->
f = angvrel<NORM, CURR>;
1772 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1773 silent_cerr(
"model namespace: "
1774 "unable to insert handler "
1775 "for function " << f->
fname << std::endl);
1781 f->
fname =
"angvrel2";
1783 f->
args.resize(1 + 2 + 1);
1788 f->
f = angvrel<SQUARE, CURR>;
1791 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1792 silent_cerr(
"model namespace: "
1793 "unable to insert handler "
1794 "for function " << f->
fname << std::endl);
1800 f->
fname =
"xangvrel";
1802 f->
args.resize(1 + 2 + 1);
1807 f->
f = angvrel<IDX1, CURR>;
1810 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1811 silent_cerr(
"model namespace: "
1812 "unable to insert handler "
1813 "for function " << f->
fname << std::endl);
1819 f->
fname =
"yangvrel";
1821 f->
args.resize(1 + 2 + 1);
1826 f->
f = angvrel<IDX2, CURR>;
1829 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1830 silent_cerr(
"model namespace: "
1831 "unable to insert handler "
1832 "for function " << f->
fname << std::endl);
1838 f->
fname =
"zangvrel";
1840 f->
args.resize(1 + 2 + 1);
1845 f->
f = angvrel<IDX3, CURR>;
1848 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1849 silent_cerr(
"model namespace: "
1850 "unable to insert handler "
1851 "for function " << f->
fname << std::endl);
1857 f->
fname =
"position_prev";
1859 f->
args.resize(1 + 1 + 1);
1863 f->
f = position<NORM, PREV>;
1866 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1867 silent_cerr(
"model namespace: "
1868 "unable to insert handler "
1869 "for function " << f->
fname << std::endl);
1875 f->
fname =
"position2_prev";
1877 f->
args.resize(1 + 1 + 1);
1881 f->
f = position<SQUARE, PREV>;
1884 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1885 silent_cerr(
"model namespace: "
1886 "unable to insert handler "
1887 "for function " << f->
fname << std::endl);
1893 f->
fname =
"xposition_prev";
1895 f->
args.resize(1 + 1 + 1);
1899 f->
f = position<IDX1, PREV>;
1902 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1903 silent_cerr(
"model namespace: "
1904 "unable to insert handler "
1905 "for function " << f->
fname << std::endl);
1911 f->
fname =
"yposition_prev";
1913 f->
args.resize(1 + 1 + 1);
1917 f->
f = position<IDX2, PREV>;
1920 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1921 silent_cerr(
"model namespace: "
1922 "unable to insert handler "
1923 "for function " << f->
fname << std::endl);
1929 f->
fname =
"zposition_prev";
1931 f->
args.resize(1 + 1 + 1);
1935 f->
f = position<IDX3, PREV>;
1938 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1939 silent_cerr(
"model namespace: "
1940 "unable to insert handler "
1941 "for function " << f->
fname << std::endl);
1947 f->
fname =
"distance_prev";
1949 f->
args.resize(1 + 2 + 1);
1954 f->
f = distance<NORM, PREV>;
1957 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1958 silent_cerr(
"model namespace: "
1959 "unable to insert handler "
1960 "for function " << f->
fname << std::endl);
1966 f->
fname =
"distance2_prev";
1968 f->
args.resize(1 + 2 + 1);
1973 f->
f = distance<SQUARE, PREV>;
1976 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1977 silent_cerr(
"model namespace: "
1978 "unable to insert handler "
1979 "for function " << f->
fname << std::endl);
1985 f->
fname =
"xdistance_prev";
1987 f->
args.resize(1 + 2 + 1);
1992 f->
f = distance<IDX1, PREV>;
1995 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
1996 silent_cerr(
"model namespace: "
1997 "unable to insert handler "
1998 "for function " << f->
fname << std::endl);
2004 f->
fname =
"ydistance_prev";
2006 f->
args.resize(1 + 2 + 1);
2011 f->
f = distance<IDX2, PREV>;
2014 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2015 silent_cerr(
"model namespace: "
2016 "unable to insert handler "
2017 "for function " << f->
fname << std::endl);
2023 f->
fname =
"zdistance_prev";
2025 f->
args.resize(1 + 2 + 1);
2030 f->
f = distance<IDX3, PREV>;
2033 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2034 silent_cerr(
"model namespace: "
2035 "unable to insert handler "
2036 "for function " << f->
fname << std::endl);
2042 f->
fname =
"xunitvec_prev";
2044 f->
args.resize(1 + 2 + 1);
2049 f->
f = unitvec<IDX1, PREV>;
2052 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2053 silent_cerr(
"model namespace: "
2054 "unable to insert handler "
2055 "for function " << f->
fname << std::endl);
2061 f->
fname =
"yunitvec_prev";
2063 f->
args.resize(1 + 2 + 1);
2068 f->
f = unitvec<IDX2, PREV>;
2071 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2072 silent_cerr(
"model namespace: "
2073 "unable to insert handler "
2074 "for function " << f->
fname << std::endl);
2080 f->
fname =
"zunitvec_prev";
2082 f->
args.resize(1 + 2 + 1);
2087 f->
f = unitvec<IDX3, PREV>;
2090 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2091 silent_cerr(
"model namespace: "
2092 "unable to insert handler "
2093 "for function " << f->
fname << std::endl);
2099 f->
fname =
"angle_prev";
2101 f->
args.resize(1 + 1 + 1);
2105 f->
f = angle<NORM, PREV>;
2108 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2109 silent_cerr(
"model namespace: "
2110 "unable to insert handler "
2111 "for function " << f->
fname << std::endl);
2117 f->
fname =
"xangle_prev";
2119 f->
args.resize(1 + 1 + 1);
2123 f->
f = angle<IDX1, PREV>;
2126 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2127 silent_cerr(
"model namespace: "
2128 "unable to insert handler "
2129 "for function " << f->
fname << std::endl);
2135 f->
fname =
"yangle_prev";
2137 f->
args.resize(1 + 1 + 1);
2141 f->
f = angle<IDX2, PREV>;
2144 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2145 silent_cerr(
"model namespace: "
2146 "unable to insert handler "
2147 "for function " << f->
fname << std::endl);
2153 f->
fname =
"zangle_prev";
2155 f->
args.resize(1 + 1 + 1);
2159 f->
f = angle<IDX3, PREV>;
2162 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2163 silent_cerr(
"model namespace: "
2164 "unable to insert handler "
2165 "for function " << f->
fname << std::endl);
2171 f->
fname =
"anglerel_prev";
2173 f->
args.resize(1 + 2 + 1);
2178 f->
f = anglerel<NORM, PREV>;
2181 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2182 silent_cerr(
"model namespace: "
2183 "unable to insert handler "
2184 "for function " << f->
fname << std::endl);
2190 f->
fname =
"xanglerel_prev";
2192 f->
args.resize(1 + 2 + 1);
2197 f->
f = anglerel<IDX1, PREV>;
2200 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2201 silent_cerr(
"model namespace: "
2202 "unable to insert handler "
2203 "for function " << f->
fname << std::endl);
2209 f->
fname =
"yanglerel_prev";
2211 f->
args.resize(1 + 2 + 1);
2216 f->
f = anglerel<IDX2, PREV>;
2219 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2220 silent_cerr(
"model namespace: "
2221 "unable to insert handler "
2222 "for function " << f->
fname << std::endl);
2228 f->
fname =
"zanglerel_prev";
2230 f->
args.resize(1 + 2 + 1);
2235 f->
f = anglerel<IDX3, PREV>;
2238 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2239 silent_cerr(
"model namespace: "
2240 "unable to insert handler "
2241 "for function " << f->
fname << std::endl);
2247 f->
fname =
"velocity_prev";
2249 f->
args.resize(1 + 1 + 1);
2253 f->
f = velocity<NORM, PREV>;
2256 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2257 silent_cerr(
"model namespace: "
2258 "unable to insert handler "
2259 "for function " << f->
fname << std::endl);
2265 f->
fname =
"velocity2_prev";
2267 f->
args.resize(1 + 1 + 1);
2271 f->
f = velocity<SQUARE, PREV>;
2274 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2275 silent_cerr(
"model namespace: "
2276 "unable to insert handler "
2277 "for function " << f->
fname << std::endl);
2283 f->
fname =
"xvelocity_prev";
2285 f->
args.resize(1 + 1 + 1);
2289 f->
f = velocity<IDX1, PREV>;
2292 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2293 silent_cerr(
"model namespace: "
2294 "unable to insert handler "
2295 "for function " << f->
fname << std::endl);
2301 f->
fname =
"yvelocity_prev";
2303 f->
args.resize(1 + 1 + 1);
2307 f->
f = velocity<IDX2, PREV>;
2310 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2311 silent_cerr(
"model namespace: "
2312 "unable to insert handler "
2313 "for function " << f->
fname << std::endl);
2319 f->
fname =
"zvelocity_prev";
2321 f->
args.resize(1 + 1 + 1);
2325 f->
f = velocity<IDX3, PREV>;
2328 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2329 silent_cerr(
"model namespace: "
2330 "unable to insert handler "
2331 "for function " << f->
fname << std::endl);
2337 f->
fname =
"vrel_prev";
2339 f->
args.resize(1 + 2 + 1);
2344 f->
f = vrel<NORM, PREV>;
2347 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2348 silent_cerr(
"model namespace: "
2349 "unable to insert handler "
2350 "for function " << f->
fname << std::endl);
2356 f->
fname =
"vrel2_prev";
2358 f->
args.resize(1 + 2 + 1);
2363 f->
f = vrel<SQUARE, PREV>;
2366 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2367 silent_cerr(
"model namespace: "
2368 "unable to insert handler "
2369 "for function " << f->
fname << std::endl);
2375 f->
fname =
"xvrel_prev";
2377 f->
args.resize(1 + 2 + 1);
2382 f->
f = vrel<IDX1, PREV>;
2385 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2386 silent_cerr(
"model namespace: "
2387 "unable to insert handler "
2388 "for function " << f->
fname << std::endl);
2394 f->
fname =
"yvrel_prev";
2396 f->
args.resize(1 + 2 + 1);
2401 f->
f = vrel<IDX2, PREV>;
2404 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2405 silent_cerr(
"model namespace: "
2406 "unable to insert handler "
2407 "for function " << f->
fname << std::endl);
2413 f->
fname =
"zvrel_prev";
2415 f->
args.resize(1 + 2 + 1);
2420 f->
f = vrel<IDX3, PREV>;
2423 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2424 silent_cerr(
"model namespace: "
2425 "unable to insert handler "
2426 "for function " << f->
fname << std::endl);
2432 f->
fname =
"angvel_prev";
2434 f->
args.resize(1 + 1 + 1);
2438 f->
f = angvel<NORM, PREV>;
2441 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2442 silent_cerr(
"model namespace: "
2443 "unable to insert handler "
2444 "for function " << f->
fname << std::endl);
2450 f->
fname =
"angvel2_prev";
2452 f->
args.resize(1 + 1 + 1);
2456 f->
f = angvel<SQUARE, PREV>;
2459 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2460 silent_cerr(
"model namespace: "
2461 "unable to insert handler "
2462 "for function " << f->
fname << std::endl);
2468 f->
fname =
"xangvel_prev";
2470 f->
args.resize(1 + 1 + 1);
2474 f->
f = angvel<IDX1, PREV>;
2477 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2478 silent_cerr(
"model namespace: "
2479 "unable to insert handler "
2480 "for function " << f->
fname << std::endl);
2486 f->
fname =
"yangvel_prev";
2488 f->
args.resize(1 + 1 + 1);
2492 f->
f = angvel<IDX2, PREV>;
2495 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2496 silent_cerr(
"model namespace: "
2497 "unable to insert handler "
2498 "for function " << f->
fname << std::endl);
2504 f->
fname =
"zangvel_prev";
2506 f->
args.resize(1 + 1 + 1);
2510 f->
f = angvel<IDX3, PREV>;
2513 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2514 silent_cerr(
"model namespace: "
2515 "unable to insert handler "
2516 "for function " << f->
fname << std::endl);
2522 f->
fname =
"angvrel_prev";
2524 f->
args.resize(1 + 2 + 1);
2529 f->
f = angvrel<NORM, PREV>;
2532 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2533 silent_cerr(
"model namespace: "
2534 "unable to insert handler "
2535 "for function " << f->
fname << std::endl);
2541 f->
fname =
"angvrel2_prev";
2543 f->
args.resize(1 + 2 + 1);
2548 f->
f = angvrel<SQUARE, PREV>;
2551 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2552 silent_cerr(
"model namespace: "
2553 "unable to insert handler "
2554 "for function " << f->
fname << std::endl);
2560 f->
fname =
"xangvrel_prev";
2562 f->
args.resize(1 + 2 + 1);
2567 f->
f = angvrel<IDX1, PREV>;
2570 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2571 silent_cerr(
"model namespace: "
2572 "unable to insert handler "
2573 "for function " << f->
fname << std::endl);
2579 f->
fname =
"yangvrel_prev";
2581 f->
args.resize(1 + 2 + 1);
2586 f->
f = angvrel<IDX2, PREV>;
2589 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2590 silent_cerr(
"model namespace: "
2591 "unable to insert handler "
2592 "for function " << f->
fname << std::endl);
2598 f->
fname =
"zangvrel_prev";
2600 f->
args.resize(1 + 2 + 1);
2605 f->
f = angvrel<IDX3, PREV>;
2608 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2609 silent_cerr(
"model namespace: "
2610 "unable to insert handler "
2611 "for function " << f->
fname << std::endl);
2619 f->
args.resize(1 + 2 + 2);
2625 f->
f = drive<false>;
2628 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2629 silent_cerr(
"model namespace: "
2630 "unable to insert handler "
2631 "for function " << f->
fname << std::endl);
2637 f->
fname =
"drivep";
2639 f->
args.resize(1 + 2 + 2);
2648 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2649 silent_cerr(
"model namespace: "
2650 "unable to insert handler "
2651 "for function " << f->
fname << std::endl);
2657 f->
fname =
"current";
2659 f->
args.resize(1 + 1 + 1);
2666 if (!
func.insert(funcType::value_type(f->
fname, f)).second) {
2667 silent_cerr(
"model namespace: "
2668 "unable to insert handler "
2669 "for function " << f->
fname << std::endl);
2728 for (funcType::iterator f =
func.begin(); f !=
func.end(); ++f) {
2742 static const std::string sf_prefix(
"sf::");
2743 if (fname.compare(0, sf_prefix.size(), sf_prefix) == 0) {
2744 std::string sfname(fname, sf_prefix.size());
2748 silent_cerr(
"ModelNameSpace::FindFunc(" << fname <<
"): unable to find scalar function \"" << sfname <<
"\"" << std::endl);
2762 static const std::string node_prefix =
"node::";
2763 if (fname.compare(0, node_prefix.size(), node_prefix) == 0) {
2764 std::string type(fname, node_prefix.size());
2767 silent_cerr(
"ModelNameSpace::GetFunc(" << fname <<
"): unable to find node type \"" << type <<
"\"" << std::endl);
2784 static const std::string elem_prefix =
"element::";
2785 if (fname.compare(0, elem_prefix.size(), elem_prefix) == 0) {
2786 std::string type(fname, elem_prefix.size());
2789 silent_cerr(
"ModelNameSpace::GetFunc(" << fname <<
"): unable to find element type \"" << type <<
"\"" << std::endl);
2817 funcType::const_iterator i =
func.find(fname);
2819 if (i !=
func.end()) {
2838 static const std::string sf_prefix(
"sf::");
2839 if (fname.compare(0, sf_prefix.size(), sf_prefix) == 0) {
2840 std::string sfname(fname, sf_prefix.size());
2844 silent_cerr(
"ModelNameSpace::FindFunc(" << fname <<
"): unable to find scalar function \"" << sfname <<
"\"" << std::endl);
2853 static const std::string node_prefix =
"node::";
2854 if (fname.compare(0, node_prefix.size(), node_prefix) == 0) {
2855 std::string type(fname, node_prefix.size());
2858 silent_cerr(
"ModelNameSpace::GetFunc(" << fname <<
"): unable to find node type \"" << type <<
"\"" << std::endl);
2868 static const std::string elem_prefix =
"element::";
2869 if (fname.compare(0, elem_prefix.size(), elem_prefix) == 0) {
2870 std::string type(fname, elem_prefix.size());
2873 silent_cerr(
"ModelNameSpace::GetFunc(" << fname <<
"): unable to find element type \"" << type <<
"\"" << std::endl);
2890 funcType::const_iterator i =
func.find(fname);
2892 if (i !=
func.end()) {
2904 for (
unsigned i = 0; i != args.size(); i++) {
2916 switch (f->
args[0]->Type()) {
2921 return TypedValue((*dynamic_cast<MathParser::MathArgInt_t *>(f->
args[0]))());
2924 return TypedValue((*dynamic_cast<MathParser::MathArgReal_t *>(f->
args[0]))());
2940 return currData.insert(currDataType::value_type(name, value)).second;
2946 currDataType::iterator i =
currData.find(name);
2959 currDataType::const_iterator i =
currData.find(name);
static int model_curr(const MathParser::MathArgs &args)
static int model_elem(const MathParser::MathArgs &args)
static int velocity(const MathParser::MathArgs &args)
MathArgPriv_t< Real, AT_REAL > MathArgReal_t
virtual const Vec3 & GetWPrev(void) const
static int angle(const MathParser::MathArgs &args)
bool PopCurrData(const std::string &name)
const BasicScalarFunction * GetScalarFunction(void)
Elem::Type str2elemtype(const char *const s)
#define MBDYN_EXCEPT_ARGS
static int angvel(const MathParser::MathArgs &args)
virtual const Mat3x3 & GetRCurr(void) const
doublereal Norm(void) const
doublereal Dot(const Vec3 &v) const
std::vector< MathArg_t * > MathArgs
virtual const Vec3 & GetXPrev(void) const
virtual unsigned int iGetPrivDataIdx(const char *s) const
static int anglerel(const MathParser::MathArgs &args)
static int position(const MathParser::MathArgs &args)
MathParser::MathArgPriv_t< Node::Type > MathArgNode
Node::Type str2nodetype(const char *const s)
MathParser::MathFunc_t unique_elem_func
Vec3 VecRot(const Mat3x3 &Phi)
virtual doublereal dGetP(const doublereal &dVar) const
static int vrel(const MathParser::MathArgs &args)
Elem * pFindElem(Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
bool bIsUnique(void) const
static const char * when2str(when_t when)
MathParser::MathFunc_t * GetFunc(const std::string &fname) const
virtual bool bIsDifferentiable(void) const
bool IsFunc(const std::string &fname) const
static int unitvec(const MathParser::MathArgs &args)
MathParser::MathFunc_t node_func
bool GetCurrData(const std::string &name, TypedValue &value) const
virtual const Mat3x3 & GetRPrev(void) const
virtual const Vec3 & GetVPrev(void) const
MathParser::MathArgPriv_t< const DataManager * > MathArgDM
MathParser::MathArgPriv_t< const BasicScalarFunction * > MathArgSF
TypedValue EvalFunc(MathParser::MathFunc_t *f) const
virtual const Vec3 & GetWCurr(void) const
MathParser::MathFunc_t elem_func
#define ASSERT(expression)
static const char * IDX2str(IDX_t IDX)
virtual doublereal ComputeDiff(const doublereal x, const integer order=1) const =0
Mat3x3 MulTM(const Mat3x3 &m) const
virtual const Vec3 & GetXCurr(void) const
ModelNameSpace(const DataManager *pDM)
MathParser::MathArgPriv_t< const DriveCaller * > MathArgDCPtr
MathArgPriv_t< std::string, AT_STRING > MathArgString_t
MathParser::MathArgPriv_t< unsigned int > MathArgSEIdx
MathParser::MathArgPriv_t< const SimulationEntity * > MathArgSEPtr
const DataManager::ElemDataStructure & GetElemDataStructure(Elem::Type Typ) const
virtual doublereal dGetPrivData(unsigned int i) const
virtual doublereal dGet(const doublereal &dVar) const =0
virtual Table * GetTable(void)
const char * psNodeNames[]
static int model_node(const MathParser::MathArgs &args)
bool PushCurrData(const std::string &name, const TypedValue &value)
const char * psElemNames[]
static int model_sf(const MathParser::MathArgs &args)
virtual const Vec3 & GetVCurr(void) const
MBDynParser & GetMBDynParser(void) const
MathParser::MathArgPriv_t< Elem::Type > MathArgElem
bool FindFunc(const std::string &fname, MathParser::MathFunc_t **fpp=0) const
static int angvrel(const MathParser::MathArgs &args)
bool IsFlag(const MathParser::ArgFlag f) const
MathArgPriv_t< Int, AT_INT > MathArgInt_t
static int distance(const MathParser::MathArgs &args)
static int drive(const MathParser::MathArgs &args)
Node * pFindNode(Node::Type Typ, unsigned int uNode) const
MathParser::MathArgPriv_t< const ModelNameSpace * > MathArgMNS
MathParser::MathFunc_t sf_func