@@ -100,6 +100,7 @@ class Basic_viewer : public CGAL::QGLViewer
100100 m_inverse_normal (inverse_normal),
101101 m_no_2D_mode (no_2D_mode),
102102 m_geometry_feature_enabled (true ),
103+ m_prev_scene_empty (true ),
103104 m_default_color_normal (220 , 60 , 20 ),
104105 m_ambient_color (0 .6f , 0 .5f , 0 .5f , 0 .5f ),
105106 m_are_buffers_initialized (false )
@@ -157,24 +158,6 @@ class Basic_viewer : public CGAL::QGLViewer
157158 setWindowTitle (title);
158159
159160 resize (CGAL_BASIC_VIEWER_INIT_SIZE_X, CGAL_BASIC_VIEWER_INIT_SIZE_Y);
160-
161- if (inverse_normal)
162- { reverse_all_normals (); }
163-
164- if (!buf.empty ())
165- {
166- auto & bbox=buf.bounding_box ();
167- double d=CGAL::sqrt (CGAL::squared_distance
168- (Local_point (bbox.xmin (), bbox.ymin (), bbox.zmin ()),
169- Local_point (bbox.xmax (), bbox.ymax (), bbox.zmax ())));
170- // std::cout<<"Length of the diagonal: "<<d<<std::endl;
171- m_size_vertices=1.5 *d;
172- m_size_edges=d;
173- m_size_rays=m_size_edges;
174- m_size_lines=m_size_edges;
175- m_size_normals=d/3 ;
176- m_height_factor_normals=0.02 ;
177- }
178161 }
179162
180163 ~Basic_viewer ()
@@ -306,6 +289,9 @@ class Basic_viewer : public CGAL::QGLViewer
306289 {
307290 initialize_buffers ();
308291 update ();
292+ if (m_prev_scene_empty)
293+ { initialize_vertices_and_edges_size (); }
294+ m_prev_scene_empty=(m_scene.empty ());
309295 }
310296
311297 void reverse_all_normals ()
@@ -1471,13 +1457,40 @@ class Basic_viewer : public CGAL::QGLViewer
14711457
14721458 if (max_geometry_output_vertices < 128 || max_geometry_output_components < 1024 )
14731459 {
1474- std::cout << " Cylinder edge and sphere vertex feature disabled! (max_geometry_output_vertices=" << max_geometry_output_vertices << " , max_geometry_output_components=" << max_geometry_output_components << " )\n " ;
1460+ std::cout << " Cylinder edge and sphere vertex feature disabled! (max_geometry_output_vertices="
1461+ << max_geometry_output_vertices << " , max_geometry_output_components="
1462+ << max_geometry_output_components << " )\n " ;
14751463 m_geometry_feature_enabled = false ;
14761464 }
14771465
1466+ // / This code cannot be done in the constructor, because the Graphics_scene
1467+ // / is not yet created (cf. for example LCC demo).
1468+ if (m_inverse_normal)
1469+ { reverse_all_normals (); }
1470+
1471+ initialize_vertices_and_edges_size ();
1472+
14781473 this ->showEntireScene ();
14791474 }
14801475
1476+ void initialize_vertices_and_edges_size ()
1477+ {
1478+ if (!m_scene.empty ())
1479+ {
1480+ auto & bbox=m_scene.bounding_box ();
1481+ double d=CGAL::sqrt (CGAL::squared_distance
1482+ (Local_point (bbox.xmin (), bbox.ymin (), bbox.zmin ()),
1483+ Local_point (bbox.xmax (), bbox.ymax (), bbox.zmax ())));
1484+ // std::cout<<"Length of the diagonal: "<<d<<std::endl;
1485+ m_size_vertices=1.5 *d;
1486+ m_size_edges=d;
1487+ m_size_rays=m_size_edges;
1488+ m_size_lines=m_size_edges;
1489+ m_size_normals=d/3 ;
1490+ m_height_factor_normals=0.02 ;
1491+ }
1492+ }
1493+
14811494 void generate_clipping_plane ()
14821495 {
14831496 qreal size=((m_scene.bounding_box ().xmax ()-m_scene.bounding_box ().xmin ()) +
@@ -1860,6 +1873,7 @@ class Basic_viewer : public CGAL::QGLViewer
18601873 bool m_inverse_normal;
18611874 bool m_no_2D_mode;
18621875 bool m_geometry_feature_enabled;
1876+ bool m_prev_scene_empty;
18631877
18641878 enum {
18651879 CLIPPING_PLANE_OFF = 0 ,
0 commit comments