vcsl_graph.cxx
Go to the documentation of this file.
1 // This is core/vcsl/vcsl_graph.cxx
2 #include "vcsl_graph.h"
3 #include <cassert>
4 #ifdef _MSC_VER
5 # include <vcl_msvc_warnings.h>
6 #endif
7 #include <vcsl/vcsl_spatial.h>
8 
9 //---------------------------------------------------------------------------
10 // Has `this' `cs' as node ?
11 //---------------------------------------------------------------------------
12 bool vcsl_graph::has(const vcsl_spatial_sptr &cs) const
13 {
14  bool result;
15 
16  std::vector<vcsl_spatial_sptr>::const_iterator i;
17 
18  result=false;
19  for (i=vertices_.begin();i!=vertices_.end()&&!result;++i)
20  result=(*i)==cs;
21 
22  return result;
23 }
24 
25 //---------------------------------------------------------------------------
26 // Spatial coordinate system number `index'
27 // REQUIRE: valid_index(index)
28 //---------------------------------------------------------------------------
29 vcsl_spatial_sptr vcsl_graph::item(unsigned int index) const
30 {
31  // require
32  assert(valid_index(index));
33 
34  return vertices_[index];
35 }
36 
37 //---------------------------------------------------------------------------
38 // Add `cs' in `this'
39 // REQUIRE: !has(cs)
40 //---------------------------------------------------------------------------
42 {
43  // require
44  assert(!has(cs));
45 
46  vertices_.push_back(cs);
47 }
48 
49 //---------------------------------------------------------------------------
50 // Remove `cs' from `this'
51 // REQUIRE: has(cs)
52 //---------------------------------------------------------------------------
54 {
55  // require
56  assert(has(cs));
57 
58  std::vector<vcsl_spatial_sptr>::iterator i;
59 
60  for (i=vertices_.begin(); i!=vertices_.end()&&((*i)!=cs); ++i)
61  ;
62  vertices_.erase(i);
63 }
64 
65 // Set the flag `reached' to false for each spatial coordinate system
66 // Used by the search path algorithm
68 {
69  std::vector<vcsl_spatial_sptr>::const_iterator i;
70 
71  for (i=vertices_.begin();i!=vertices_.end();++i)
72  (*i)->set_reached(false);
73 }
std::vector< vcsl_spatial_sptr > vertices_
Vertices of the graph: all the spatial coordinate systems.
Definition: vcsl_graph.h:91
void put(const vcsl_spatial_sptr &cs)
Add ‘cs’ in ‘this’.
Definition: vcsl_graph.cxx:41
Spatial coordinate system transformation graph.
void remove(const vcsl_spatial_sptr &cs)
Remove ‘cs’ from ‘this’.
Definition: vcsl_graph.cxx:53
void init_vertices() const
Set the flag ‘reached’ to false for each spatial coordinate system.
Definition: vcsl_graph.cxx:67
bool valid_index(unsigned int index) const
Is ‘index’ valid in the list of the spatial coordinate systems ?.
Definition: vcsl_graph.h:62
bool has(const vcsl_spatial_sptr &cs) const
Has ‘this’ ‘cs’ as node ?.
Definition: vcsl_graph.cxx:12
A spatial coordinate system.
vcsl_spatial_sptr item(unsigned int index) const
Spatial coordinate system number ‘index’.
Definition: vcsl_graph.cxx:29