mirror of https://github.com/CGAL/cgal
the outlines of the faces are drawn from the arrangement data itself now (no KML needed)
This commit is contained in:
parent
cec57f2d5d
commit
0a10e28440
|
|
@ -297,9 +297,6 @@ Aos::Approx_arc Aos::get_approx_identification_curve(double error)
|
|||
|
||||
Aos::Approx_arcs Aos::get_approx_arcs(double error)
|
||||
{
|
||||
//Geom_traits traits;
|
||||
Arrangement arr(&s_traits);
|
||||
|
||||
auto ctr_p = s_traits.construct_point_2_object();
|
||||
auto ctr_cv = s_traits.construct_curve_2_object();
|
||||
|
||||
|
|
@ -310,36 +307,13 @@ Aos::Approx_arcs Aos::get_approx_arcs(double error)
|
|||
//xcvs.push_back(ctr_cv(ctr_p(1, 0, 0), ctr_p(0, 1, 0), Dir3(0, 0, -1)));
|
||||
//xcvs.push_back(ctr_cv(Dir3(0, 0, -1)));
|
||||
|
||||
auto approx = s_traits.approximate_2_object();
|
||||
|
||||
auto approx_arcs = get_approx_curves(xcvs, error);
|
||||
//std::vector<std::vector<QVector3D>> arcs;
|
||||
//for (const auto& xcv : xcvs)
|
||||
//{
|
||||
// std::vector<Approximate_point_2> v;
|
||||
// auto oi2 = approx(xcv, error, std::back_insert_iterator(v));
|
||||
//
|
||||
// std::vector<QVector3D> arc_points;
|
||||
// for (const auto& p : v)
|
||||
// {
|
||||
// const QVector3D arc_point(p.dx(), p.dy(), p.dz());
|
||||
// arc_points.push_back(arc_point);
|
||||
// }
|
||||
// arcs.push_back(std::move(arc_points));
|
||||
//}
|
||||
//std::cout << "offset count = " << m_arc_offsets.size() << std::endl;
|
||||
|
||||
return approx_arcs;
|
||||
}
|
||||
Aos::Approx_arcs Aos::get_approx_arcs(const Kml::Placemark& placemark, double error)
|
||||
{
|
||||
//Geom_traits traits;
|
||||
auto ctr_p = s_traits.construct_point_2_object();
|
||||
auto ctr_cv = s_traits.construct_curve_2_object();
|
||||
|
||||
auto xcvs = get_arcs(placemark);
|
||||
auto arcs = ::get_approx_curves(xcvs, error);
|
||||
|
||||
return arcs;
|
||||
}
|
||||
|
||||
|
|
@ -1936,4 +1910,20 @@ std::string Aos::locate_country(Arr_handle arrh, const QVector3D& point)
|
|||
//else CGAL_error_msg("Invalid object.");
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Aos::Approx_arcs Aos::get_approx_arcs_from_faces_edges(Arr_handle arrh,
|
||||
float error)
|
||||
{
|
||||
auto& arr = *reinterpret_cast<Countries_arr*>(arrh.get());
|
||||
auto ctr_cv = s_traits.construct_curve_2_object();
|
||||
Curves xcvs;
|
||||
for (auto eit = arr.halfedges_begin(); eit != arr.halfedges_end(); ++eit)
|
||||
{
|
||||
auto& s = eit->curve();
|
||||
xcvs.push_back( ctr_cv(s.source(), s.target()) );
|
||||
}
|
||||
|
||||
auto arcs = ::get_approx_curves(xcvs, error);
|
||||
return arcs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ public:
|
|||
static Country_color_map get_color_mapping(Arr_handle arrh);
|
||||
|
||||
static std::string locate_country(Arr_handle arrh, const QVector3D& point);
|
||||
|
||||
// this will get the approximate arcs of face-edges from the arrangement
|
||||
// NOTE: this is similar to "get_approx_arcs(KML::Placemarks&, float)" above!
|
||||
static Approx_arcs get_approx_arcs_from_faces_edges(Arr_handle arrh,
|
||||
float error);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -277,9 +277,9 @@ 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.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_equatorial_guinea.kml";
|
||||
const auto file_name = data_path + "ne_110m_admin_0_countries_equatorial_guinea.kml";
|
||||
m_countries = Kml::read(file_name);
|
||||
|
||||
// find the country with the least number of nodes
|
||||
|
|
@ -326,7 +326,7 @@ void Main_widget::initializeGL()
|
|||
|
||||
// triangulation
|
||||
{
|
||||
qDebug() << "constructiong arr..";
|
||||
qDebug() << "loading arr..";
|
||||
//auto arrh = Aos::construct(m_countries);
|
||||
m_arrh = Aos::load_arr("C:/work/gsoc2023/ne_110m_admin_0_countries.json");
|
||||
if (m_arrh == nullptr)
|
||||
|
|
@ -456,6 +456,16 @@ void Main_widget::init_shader_programs()
|
|||
|
||||
void Main_widget::init_country_borders(float error)
|
||||
{
|
||||
// this part does the same as the code below but using arrangement!
|
||||
// NOTE: the old code interferes with some logic (NEEDS REFACTORING!!!)
|
||||
{
|
||||
m_country_borders.clear();
|
||||
qDebug() << "approximating the arcs of each edge of all faces..";
|
||||
auto all_approx_arcs = Aos::get_approx_arcs_from_faces_edges(m_arrh, error);
|
||||
m_gr_all_approx_arcs = std::make_unique<Line_strips>(all_approx_arcs);
|
||||
return;
|
||||
}
|
||||
|
||||
// TO-DO: move this code to resizeGL (when viewport is initialized)
|
||||
// has to be defined after camera has been defined:
|
||||
// because we want to compute the error based on camera parameters!
|
||||
|
|
@ -637,8 +647,9 @@ void Main_widget::paintGL()
|
|||
// draw all countries
|
||||
float a = 0.0;
|
||||
sp.set_uniform("u_color", QVector4D(a, a, a, 1));
|
||||
for(auto& country_border : m_country_borders)
|
||||
country_border->draw();
|
||||
//for(auto& country_border : m_country_borders)
|
||||
// country_border->draw();
|
||||
m_gr_all_approx_arcs->draw();
|
||||
|
||||
//// draw the SELECTED COUNTRY in BLUE
|
||||
//auto& selected_country = m_country_borders[m_selected_country_index];
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ protected:
|
|||
private:
|
||||
// ARRANGEMENT
|
||||
Aos::Arr_handle m_arrh;
|
||||
std::unique_ptr<Line_strips> m_gr_all_approx_arcs;
|
||||
|
||||
// GUI: event handler for picking with right mouse button
|
||||
std::unique_ptr<GUI_event_handler> m_pick_handler;
|
||||
|
|
|
|||
Loading…
Reference in New Issue