cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Unexpected Result of CGAL::draw() for Nef Polyhedra

Open andlarson opened this issue 1 year ago • 4 comments

Issue Details

I created a 3D Nef Polyhedra composed of a single halfspace and then attempted to draw it using CGAL::draw() from draw_nef_3.h. The drawing window contains a rendering of the halfspace but it also contains a mysterious cube. It's not clear to me why a cube is being rendered - my code never issues a command to draw a Nef Polyhedra that looks like a cube. How can I get rid of this cube from the drawing? Is the cube supposed to be there?

I've tried drawing other 3D Nef Polyhedra and I never can seem to get this cube to disappear. It interferes when drawing more complex 3D Nef Polyhedra.

Screenshot 2024-07-22 at 4 16 01 PM Screenshot 2024-07-22 at 4 16 08 PM

Source Code

#include <iostream>

#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/draw_nef_3.h>

typedef CGAL::Gmpq number_kernel_t;
typedef CGAL::Extended_cartesian<number_kernel_t> geom_kernel_t;
typedef CGAL::Nef_polyhedron_3<geom_kernel_t> nef_polyhedron_t;
typedef CGAL::Nef_polyhedron_3<geom_kernel_t>::Plane_3 plane_3_t;
typedef CGAL::Nef_polyhedron_3<geom_kernel_t>::Point_3 point_3_t;
typedef CGAL::Nef_polyhedron_3<geom_kernel_t>::Vector_3 vector_3_t;

int main(int argc, char *argv[])
{
    point_3_t v_p1(0, 0, 0);
    point_3_t v_p2(1, 1, 1);
    vector_3_t v(v_p1, v_p2); 

    point_3_t origin(0, 0, 0);
    plane_3_t plane(origin, v);
    
    nef_polyhedron_t polyhedron(plane, nef_polyhedron_t::INCLUDED);

    CGAL::draw(polyhedron);

    return 0;
}

When I run this code, "Using OpenGL context 4.1 GL" is emitted.

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): MacOS Sonoma 14.5
  • Compiler: Apple Clang 14.0.3
  • Release or debug mode: Debug
  • Specific flags used (if any): None
  • CGAL version: 5.6.1 from Homebrew
  • Boost version: 1.85.0 from Homebrew
  • Other libraries versions if used: Qt 5.15.13 from Homebrew

andlarson avatar Jul 22 '24 23:07 andlarson

With Extended Cartesian this is probably the infimaximal box.

afabri avatar Jul 23 '24 13:07 afabri

Ah, that makes sense, thanks for the hint.

andlarson avatar Jul 24 '24 06:07 andlarson

@andlarson can you confirm that this is the explanation? It might make sense to draw the cube only as wire frame, based on the Point_type documented here.

afabri avatar Aug 06 '24 08:08 afabri

@afabri - that's again extended coordinates. I've added a new comment to my issue, which was closed in 2023 - no segmentation fault anymore, but the picture looks strange. Please see: https://github.com/CGAL/cgal/issues/7377#issuecomment-2424526757.

Thank you!

alekseYY avatar Oct 20 '24 04:10 alekseYY