DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testMeshFromPoints.cpp
1 
30 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/shapes/fromPoints/MeshFromPoints.h"
36 
37 using namespace std;
38 using namespace DGtal;
39 using namespace DGtal::Z2i;
40 
41 
42 
44 // Functions for testing class MeshFromPoints.
46 
50 bool testMeshFromPoints()
51 {
52 
53  trace.beginBlock ( "Testing MeshFromPoints ..." );
54 
56  Point p0=Point(0,0);
57  Point p1=Point(0,1);
58  Point p2=Point(1,2);
59  Point p3=Point(3,2);
60  Point p4=Point(3,3);
61  Point p5=Point(3,4);
62  Point p6=Point(4,6);
63 
64  aMesh.addVertex(p0);
65  aMesh.addVertex(p1);
66  aMesh.addVertex(p2);
67  aMesh.addVertex(p3);
68  aMesh.addVertex(p4);
69  aMesh.addVertex(p5);
70 
71  aMesh.addTriangularFace(0,1,2);
72  aMesh.addTriangularFace(3,4,5);
73 
74  MeshFromPoints<Point>::MeshFace tface0 = aMesh.getFace(0);
75  MeshFromPoints<Point>::MeshFace tface1 = aMesh.getFace(1);
76  Point p0f0 = aMesh.getVertex(tface0.at(0));
77  Point p1f0 = aMesh.getVertex(tface0.at(1));
78  Point p2f0 = aMesh.getVertex(tface0.at(2));
79 
80  Point p0f1 = aMesh.getVertex(tface1.at(0));
81  Point p1f1 = aMesh.getVertex(tface1.at(1));
82  Point p2f1 = aMesh.getVertex(tface1.at(2));
83  trace.info() << "Set of points" << endl;
84  trace.info() << p0 << p1 << p2 << endl;
85  trace.info() << p3 << p4 << p5 << endl;
86 
87  trace.info() << "Face1 points " << endl;
88  trace.info() << p0f0 << p1f0 << p2f0<< endl;
89 
90  trace.info() << "Face2 points " << endl;
91  trace.info() << p0f1 << p1f1 << p2f1<< endl;
92 
93 
94  return (p0==p0f0) && (p1==p1f0) && (p2==p2f0) &&
95  (p3==p0f1) && (p4==p1f1) && (p5==p2f1) ;
96 }
97 
99 // Standard services - public :
100 
101 int main( int argc, char** argv )
102 {
103  trace.beginBlock ( "Testing class MeshFromPoints" );
104  trace.info() << "Args:";
105  for ( int i = 0; i < argc; ++i )
106  trace.info() << " " << argv[ i ];
107  trace.info() << endl;
108 
109  bool res = testMeshFromPoints(); // && ... other tests
110  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
111  trace.endBlock();
112  return res ? 0 : 1;
113 }
114 // //