Merge pull request #2757 from maxGimeno/BGL-Add_facegraph_validity_check_function-GF

BGL:  Add a  FaceGraph validity check function
This commit is contained in:
Laurent Rineau 2018-05-28 13:58:07 +02:00
commit 851dfabd29
25 changed files with 447 additions and 120 deletions

View File

@ -618,6 +618,9 @@ user might encounter.
- `CGAL::is_quad()` - `CGAL::is_quad()`
- `CGAL::is_quad_mesh()` - `CGAL::is_quad_mesh()`
- `CGAL::is_isolated_quad()` - `CGAL::is_isolated_quad()`
- `CGAL::is_valid_halfedge_graph()`
- `CGAL::is_valid_face_graph()`
- `CGAL::is_valid_polygon_mesh()`
- `CGAL::is_tetrahedron()` - `CGAL::is_tetrahedron()`
- `CGAL::is_hexahedron()` - `CGAL::is_hexahedron()`

View File

@ -1178,7 +1178,7 @@ collapse_edge(typename boost::graph_traits<Graph>::edge_descriptor v0v1,
lP_Erased = true ; lP_Erased = true ;
} }
CGAL_expensive_assertion(is_valid(g)); CGAL_expensive_assertion(is_valid_polygon_mesh(g));
return lP_Erased ? q : p ; return lP_Erased ? q : p ;
} }

View File

@ -691,7 +691,7 @@ template <class Graph>
bool bool
is_valid(const Graph_with_descriptor_with_graph<Graph> & w, bool verbose = false) is_valid(const Graph_with_descriptor_with_graph<Graph> & w, bool verbose = false)
{ {
return is_valid(*w.graph,verbose); return is_valid_polygon_mesh(*w.graph,verbose);
} }

View File

