mirror of https://github.com/CGAL/cgal
Merge pull request #1198 from maxGimeno/Import_AABB_Tree_demo-GF
Polyhedron_Demo: Import AABB_Tree demo
This commit is contained in:
commit
be27bf69b7
|
|
@ -1111,7 +1111,6 @@ void Scene::compute_distance_function(const Tree& tree)
|
||||||
{
|
{
|
||||||
// Get transformation
|
// Get transformation
|
||||||
Aff_transformation t = frame_transformation();
|
Aff_transformation t = frame_transformation();
|
||||||
|
|
||||||
m_max_distance_function = FT(0);
|
m_max_distance_function = FT(0);
|
||||||
FT diag = bbox_diag();
|
FT diag = bbox_diag();
|
||||||
|
|
||||||
|
|
@ -1126,7 +1125,6 @@ void Scene::compute_distance_function(const Tree& tree)
|
||||||
for(int j=0 ; j<m_grid_size ; ++j)
|
for(int j=0 ; j<m_grid_size ; ++j)
|
||||||
{
|
{
|
||||||
FT y = -diag/fd + FT(j)/FT(m_grid_size) * dy;
|
FT y = -diag/fd + FT(j)/FT(m_grid_size) * dy;
|
||||||
|
|
||||||
Point query = t( Point(x,y,z) );
|
Point query = t( Point(x,y,z) );
|
||||||
FT dist = CGAL::sqrt( tree.squared_distance(query) );
|
FT dist = CGAL::sqrt( tree.squared_distance(query) );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -203,6 +203,10 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
gl_splat
|
gl_splat
|
||||||
)
|
)
|
||||||
qt5_use_modules(scene_basic_objects OpenGL Gui Xml Script Widgets)
|
qt5_use_modules(scene_basic_objects OpenGL Gui Xml Script Widgets)
|
||||||
|
|
||||||
|
add_library(scene_color_ramp SHARED Color_ramp.cpp)
|
||||||
|
qt5_use_modules(scene_color_ramp Core)
|
||||||
|
|
||||||
add_library(point_dialog SHARED Show_point_dialog.cpp Show_point_dialog.ui ${Show_point_dialogUI_FILES})
|
add_library(point_dialog SHARED Show_point_dialog.cpp Show_point_dialog.ui ${Show_point_dialogUI_FILES})
|
||||||
qt5_use_modules(point_dialog OpenGL Gui Xml Script Widgets)
|
qt5_use_modules(point_dialog OpenGL Gui Xml Script Widgets)
|
||||||
|
|
||||||
|
|
@ -253,7 +257,8 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
scene_basic_objects)
|
scene_basic_objects)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_item(scene_implicit_function_item Scene_implicit_function_item.cpp Color_ramp.cpp )
|
add_item(scene_implicit_function_item Scene_implicit_function_item.cpp )
|
||||||
|
target_link_libraries(scene_implicit_function_item scene_color_ramp)
|
||||||
|
|
||||||
add_item(scene_polygon_soup_item Scene_polygon_soup_item.cpp)
|
add_item(scene_polygon_soup_item Scene_polygon_soup_item.cpp)
|
||||||
target_link_libraries(scene_polygon_soup_item scene_polyhedron_item)
|
target_link_libraries(scene_polygon_soup_item scene_polyhedron_item)
|
||||||
|
|
@ -271,6 +276,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
foreach( lib
|
foreach( lib
|
||||||
demo_framework
|
demo_framework
|
||||||
scene_basic_objects
|
scene_basic_objects
|
||||||
|
scene_color_ramp
|
||||||
scene_polyhedron_item
|
scene_polyhedron_item
|
||||||
scene_polygon_soup_item
|
scene_polygon_soup_item
|
||||||
scene_nef_polyhedron_item)
|
scene_nef_polyhedron_item)
|
||||||
|
|
@ -330,6 +336,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
demo_framework
|
demo_framework
|
||||||
scene_polyhedron_item
|
scene_polyhedron_item
|
||||||
scene_points_with_normal_item
|
scene_points_with_normal_item
|
||||||
|
scene_color_ramp
|
||||||
scene_implicit_function_item
|
scene_implicit_function_item
|
||||||
scene_polylines_item
|
scene_polylines_item
|
||||||
scene_basic_objects
|
scene_basic_objects
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,21 @@ Color_ramp::build_blue()
|
||||||
r_.add(0.1,0.4);
|
r_.add(0.1,0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Color_ramp::build_thermal()
|
||||||
|
{
|
||||||
|
r_.rebuild(1,0.5);
|
||||||
|
g_.rebuild(1,0);
|
||||||
|
b_.rebuild(1,0);
|
||||||
|
|
||||||
|
r_.add(0.3,1);
|
||||||
|
r_.add(0.05,1);
|
||||||
|
g_.add(0.05,0.8);
|
||||||
|
g_.add(0.3,0.5);
|
||||||
|
b_.add(0.05,0.6);
|
||||||
|
b_.add(0.05,0.3);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Color_ramp::
|
Color_ramp::
|
||||||
print() const
|
print() const
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,16 @@
|
||||||
#ifndef _COLOR_RAMP_H
|
#ifndef _COLOR_RAMP_H
|
||||||
#define _COLOR_RAMP_H
|
#define _COLOR_RAMP_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
#ifdef scene_color_ramp_EXPORTS
|
||||||
|
# define SCENE_COLOR_RAMP_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define SCENE_COLOR_RAMP_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
class Color_component
|
class SCENE_COLOR_RAMP_EXPORT Color_component
|
||||||
{
|
{
|
||||||
typedef std::list<std::pair<double,double> > Values;
|
typedef std::list<std::pair<double,double> > Values;
|
||||||
|
|
||||||
|
|
@ -26,7 +33,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Color_ramp
|
class SCENE_COLOR_RAMP_EXPORT Color_ramp
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
Color_ramp();
|
Color_ramp();
|
||||||
|
|
@ -39,6 +46,7 @@ public :
|
||||||
|
|
||||||
void build_red();
|
void build_red();
|
||||||
void build_blue();
|
void build_blue();
|
||||||
|
void build_thermal();
|
||||||
void print() const;
|
void print() const;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
include( polyhedron_demo_macros )
|
include( polyhedron_demo_macros )
|
||||||
|
|
||||||
polyhedron_demo_plugin(cut_plugin Cut_plugin)
|
polyhedron_demo_plugin(cut_plugin Cut_plugin )
|
||||||
target_link_libraries(cut_plugin scene_polyhedron_item scene_basic_objects)
|
target_link_libraries(cut_plugin scene_polyhedron_item scene_basic_objects scene_color_ramp)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -2,32 +2,6 @@
|
||||||
using namespace CGAL::Three;
|
using namespace CGAL::Three;
|
||||||
|
|
||||||
|
|
||||||
struct Scene_plane_item_priv
|
|
||||||
{
|
|
||||||
Scene_plane_item_priv(Scene_plane_item* parent)
|
|
||||||
{
|
|
||||||
item = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
~Scene_plane_item_priv() {
|
|
||||||
}
|
|
||||||
|
|
||||||
double scene_diag() const {
|
|
||||||
const Scene_item::Bbox& bbox = item->scene->bbox();
|
|
||||||
const double& xdelta = bbox.xmax()-bbox.xmin();
|
|
||||||
const double& ydelta = bbox.ymax()-bbox.ymin();
|
|
||||||
const double& zdelta = bbox.zmax()-bbox.zmin();
|
|
||||||
const double diag = std::sqrt(xdelta*xdelta +
|
|
||||||
ydelta*ydelta +
|
|
||||||
zdelta*zdelta);
|
|
||||||
return diag * 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Scene_plane_item* item;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
Scene_plane_item::Scene_plane_item(const CGAL::Three::Scene_interface* scene_interface)
|
Scene_plane_item::Scene_plane_item(const CGAL::Three::Scene_interface* scene_interface)
|
||||||
:CGAL::Three::Scene_item(NbOfVbos,NbOfVaos),
|
:CGAL::Three::Scene_item(NbOfVbos,NbOfVaos),
|
||||||
|
|
@ -37,13 +11,11 @@ Scene_plane_item::Scene_plane_item(const CGAL::Three::Scene_interface* scene_int
|
||||||
frame(new ManipulatedFrame())
|
frame(new ManipulatedFrame())
|
||||||
{
|
{
|
||||||
setNormal(0., 0., 1.);
|
setNormal(0., 0., 1.);
|
||||||
d = new Scene_plane_item_priv(this);
|
|
||||||
//Generates an integer which will be used as ID for each buffer
|
//Generates an integer which will be used as ID for each buffer
|
||||||
invalidateOpenGLBuffers();
|
invalidateOpenGLBuffers();
|
||||||
}
|
}
|
||||||
Scene_plane_item::~Scene_plane_item() {
|
Scene_plane_item::~Scene_plane_item() {
|
||||||
delete frame;
|
delete frame;
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene_plane_item::initializeBuffers(Viewer_interface *viewer) const
|
void Scene_plane_item::initializeBuffers(Viewer_interface *viewer) const
|
||||||
|
|
@ -75,12 +47,12 @@ void Scene_plane_item::initializeBuffers(Viewer_interface *viewer) const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene_plane_item::compute_normals_and_vertices(void)
|
void Scene_plane_item::compute_normals_and_vertices(void) const
|
||||||
{
|
{
|
||||||
positions_quad.resize(0);
|
positions_quad.resize(0);
|
||||||
positions_lines.resize(0);
|
positions_lines.resize(0);
|
||||||
|
|
||||||
const double diag = d->scene_diag();
|
const double diag = scene_diag();
|
||||||
//The quad
|
//The quad
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -94,11 +66,11 @@ void Scene_plane_item::compute_normals_and_vertices(void)
|
||||||
positions_quad.push_back(-diag);
|
positions_quad.push_back(-diag);
|
||||||
positions_quad.push_back(0.0);
|
positions_quad.push_back(0.0);
|
||||||
|
|
||||||
positions_quad.push_back(-diag);
|
|
||||||
positions_quad.push_back(diag);
|
positions_quad.push_back(diag);
|
||||||
|
positions_quad.push_back(-diag);
|
||||||
positions_quad.push_back(0.0);
|
positions_quad.push_back(0.0);
|
||||||
positions_quad.push_back(diag);
|
|
||||||
positions_quad.push_back(-diag);
|
positions_quad.push_back(-diag);
|
||||||
|
positions_quad.push_back(diag);
|
||||||
positions_quad.push_back(0.0);
|
positions_quad.push_back(0.0);
|
||||||
positions_quad.push_back(diag);
|
positions_quad.push_back(diag);
|
||||||
positions_quad.push_back(diag);
|
positions_quad.push_back(diag);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_epic;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_epic;
|
||||||
typedef Kernel_epic::Plane_3 Plane_3;
|
typedef Kernel_epic::Plane_3 Plane_3;
|
||||||
|
|
||||||
struct Scene_plane_item_priv;
|
|
||||||
class SCENE_BASIC_OBJECTS_EXPORT Scene_plane_item
|
class SCENE_BASIC_OBJECTS_EXPORT Scene_plane_item
|
||||||
: public CGAL::Three::Scene_item
|
: public CGAL::Three::Scene_item
|
||||||
{
|
{
|
||||||
|
|
@ -28,6 +27,16 @@ public:
|
||||||
Scene_plane_item(const CGAL::Three::Scene_interface* scene_interface);
|
Scene_plane_item(const CGAL::Three::Scene_interface* scene_interface);
|
||||||
~Scene_plane_item();
|
~Scene_plane_item();
|
||||||
|
|
||||||
|
double scene_diag() const {
|
||||||
|
const Scene_item::Bbox& bbox = scene->bbox();
|
||||||
|
const double& xdelta = bbox.xmax()-bbox.xmin();
|
||||||
|
const double& ydelta = bbox.ymax()-bbox.ymin();
|
||||||
|
const double& zdelta = bbox.zmax()-bbox.zmin();
|
||||||
|
const double diag = std::sqrt(xdelta*xdelta +
|
||||||
|
ydelta*ydelta +
|
||||||
|
zdelta*zdelta);
|
||||||
|
return diag * 0.7;
|
||||||
|
}
|
||||||
bool isFinite() const { return false; }
|
bool isFinite() const { return false; }
|
||||||
bool isEmpty() const { return false; }
|
bool isEmpty() const { return false; }
|
||||||
void compute_bbox() const { _bbox = Bbox(); }
|
void compute_bbox() const { _bbox = Bbox(); }
|
||||||
|
|
@ -61,9 +70,6 @@ public Q_SLOTS:
|
||||||
|
|
||||||
void setManipulatable(bool b = true);
|
void setManipulatable(bool b = true);
|
||||||
protected:
|
protected:
|
||||||
friend struct Scene_plane_item_priv;
|
|
||||||
Scene_plane_item_priv* d;
|
|
||||||
|
|
||||||
|
|
||||||
const CGAL::Three::Scene_interface* scene;
|
const CGAL::Three::Scene_interface* scene;
|
||||||
bool manipulable;
|
bool manipulable;
|
||||||
|
|
@ -88,7 +94,7 @@ protected:
|
||||||
mutable QOpenGLShaderProgram *program;
|
mutable QOpenGLShaderProgram *program;
|
||||||
|
|
||||||
void initializeBuffers(CGAL::Three::Viewer_interface*)const;
|
void initializeBuffers(CGAL::Three::Viewer_interface*)const;
|
||||||
void compute_normals_and_vertices(void);
|
void compute_normals_and_vertices(void) const;
|
||||||
mutable bool are_buffers_filled;
|
mutable bool are_buffers_filled;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1272,7 +1272,7 @@ Scene_polyhedron_item::select(double orig_x,
|
||||||
typedef Input_facets_AABB_tree Tree;
|
typedef Input_facets_AABB_tree Tree;
|
||||||
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
|
typedef Tree::Object_and_primitive_id Object_and_primitive_id;
|
||||||
|
|
||||||
Tree* aabb_tree = static_cast<Input_facets_AABB_tree*>(d->get_aabb_tree());
|
Tree* aabb_tree = static_cast<Tree*>(d->get_aabb_tree());
|
||||||
if(aabb_tree)
|
if(aabb_tree)
|
||||||
{
|
{
|
||||||
const Kernel::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
const Kernel::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
||||||
|
|
@ -1756,3 +1756,4 @@ bool Scene_polyhedron_item::triangulated(){return d->poly->is_pure_triangle();}
|
||||||
bool Scene_polyhedron_item::self_intersected(){return !(d->self_intersect);}
|
bool Scene_polyhedron_item::self_intersected(){return !(d->self_intersect);}
|
||||||
void Scene_polyhedron_item::setItemIsMulticolor(bool b){ d->is_multicolor = b;}
|
void Scene_polyhedron_item::setItemIsMulticolor(bool b){ d->is_multicolor = b;}
|
||||||
bool Scene_polyhedron_item::isItemMulticolor(){ return d->is_multicolor;}
|
bool Scene_polyhedron_item::isItemMulticolor(){ return d->is_multicolor;}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue