1 #ifndef GEODESIC_ALGORITHM_GRAPH_BASE_010907 2 #define GEODESIC_ALGORITHM_GRAPH_BASE_010907 24 void propagate(std::vector<SurfacePoint>& sources,
26 std::vector<SurfacePoint>* stop_points = NULL);
29 std::vector<SurfacePoint>& path);
32 std::vector<SurfacePoint>& path,std::vector<unsigned>& indexVertex);
35 double& best_source_distance);
41 double memory =
m_nodes.size()*
sizeof(Node);
42 std::cout <<
"uses about " << memory/1e6 <<
"Mb of memory" <<std::endl;
58 node_pointer best_node = NULL;
67 std::vector<node_pointer> possible_nodes;
71 for(
unsigned i=0; i<possible_nodes.size(); ++i)
73 node_pointer node = possible_nodes[i];
75 double distance_from_dest = node->
distance(&point);
100 std::vector<node_pointer>& storage) = 0;
103 std::vector<node_pointer>& storage,
104 std::vector<double>& distances,
105 double threshold_distance) = 0;
117 double max_propagation_distance,
118 std::vector<SurfacePoint>* stop_points)
125 for(
unsigned i=0; i<
m_nodes.size(); ++i)
130 clock_t start = clock();
132 std::vector<node_pointer> visible_nodes;
133 for(
unsigned i=0; i<
m_sources.size(); ++i)
139 for(
unsigned j=0; j<visible_nodes.size(); ++j)
142 double distance = node->
distance(source);
143 if(distance < node->distance_from_source())
150 visible_nodes.clear();
153 for(
unsigned i=0; i<
m_nodes.size(); ++i)
161 unsigned counter = 0;
162 unsigned satisfied_index = 0;
164 std::vector<double> distances_between_nodes;
167 if(counter++ % 10 == 0)
179 visible_nodes.clear();
180 distances_between_nodes.clear();
183 distances_between_nodes,
186 for(
unsigned i=0; i<visible_nodes.size(); ++i)
191 distances_between_nodes[i])
195 typename queue_type::iterator iter =
m_queue.find(next_node);
200 distances_between_nodes[i];
209 clock_t finish = clock();
210 m_time_consumed = (
static_cast<double>(finish)-static_cast<double>(start))/CLOCKS_PER_SEC;
217 double queue_min_distance = (*
m_queue.begin())->distance_from_source();
228 if(queue_min_distance < node.distance_from_source() +
m_stop_vertices[index].second)
239 std::vector<SurfacePoint>& path)
243 double total_path_length;
251 path.push_back(destination);
253 if(node->
distance(&destination) > 1e-50)
267 path.push_back(source);
273 std::vector<SurfacePoint>& path,std::vector<unsigned>& indexVertex)
278 double total_path_length;
286 path.push_back(destination);
288 if(node->
distance(&destination) > 1e-50)
307 path.push_back(source);
312 double& best_source_distance)
320 #endif //GEODESIC_ALGORITHM_GRAPH_BASE_010907 bool check_stop_conditions(unsigned &index)
virtual void list_nodes_visible_from_node(node_pointer node, std::vector< node_pointer > &storage, std::vector< double > &distances, double threshold_distance)=0
unsigned best_source(SurfacePoint &point, double &best_source_distance)
node_pointer & previous()
std::set< node_pointer, Node > queue_type
double m_propagation_distance_stopped
void set_stop_conditions(std::vector< SurfacePoint > *stop_points, double stop_distance)
std::vector< stop_vertex_with_distace_type > m_stop_vertices
GeodesicAlgorithmGraphBase(geodesic::Mesh *mesh)
SurfacePoint & surface_point()
void trace_back(SurfacePoint &destination, std::vector< SurfacePoint > &path)
node_pointer best_first_node(SurfacePoint &point, double &best_total_distance)
void propagate(std::vector< SurfacePoint > &sources, double max_propagation_distance=GEODESIC_INF, std::vector< SurfacePoint > *stop_points=NULL)
virtual void print_statistics()
void trace_back_with_index(SurfacePoint &destination, std::vector< SurfacePoint > &path, std::vector< unsigned > &indexVertex)
unsigned node_index(vertex_pointer v)
~GeodesicAlgorithmGraphBase()
double const GEODESIC_INF
base_pointer & base_element()
virtual void list_nodes_visible_from_source(MeshElementBase *p, std::vector< node_pointer > &storage)=0
unsigned & source_index()
double m_max_propagation_distance
double distance(double *v)
std::vector< SurfacePoint > m_sources
void set_sources(std::vector< SurfacePoint > &sources)
std::vector< Node > m_nodes
double & distance_from_source()