comparison c/Motion.cpp @ 201:f7ddfc4aeb1e

added tests for graphs
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 05 Mar 2012 01:52:56 -0500
parents 0a27fa343257
children bc93e87a2108 bc4ea09b1743
comparison
equal deleted inserted replaced
200:0a27fa343257 201:f7ddfc4aeb1e
82 float distance = norm(positions->getPointAtInstant(t)-ft.positions->getPointAtInstant(t)); 82 float distance = norm(positions->getPointAtInstant(t)-ft.positions->getPointAtInstant(t));
83 if (distance < minDistance) 83 if (distance < minDistance)
84 minDistance = distance; 84 minDistance = distance;
85 else if (distance > maxDistance) 85 else if (distance > maxDistance)
86 maxDistance = distance; 86 maxDistance = distance;
87 connected = connected && (maxDistance-minDistance < segmentationDistance); 87 connected = connected && (maxDistance-minDistance <= segmentationDistance);
88 t++; 88 t++;
89 } 89 }
90 90
91 return connected; 91 return connected;
92 } 92 }
175 void FeatureGraph::connectedComponents(const int& lastInstant) { 175 void FeatureGraph::connectedComponents(const int& lastInstant) {
176 computeVertexIndex(); 176 computeVertexIndex();
177 property_map<UndirectedGraph, int VertexInformation::*>::type components = get(&VertexInformation::index, graph); 177 property_map<UndirectedGraph, int VertexInformation::*>::type components = get(&VertexInformation::index, graph);
178 178
179 int num = connected_components(graph, components, vertex_index_map(get(&VertexInformation::index, graph))); 179 int num = connected_components(graph, components, vertex_index_map(get(&VertexInformation::index, graph)));
180 cout << "Total number of components: " << num << endl; 180 cout << "last instant threshold " << lastInstant << " Total number of components: " << num << endl;
181 181
182 vector<unsigned int> lastInstants(num, 0); 182 vector<unsigned int> lastInstants(num, 0); // last instant of component with id
183 vector<vector<vertex_descriptor> > tmpobjects(num), objects; 183 vector<vector<vertex_descriptor> > tmpobjects(num), objects; // vector of components (component = vector of vertex descriptors)
184 184
185 graph_traits<UndirectedGraph>::vertex_iterator vi, vend; 185 graph_traits<UndirectedGraph>::vertex_iterator vi, vend;
186 for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) { 186 for(tie(vi,vend) = vertices(graph); vi != vend; ++vi) {
187 //for (int i = 0; i < nVertices; ++i) { 187 //for (int i = 0; i < nVertices; ++i) {
188 unsigned int id = components[*vi]; 188 unsigned int id = components[*vi];