diff --git a/AABB_tree/demo/AABB_tree/MainWindow.cpp b/AABB_tree/demo/AABB_tree/MainWindow.cpp index 3f92a472584..c12640e7913 100644 --- a/AABB_tree/demo/AABB_tree/MainWindow.cpp +++ b/AABB_tree/demo/AABB_tree/MainWindow.cpp @@ -93,6 +93,9 @@ void MainWindow::open(QString filename) settings.setValue("OFF open directory", fileinfo.absoluteDir().absolutePath()); this->addToRecentFiles(filename); + + // update bbox + updateViewerBBox(); } } } diff --git a/AABB_tree/demo/AABB_tree/Scene.cpp b/AABB_tree/demo/AABB_tree/Scene.cpp index b52f116511c..6704faf4cf0 100644 --- a/AABB_tree/demo/AABB_tree/Scene.cpp +++ b/AABB_tree/demo/AABB_tree/Scene.cpp @@ -72,6 +72,24 @@ int Scene::open(QString filename) return 0; } +Scene::Bbox Scene::bbox() +{ + if(m_pPolyhedron == NULL) + return Bbox(); + + if(m_pPolyhedron->empty()) + return Bbox(); + + std::cout << "Compute bbox..."; + Polyhedron::Point_iterator it = m_pPolyhedron->points_begin(); + Bbox bbox = (*it).bbox(); + for(; it != m_pPolyhedron->points_end();it++) + bbox = bbox + (*it).bbox(); + std::cout << "done." << std::endl; + + return bbox; +} + void Scene::draw() { if(m_view_polyhedron) diff --git a/AABB_tree/demo/AABB_tree/Scene.h b/AABB_tree/demo/AABB_tree/Scene.h index dfa25abfad7..a8151ca9997 100644 --- a/AABB_tree/demo/AABB_tree/Scene.h +++ b/AABB_tree/demo/AABB_tree/Scene.h @@ -16,6 +16,22 @@ class Scene { +public: + Scene(); + ~Scene(); +public: + // types + typedef CGAL::Bbox_3 Bbox; + typedef CGAL::AABB_polyhedron_triangle_primitive Primitive; + typedef CGAL::AABB_traits Traits; + typedef CGAL::AABB_tree Facet_tree; + typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id; + typedef Facet_tree::Primitive_id Primitive_id; + +public: + Bbox bbox(); // computes and return polyhedron bbox + void draw(); + private: // member data Polyhedron *m_pPolyhedron; @@ -32,18 +48,7 @@ private: typedef std::pair Point_distance; Point_distance m_distance_function[100][100]; -public: - Scene(); - ~Scene(); - -public: - void draw(); - - typedef CGAL::Bbox_3 Bbox; - Bbox bbox() { return Bbox(); } - -public: - +private: // utility functions Vector random_vector(); Ray random_ray(const Bbox& bbox); @@ -53,6 +58,7 @@ public: Plane random_plane(const Bbox& bbox); Segment random_segment(const Bbox& bbox); +public: // file menu int open(QString filename); @@ -84,12 +90,6 @@ public: bool m_view_segments; bool m_view_polyhedron; - // types - typedef CGAL::AABB_polyhedron_triangle_primitive Primitive; - typedef CGAL::AABB_traits Traits; - typedef CGAL::AABB_tree Facet_tree; - typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id; - typedef Facet_tree::Primitive_id Primitive_id; // benchmarks enum {DO_INTERSECT,