73SCENARIO(
"TriangulatedSurface< RealPoint3 > build tests",
"[trisurf][build]" )
75 GIVEN(
"Two triangles incident by an edge" ) {
77 THEN(
"The mesh has 4 vertices, v0 has 2 neighbors, v1 has 3 neighbors, etc" ) {
79 REQUIRE( trimesh.degree( 0 ) == 2 );
80 REQUIRE( trimesh.degree( 1 ) == 3 );
81 REQUIRE( trimesh.degree( 2 ) == 3 );
82 REQUIRE( trimesh.degree( 3 ) == 2 );
84 THEN(
"Euler number is 1 as is the Euler number of a disk." )
86 REQUIRE( trimesh.nbVertices() == 4 );
87 REQUIRE( trimesh.nbEdges() == 5 );
88 REQUIRE( trimesh.nbFaces() == 2 );
89 REQUIRE( trimesh.Euler() == 1 );
91 THEN(
"Breadth-first visiting the mesh from vertex 3, visit 3, then {1,2}, then 0." )
94 std::vector<unsigned long> vertices;
95 std::vector<unsigned long> distances;
98 vertices.push_back( visitor.
current().first );
99 distances.push_back( visitor.
current().second );
102 REQUIRE( vertices.size() == 4 );
103 REQUIRE( distances.size() == 4 );
104 int expected_vertices1[] = { 3, 1, 2, 0};
105 int expected_vertices2[] = { 3, 2, 1, 0};
106 int expected_distance [] = { 0, 1, 1, 2};
108 = std::equal( vertices.begin(), vertices.end(), expected_vertices1 )
109 || std::equal( vertices.begin(), vertices.end(), expected_vertices2 );
112 = std::equal( distances.begin(), distances.end(), expected_distance );
115 THEN(
"The mesh has 4 boundary vertices" ) {
117 std::sort( bv.begin(), bv.end() );
118 int expected_bv [] = { 0, 1, 2, 3};
120 bool bv_ok = std::equal( bv.begin(), bv.end(), expected_bv );
123 THEN(
"The mesh has 4 boundary arcs" ) {
124 ArcRange ba = trimesh.allBoundaryArcs();
127 THEN(
"The face along (1,2) is a triangle (0,1,2)" ) {
128 ArcT a12 = trimesh.arc( 1, 2 );
129 Face f = trimesh.faceAroundArc( a12 );
130 ArcRange A = trimesh.arcsAroundFace( f );
134 REQUIRE( trimesh.head(
A[ 0 ] ) == T[ 0 ] );
135 REQUIRE( trimesh.head(
A[ 1 ] ) == T[ 1 ] );
136 REQUIRE( trimesh.head(
A[ 2 ] ) == T[ 2 ] );
137 std::sort( T.begin(), T.end() );
142 THEN(
"The face along (2,1) is a triangle (2,1,3)" ) {
143 ArcT a21 = trimesh.arc( 2, 1 );
144 Face f = trimesh.faceAroundArc( a21 );
147 std::sort( T.begin(), T.end() );
152 THEN(
"The mesh has the barycenter (0.5, 0.5, 0.25) " ) {
155 for (
Vertex v = 0; v < trimesh.size(); ++v )
162 THEN(
"We can convert the triangulated surface to a mesh and vice versa" ) {
169 REQUIRE( trimesh2.nbVertices() == trimesh.nbVertices() );
170 REQUIRE( trimesh2.nbArcs() == trimesh.nbArcs() );
171 REQUIRE( trimesh2.nbFaces() == trimesh.nbFaces() );
173 THEN(
"We can iterate over the vertices" ) {
175 RealPoint exp_positions[] = { { 0,0,0 }, { 1,0,0 }, { 0,1,0 }, { 1,1,1 } };
176 for (
auto it = trimesh.begin(), itE = trimesh.end(); it != itE; ++it ) {
177 REQUIRE( positions[ *it ] == exp_positions[ *it ] );
183SCENARIO(
"TriangulatedSurface< RealPoint3 > flip tests",
"[trisurf][flip]" )
185 GIVEN(
"Two triangles incident by an edge" ) {
187 auto nbv = trimesh.nbVertices();
188 auto nbe = trimesh.nbEdges();
189 auto nbf = trimesh.nbFaces();
192 for (
ArcT a = 0; a < trimesh.nbArcs(); a++ )
193 if ( trimesh.isFlippable( a ) ) {
197 THEN(
"Only two arcs are flippable" ){
200 THEN(
"The mesh has same number of vertices, edges, faces after flip." ) {
202 REQUIRE( trimesh.nbVertices() == nbv );
203 REQUIRE( trimesh.nbEdges() == nbe );
204 REQUIRE( trimesh.nbFaces() == nbf );
206 THEN(
"Edge (1,2) has 4 vertices around, in order (2,0,1,3)." ) {
207 VertexRange V = trimesh.verticesOfFacesAroundArc( trimesh.arc( 1, 2 ) );
208 int expected_V [] = { 2, 0, 1, 3};
210 bool V_ok = std::equal( V.begin(), V.end(), expected_V );