mirror of https://github.com/CGAL/cgal
test helpers
This commit is contained in:
parent
6fdb64eb7a
commit
6e7debb874
|
|
@ -200,16 +200,13 @@ typename boost::graph_traits<Graph>::halfedge_descriptor
|
|||
make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
||||
const P& p4, const P& p5, const P& p6, const P& p7, Graph& g)
|
||||
{
|
||||
std::cerr << "A"<< std::endl;
|
||||
typedef typename boost::graph_traits<Graph> Traits;
|
||||
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename Traits::vertex_descriptor vertex_descriptor;
|
||||
typedef typename Traits::face_descriptor face_descriptor;
|
||||
|
||||
halfedge_descriptor hb = make_quadrangle(p0, p1, p2, p3, g);
|
||||
std::cerr << "B"<< std::endl;
|
||||
halfedge_descriptor ht = prev(make_quadrangle(p4, p7, p6, p5, g),g);
|
||||
std::cerr << "C"<< std::endl;
|
||||
for(int i=0; i <4; i++){
|
||||
halfedge_descriptor h = halfedge(add_edge(g),g);
|
||||
set_target(h,target(hb,g),g);
|
||||
|
|
@ -222,12 +219,10 @@ make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
|||
hb = next(hb,g);
|
||||
ht = prev(ht,g);
|
||||
}
|
||||
std::cerr << "D"<< std::endl;
|
||||
for(int i=0; i <4; i++){
|
||||
fill_hole(opposite(hb,g),g);
|
||||
hb = next(hb,g);
|
||||
}
|
||||
std::cerr << "E"<< std::endl;
|
||||
return hb;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ template <typename FaceGraph>
|
|||
if(! is_border(opposite(hd,g),g)) return false;
|
||||
hd = next(hd,g);
|
||||
}
|
||||
return next(hd,g)== beg;
|
||||
return hd == beg;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -207,7 +207,7 @@ bool is_quad(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, co
|
|||
if(! is_border(opposite(hd,g),g)) return false;
|
||||
hd = next(hd,g);
|
||||
}
|
||||
return next(hd,g)== beg;
|
||||
return hd == beg;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -245,6 +245,7 @@ template <typename FaceGraph>
|
|||
template <typename FaceGraph>
|
||||
bool is_tetrahedron( typename boost::graph_traits<FaceGraph>::halfedge_descriptor h1, const FaceGraph& g)
|
||||
{
|
||||
if(is_border(h1,g)) return false;
|
||||
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
|
||||
halfedge_descriptor h2 = next(h1,g);
|
||||
halfedge_descriptor h3 = next(h2,g);
|
||||
|
|
@ -258,6 +259,7 @@ bool is_tetrahedron( typename boost::graph_traits<FaceGraph>::halfedge_descripto
|
|||
if ( h6 == opposite(h2,g) ) return false;
|
||||
// exact three edges at vertices 1, 2, 3.
|
||||
if ( next(opposite(h4,g),g) != opposite(h3,g) ) return false;
|
||||
std::cerr << "B1"<< std::endl;
|
||||
if ( next(opposite(h5,g),g) != opposite(h1,g) ) return false;
|
||||
if ( next(opposite(h6,g),g) != opposite(h2,g) ) return false;
|
||||
// three edges at v4.
|
||||
|
|
@ -278,6 +280,44 @@ bool is_tetrahedron( typename boost::graph_traits<FaceGraph>::halfedge_descripto
|
|||
}
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup PkgBGLHelperFct
|
||||
returns `true` iff the connected component denoted by `h` is a hexahedron.
|
||||
*/
|
||||
template <typename FaceGraph>
|
||||
bool is_hexahedron( typename boost::graph_traits<FaceGraph>::halfedge_descriptor h1, const FaceGraph& g)
|
||||
{
|
||||
if(is_border(h1,g)) return false;
|
||||
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
|
||||
halfedge_descriptor h2 = next(h1,g);
|
||||
halfedge_descriptor h3 = next(h2,g);
|
||||
halfedge_descriptor h4 = next(h3,g);
|
||||
halfedge_descriptor h1o = opposite(h1,g);
|
||||
halfedge_descriptor h2o = opposite(h2,g);
|
||||
halfedge_descriptor h3o = opposite(h3,g);
|
||||
halfedge_descriptor h4o = opposite(h4,g);
|
||||
if(opposite(next(h2o,g),g) != prev(h1o,g)) return false;
|
||||
if(opposite(next(h3o,g),g) != prev(h2o,g)) return false;
|
||||
if(opposite(next(h4o,g),g) != prev(h3o,g)) return false;
|
||||
if(opposite(next(h1o,g),g) != prev(h4o,g)) return false;
|
||||
if(! is_quad(face(h1,g),g)) return false;
|
||||
if(! is_quad(face(h1o,g),g)) return false;
|
||||
if(! is_quad(face(h2o,g),g)) return false;
|
||||
if(! is_quad(face(h3o,g),g)) return false;
|
||||
if(! is_quad(face(h4o,g),g)) return false;
|
||||
h1o =next(next(h1o,g),g);
|
||||
h2o =next(next(h2o,g),g);
|
||||
h3o =next(next(h3o,g),g);
|
||||
h4o =next(next(h4o,g),g);
|
||||
if(next(opposite(h2o,g),g) != opposite(h1o,g)) return false;
|
||||
if(next(opposite(h3o,g),g) != opposite(h2o,g)) return false;
|
||||
if(next(opposite(h4o,g),g) != opposite(h3o,g)) return false;
|
||||
if(next(opposite(h1o,g),g) != opposite(h4o,g)) return false;
|
||||
|
||||
if(! is_quad(face(opposite(h4o,g),g),g)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ create_single_source_cgal_program( "graph_concept_Polyhedron_3.cpp" )
|
|||
create_single_source_cgal_program( "graph_concept_Triangulation_2.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "test_graph_geometry.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "test_helpers.cpp" )
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries( test_graph_geometry ${OPENMESH_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
OFF
|
||||
8 6 0
|
||||
0 0 0
|
||||
1 0 0
|
||||
1 1 0
|
||||
0 1 0
|
||||
0 0 1
|
||||
1 0 1
|
||||
1 1 1
|
||||
0 1 1
|
||||
4 0 1 5 4
|
||||
4 4 5 6 7
|
||||
4 5 1 2 6
|
||||
4 2 1 0 3
|
||||
4 4 7 3 0
|
||||
4 7 6 2 3
|
||||
|
|
@ -1,15 +1,11 @@
|
|||
OFF
|
||||
5 6 0
|
||||
4 4 0
|
||||
|
||||
0 0 100
|
||||
100 0 0
|
||||
0 100 0
|
||||
0 0 0
|
||||
25 25 0
|
||||
3 3 4 1
|
||||
3 0 3 1
|
||||
3 0 2 3
|
||||
3 0 1 2
|
||||
3 2 4 3
|
||||
3 1 4 2
|
||||
|
||||
1 0 0
|
||||
0 1 0
|
||||
0 0 1
|
||||
3 0 1 2
|
||||
3 3 1 0
|
||||
3 3 2 1
|
||||
3 3 0 2
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
|
||||
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
void
|
||||
test(char *fname, bool triangle, bool quad, bool tetrahedron, bool hexahedron)
|
||||
{
|
||||
std::cerr << "test(" << fname << ")"<< std::endl;
|
||||
Mesh m;
|
||||
std::ifstream in(fname);
|
||||
in >> m;
|
||||
halfedge_descriptor hd = *halfedges(m).first;
|
||||
assert(CGAL::is_triangle(hd, m) == triangle);
|
||||
assert(CGAL::is_quad(hd, m) == quad);
|
||||
assert(CGAL::is_tetrahedron(hd, m) == tetrahedron);
|
||||
assert(CGAL::is_hexahedron(hd, m) == hexahedron);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// triangle quad tetra hexa
|
||||
test("data/triangle.off", true, false, false, false );
|
||||
test("data/quad.off", false, true, false, false );
|
||||
test("data/tetrahedron.off", false, false, true, false );
|
||||
test("data/cube.off", false, false, false, false );
|
||||
test("data/cube-quads.off", false, false, false, true );
|
||||
|
||||
std::cerr << "done" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue