CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.97k stars 1.38k forks source link

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

Open andlarson opened 3 months ago

andlarson commented 3 months ago

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

afabri commented 3 months ago

With Extended Cartesian this is probably the infimaximal box.

andlarson commented 3 months ago

Ah, that makes sense, thanks for the hint.

afabri commented 2 months ago

@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.

alekseYY commented 1 week ago

@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!