Merge pull request #6390 from gdamiand/draw_nef_3-gdamiand

Draw nef 3
This commit is contained in:
Laurent Rineau 2022-03-10 11:05:23 +01:00
commit df3a53110e
3 changed files with 51 additions and 9 deletions

16
Data/data/meshes/beam.off Normal file
View File

@ -0,0 +1,16 @@
OFF
8 6 0
2.7 2.7 2.3
2.7 2.3 2.3
2.3 2.7 2.3
2.3 2.3 2.3
2.7 2.7 -1.3
2.7 2.3 -1.3
2.3 2.7 -1.3
2.3 2.3 -1.3
4 0 1 3 2
4 5 4 6 7
4 0 2 6 4
4 3 1 5 7
4 0 4 5 1
4 6 2 3 7

View File

@ -13,15 +13,18 @@ typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
int main(int argc, char *argv[])
{
// read OFF file into a polyhedron
Polyhedron P;
std::ifstream ifs((argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross_quad.off"));
ifs >> P;
Polyhedron P1, P2;
std::ifstream ifs1((argc > 1) ? argv[1] : CGAL::data_file_path("meshes/cross_quad.off"));
ifs1 >> P1;
std::ifstream ifs2((argc > 1) ? argv[1] : CGAL::data_file_path("meshes/beam.off"));
ifs2 >> P2;
// initialize nef from polyhedron
Nef_polyhedron N(P);
Nef_polyhedron N1(P1);
Nef_polyhedron N2(P2);
// draw Nef Polyhedron
CGAL::draw(N);
CGAL::draw(N1-N2);
return EXIT_SUCCESS;
}

View File

@ -103,9 +103,10 @@ protected:
return;
}
SHalfedge_const_handle se;
Halffacet_cycle_const_iterator fc;
fc = f->facet_cycles_begin();
Halffacet_cycle_const_iterator fc=f->facet_cycles_begin();
se = SHalfedge_const_handle(fc); // non-zero if shalfedge is returned
if(se == 0)
@ -118,13 +119,35 @@ protected:
SHalfedge_around_facet_const_circulator hc_start(se);
SHalfedge_around_facet_const_circulator hc_end(hc_start);
Vertex_const_handle lastvh;
CGAL_For_all(hc_start, hc_end) {
Vertex_const_handle vh = hc_start->source()->center_vertex();
Vertex_const_handle vh=hc_start->source()->center_vertex();
lastvh=vh;
viewer.add_point_in_face(vh->point(),
viewer.get_vertex_normal(vh));
}
// Now iterate through holes of the face
++fc;
while(fc!=f->facet_cycles_end())
{
se = SHalfedge_const_handle(fc);
hc_start=se;
hc_end=hc_start;
CGAL_For_all(hc_start, hc_end) {
Vertex_const_handle vh=hc_start->source()->center_vertex();
viewer.add_point_in_face(vh->point(),
viewer.get_vertex_normal(vh));
}
viewer.add_point_in_face(hc_start->source()->center_vertex()->point(),
viewer.get_vertex_normal(hc_start->source()->center_vertex()));
viewer.add_point_in_face(lastvh->point(),
viewer.get_vertex_normal(lastvh));
++fc;
}
viewer.face_end();
facets_done[f] = true;
facets_done[f]=true;
n_faces++;
}