DGtal  0.9.3
testSTLMapToVertexMapAdapter.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include <vector>
33 #include "DGtal/helpers/StdDefs.h"
34 
35 #include "DGtal/base/Common.h"
36 #include "DGtal/graph/CVertexMap.h"
37 #include "DGtal/graph/STLMapToVertexMapAdapter.h"
38 #include <map>
40 
41 
42 
43 using namespace std;
44 using namespace DGtal;
45 using namespace DGtal::concepts;
46 
53 // Functions for testing class Adjacency.
56 
58 {
59  typedef Z2i::Point Point;
60  typedef Z2i::Point Vertex;
61  typedef int Value;
62  typedef map<Vertex, Value> Map;
63  typedef STLMapToVertexMapAdapter<Map> VertexMap;
64  VertexMap myMap;
65  BOOST_CONCEPT_ASSERT((CVertexMap<VertexMap>));
66  myMap.setValue(Point(1,1), 10);
67  myMap.setValue(Point(2,3), 2);
68 
69  return (myMap(Point(1,1)) == 10 && myMap(Point(2,3)) == 2);
70 }
71 
72 
73 
75 // Standard services - public :
76 
77 int main( int /*argc*/, char** /*argv*/ )
78 {
79  trace.beginBlock ( "Testing class STLMapToVertexMapAdapter" );
80 
81  bool res = testMapToVertexMap(); // && ... other tests
82  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
83  trace.endBlock();
84  return res ? 0 : 1;
85 }
86 // //
void beginBlock(const std::string &keyword="")
std::unordered_map< Cell, CubicalCellData > Map
Trace trace
Definition: Common.h:137
STL namespace.
double endBlock()
int main(int, char **)
Aim: Gathers several functions useful for concept checks.
std::ostream & emphase()
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
MyDigitalSurface::Vertex Vertex
Aim: This class adapts any map of the STL to match with the CVertexMap concept.
bool testMapToVertexMap()
Aim: models of CVertexMap concept implement mapping between graph vertices and values.
Definition: CVertexMap.h:96