Skip to content

Commit

Permalink
Corrected the rendering and arrangement construction logic (TODO: we …
Browse files Browse the repository at this point in the history
…need to take outer and inner boundaries separately)
  • Loading branch information
denizdiktas committed Jul 3, 2023
1 parent 2b251e5 commit 1c934d7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
54 changes: 28 additions & 26 deletions Arrangement_on_surface_2/demo/earth/Aos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ void Aos::check(const Kml::Placemarks& placemarks)
for (const auto& inner_boundary : polygon.inner_boundaries)
linear_rings.push_back(inner_boundary);

// convert the nodes to points on unit-sphere
std::vector<Approximate_Vector_3> sphere_points;
// loop on outer and inner boundaries
for(const auto& lring : linear_rings)
{
// convert the nodes to points on unit-sphere
std::vector<Approximate_Vector_3> sphere_points;
for (const auto& node : lring.nodes)
{
num_counted_nodes++;
Expand All @@ -110,18 +111,18 @@ void Aos::check(const Kml::Placemarks& placemarks)
sphere_points.push_back(v);
CGAL::insert_point(arr, ctr_p(p.x, p.y, p.z));
}
}

// add curves
int num_points = sphere_points.size();
for (int i = 0; i < num_points -1; i++)
{
num_counted_arcs++;
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
auto xcv = ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z()));
xcvs.push_back(xcv);
// add curves
int num_points = sphere_points.size();
for (int i = 0; i < num_points - 1; i++)
{
num_counted_arcs++;
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
auto xcv = ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z()));
xcvs.push_back(xcv);
}
}
}
}
Expand Down Expand Up @@ -173,10 +174,11 @@ std::vector<QVector3D> Aos::ext_check(const Kml::Placemarks& placemarks)
for (const auto& inner_boundary : polygon.inner_boundaries)
linear_rings.push_back(inner_boundary);

// convert the nodes to points on unit-sphere
std::vector<Approximate_Vector_3> sphere_points;
// loop on all linear-rings (outer and inner rings)
for (const auto& lring : linear_rings)
{
// convert the nodes to points on unit-sphere
std::vector<Approximate_Vector_3> sphere_points;
for (const auto& node : lring.nodes)
{
num_counted_nodes++;
Expand All @@ -185,18 +187,18 @@ std::vector<QVector3D> Aos::ext_check(const Kml::Placemarks& placemarks)
sphere_points.push_back(v);
CGAL::insert_point(arr, ctr_p(p.x, p.y, p.z));
}
}

// add curves
int num_points = sphere_points.size();
for (int i = 0; i < sphere_points.size() - 1; i++)
{
num_counted_arcs++;
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
auto xcv = ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z()));
xcvs.push_back(xcv);
// add curves
int num_points = sphere_points.size();
for (int i = 0; i < num_points - 1; ++i)
{
num_counted_arcs++;
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
auto xcv = ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z()));
xcvs.push_back(xcv);
}
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions Arrangement_on_surface_2/demo/earth/Geodesic_arcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,25 @@ Geodesic_arcs::Approx_arcs Geodesic_arcs::get_approx_arcs(const Kml::Placemark&


// convert the nodes to points on unit-sphere
std::vector<Approximate_Vector_3> sphere_points;
for (const auto& lring : linear_rings)
{
std::vector<Approximate_Vector_3> sphere_points;
for (const auto& node : lring.nodes)
{
const auto p = node.get_coords_3d();
Approximate_Vector_3 v(p.x, p.y, p.z);
sphere_points.push_back(v);
}
}

// add curves
int num_points = sphere_points.size();
for (int i = 0; i < num_points - 1; i++)
{
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
xcvs.push_back(ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z())));
// add geodesic arcs for the current LinearRing
int num_points = sphere_points.size();
for (int i = 0; i < num_points - 1; i++)
{
const auto p1 = sphere_points[i];
const auto p2 = sphere_points[i + 1];
xcvs.push_back(ctr_cv(ctr_p(p1.x(), p1.y(), p1.z()),
ctr_p(p2.x(), p2.y(), p2.z())));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void Main_widget::initializeGL()
auto dup_nodes = Kml::get_duplicates(countries);

// initialize rendering of DUPLICATE VERTICES
if(1)
if(0)
{
std::vector<QVector3D> vertices;
for (const auto& node : dup_nodes)
Expand Down Expand Up @@ -466,7 +466,7 @@ void Main_widget::paintGL()
const QVector4D vertex_color(1, 0, 0, 1);
sp.set_uniform("u_color", vertex_color);
glPointSize(5);
//m_vertices->draw();
m_vertices->draw();

sp.unuse();
}
Expand Down

0 comments on commit 1c934d7

Please sign in to comment.