@ -621,12 +621,6 @@ add_face(OPEN_MESH_CLASS& sm)
return sm.new_face(); return sm.new_face();
} }
template<typename K>
bool is_valid(OPEN_MESH_CLASS& sm, bool /* verbose */ = false)
{
return CGAL::is_valid_polygon_mesh(sm);
}
} // namespace OpenMesh } // namespace OpenMesh
namespace CGAL { namespace CGAL {

View File

@ -29,6 +29,7 @@
#include <CGAL/boost/graph/internal/Has_member_clear.h> #include <CGAL/boost/graph/internal/Has_member_clear.h>
#include <CGAL/function_objects.h> #include <CGAL/function_objects.h>
#include <boost/unordered_set.hpp> #include <boost/unordered_set.hpp>
#include <CGAL/IO/Verbose_ostream.h>
namespace CGAL { namespace CGAL {
@ -355,30 +356,292 @@ bool is_valid_face_descriptor( typename boost::graph_traits<FaceGraph>::face_des
return true; return true;
} }
/*!
template <typename FaceGraph> \ingroup PkgBGLHelperFct
bool is_valid_polygon_mesh(const FaceGraph& g) * \brief checks the integrity of `g`.
*
* `g` is valid if it follows the rules of the `HalfedgeListGraph` concept,
* and all of its associations are reciprocal.
* For example, `prev(next(h, g), g)` must be `h`,
* and `next(prev(h, g), g)` must be `h`.
* \param g the `Graph` to test.
* \param verb : if `true`, the details of the check will be written in the standard output.
*
* \tparam `Graph` a model of `HalfedgeListGraph`
* \return `true` if `g` is valid, `false` otherwise.
*
*/
template<typename Graph>
bool is_valid_halfedge_graph(const Graph& g, bool verb = false)
{ {
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor; typedef typename boost::graph_traits<Graph>::vertices_size_type vertex_size_type;
BOOST_FOREACH(vertex_descriptor v, vertices(g)){ typedef typename boost::graph_traits<Graph>::halfedges_size_type halfedges_size_type;
if(! is_valid_vertex_descriptor(v,g)){ Verbose_ostream verr(verb);
return false; std::size_t num_v(std::distance(boost::begin(vertices(g)), boost::end(vertices(g)))),
num_h(std::distance(boost::begin(halfedges(g)), boost::end(halfedges(g))));
bool valid = ( 1 != (num_h& 1));
if ( ! valid)
verr << "number of halfedges is odd." << std::endl;
// All halfedges.
halfedges_size_type n = 0;
BOOST_FOREACH(halfedge_descriptor begin, halfedges(g)) {
if(!valid)
break;
verr << "halfedge " << n << std::endl;
// Pointer integrity.
valid = valid && ( next(begin, g) != boost::graph_traits<Graph>::null_halfedge());
valid = valid && ( opposite(begin, g) != boost::graph_traits<Graph>::null_halfedge());
if ( ! valid) {
verr << " pointer integrity corrupted (ptr==0)."
<< std::endl;
break;
} }
} //edge integrity
BOOST_FOREACH(halfedge_descriptor h, halfedges(g)){ valid = valid && ( halfedge(edge(begin, g), g) == begin);
if(! is_valid_halfedge_descriptor(h,g)){ // opposite integrity.
return false; valid = valid && ( opposite(begin, g) != begin);
valid = valid && ( opposite(opposite(begin, g), g) == begin);
if ( ! valid) {
verr << " opposite pointer integrity corrupted."
<< std::endl;
break;
} }
} // previous integrity.
BOOST_FOREACH(face_descriptor f, faces(g)){ valid = valid && ( prev(next(begin, g), g) == begin);
if(! is_valid_face_descriptor(f,g)){ valid = valid && ( next(prev(begin, g), g) == begin);
return false; if ( ! valid) {
verr << " previous pointer integrity corrupted."
<< std::endl;
break;
} }
// vertex integrity.
valid = valid && ( target(begin, g) != boost::graph_traits<Graph>::null_vertex());
if ( ! valid) {
verr << " vertex pointer integrity corrupted."
<< std::endl;
break;
}
valid = valid && ( target(begin, g) ==
target(opposite(next(begin, g), g), g));
if ( ! valid) {
verr << " vertex pointer integrity2 corrupted."
<< std::endl;
break;
}
++n;
} }
return true; if ( valid && n != num_h)
verr << "counting halfedges failed." << std::endl;
// All vertices.
vertex_size_type v = 0;
n = 0;
BOOST_FOREACH(vertex_descriptor vbegin, vertices(g)){
if(!valid)
break;
verr << "vertex " << v << std::endl;
// Pointer integrity.
if ( halfedge(vbegin, g) != boost::graph_traits<Graph>::null_halfedge())
valid = valid && (
target( halfedge(vbegin, g), g) == vbegin);
else
valid = false;
if ( ! valid) {
verr << " halfedge pointer in vertex corrupted."
<< std::endl;
break;
}
// cycle-around-vertex test.
halfedge_descriptor h = halfedge(vbegin, g);
if ( h != boost::graph_traits<Graph>::null_halfedge()) {
halfedge_descriptor ge = h;
do {
verr << " halfedge " << n << std::endl;
++n;
h = opposite(next(h, g), g);
valid = valid && ( n <= num_h && n!=0);
if ( ! valid)
verr << " too many halfedges around vertices."
<< std::endl;
} while ( valid && (h != ge));
}
++v;
}
if ( valid && v != num_v)
verr << "counting vertices failed." << std::endl;
if ( valid && ( n != num_h))
verr << "counting halfedges via vertices failed." << std::endl;
valid = valid && ( v == num_v);
// All halfedges.
n = 0;
BOOST_FOREACH(halfedge_descriptor i, halfedges(g)){
verr << "halfedge " << n << std::endl;
// At least triangular facets and distinct geometry.
valid = valid && ( next(i, g) != i);
valid = valid && ( target(i, g) != target(opposite(i, g), g));
if ( ! valid) {
verr << " pointer validity corrupted."
<< std::endl;
break;
}
++n;
} }
valid = valid && (n == num_h);
if ( n != num_h)
verr << "counting halfedges failed." << std::endl;
verr << "structure is "
<< ( valid ? "valid." : "NOT VALID.") << std::endl;
return valid;
}
/*!
\ingroup PkgBGLHelperFct
* \brief checks the integrity of `g`.
*
* `g` is valid if it is a valid `HalfedgeListGraph`, if it follows the rules
* of the `FaceListGraph` concept, and all of its associations are reciprocal.
* For example, `face(halfedge(f,g),g)` must be `f`.
* calls `is_valid_halfedge_graph()`
* \param g the `Graph` to test.
* \param verb : if `true`, the details of the check will be written in the standard output.
*
* \tparam `Graph` a model of `FaceListGraph`
* \return `true` if `g` is valid, `false` otherwise.
*
* \see `is_valid_halfedge_graph()`
*/
template<typename Graph>
bool is_valid_face_graph(const Graph& g, bool verb = false)
{
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
typedef typename boost::graph_traits<Graph>::faces_size_type faces_size_type;
typedef typename boost::graph_traits<Graph>::halfedges_size_type halfedges_size_type;
std::size_t num_f(std::distance(boost::begin(faces(g)), boost::end(faces(g)))),
num_h(std::distance(boost::begin(halfedges(g)), boost::end(halfedges(g))));
//is valid halfedge_graph ?
bool valid=is_valid_halfedge_graph(g, verb);
if ( ! valid) {
return false;
}
Verbose_ostream verr(verb);
// All faces.
faces_size_type f = 0;
std::size_t n = 0;
halfedges_size_type nb = 0;
BOOST_FOREACH(face_descriptor fbegin, faces(g)){
if(!valid)
break;
verr << "face " << f << std::endl;
// Pointer integrity.
if ( halfedge(fbegin, g) != boost::graph_traits<Graph>::null_halfedge())
valid = valid && (
face(halfedge(fbegin, g), g) == fbegin);
else
valid = false;
if ( ! valid) {
verr << " halfedge pointer in face corrupted." << std::endl;
break;
}
// cycle-around-face test.
halfedge_descriptor h = halfedge( fbegin, g);
if (h != boost::graph_traits<Graph>::null_halfedge()) {
halfedge_descriptor ge = h;
do {
verr << " halfedge " << n << std::endl;
++n;
h = next(h, g);
valid = valid && ( n <= num_h && n!=0);
if ( ! valid)
verr << " too many halfedges around faces."
<< std::endl;
} while ( valid && (h != ge));
}
++f;
}
if ( valid && f != num_f)
verr << "counting faces failed." << std::endl;
BOOST_FOREACH(halfedge_descriptor i, halfedges(g)){
//counting borders
if ( is_border(i, g))
++nb;
// face integrity.
valid = valid && ( face(i, g) == face(next(i, g), g));
if ( ! valid) {
verr << " face pointer integrity2 corrupted."
<< std::endl;
break;
}
}
verr << "sum border halfedges (2*nb) = " << 2 * nb << std::endl;
if ( valid && n + nb != num_h)
verr << "counting halfedges via faces failed." << std::endl;
valid = valid && ( f == num_f);
valid = valid && ( n + nb == num_h);
verr << "is_valid(): structure is " << ( valid ? "valid." :
"NOT VALID.") << std::endl;
return valid;
}
/*!
\ingroup PkgBGLHelperFct
* \brief checks the integrity of `g`.
*
* `g` is valid if it is a valid `FaceListGraph` and it has distinct faces on each side of an edge.
* calls `is_valid_face_graph()`.
*
* \param g the `Mesh` to test.
* \param verb : if `true`, the details of the check will be written in the standard output.
*
* \tparam Mesh a model of `FaceListGraph` and `HalfedgeListGraph`, and follows
* the definition of a \ref PMPDef "PolygonMesh"
* \return `true` if `g` is valid, `false` otherwise.
*
* \see `is_valid_face_graph()`
* \see `is_valid_halfedge_graph()`
*
*/
template <typename Mesh>
bool is_valid_polygon_mesh(const Mesh& g, bool verb = false)
{
typedef typename boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
Verbose_ostream verr(verb);
bool valid=is_valid_face_graph(g, verb);
//test for 2-manifoldness
// Distinct facets on each side of an halfedge.
BOOST_FOREACH(halfedge_descriptor i, halfedges(g)){
valid = valid && (face(i, g) != face(opposite(i, g), g));
if ( ! valid) {
verr << " both incident facets are equal." << std::endl;
break;
}
valid = valid && ( next(next(i, g), g) != i);
valid = valid && ( target(i, g) != target(next(i, g), g));
valid = valid && ( target(i, g) != target(next(next(i, g), g), g));
if ( ! valid) {
verr << " incident facet is not at least a triangle."
<< std::endl;
break;
}
if ( ! valid) {
verr << " incident facet is not at least a triangle."
<< std::endl;
break;
}
}
return valid;
}
/*! /*!
\ingroup PkgBGLHelperFct \ingroup PkgBGLHelperFct

View File

@ -41,7 +41,7 @@ join_face_test()
assert(degree(f.w, f.m) == 2); assert(degree(f.w, f.m) == 2);
assert(degree(f.v, f.m) == 3); assert(degree(f.v, f.m) == 3);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
@ -63,7 +63,7 @@ remove_face_test_1()
CGAL::Euler::remove_face(e,f.m); CGAL::Euler::remove_face(e,f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert_EQUAL(degree(f.v, f.m) == 3); assert_EQUAL(degree(f.v, f.m) == 3);
assert_EQUAL(degree(f.x, f.m) == 2); assert_EQUAL(degree(f.x, f.m) == 2);
@ -99,7 +99,7 @@ remove_face_test_2()
assert(found); assert(found);
assert(face(e, f.m) == f.f1); assert(face(e, f.m) == f.f1);
CGAL::Euler::remove_face(e,f.m); CGAL::Euler::remove_face(e,f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert(CGAL::internal::exact_num_faces(f.m) == 3); assert(CGAL::internal::exact_num_faces(f.m) == 3);
assert(CGAL::internal::exact_num_edges(f.m) == 7); assert(CGAL::internal::exact_num_edges(f.m) == 7);
@ -128,7 +128,7 @@ add_face_to_border_test()
CGAL::Euler::add_face_to_border(f.h1, f.h2, f.m); CGAL::Euler::add_face_to_border(f.h1, f.h2, f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
@ -158,7 +158,7 @@ add_vertex_and_face_to_border_test()
} }
halfedge_descriptor res = CGAL::Euler::add_vertex_and_face_to_border(f.h1, f.h2, f.m); halfedge_descriptor res = CGAL::Euler::add_vertex_and_face_to_border(f.h1, f.h2, f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert(! CGAL::is_border(res,m)); assert(! CGAL::is_border(res,m));
assert(CGAL::is_border(opposite(res,m),m)); assert(CGAL::is_border(opposite(res,m),m));
@ -169,8 +169,6 @@ add_vertex_and_face_to_border_test()
} }
assert(blength == 0); assert(blength == 0);
} }
@ -193,7 +191,7 @@ join_vertex_interior_test()
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 3); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 3);
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3);
assert(degree(f.x, f.m) == 4); assert(degree(f.x, f.m) == 4);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
template <typename T> template <typename T>
@ -218,7 +216,7 @@ join_vertex_exterior_test()
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 4); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 4);
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3);
assert(degree(f.y, f.m) == 3); assert(degree(f.y, f.m) == 3);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
{ {
@ -237,7 +235,7 @@ join_vertex_exterior_test()
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 4); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f1, f.m), f.m)) == 4);
assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3); assert(boost::distance(CGAL::halfedges_around_face(halfedge(f.f2, f.m), f.m)) == 3);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert(degree(f.w, f.m) == 3); assert(degree(f.w, f.m) == 3);
} }
@ -261,7 +259,7 @@ split_vertex()
// split border vertex y // split border vertex y
CGAL::Euler::split_vertex(h1, h2,f.m); CGAL::Euler::split_vertex(h1, h2,f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert(CGAL::internal::exact_num_vertices(f.m) == 7); assert(CGAL::internal::exact_num_vertices(f.m) == 7);
assert(CGAL::internal::exact_num_edges(f.m) == 8); assert(CGAL::internal::exact_num_edges(f.m) == 8);
assert(boost::distance(CGAL::halfedges_around_face(h1, f.m)) == 5); assert(boost::distance(CGAL::halfedges_around_face(h1, f.m)) == 5);
@ -279,13 +277,13 @@ split_join_vertex_inverse()
boost::tie(h, found) = halfedge(f.w, f.x, f.m); boost::tie(h, found) = halfedge(f.w, f.x, f.m);
assert(found); assert(found);
CGAL::Euler::join_vertex(h,f.m); CGAL::Euler::join_vertex(h,f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
boost::tie(h1, found) = halfedge(f.z, f.x, f.m); boost::tie(h1, found) = halfedge(f.z, f.x, f.m);
assert(found); assert(found);
boost::tie(h2, found) = halfedge(f.v, f.x, f.m); boost::tie(h2, found) = halfedge(f.v, f.x, f.m);
assert(found); assert(found);
CGAL::Euler::join_vertex(CGAL::Euler::split_vertex(h1, h2,f.m),f.m); CGAL::Euler::join_vertex(CGAL::Euler::split_vertex(h1, h2,f.m),f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
assert(CGAL::internal::exact_num_vertices(f.m)== 5); assert(CGAL::internal::exact_num_vertices(f.m)== 5);
assert(CGAL::internal::exact_num_faces(f.m) == 2); assert(CGAL::internal::exact_num_faces(f.m) == 2);
@ -305,7 +303,7 @@ join_loop_test()
CGAL::Euler::join_loop(f.h1, f.h2, f.m); CGAL::Euler::join_loop(f.h1, f.h2, f.m);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
template <typename T> template <typename T>
@ -319,7 +317,7 @@ split_loop_test()
assert(CGAL::internal::exact_num_vertices(f.m) == 8); assert(CGAL::internal::exact_num_vertices(f.m) == 8);
assert(CGAL::internal::exact_num_faces(f.m) == 8); assert(CGAL::internal::exact_num_faces(f.m) == 8);
assert(CGAL::internal::exact_num_halfedges(f.m) == 24); assert(CGAL::internal::exact_num_halfedges(f.m) == 24);
assert(CGAL::is_valid(f.m)); assert(CGAL::is_valid_polygon_mesh(f.m));
} }
template <typename T> template <typename T>

View File

@ -272,7 +272,7 @@ void test_read(const Graph& g)
std::map<g_face_descriptor, std::size_t> map; std::map<g_face_descriptor, std::size_t> map;
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default()); CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
Adapter fg(g, 0, boost::make_assoc_property_map(map)); Adapter fg(g, 0, boost::make_assoc_property_map(map));
assert(CGAL::is_valid(fg)); assert(CGAL::is_valid_polygon_mesh(fg));
} }
template <typename Graph> template <typename Graph>
@ -357,7 +357,7 @@ void test_mesh(Adapter fga)
CGAL_GRAPH_TRAITS_MEMBERS(Adapter); CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
//check that there is the right number of simplices in fga //check that there is the right number of simplices in fga
CGAL_assertion(CGAL::is_valid(fga)); CGAL_assertion(CGAL::is_valid_polygon_mesh(fga));
CGAL_assertion(num_faces(fga) == 2); CGAL_assertion(num_faces(fga) == 2);
CGAL_assertion(num_edges(fga) == 5); CGAL_assertion(num_edges(fga) == 5);
CGAL_assertion(num_halfedges(fga) == 10); CGAL_assertion(num_halfedges(fga) == 10);

View File

@ -55,7 +55,7 @@ int main()
} }
assert(index == 25); assert(index == 25);
assert(is_valid(sm)); assert(is_valid_polygon_mesh(sm));
return 0; return 0;
} }

View File

@ -157,7 +157,7 @@ template <typename Graph>
struct Surface_fixture_1 { struct Surface_fixture_1 {
Surface_fixture_1() { Surface_fixture_1() {
assert(read_a_mesh(m, "data/fixture1.off")); assert(read_a_mesh(m, "data/fixture1.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));
@ -206,7 +206,7 @@ template <typename Graph>
struct Surface_fixture_2 { struct Surface_fixture_2 {
Surface_fixture_2() { Surface_fixture_2() {
assert(read_a_mesh(m, "data/fixture2.off")); assert(read_a_mesh(m, "data/fixture2.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));
@ -267,7 +267,7 @@ template <typename Graph>
struct Surface_fixture_3 { struct Surface_fixture_3 {
Surface_fixture_3() { Surface_fixture_3() {
assert(read_a_mesh(m, "data/fixture3.off")); assert(read_a_mesh(m, "data/fixture3.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));
@ -313,7 +313,7 @@ template <typename Graph>
struct Surface_fixture_4 { struct Surface_fixture_4 {
Surface_fixture_4() { Surface_fixture_4() {
assert(read_a_mesh(m, "data/fixture4.off")); assert(read_a_mesh(m, "data/fixture4.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));
@ -348,7 +348,7 @@ template <typename Graph>
struct Surface_fixture_5 { struct Surface_fixture_5 {
Surface_fixture_5() { Surface_fixture_5() {
assert(read_a_mesh(m, "data/add_face_to_border.off")); assert(read_a_mesh(m, "data/add_face_to_border.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));
@ -378,7 +378,7 @@ template <typename Graph>
struct Surface_fixture_6 { struct Surface_fixture_6 {
Surface_fixture_6() { Surface_fixture_6() {
assert(read_a_mesh(m, "data/quad.off")); assert(read_a_mesh(m, "data/quad.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::graph_traits<Graph>::halfedge_descriptor h; typename boost::graph_traits<Graph>::halfedge_descriptor h;
@ -397,7 +397,7 @@ template <typename Graph>
struct Surface_fixture_7 { struct Surface_fixture_7 {
Surface_fixture_7() { Surface_fixture_7() {
assert(read_a_mesh(m, "data/cube.off")); assert(read_a_mesh(m, "data/cube.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
h = *(halfedges(m).first); h = *(halfedges(m).first);
} }
@ -410,7 +410,7 @@ template <typename Graph>
struct Surface_fixture_8 { struct Surface_fixture_8 {
Surface_fixture_8() { Surface_fixture_8() {
assert(read_a_mesh(m, "data/fixture5.off")); assert(read_a_mesh(m, "data/fixture5.off"));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type typename boost::property_map<Graph, CGAL::vertex_point_t>::const_type
pm = get(CGAL::vertex_point, const_cast<const Graph&>(m)); pm = get(CGAL::vertex_point, const_cast<const Graph&>(m));

View File

@ -10,13 +10,13 @@ void test() {
std::cout << "Error reading file: " << fname << std::endl; std::cout << "Error reading file: " << fname << std::endl;
} }
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
CGAL::clear(m); CGAL::clear(m);
assert(num_vertices(m) == 0); assert(num_vertices(m) == 0);
assert(num_faces(m) == 0); assert(num_faces(m) == 0);
assert(num_edges(m) == 0); assert(num_edges(m) == 0);
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
} }
int main() int main()

View File

@ -254,9 +254,10 @@ void test_faces(const G& g)
template<typename G> template<typename G>
void test_read(const G& g) void test_read(const G& g)
{ {
assert(CGAL::is_valid(g)); assert(CGAL::is_valid_polygon_mesh(g));
} }
template <typename Graph> template <typename Graph>
void void
test(const std::vector<Graph>& graphs) test(const std::vector<Graph>& graphs)

View File

@ -1,6 +1,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <CGAL/Surface_mesh.h> #include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/helpers.h> #include <CGAL/boost/graph/helpers.h>
#include <CGAL/boost/graph/Euler_operations.h> #include <CGAL/boost/graph/Euler_operations.h>
@ -25,9 +26,85 @@ test(const char *fname, bool triangle, bool quad, bool tetrahedron, bool hexahed
assert(CGAL::is_hexahedron(hd, m) == hexahedron); assert(CGAL::is_hexahedron(hd, m) == hexahedron);
} }
template <typename Mesh>
void
test_validity(Mesh& mesh)
{
typedef typename boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef typename boost::property_map<Mesh, CGAL::vertex_point_t>::type VPMap;
VPMap vpmap = get(CGAL::vertex_point, mesh);
vertex_descriptor vertices[4];
edge_descriptor edges[4];
vertices[0] = add_vertex(mesh);
vertices[1] = add_vertex(mesh);
vertices[2] = add_vertex(mesh);
vertices[3] = add_vertex(mesh);
put(vpmap, vertices[0], Point_3(0,0,0));
put(vpmap, vertices[1], Point_3(1,0,0));
put(vpmap, vertices[2], Point_3(1,1,0));
put(vpmap, vertices[3], Point_3(0,1,0));
edges[0] = add_edge(mesh);
edges[1] = add_edge(mesh);
edges[2] = add_edge(mesh);
edges[3] = add_edge(mesh);
assert(!CGAL::is_valid_halfedge_graph(mesh));
for(int i=0; i<4; ++i)
{
set_target(halfedge(edges[i], mesh), vertices[i], mesh);
set_halfedge(vertices[i], halfedge(edges[i], mesh), mesh);
}
for(int i=0; i<4; ++i)
set_target(opposite(halfedge(edges[i], mesh), mesh), vertices[(i+1)%4], mesh);
for(int i=0; i<4; ++i)
{
set_next(halfedge(edges[(i+1)%4], mesh), halfedge(edges[i], mesh), mesh);
set_next(opposite(halfedge(edges[i], mesh), mesh),
opposite(halfedge(edges[(i+1)%4], mesh), mesh), mesh);
}
assert(CGAL::is_valid_halfedge_graph(mesh));
face_descriptor faces[1];
faces[0] = add_face(mesh);
assert(!CGAL::is_valid_face_graph(mesh));
for(int i=0; i<4; ++i)
{
set_face(opposite(halfedge(edges[i], mesh), mesh), faces[0], mesh);
}
set_halfedge(faces[0], opposite(halfedge(edges[0], mesh), mesh), mesh);
assert(CGAL::is_valid_face_graph(mesh));
assert(CGAL::is_valid_polygon_mesh(mesh));
Mesh dummy;
vertices[0] = add_vertex(dummy);
vertices[1] = add_vertex(dummy);
edges[0] = add_edge(dummy);
set_target(halfedge(edges[0], dummy), vertices[0], dummy);
set_halfedge(vertices[0], halfedge(edges[0], dummy), dummy);
set_target(opposite(halfedge(edges[0], dummy), dummy), vertices[1], dummy);
set_halfedge(vertices[1], opposite(halfedge(edges[0], dummy), dummy), dummy);
set_next(halfedge(edges[0], dummy), opposite(halfedge(edges[0], dummy), dummy), dummy);
set_next(opposite(halfedge(edges[0], dummy), dummy), halfedge(edges[0], dummy), dummy);
faces[0] = add_face(dummy);
set_halfedge(faces[0], opposite(halfedge(edges[0], dummy), dummy), dummy);
set_face(halfedge(edges[0], dummy), faces[0], dummy);
set_face(opposite(halfedge(edges[0], dummy), dummy), faces[0], dummy);
assert(CGAL::is_valid_face_graph(dummy));
assert(!CGAL::is_valid_polygon_mesh(dummy));
}
int main() int main()
{ {
typedef CGAL::Surface_mesh<Point_3> Mesh; typedef CGAL::Surface_mesh<Point_3> Mesh;
Mesh mesh;
test_validity(mesh);
// triangle quad tetra hexa // triangle quad tetra hexa
test<Mesh>("data/triangle.off", true, false, false, false ); test<Mesh>("data/triangle.off", true, false, false, false );
test<Mesh>("data/quad.off", false, true, false, false ); test<Mesh>("data/quad.off", false, true, false, false );
@ -43,43 +120,42 @@ int main()
halfedge_descriptor hd; halfedge_descriptor hd;
hd = CGAL::make_triangle(a,b,c,m); hd = CGAL::make_triangle(a,b,c,m);
assert(CGAL::is_isolated_triangle(hd,m)); assert(CGAL::is_isolated_triangle(hd,m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
hd = CGAL::make_quad(a,b,c,d,m); hd = CGAL::make_quad(a,b,c,d,m);
assert(CGAL::is_isolated_quad(hd,m)); assert(CGAL::is_isolated_quad(hd,m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
assert(CGAL::is_quad_mesh(m)); assert(CGAL::is_quad_mesh(m));
m.clear(); m.clear();
hd = CGAL::make_tetrahedron(a,b,c,d,m); hd = CGAL::make_tetrahedron(a,b,c,d,m);
assert(CGAL::is_tetrahedron(hd,m)); assert(CGAL::is_tetrahedron(hd,m));
assert(CGAL::is_triangle_mesh(m)); assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
hd = CGAL::make_hexahedron(a,b,c,d,aa,bb,cc,dd,m); hd = CGAL::make_hexahedron(a,b,c,d,aa,bb,cc,dd,m);
assert(CGAL::is_hexahedron(hd,m)); assert(CGAL::is_hexahedron(hd,m));
assert(CGAL::is_quad_mesh(m)); assert(CGAL::is_quad_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
CGAL::make_icosahedron<Mesh, Point_3>(m); CGAL::make_icosahedron<Mesh, Point_3>(m);
assert(num_faces(m) == 20); assert(num_faces(m) == 20);
assert(CGAL::is_triangle_mesh(m)); assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
hd = CGAL::make_pyramid<Mesh, Point_3>(3, m); hd = CGAL::make_pyramid<Mesh, Point_3>(3, m);
assert(num_faces(m) == 6); assert(num_faces(m) == 6);
assert(CGAL::is_triangle_mesh(m)); assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
hd = CGAL::make_regular_prism<Mesh, Point_3>(4, m); hd = CGAL::make_regular_prism<Mesh, Point_3>(4, m);
assert(num_faces(m) == 16); assert(num_faces(m) == 16);
assert(CGAL::is_triangle_mesh(m)); assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
m.clear(); m.clear();
CGAL::make_grid(3,3,m); CGAL::make_grid(3,3,m);
assert(num_faces(m) == 9); assert(num_faces(m) == 9);
assert(CGAL::is_quad_mesh(m)); assert(CGAL::is_quad_mesh(m));
assert(CGAL::is_valid(m)); assert(CGAL::is_valid_polygon_mesh(m));
std::cerr << "done" << std::endl; std::cerr << "done" << std::endl;
return 0; return 0;
} }

View File

@ -261,7 +261,7 @@ is_valid( bool verb, int level) const {
if ( begin->is_border()) if ( begin->is_border())
++nb; ++nb;
} }
verr << "summe border halfedges (2*nb) = " << 2 * nb << std::endl; verr << "sum border halfedges (2*nb) = " << 2 * nb << std::endl;
if ( valid && n != hds->size_of_halfedges()) if ( valid && n != hds->size_of_halfedges())
verr << "counting halfedges failed." << std::endl; verr << "counting halfedges failed." << std::endl;
if ( valid && level >= 4 && (nb != hds->size_of_border_halfedges())) if ( valid && level >= 4 && (nb != hds->size_of_border_halfedges()))

View File

@ -207,7 +207,10 @@ Release date: April 2018
### CGAL and the Boost Graph Library (BGL) ### CGAL and the Boost Graph Library (BGL)
- Added helper function `CGAL::expand_face_selection_for_removal` that - Add helper function `CGAL::is_valid_polygon_mesh` that checks the
validity of a polygon mesh using BGL functions.
- Add helper function `CGAL::expand_face_selection_for_removal` that
expands a face selection to avoid creating a non manifold mesh when expands a face selection to avoid creating a non manifold mesh when
removing the selected faces. removing the selected faces.

View File

@ -1021,7 +1021,7 @@ namespace internal {
put(vpmap_, vp.first, initial_pos);//cancel move put(vpmap_, vp.first, initial_pos);//cancel move
} }
CGAL_assertion(is_valid(mesh_)); CGAL_assertion(is_valid_polygon_mesh(mesh_));
CGAL_assertion(is_triangle_mesh(mesh_)); CGAL_assertion(is_triangle_mesh(mesh_));
}//end for loop (nit == nb_iterations) }//end for loop (nit == nb_iterations)
@ -1055,7 +1055,7 @@ namespace internal {
Point proj = trees[patch_id_to_index_map[get_patch_id(face(halfedge(v, mesh_), mesh_))]]->closest_point(get(vpmap_, v)); Point proj = trees[patch_id_to_index_map[get_patch_id(face(halfedge(v, mesh_), mesh_))]]->closest_point(get(vpmap_, v));
put(vpmap_, v, proj); put(vpmap_, v, proj);
} }
CGAL_assertion(is_valid(mesh_)); CGAL_assertion(is_valid_polygon_mesh(mesh_));
CGAL_assertion(is_triangle_mesh(mesh_)); CGAL_assertion(is_triangle_mesh(mesh_));
#ifdef CGAL_PMP_REMESHING_DEBUG #ifdef CGAL_PMP_REMESHING_DEBUG
debug_self_intersections(); debug_self_intersections();

View File

@ -176,7 +176,7 @@ bool is_outward_oriented(const PolygonMesh& pmesh,
const NamedParameters& np) const NamedParameters& np)
{ {
CGAL_warning(CGAL::is_closed(pmesh)); CGAL_warning(CGAL::is_closed(pmesh));
CGAL_precondition(CGAL::is_valid(pmesh)); CGAL_precondition(CGAL::is_valid_polygon_mesh(pmesh));
//check for empty pmesh //check for empty pmesh
CGAL_warning(faces(pmesh).first != faces(pmesh).second); CGAL_warning(faces(pmesh).first != faces(pmesh).second);
@ -480,7 +480,7 @@ void orient(TriangleMesh& tm, const NamedParameters& np)
NamedParameters>::const_type Fid_map; NamedParameters>::const_type Fid_map;
CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_triangle_mesh(tm));
CGAL_assertion(is_valid(tm)); CGAL_assertion(is_valid_polygon_mesh(tm));
CGAL_assertion(is_closed(tm)); CGAL_assertion(is_closed(tm));
using boost::choose_param; using boost::choose_param;

View File

@ -644,7 +644,7 @@ std::size_t remove_null_edges(
if ( traits.equal_3_object()(get(vpmap, target(hd, tmesh)), get(vpmap, source(hd, tmesh))) ) if ( traits.equal_3_object()(get(vpmap, target(hd, tmesh)), get(vpmap, source(hd, tmesh))) )
null_edges_to_remove.insert(edge(hd, tmesh)); null_edges_to_remove.insert(edge(hd, tmesh));
CGAL_assertion( is_valid(tmesh) ); CGAL_assertion( is_valid_polygon_mesh(tmesh) );
} }
} }
@ -1409,10 +1409,11 @@ remove_self_intersections_one_step(TriangleMesh& tm,
// some boundary cycle of halfedges // some boundary cycle of halfedges
bool topology_issue = false; bool topology_issue = false;
if (verbose) if (verbose)
{ {
std::cout << " DEBUG: is_valid in one_step(tm)? "; std::cout << " DEBUG: is_valid in one_step(tm)? ";
std::cout.flush(); std::cout.flush();
std::cout << is_valid(tm) << "\n"; std::cout << is_valid_polygon_mesh(tm) << "\n";
} }
if(!faces_to_remove.empty()){ if(!faces_to_remove.empty()){
@ -1693,7 +1694,7 @@ remove_self_intersections_one_step(TriangleMesh& tm,
if (verbose) if (verbose)
{ {
std::cout << " DEBUG: is_valid(tm) in one_step, before mesh changes? "; std::cout << " DEBUG: is_valid(tm) in one_step, before mesh changes? ";
std::cout << is_valid(tm) << std::endl; std::cout << is_valid_polygon_mesh(tm) << std::endl;
} }
//try hole_filling. //try hole_filling.
@ -1858,7 +1859,7 @@ remove_self_intersections_one_step(TriangleMesh& tm,
std::cout << " DEBUG: " << cc_faces.size() << " triangles removed, " std::cout << " DEBUG: " << cc_faces.size() << " triangles removed, "
<< patch.size() << " created\n"; << patch.size() << " created\n";
CGAL_assertion(is_valid(tm)); CGAL_assertion(is_valid_polygon_mesh(tm));
something_was_done = true; something_was_done = true;
} }
@ -1888,13 +1889,13 @@ bool remove_self_intersections(TriangleMesh& tm, const NamedParameters& np)
bool preserve_genus = boost::choose_param(boost::get_param(np, internal_np::preserve_genus), true); bool preserve_genus = boost::choose_param(boost::get_param(np, internal_np::preserve_genus), true);
if (verbose) if (verbose)
std::cout << "DEBUG: Starting remove_self_intersections, is_valid(tm)? " << is_valid(tm) << "\n"; std::cout << "DEBUG: Starting remove_self_intersections, is_valid(tm)? " << is_valid_polygon_mesh(tm) << "\n";
// first handle the removal of degenerate faces // first handle the removal of degenerate faces
remove_degenerate_faces(tm, np); remove_degenerate_faces(tm, np);
if (verbose) if (verbose)
std::cout << "DEBUG: After degenerate faces removal, is_valid(tm)? " << is_valid(tm) << "\n"; std::cout << "DEBUG: After degenerate faces removal, is_valid(tm)? " << is_valid_polygon_mesh(tm) << "\n";
// Look for self-intersections in the polyhedron and remove them // Look for self-intersections in the polyhedron and remove them
int step=-1; int step=-1;

View File

@ -26,7 +26,7 @@ void fix(const char* fname)
} }
CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh); CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh);
assert( CGAL::is_valid(mesh) ); assert( CGAL::is_valid_polygon_mesh(mesh) );
} }
int main() int main()

View File

@ -30,7 +30,7 @@ void test_middle_edge()
CGAL_assertion( h!=GT::null_halfedge() ); CGAL_assertion( h!=GT::null_halfedge() );
CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm);
CGAL_assertion(is_valid(tm)); CGAL_assertion(is_valid_polygon_mesh(tm));
CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_triangle_mesh(tm));
std::ofstream out("edge_middle_out.off"); std::ofstream out("edge_middle_out.off");
out << tm; out << tm;
@ -56,7 +56,7 @@ void test_edge_border_case1()
CGAL_assertion( h!=GT::null_halfedge() ); CGAL_assertion( h!=GT::null_halfedge() );
CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm);
CGAL_assertion(is_valid(tm)); CGAL_assertion(is_valid_polygon_mesh(tm));
CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_triangle_mesh(tm));
std::ofstream out("edge_border_case1_out.off"); std::ofstream out("edge_border_case1_out.off");
out << tm; out << tm;
@ -82,7 +82,7 @@ void test_edge_border_case2()
CGAL_assertion( h!=GT::null_halfedge() ); CGAL_assertion( h!=GT::null_halfedge() );
CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm); CGAL::Polygon_mesh_processing::remove_a_border_edge(edge(h,tm), tm);
CGAL_assertion(is_valid(tm)); CGAL_assertion(is_valid_polygon_mesh(tm));
CGAL_assertion(is_triangle_mesh(tm)); CGAL_assertion(is_triangle_mesh(tm));
std::ofstream out("edge_border_case2_out.off"); std::ofstream out("edge_border_case2_out.off");
out << tm; out << tm;

View File

@ -52,7 +52,7 @@ void test_surface_mesh(const char* fname)
CGAL::Polygon_mesh_processing::stitch_borders(m); CGAL::Polygon_mesh_processing::stitch_borders(m);
//todo : add a validity test //todo : add a validity test
assert(is_valid(m)); assert(is_valid_polygon_mesh(m));
std::cout << "OK\n"; std::cout << "OK\n";
} }

View File

@ -291,7 +291,7 @@ bool read_surf(std::istream& input, std::vector<Mesh>& output,
converter(mesh, false/*insert_isolated_vertices*/); converter(mesh, false/*insert_isolated_vertices*/);
CGAL_assertion(PMP::remove_isolated_vertices(mesh) == 0); CGAL_assertion(PMP::remove_isolated_vertices(mesh) == 0);
CGAL_assertion(is_valid(mesh)); CGAL_assertion(is_valid_polygon_mesh(mesh));
} // end loop on patches } // end loop on patches
return true; return true;

View File

@ -463,12 +463,6 @@ reserve(CGAL::Polyhedron_3<Gt,I,HDS,A>& p,
p.reserve(nv, 2*ne, nf); p.reserve(nv, 2*ne, nf);
} }
template<class Gt, class I, CGAL_HDS_PARAM_, class A>
bool is_valid(const CGAL::Polyhedron_3<Gt,I,HDS,A>& p, bool verbose = false)
{
return p.is_valid(verbose);
}
template<class Gt, class I, CGAL_HDS_PARAM_, class A> template<class Gt, class I, CGAL_HDS_PARAM_, class A>
void normalize_border(CGAL::Polyhedron_3<Gt,I,HDS,A>& p) void normalize_border(CGAL::Polyhedron_3<Gt,I,HDS,A>& p)
{ {

View File

@ -173,7 +173,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) {
for (std::size_t i = 0; i < num_v; i++, ++vitr) for (std::size_t i = 0; i < num_v; i++, ++vitr)
put(vpm, *vitr, vertex_point_buffer[i]); put(vpm, *vitr, vertex_point_buffer[i]);
// CGAL_postcondition(p.is_valid()); CGAL_postcondition(CGAL::is_valid_polygon_mesh(p));
delete []vertex_point_buffer; delete []vertex_point_buffer;
} }
@ -277,7 +277,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) {
for (std::size_t i = 0; i < num_v; i++, ++vitr) for (std::size_t i = 0; i < num_v; i++, ++vitr)
put(vpm, *vitr, vertex_point_buffer[i]); put(vpm, *vitr, vertex_point_buffer[i]);
// CGAL_postcondition(p.is_valid()); CGAL_postcondition(CGAL::is_valid_polygon_mesh(p));
delete []vertex_point_buffer; delete []vertex_point_buffer;
} }
@ -527,7 +527,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask,
} }
} }
// CGAL_postcondition(p.is_valid()); CGAL_postcondition(CGAL::is_valid_polygon_mesh(p));
delete []cpt; delete []cpt;
} }

