@@ -891,35 +891,33 @@ namespace geode
891891    BoundingBox3D BRep::bounding_box () const 
892892    {
893893        geode::BoundingBox3D bbox;
894+         bool  bbox_computed{ false  };
894895        if ( const  auto  box = internal::meshes_bounding_box< 3  >( surfaces () ) )
895896        {
896897            bbox.add_box ( box.value () );
898+             bbox_computed = true ;
897899        }
898900        if ( const  auto  box = internal::meshes_bounding_box< 3  >( lines () ) )
899901        {
900902            bbox.add_box ( box.value () );
903+             bbox_computed = true ;
901904        }
902905        if ( const  auto  box = internal::meshes_bounding_box< 3  >( corners () ) )
903906        {
904907            bbox.add_box ( box.value () );
908+             bbox_computed = true ;
905909        }
906-         try 
910+         for (  const   auto & block :  blocks () ) 
907911        {
908-             if (  const  auto  box = 
909-                     internal::meshes_bounding_box<  3  >(  blocks () )  )
912+             const  auto & block_mesh = block. mesh (); 
913+             if ( block_mesh. nb_vertices () ==  0  )
910914            {
911-                 bbox. add_box ( box. value () ) ;
915+                 continue ;
912916            }
917+             bbox.add_box ( block_mesh.bounding_box () );
918+             bbox_computed = true ;
913919        }
914-         catch ( const  OpenGeodeException& )
915-         {
916-             OPENGEODE_EXCEPTION (
917-                 nb_corners () > 0  || nb_lines () > 0  || nb_surfaces () > 0 ,
918-                 " [BRep::bounding_box] Cannot return the bounding_box of a BRep " 
919-                 " with not meshes Blocks and no Corners, no Lines and no " 
920-                 " Surfaces."   );
921-         }
922-         OPENGEODE_EXCEPTION ( bbox.min () <= bbox.max (),
920+         OPENGEODE_EXCEPTION ( bbox_computed && bbox.min () <= bbox.max (),
923921            " [BRep::bounding_box] Cannot return the " 
924922            " bounding_box of an empty BRep."   );
925923        return  bbox;
0 commit comments