------------------------------------------------------------------------------
| 1246 | |
| 1247 | //------------------------------------------------------------------------------ |
| 1248 | std::vector<int> vtkDataAssembly::SelectNodes( |
| 1249 | const std::vector<std::string>& path_queries, int traversal_order) const |
| 1250 | { |
| 1251 | const auto& internals = (*this->Internals); |
| 1252 | vtkNew<SelectNodesVisitor> visitor; |
| 1253 | for (const auto& query : path_queries) |
| 1254 | { |
| 1255 | vtkLogF(TRACE, "query='%s'", query.c_str()); |
| 1256 | if (query.empty()) |
| 1257 | { |
| 1258 | continue; |
| 1259 | } |
| 1260 | try |
| 1261 | { |
| 1262 | auto set = internals.Document.select_nodes(query.c_str()); |
| 1263 | |
| 1264 | auto notUsed = std::accumulate(set.begin(), set.end(), &visitor->UnorderedSelectedNodes, |
| 1265 | [&internals](std::unordered_set<int>* result, const pugi::xpath_node& xnode) |
| 1266 | { |
| 1267 | if (xnode.node() == internals.Document) |
| 1268 | { |
| 1269 | // note: if xpath matches the document, the xnode is the document and not the |
| 1270 | // first-child and the attribute request fails. |
| 1271 | result->insert(0); |
| 1272 | } |
| 1273 | else if (::IsAssemblyNode(xnode.node())) |
| 1274 | { |
| 1275 | result->insert(xnode.node().attribute("id").as_int(-1)); |
| 1276 | } |
| 1277 | return result; |
| 1278 | }); |
| 1279 | (void)notUsed; |
| 1280 | } |
| 1281 | catch (pugi::xpath_exception& exp) |
| 1282 | { |
| 1283 | vtkLogF(TRACE, "xpath exception: %s", exp.what()); |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | this->Visit(visitor, traversal_order); |
| 1288 | return visitor->SelectedNodes; |
| 1289 | } |
| 1290 | |
| 1291 | //------------------------------------------------------------------------------ |
| 1292 | bool vtkDataAssembly::RemapDataSetIndices( |