diff --git a/Arrangement_on_surface_2/demo/earth/Aos.cpp b/Arrangement_on_surface_2/demo/earth/Aos.cpp index 3a9563c287a..7e70d1cd93d 100644 --- a/Arrangement_on_surface_2/demo/earth/Aos.cpp +++ b/Arrangement_on_surface_2/demo/earth/Aos.cpp @@ -1310,6 +1310,10 @@ Aos::Arr_handle Aos::construct(Kml::Placemarks& placemarks) #include //#include +#include +#include +#include + std::vector Aos::get_triangles(Arr_handle arrh) { typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -1356,9 +1360,20 @@ std::vector Aos::get_triangles(Arr_handle arrh) // RESULTING TRIANGLE POINTS (every 3 point => triangle) std::vector triangles; + std::cout << "triangulating individual faces\n"; + // loop on all approximated faces for (auto& face_points : all_faces) { + std::cout << "num face points = " << face_points.size() << std::endl; + // no need to triangulate if the number of points is 3 + if (face_points.size() == 3) + { + triangles.insert(triangles.end(), face_points.begin(), face_points.end()); + continue; + } + + // find the centroid of all face-points QVector3D centroid(0, 0, 0); for (const auto& fp : face_points) @@ -1394,9 +1409,20 @@ std::vector Aos::get_triangles(Arr_handle arrh) CDT cdt; cdt.insert_constraint(polygon.vertices_begin(), polygon.vertices_end(), true); + std::unordered_map in_domain_map; + boost::associative_property_map< std::unordered_map > + in_domain(in_domain_map); + + //Mark facets that are inside the domain bounded by the polygon + CGAL::mark_domain_in_triangulation(cdt, in_domain); + // loop on all the triangles ("faces" in triangulation doc) for (Face_handle f : cdt.finite_face_handles()) { + // if the current triangles is not inside the polygon -> skip it + if (false == get(in_domain, f)) + continue; + for(int i=0; i<3; ++i) { auto tp = f->vertex(i)->point(); diff --git a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp index cc4f3ac1b52..5c434e3c0b7 100644 --- a/Arrangement_on_surface_2/demo/earth/Main_widget.cpp +++ b/Arrangement_on_surface_2/demo/earth/Main_widget.cpp @@ -177,8 +177,8 @@ void Main_widget::initializeGL() //Shapefile::read(shape_file_name); //const auto file_name = data_path + "world_countries.kml"; - //const auto file_name = data_path + "ne_110m_admin_0_countries.kml"; - const auto file_name = data_path + "ne_110m_admin_0_countries_africa.kml"; + const auto file_name = data_path + "ne_110m_admin_0_countries.kml"; + //const auto file_name = data_path + "ne_110m_admin_0_countries_africa.kml"; m_countries = Kml::read(file_name); auto dup_nodes = Kml::get_duplicates(m_countries); //auto all_nodes = Kml::generate_ids(m_countries); @@ -199,8 +199,12 @@ void Main_widget::initializeGL() // trianglulation { + qDebug() << "constructiong arr.."; auto arrh = Aos::construct(m_countries); + + qDebug() << "generating triangles.."; auto triangle_points = Aos::get_triangles(arrh); + qDebug() << "num triangles = " << triangle_points.size() / 3; g_face_triangles = std::make_unique(triangle_points); } @@ -477,22 +481,25 @@ void Main_widget::paintGL() auto& sp = m_sp_smooth; sp.use(); sp.set_uniform("u_mvp", mvp); - sp.set_uniform("u_color", m_sphere->get_color()); + QVector4D sphere_color(167. / 255, 205. / 255, 242. / 255, 1); + sp.set_uniform("u_color", sphere_color); + //sp.set_uniform("u_color", m_sphere->get_color()); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); m_sphere->draw(); // DRAW SOLID FACES + if(1) { glDisable(GL_DEPTH_TEST); QVector4D face_color(1, .5, 0, 1); sp.set_uniform("u_color", face_color); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); g_face_triangles->draw(); - sp.set_uniform("u_color", QVector4D(0,0,0,1)); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - g_face_triangles->draw(); + //sp.set_uniform("u_color", QVector4D(0,0,0,1)); + //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + //g_face_triangles->draw(); } sp.unuse(); @@ -504,6 +511,7 @@ void Main_widget::paintGL() sp.use(); sp.set_uniform("u_mvp", mvp); + glEnable(GL_DEPTH_TEST); m_world_coord_axes->draw(); sp.unuse();