mirror of https://github.com/CGAL/cgal
Add is_valid_*_descriptor() overloads for Surface_mesh
This commit is contained in:
parent
60ecc51ba7
commit
b597aa8aab
|
|
@ -29,6 +29,7 @@
|
|||
#include <CGAL/Named_function_parameters.h>
|
||||
#include <CGAL/circulator.h>
|
||||
#include <CGAL/Handle_hash_function.h>
|
||||
#include <CGAL/IO/Verbose_ostream.h>
|
||||
#include <CGAL/Iterator_range.h>
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
|
|
@ -1466,7 +1467,7 @@ public:
|
|||
|
||||
/// perform an expensive validity check on the data structure and
|
||||
/// print found errors to `std::cerr` when `verbose == true`.
|
||||
bool is_valid(bool verbose = true) const
|
||||
bool is_valid(bool verbose = true) const
|
||||
{
|
||||
bool valid = true;
|
||||
size_type vcount = 0, hcount = 0, fcount = 0;
|
||||
|
|
@ -1578,21 +1579,29 @@ public:
|
|||
}
|
||||
|
||||
/// performs a validity check on a single vertex.
|
||||
bool is_valid(Vertex_index v) const {
|
||||
bool is_valid(Vertex_index v,
|
||||
bool verbose = true) const
|
||||
{
|
||||
Verbose_ostream verr(verbose);
|
||||
|
||||
if(!has_valid_index(v))
|
||||
return false;
|
||||
|
||||
Halfedge_index h = vconn_[v].halfedge_;
|
||||
if(h!= null_halfedge() && (!has_valid_index(h) || is_removed(h))) {
|
||||
std::cerr << "Vertex connectivity halfedge error in " << (size_type)v
|
||||
<< " with " << (size_type)h << std::endl;
|
||||
return false;
|
||||
if(h != null_halfedge() && (!has_valid_index(h) || is_removed(h))) {
|
||||
verr << "Vertex connectivity halfedge error: Vertex " << (size_type)v
|
||||
<< " with " << (size_type)h << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// performs a validity check on a single halfedge.
|
||||
bool is_valid(Halfedge_index h) const {
|
||||
bool is_valid(Halfedge_index h,
|
||||
bool verbose = true) const
|
||||
{
|
||||
Verbose_ostream verr(verbose);
|
||||
|
||||
if(!has_valid_index(h))
|
||||
return false;
|
||||
|
||||
|
|
@ -1605,30 +1614,30 @@ public:
|
|||
// don't validate the face if this is a border halfedge
|
||||
if(!is_border(h)) {
|
||||
if(!has_valid_index(f) || is_removed(f)) {
|
||||
std::cerr << "Halfedge connectivity Face "
|
||||
<< (!has_valid_index(f) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
verr << "Halfedge connectivity error: Face "
|
||||
<< (!has_valid_index(f) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!has_valid_index(v) || is_removed(v)) {
|
||||
std::cerr << "Halfedge connectivity Vertex "
|
||||
<< (!has_valid_index(v) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
verr << "Halfedge connectivity error: Vertex "
|
||||
<< (!has_valid_index(v) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if(!has_valid_index(hn) || is_removed(hn)) {
|
||||
std::cerr << "Halfedge connectivity hnext "
|
||||
<< (!has_valid_index(hn) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
verr << "Halfedge connectivity error: hnext "
|
||||
<< (!has_valid_index(hn) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
valid = false;
|
||||
}
|
||||
if(!has_valid_index(hp) || is_removed(hp)) {
|
||||
std::cerr << "Halfedge connectivity hprev "
|
||||
<< (!has_valid_index(hp) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
verr << "Halfedge connectivity error: hprev "
|
||||
<< (!has_valid_index(hp) ? "invalid" : "removed")
|
||||
<< " in " << (size_type)h << std::endl;
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
|
|
@ -1636,25 +1645,31 @@ public:
|
|||
|
||||
|
||||
/// performs a validity check on a single edge.
|
||||
bool is_valid(Edge_index e) const {
|
||||
bool is_valid(Edge_index e,
|
||||
bool verbose = true) const
|
||||
{
|
||||
if(!has_valid_index(e))
|
||||
return false;
|
||||
|
||||
Halfedge_index h = halfedge(e);
|
||||
return is_valid(h) && is_valid(opposite(h));
|
||||
return is_valid(h, verbose) && is_valid(opposite(h), verbose);
|
||||
}
|
||||
|
||||
|
||||
/// performs a validity check on a single face.
|
||||
bool is_valid(Face_index f) const {
|
||||
bool is_valid(Face_index f,
|
||||
bool verbose = true) const
|
||||
{
|
||||
Verbose_ostream verr(verbose);
|
||||
|
||||
if(!has_valid_index(f))
|
||||
return false;
|
||||
|
||||
Halfedge_index h = fconn_[f].halfedge_;
|
||||
if(!has_valid_index(h) || is_removed(h)) {
|
||||
std::cerr << "Face connectivity halfedge error in " << (size_type)f
|
||||
<< " with " << (size_type)h << std::endl;
|
||||
return false;
|
||||
verr << "Face connectivity halfedge error: Face " << (size_type)f
|
||||
<< " with " << (size_type)h << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,6 +528,51 @@ template<typename P>
|
|||
void normalize_border(const CGAL::Surface_mesh<P>&)
|
||||
{}
|
||||
|
||||
|
||||
template <typename P>
|
||||
bool is_valid_vertex_descriptor(typename boost::graph_traits<CGAL::Surface_mesh<P> >::vertex_descriptor v,
|
||||
const CGAL::Surface_mesh<P>& g,
|
||||
const bool verbose = false)
|
||||
{
|
||||
if(!g.is_valid(v, verbose))
|
||||
return false;
|
||||
|
||||
return BGL::is_valid_vertex_descriptor(v, g, verbose);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
bool is_valid_halfedge_descriptor(typename boost::graph_traits<CGAL::Surface_mesh<P> >::halfedge_descriptor h,
|
||||
const CGAL::Surface_mesh<P>& g,
|
||||
const bool verbose = false)
|
||||
{
|
||||
if(!g.is_valid(h, verbose))
|
||||
return false;
|
||||
|
||||
return BGL::is_valid_halfedge_descriptor(h, g, verbose);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
bool is_valid_edge_descriptor(typename boost::graph_traits<CGAL::Surface_mesh<P> >::edge_descriptor e,
|
||||
const CGAL::Surface_mesh<P>& g,
|
||||
const bool verbose = false)
|
||||
{
|
||||
if(!g.is_valid(e, verbose))
|
||||
return false;
|
||||
|
||||
return BGL::is_valid_edge_descriptor(e, g, verbose);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
bool is_valid_face_descriptor(typename boost::graph_traits<CGAL::Surface_mesh<P> >::face_descriptor f,
|
||||
const CGAL::Surface_mesh<P>& g,
|
||||
const bool verbose = false)
|
||||
{
|
||||
if(!g.is_valid(f, verbose))
|
||||
return false;
|
||||
|
||||
return BGL::is_valid_face_descriptor(f, g, verbose);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // DOXYGEN_RUNNING
|
||||
|
|
|
|||
Loading…
Reference in New Issue