MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / Copy

Method Copy

src/PLPSLAM/solve/GCRANSAC/pearl/maxflow.cpp:749–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747
748template <typename captype, typename tcaptype, typename flowtype>
749void Graph<captype, tcaptype, flowtype>::Copy(Graph<captype, tcaptype, flowtype> *g0)
750{
751 node *i;
752 arc *a;
753
754 reset();
755
756 if (node_max < nodes + g0->node_num)
757 {
758 free(nodes);
759 nodes = node_last = (node *)malloc(g0->node_num * sizeof(node));
760 node_max = nodes + g0->node_num;
761 }
762 if (arc_max < arcs + (g0->arc_last - g0->arcs))
763 {
764 free(arcs);
765 arcs = arc_last = (arc *)malloc((g0->arc_last - g0->arcs) * sizeof(arc));
766 arc_max = arcs + (g0->arc_last - g0->arcs);
767 }
768
769 node_num = g0->node_num;
770 node_last = nodes + node_num;
771 memcpy(nodes, g0->nodes, node_num * sizeof(node));
772 for (i = nodes; i < node_last; i++)
773 {
774 if (i->first)
775 i->first = (arc *)((char *)arcs + (((char *)i->first) - ((char *)g0->arcs)));
776 if (i->parent && i->parent != TERMINAL && i->parent != ORPHAN)
777 i->parent = (arc *)((char *)arcs + (((char *)i->parent) - ((char *)g0->arcs)));
778 if (i->next)
779 i->next = (node *)((char *)nodes + (((char *)i->next) - ((char *)g0->nodes)));
780 }
781
782 arc_last = arcs + (g0->arc_last - g0->arcs);
783 memcpy(arcs, g0->arcs, (g0->arc_last - g0->arcs) * sizeof(arc));
784 for (a = arcs; a < arc_last; a++)
785 {
786 a->head = (node *)((char *)nodes + (((char *)a->head) - ((char *)g0->nodes)));
787 if (a->next)
788 a->next = (arc *)((char *)arcs + (((char *)a->next) - ((char *)g0->arcs)));
789 a->sister = (arc *)((char *)arcs + (((char *)a->sister) - ((char *)g0->arcs)));
790 }
791
792 error_function = g0->error_function;
793 flow = g0->flow;
794 maxflow_iteration = g0->maxflow_iteration;
795
796 queue_first[0] = (g0->queue_first[0] == NULL) ? NULL : (node *)((char *)nodes + (((char *)g0->queue_first[0]) - ((char *)g0->nodes)));
797 queue_first[1] = (g0->queue_first[1] == NULL) ? NULL : (node *)((char *)nodes + (((char *)g0->queue_first[1]) - ((char *)g0->nodes)));
798 queue_last[0] = (g0->queue_last[0] == NULL) ? NULL : (node *)((char *)nodes + (((char *)g0->queue_last[0]) - ((char *)g0->nodes)));
799 queue_last[1] = (g0->queue_last[1] == NULL) ? NULL : (node *)((char *)nodes + (((char *)g0->queue_last[1]) - ((char *)g0->nodes)));
800 TIME = g0->TIME;
801}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected