InsertEdgeDelta.cpp

Go to the documentation of this file.
00001 
00008 /* Copyright © 2009 James Legg.
00009     This program is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 */
00014 
00015 #include "InsertEdgeDelta.h"
00016 #include "../Track.h"
00017 
00018 #include <Debug.h>
00019 
00020 namespace Document
00021 {
00022 
00023 InsertRemoveEdgeIdentifier::InsertRemoveEdgeIdentifier(Track::PathEdge object)
00024     :   InsertRemoveIdentifier<std::size_t, Track::PathEdge>(object.get_name())
00025 {
00026 }
00027 
00028 InsertRemoveEdgeIdentifier::InsertRemoveEdgeIdentifier(std::size_t edge_index)
00029     :   InsertRemoveIdentifier<std::size_t, Track::PathEdge>(edge_index)
00030 {
00031 }
00032 
00033 void InsertRemoveEdgeIdentifier::insert(Track::Track & track, Track::PathEdge object) const
00034 {
00035     assert(identifier == object.get_name());
00036     // find which vertices to attach to.
00037     typedef Track::Path::Graph::vertex_descriptor VertexDescriptor;
00038     Track::Path & path = track.get_path();
00039     Track::Path::Graph & graph = path.graph;
00040     VertexDescriptor source = path.get_node_descriptor(object.get_start_vertex_name());
00041     VertexDescriptor target = path.get_node_descriptor(object.get_finish_vertex_name());
00042     boost::add_edge(source, target, object, graph);
00043 }
00044 
00045 Track::PathEdge InsertRemoveEdgeIdentifier::remove(Track::Track & track) const
00046 {
00048     // remove the associated edge.
00049     Track::Path & path = track.get_path();
00050     Track::Path::Graph & graph = path.graph;
00051     Track::Path::Graph::edge_descriptor edge_descriptor = path.get_edge_descriptor(identifier);
00052     Track::PathEdge edge = graph[edge_descriptor];
00053     boost::remove_edge(edge_descriptor, graph);
00054     return edge;
00055 }
00056 
00057 } // namespace Document

Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:11 2010 by Doxygen version 1.4.7 for Racer version svn335.