Skip to content

Commit

Permalink
clean up and move skip test to export header
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Aug 14, 2024
1 parent 3186833 commit 403ec19
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 68 deletions.
4 changes: 0 additions & 4 deletions Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,6 @@ visit_shell_objects(typename Traits::SFace_handle f, Visitor& V) const
}
Halffacet_handle f = ec->twin()->facet();
if ( Done[f] ) continue;
Halffacet_handle tf = f->twin();
if ((f->incident_volume() == tf->incident_volume()) && Done[tf]) {
continue; // for example when we have to do with the unbounded volume and a surface with boundaries
}
FacetCandidates.push_back(f); Done[f] = true;
}
} else if (fc.is_svertex() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
#include <CGAL/Kernel/global_functions_3.h>
#include <CGAL/Nef_S2/Generic_handle_map.h>

#include <unordered_map>

Expand Down Expand Up @@ -81,13 +82,15 @@ struct Shell_polygons_visitor
Vertex_index_map& vertex_indices;
PolygonRange& polygons;
bool triangulate_all_faces;
CGAL::Generic_handle_map<bool> Done;

Shell_polygons_visitor(Vertex_index_map& vertex_indices,
PolygonRange& polygons,
bool triangulate_all_faces)
: vertex_indices( vertex_indices )
, polygons(polygons)
, triangulate_all_faces(triangulate_all_faces)
, Done(false)
{}

std::size_t get_cycle_length( typename Nef_polyhedron::Halffacet_cycle_const_iterator hfc) const
Expand All @@ -103,6 +106,14 @@ struct Shell_polygons_visitor

void visit(typename Nef_polyhedron::Halffacet_const_handle opposite_facet)
{
typename Nef_polyhedron::Halffacet_const_handle twin_facet = opposite_facet->twin();

// skip when we have to do with the unbounded volume and a surface with boundaries
if ((twin_facet->incident_volume() == opposite_facet->incident_volume()) && Done[twin_facet])
return;

Done[opposite_facet] = true;

bool is_marked=opposite_facet->incident_volume()->mark();

CGAL_assertion(Nef_polyhedron::Infi_box::is_standard(opposite_facet->plane()));
Expand Down Expand Up @@ -352,11 +363,9 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef,
typename Nef_polyhedron::Volume_const_iterator vol_it = nef.volumes_begin(),
vol_end = nef.volumes_end();

if (Nef_polyhedron::Infi_box::extended_kernel()) {
++vol_it; // skip Infi_box
}
if (Nef_polyhedron::Infi_box::extended_kernel()) ++vol_it; // skip Infi_box

CGAL_assertion ( vol_it != vol_end );
if ( vol_it == vol_end ) return;

Converter to_output;
bool handling_unbounded_volume = true;
Expand All @@ -374,71 +383,15 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef,
CGAL_For_all(ec,ee)
{
typename Nef_polyhedron::SVertex_const_handle vv = ec->twin()->source();
//~ if ( !SD.is_isolated(vv) && !Done[vv] ) {
//~ V.visit(vv); // report edge
//~ Done[vv] = Done[vv->twin()] = true;
//~ }

typename Nef_polyhedron::Halffacet_const_handle f = ec->twin()->facet();
return f->incident_volume()!=f->twin()->incident_volume();
//~ if ( Done[f] ) continue;
//~ Halffacet_handle tf = f->twin();
//~ }
//~ FacetCandidates.push_back(f); Done[f] = true;
if (f->incident_volume()==f->twin()->incident_volume())
return false;
}
}

#if 0
else if (fc.is_svertex() ) {
SVertex_handle v(fc);
if ( Done[v] ) continue;
V.visit(v); // report edge
V.visit(v->twin());
Done[v] = Done[v->twin()] = true;
CGAL_assertion(SD.is_isolated(v));
SFaceCandidates.push_back(v->twin()->incident_sface());
Done[v->twin()->incident_sface()]=true;
// note that v is isolated, thus twin(v) is isolated too
// SM_const_decorator SD;
// SFace_const_handle fo;
// fo = v->twin()->incident_sface();
/*
if(SD.is_isolated(v))
fo = v->source()->sfaces_begin();
else
fo = v->twin()->incident_sface();
*/
} else if (fc.is_shalfloop() ) {
SHalfloop_handle l(fc);
V.visit(l);
Halffacet_handle f = l->twin()->facet();
if ( Done[f] ) continue;
FacetCandidates.push_back(f); Done[f] = true;
} else CGAL_error_msg("Damn wrong handle.");
#endif
}

return false;

//~ typename Nef_polyhedron::SHalfedge_const_handle e(sf);
//~ typename Nef_polyhedron::SHalffacet_const_handle f = e->facet();
//~ e->facet()
//~ SHalfedge_around_sface_circulator ec(e),ee(e);
//~ CGAL_For_all(ec,ee) {
//~ SVertex_handle vv = ec->twin()->source();
//~ if ( !SD.is_isolated(vv) && !Done[vv] ) {
//~ V.visit(vv); // report edge
//~ Done[vv] = Done[vv->twin()] = true;
//~ }
//~ Halffacet_handle f = ec->twin()->facet();
//~ if ( Done[f] ) continue;

//~ if (CGAL::assign(f,*sfh))
//~ {
//~ std::cout << "COUCOU\n";
//~ return f->incident_volume()!=f->twin()->incident_volume();
//~ }
//~ else
//~ return false;
return true;
};

for (;vol_it!=vol_end;++vol_it)
Expand Down
1 change: 1 addition & 0 deletions Nef_3/test/Nef_3/issue_6423.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ int main()
CGAL::convert_nef_polyhedron_to_polygon_mesh(nefPoly, convertedSurfaceMesh, true);
std::cout << "After conversion, number_of_faces: " << convertedSurfaceMesh.number_of_faces() << std::endl;
std::cout << convertedSurfaceMesh << std::endl;
std::ofstream("out.off") << convertedSurfaceMesh;
return EXIT_SUCCESS;
}

0 comments on commit 403ec19

Please sign in to comment.