Skip to content

Small issue in Basic viewer #9377

@pingpong74

Description

@pingpong74

Wrong calculation in basic viewer

In the function initialize_vertices_and_edges_size(), the 2D case isn't handled correctly.
Source code:

void initialize_vertices_and_edges_size()
  {
    if(!m_scene.empty())
    {
      auto& bbox=m_scene.bounding_box();

      double d=is_two_dimensional()
              ?2.5
              : CGAL::sqrt(CGAL::squared_distance
                           (Local_point(bbox.xmin(), bbox.ymin(), bbox.zmin()),
                            Local_point(bbox.xmax(), bbox.ymax(), bbox.zmax())));

      m_size_vertices=1.5*d;
      m_size_edges=d;
      m_size_rays=m_size_edges;
      m_size_lines=m_size_edges;
      m_size_normals=d/3;
      m_height_factor_normals=0.02;
    }
  }

This can be fixed easily as the calculation is performed correctly in set_camera_mode() function.

Suggested change:

We can calculate d as

      double d;
      if (is_two_dimensional())
      {
        if (m_scene.has_zero_x())
          d = CGAL::sqrt(CGAL::squared_distance(
                Local_point(0, bbox.ymin(), bbox.zmin()),
                Local_point(0, bbox.ymax(), bbox.zmax())));
        else if (m_scene.has_zero_y())
          d = CGAL::sqrt(CGAL::squared_distance(
                Local_point(bbox.xmin(), 0, bbox.zmin()),
                Local_point(bbox.xmax(), 0, bbox.zmax())));
        else
          d = CGAL::sqrt(CGAL::squared_distance(
                Local_point(bbox.xmin(), bbox.ymin(), 0),
                Local_point(bbox.xmax(), bbox.ymax(), 0)));

      }
      else
      {
        d = CGAL::sqrt(CGAL::squared_distance(
              Local_point(bbox.xmin(), bbox.ymin(), bbox.zmin()),
              Local_point(bbox.xmax(), bbox.ymax(), bbox.zmax())));

        if (d < 1e-10) d = 1.0;
      }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions