DGtal  1.5.beta
testSTLMapToVertexMapAdapter.cpp
Go to the documentation of this file.
1 
31 #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 
54 // 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 // //
Aim: This class adapts any map of the STL to match with the CVertexMap concept.
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
Aim: Gathers several functions useful for concept checks.
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
Aim: models of CVertexMap concept implement mapping between graph vertices and values.
Definition: CVertexMap.h:98
MyPointD Point
Definition: testClone2.cpp:383
std::unordered_map< Cell, CubicalCellData > Map
bool testMapToVertexMap()
int main(int, char **)
TriMesh::Vertex Vertex