Permutation<ToFrame, FromFrame> Permutation<FromFrame, ToFrame>::Inverse() const { using PFT = Permutation<FromFrame, ToFrame>; using PTF = Permutation<ToFrame, FromFrame>; static std::map<PFT::CoordinatePermutation, typename PTF::CoordinatePermutation> const inverse = { {PFT::XYZ, PTF::XYZ}, {PFT::YZX, PTF::ZXY}, {PFT::ZXY, PTF::YZX}, {PFT::XZY, PTF::XZY}, {PFT::ZYX, PTF::ZYX}, {PFT::YXZ, PTF::YXZ}}; return PTF(inverse.at(coordinate_permutation_)); }
void printGraph(Graph *graph, FILE *file) { /* The node and edge counts are used in the IDs of the printed graph. The item's * index in the graph is not suitable for this purpose because there may be holes * in the graph's node array. The counts are also used to control the number of * nodes and edges printed per line. */ int index, node_count = 0, edge_count = 0; if(graph == NULL || graph->number_of_nodes == 0) { PTF("[ | ]\n"); return; } PTF("[ "); /* Maps a node's graph-index to the ID it is printed with (node_count). */ int output_indices[graph->nodes.size]; for(index = 0; index < graph->nodes.size; index++) { Node *node = getNode(graph, index); if(node->index == -1) { output_indices[index] = -1; continue; } /* Five nodes per line */ if(node_count != 0 && node_count % 5 == 0) PTF("\n "); output_indices[index] = node_count; if(node->root) PTF("(%d(R), ", node_count++); else PTF("(%d, ", node_count++); printHostLabel(node->label, file); PTF(") "); } if(graph->number_of_edges == 0) { PTF("| ]\n\n"); return; } PTF("|\n "); for(index = 0; index < graph->edges.size; index++) { Edge *edge = getEdge(graph, index); if(edge->index == -1) continue; /* Three edges per line */ if(edge_count != 0 && edge_count % 3 == 0) PTF("\n "); PTF("(%d, ", edge_count++); PTF("%d, %d, ", output_indices[edge->source], output_indices[edge->target]); printHostLabel(edge->label, file); PTF(") "); } PTF("]\n\n"); }