mirror of https://github.com/CGAL/cgal
Merge pull request #5539 from sloriot/PMP-coref_check_si
Collect faces incident to edges too
This commit is contained in:
commit
e9c97d2b59
|
|
@ -324,23 +324,41 @@ class Callback_with_self_intersection_report
|
|||
: public Base
|
||||
{
|
||||
typedef typename Base::face_descriptor face_descriptor;
|
||||
typedef typename Base::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename Base::Box Box;
|
||||
boost::shared_ptr< std::set<face_descriptor> > faces_with_bbox_involved_in_intersections;
|
||||
std::set<face_descriptor>* tmf_collected_faces_ptr;
|
||||
std::set<face_descriptor>* tme_collected_faces_ptr;
|
||||
public:
|
||||
Callback_with_self_intersection_report(const Base& base)
|
||||
: Base(base), faces_with_bbox_involved_in_intersections(new std::set<face_descriptor>())
|
||||
Callback_with_self_intersection_report(const Base& base,
|
||||
std::set<face_descriptor>& tmf_collected_faces,
|
||||
std::set<face_descriptor>& tme_collected_faces)
|
||||
: Base(base),
|
||||
tmf_collected_faces_ptr(&tmf_collected_faces),
|
||||
tme_collected_faces_ptr(&tme_collected_faces)
|
||||
{}
|
||||
|
||||
void operator()( const Box* fb, const Box* eb) {
|
||||
faces_with_bbox_involved_in_intersections->insert( face(fb->info(), this->tm_faces) );
|
||||
halfedge_descriptor h = eb->info();
|
||||
if (!is_border(h, this->tm_edges))
|
||||
tme_collected_faces_ptr->insert( face(h, this->tm_edges) );
|
||||
h = opposite(h, this->tm_edges);
|
||||
if (!is_border(h, this->tm_edges))
|
||||
tme_collected_faces_ptr->insert( face(h, this->tm_edges) );
|
||||
tmf_collected_faces_ptr->insert( face(fb->info(), this->tm_faces) );
|
||||
Base::operator()(fb, eb);
|
||||
}
|
||||
bool self_intersections_found()
|
||||
{
|
||||
return Polygon_mesh_processing::does_self_intersect(
|
||||
*faces_with_bbox_involved_in_intersections,
|
||||
this->tm_faces,
|
||||
Polygon_mesh_processing::parameters::vertex_point_map(this->vpmap_tmf));
|
||||
return
|
||||
Polygon_mesh_processing::does_self_intersect(
|
||||
*tmf_collected_faces_ptr,
|
||||
this->tm_faces,
|
||||
Polygon_mesh_processing::parameters::vertex_point_map(this->vpmap_tmf))
|
||||
||
|
||||
Polygon_mesh_processing::does_self_intersect(
|
||||
*tme_collected_faces_ptr,
|
||||
this->tm_edges,
|
||||
Polygon_mesh_processing::parameters::vertex_point_map(this->vpmap_tme));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,10 @@ class Intersection_of_triangle_meshes
|
|||
const TriangleMesh& tm_e,
|
||||
const VPMF& vpm_f,
|
||||
const VPME& vpm_e,
|
||||
bool throw_on_self_intersection)
|
||||
bool throw_on_self_intersection,
|
||||
std::set<face_descriptor>& tm_f_faces,
|
||||
std::set<face_descriptor>& tm_e_faces,
|
||||
bool run_check)
|
||||
{
|
||||
std::vector<Box> face_boxes, edge_boxes;
|
||||
std::vector<Box*> face_boxes_ptr, edge_boxes_ptr;
|
||||
|
|
@ -245,11 +248,11 @@ class Intersection_of_triangle_meshes
|
|||
#endif
|
||||
//using pointers in box_intersection_d is about 10% faster
|
||||
if (throw_on_self_intersection){
|
||||
Callback_with_self_intersection_report<TriangleMesh, Callback> callback_si(callback);
|
||||
Callback_with_self_intersection_report<TriangleMesh, Callback> callback_si(callback, tm_f_faces, tm_e_faces);
|
||||
CGAL::box_intersection_d( face_boxes_ptr.begin(), face_boxes_ptr.end(),
|
||||
edge_boxes_ptr.begin(), edge_boxes_ptr.end(),
|
||||
callback_si, cutoff );
|
||||
if (callback_si.self_intersections_found())
|
||||
if (run_check && callback_si.self_intersections_found())
|
||||
throw Self_intersection_exception();
|
||||
}
|
||||
else {
|
||||
|
|
@ -1302,8 +1305,11 @@ public:
|
|||
const VertexPointMap1& vpm1=nodes.vpm1;
|
||||
const VertexPointMap2& vpm2=nodes.vpm2;
|
||||
|
||||
filter_intersections(tm1, tm2, vpm1, vpm2, throw_on_self_intersection);
|
||||
filter_intersections(tm2, tm1, vpm2, vpm1, throw_on_self_intersection);
|
||||
// used only if throw_on_self_intersection == true
|
||||
std::set<face_descriptor> tm1_faces;
|
||||
std::set<face_descriptor> tm2_faces;
|
||||
filter_intersections(tm1, tm2, vpm1, vpm2, throw_on_self_intersection, tm1_faces, tm2_faces, false);
|
||||
filter_intersections(tm2, tm1, vpm2, vpm1, throw_on_self_intersection, tm2_faces, tm1_faces, true);
|
||||
|
||||
Node_id current_node((std::numeric_limits<Node_id>::max)());
|
||||
CGAL_assertion(current_node+1==0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue