33#include "DGtal/base/Common.h"
34#include "ConfigTest.h"
35#include "DGtalCatch.h"
36#include "DGtal/helpers/StdDefs.h"
37#include "DGtal/kernel/PointVector.h"
38#include "DGtal/graph/CUndirectedSimpleGraph.h"
39#include "DGtal/graph/BreadthFirstVisitor.h"
40#include "DGtal/shapes/TriangulatedSurface.h"
41#include "DGtal/shapes/MeshHelpers.h"
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" ) {
84 THEN(
"Euler number is 1 as is the Euler number of a disk." )
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" ) {
127 THEN(
"The face along (1,2) is a triangle (0,1,2)" ) {
128 ArcT a12 = trimesh.
arc( 1, 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 );
147 std::sort( T.begin(), T.end() );
152 THEN(
"The mesh has the barycenter (0.5, 0.5, 0.25) " ) {
162 THEN(
"We can convert the triangulated surface to a mesh and vice versa" ) {
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" ) {
197 THEN(
"Only two arcs are flippable" ){
200 THEN(
"The mesh has same number of vertices, edges, faces after flip." ) {
206 THEN(
"Edge (1,2) has 4 vertices around, in order (2,0,1,3)." ) {
208 int expected_V [] = { 2, 0, 1, 3};
210 bool V_ok = std::equal( V.begin(), V.end(), expected_V );
216SCENARIO(
"TriangulatedSurface< RealPoint3 > concept check tests",
"[trisurf][concepts]" )
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
const Node & current() const
static bool mesh2TriangulatedSurface(const Mesh< Point > &mesh, TriangulatedSurface< Point > &trisurf)
static void triangulatedSurface2Mesh(const TriangulatedSurface< Point > &trisurf, Mesh< Point > &mesh)
Aim: This class is defined to represent a surface mesh through a set of vertices and faces....
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Represents a triangulated surface. The topology is stored with a half-edge data structure....
Size degree(const Vertex &v) const
VertexRange verticesOfFacesAroundArc(const Arc a) const
VertexRange allBoundaryVertices() const
ConstIterator begin() const
HalfEdgeDataStructure::HalfEdgeIndex Arc
std::vector< Vertex > VertexRange
HalfEdgeDataStructure::FaceIndex Face
Vertex head(const Arc &a) const
bool isFlippable(const Arc a) const
Arc arc(const Vertex &t, const Vertex &h) const
ArcRange arcsAroundFace(const Face &f) const
ArcRange allBoundaryArcs() const
VertexIndex addVertex(const Point &vdata)
FaceIndex addTriangle(VertexIndex v0, VertexIndex v1, VertexIndex v2)
VertexRange verticesAroundFace(const Face &f) const
Face faceAroundArc(const Arc &a) const
std::vector< Arc > ArcRange
ConstIterator end() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
GIVEN("A cubical complex with random 3-cells")
REQUIRE(domain.isInside(aPoint))
TriMesh::VertexRange VertexRange
TriMesh::PositionsMap PositionsMap
TriangulatedSurface< RealPoint > TriMesh
PointVector< 3, double > RealPoint
TriMesh::ArcRange ArcRange
TriMesh makeTwoTriangles()
SCENARIO("UnorderedSetByBlock< PointVector< 2, int > unit tests with 32 bits blocks", "[unorderedsetbyblock][2d]")