Skip to content

Commit

Permalink
Added: identification curve in the scene
Browse files Browse the repository at this point in the history
  • Loading branch information
denizdiktas committed Jul 7, 2023
1 parent 9f98df3 commit 7ba83df
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
30 changes: 28 additions & 2 deletions Arrangement_on_surface_2/demo/earth/Aos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,32 @@ namespace {
}


Aos::Approx_arc Aos::get_approx_identification_curve(double error)
{
Geom_traits traits;
auto ctr_p = traits.construct_point_2_object();
auto ctr_cv = traits.construct_curve_2_object();

// identification curve (meridian pierced by NEGATIVE Y-AXIS)
auto xcv = ctr_cv(ctr_p(0, 0, -1), ctr_p(0, 0, 1), Dir3(0,1,0));

auto approx = traits.approximate_2_object();
Approx_arc approx_arc;
{
std::vector<Approximate_point_2> v;
auto oi2 = approx(xcv, error, std::back_insert_iterator(v));
for (const auto& p : v)
{
const QVector3D arc_point(p.dx(), p.dy(), p.dz());
approx_arc.push_back(arc_point);
}
}

return approx_arc;
}

Aos::Approx_arcs Aos::get_approx_arcs(double error)
{
// Construct the arrangement from 12 geodesic arcs.
Geom_traits traits;
Arrangement arr(&traits);

Expand Down Expand Up @@ -311,7 +334,10 @@ std::vector<QVector3D> Aos::ext_check(const Kml::Placemarks& placemarks)

if (1 == vit->degree())
{
std::cout << "1-deg vertex: " << std::boolalpha << vit->incident_halfedges()->target()->data().v << std::endl;
auto p = vit->point();
auto p2 = p.location();
std::cout << "deg-1 vertex = " << p << std::endl;
std::cout << "deg-1 vertex: " << std::boolalpha << vit->incident_halfedges()->target()->data().v << std::endl;
}


Expand Down
6 changes: 5 additions & 1 deletion Arrangement_on_surface_2/demo/earth/Aos.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
class Aos
{
public:
using Approx_arcs = std::vector<std::vector<QVector3D>>;
using Approx_arc = std::vector<QVector3D>;
using Approx_arcs = std::vector<Approx_arc>;


static Approx_arc get_approx_identification_curve(double error);

// this constructs some sample arcs manually (used to check the visual output)
static Approx_arcs get_approx_arcs(double error);
Expand Down
9 changes: 9 additions & 0 deletions Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,18 @@ void Main_widget::init_camera()
}
void Main_widget::init_geometry()
{
// SPHERE
int num_slices, num_stacks;
num_slices = num_stacks = 64;
float r = 1;
m_sphere = std::make_unique<Sphere>(num_slices, num_stacks, r);
const float c = 0.8;
m_sphere->set_color(c, c, c, 1);

// IDENTIFICATION CURVE
const double error = 0.001;
auto approx_ident_curve = Aos::get_approx_identification_curve(error);
m_identification_curve = std::make_unique<Line_strips>(approx_ident_curve);

const float axes_length = 2;
m_world_coord_axes = std::make_unique<World_coord_axes>(axes_length);
Expand Down Expand Up @@ -475,6 +480,10 @@ void Main_widget::paintGL()
glLineWidth(5);
sp.set_uniform("u_plane", plane);

// IDENTIFICATION CURVE
sp.set_uniform("u_color", QVector4D(0, 1, 1, 1));
m_identification_curve->draw(m_selected_arc_index);

// draw all countries
float a = 0.0;
sp.set_uniform("u_color", QVector4D(a, a, a, 1));
Expand Down
1 change: 1 addition & 0 deletions Arrangement_on_surface_2/demo/earth/Main_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
std::unique_ptr<World_coord_axes> m_world_coord_axes;
std::unique_ptr<Line_strips> m_geodesic_arcs;
std::unique_ptr<Vertices> m_vertices;
std::unique_ptr<Line_strips> m_identification_curve;

// COUNTRY DATA
Kml::Placemarks m_countries;
Expand Down

0 comments on commit 7ba83df

Please sign in to comment.