View File

@ -58,7 +58,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH); Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Catmull-Clark subdivision on 'opened' quad mesh // test Catmull-Clark subdivision on 'opened' quad mesh
@ -69,7 +69,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH); Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
@ -81,7 +81,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH); Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Loop subdivision on 'opened' tri mesh // test Loop subdivision on 'opened' tri mesh
@ -92,7 +92,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH); Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Doo-Sabin subdivision on general mesh // test Doo-Sabin subdivision on general mesh
@ -103,7 +103,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH); Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on tri mesh // test Sqrt-3 subdivision on tri mesh
@ -114,7 +114,7 @@ void test_Subdivision_surface_3() {
mesh >> P; mesh >> P;
Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH); Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
} }
@ -130,7 +130,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH); Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Catmull-Clark subdivision on 'opened' quad mesh // test Catmull-Clark subdivision on 'opened' quad mesh
@ -141,7 +141,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH); Subdivision_method_3::CatmullClark_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
@ -153,7 +153,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH); Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Loop subdivision on 'opened' tri mesh // test Loop subdivision on 'opened' tri mesh
@ -164,7 +164,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH); Subdivision_method_3::Loop_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Doo-Sabin subdivision on general mesh // test Doo-Sabin subdivision on general mesh
@ -175,7 +175,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH); Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P, true));
} }
// test Doo-Sabin subdivision on 'opened' quad mesh // test Doo-Sabin subdivision on 'opened' quad mesh
@ -186,7 +186,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH); Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on tri mesh // test Sqrt-3 subdivision on tri mesh
@ -197,7 +197,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH); Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on 'opened' tri mesh // test Sqrt-3 subdivision on 'opened' tri mesh
@ -208,7 +208,7 @@ void test_Subdivision_surface_3_SM() {
mesh >> P; mesh >> P;
Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH); Subdivision_method_3::Sqrt3_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
} }
@ -225,7 +225,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::CatmullClark_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::CatmullClark_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Catmull-Clark subdivision on 'opened' quad mesh // test Catmull-Clark subdivision on 'opened' quad mesh
@ -237,7 +237,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::CatmullClark_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::CatmullClark_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
@ -250,7 +250,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::Loop_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::Loop_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Loop subdivision on 'opened' tri mesh // test Loop subdivision on 'opened' tri mesh
@ -262,7 +262,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::Loop_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::Loop_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Doo-Sabin subdivision on 'opened' tri mesh // test Doo-Sabin subdivision on 'opened' tri mesh
@ -274,7 +274,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::DooSabin_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::DooSabin_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Doo-Sabin subdivision on 'opened' quad mesh // test Doo-Sabin subdivision on 'opened' quad mesh
@ -285,7 +285,7 @@ void test_Subdivision_surface_3_SM_NP() {
mesh >> P; mesh >> P;
Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH); Subdivision_method_3::DooSabin_subdivision(P,TEST_DEPTH);
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on tri mesh // test Sqrt-3 subdivision on tri mesh
@ -298,7 +298,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::Sqrt3_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P)) Subdivision_method_3::Sqrt3_subdivision(P,Subdivision_method_3::parameters::vertex_point_map(get(vertex_point, P))
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on 'opened' tri mesh // test Sqrt-3 subdivision on 'opened' tri mesh
@ -314,7 +314,7 @@ void test_Subdivision_surface_3_SM_NP() {
std::ofstream out("out_0.off"); std::ofstream out("out_0.off");
out << P; out << P;
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
// test Sqrt-3 subdivision on 'opened' tri mesh & with external property map // test Sqrt-3 subdivision on 'opened' tri mesh & with external property map
@ -347,7 +347,7 @@ void test_Subdivision_surface_3_SM_NP() {
Subdivision_method_3::parameters::vertex_point_map(apm) Subdivision_method_3::parameters::vertex_point_map(apm)
.number_of_iterations(TEST_DEPTH)); .number_of_iterations(TEST_DEPTH));
assert(P.is_valid()); assert(CGAL::is_valid_polygon_mesh(P));
} }
} }

View File

@ -522,12 +522,6 @@ add_face(InputIterator begin, InputIterator end, CGAL::Surface_mesh<P>& sm)
return sm.add_face(v); return sm.add_face(v);
} }
template<typename P>
bool is_valid(const CGAL::Surface_mesh<P>& sm, bool verbose = false)
{
return sm.is_valid(verbose);
}
template<typename P> template<typename P>
void normalize_border(const CGAL::Surface_mesh<P>&) void normalize_border(const CGAL::Surface_mesh<P>&)
{} {}