diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 752942da33f..ce816b6b64d 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -177,6 +177,8 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) add_item(scene_polyhedron_item Scene_polyhedron_item.cpp ${statisticsPolyhedronUI_FILES})# Scene_polyhedron_item.moc) add_item(scene_polyhedron_transform_item Plugins/PCA/Scene_polyhedron_transform_item.cpp )#Scene_polyhedron_transform_item.moc) + add_item(scene_segmented_image_item Scene_segmented_image_item.cpp) + # special target_link_libraries(scene_polyhedron_transform_item scene_polyhedron_item) @@ -200,7 +202,11 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) target_link_libraries(scene_polyhedron_shortest_path_item scene_polyhedron_item_decorator scene_polyhedron_item scene_polylines_item) if(EIGEN3_FOUND ) + qt5_wrap_ui( editionUI_FILES Plugins/Surface_modeling/Deform_mesh.ui ) add_item(scene_textured_polyhedron_item Scene_textured_polyhedron_item.cpp texture.cpp)# Scene_textured_polyhedron_item.moc) + add_item(scene_edit_polyhedron_item Plugins/Surface_modeling/Scene_edit_polyhedron_item.cpp + ${editionUI_FILES}) + target_link_libraries(scene_edit_polyhedron_item scene_polyhedron_item scene_polyhedron_item_k_ring_selection) endif() add_item(scene_implicit_function_item Scene_implicit_function_item.cpp Color_ramp.cpp )#Scene_implicit_function_item.moc) @@ -214,6 +220,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) target_link_libraries( scene_points_with_normal_item gl_splat) target_link_libraries( demo_framework gl_splat) + foreach( lib diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/CMakeLists.txt index 48d3b376fb4..a12d86da3d3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/CMakeLists.txt @@ -1,7 +1,7 @@ include( polyhedron_demo_macros ) - if ( Boost_VERSION GREATER 103400 ) + +if ( Boost_VERSION GREATER 103400 ) remove_definitions(-DQT_STATICPLUGIN) - add_item(scene_segmented_image_item Scene_segmented_image_item.cpp) qt5_wrap_cpp( VOLUME_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/Volume_plane_thread.h ) qt5_wrap_cpp( VOLUME_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/Volume_plane_interface.h ) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.cpp deleted file mode 100644 index a58a9e4647a..00000000000 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.cpp +++ /dev/null @@ -1,920 +0,0 @@ -#include "config.h" - -#include "Scene_segmented_image_item.h" -#include "Image_type.h" -#include -#include -#include -#include -#include - - - -// ----------------------------------- -// Internal classes -// ----------------------------------- -namespace internal { - -class Image_accessor -{ -public: - Image_accessor(const Image& im, int dx=1, int dy=1, int dz=1); - - bool is_vertex_active(std::size_t i, std::size_t j, std::size_t k) const; - const QColor& vertex_color(std::size_t i, std::size_t j, std::size_t k) const; - void normal(std::size_t i, std::size_t j, std::size_t k, - float& x, float& y, float& z) const; - - int dx() const { return dx_; } - int dy() const { return dy_; } - int dz() const { return dz_; } - std::size_t xdim() const { return im_.xdim(); } - std::size_t ydim() const { return im_.ydim(); } - std::size_t zdim() const { return im_.zdim(); } - double vx() const { return im_.vx(); } - double vy() const { return im_.vy(); } - double vz() const { return im_.vz(); } - -private: - unsigned char non_null_neighbor_data(std::size_t i, - std::size_t j, - std::size_t k) const; - - unsigned char image_data(std::size_t i, std::size_t j, std::size_t k) const; - - void add_to_normal(unsigned char v, - float& x, float& y, float& z, - int dx, int dy, int dz) const; - -private: - const Image& im_; - int dx_, dy_, dz_; - const QColor default_color_; - std::map colors_; -}; - - -Image_accessor::Image_accessor(const Image& im, int dx, int dy, int dz) -: im_(im) -, dx_(dx) -, dy_(dy) -, dz_(dz) -, default_color_() -, colors_() -{ - const std::size_t xdim = im_.xdim(); - const std::size_t ydim = im_.ydim(); - const std::size_t zdim = im_.zdim(); - - for(std::size_t i=0 ; i::iterator it = colors_.begin(), - end = colors_.end() ; it != end ; ++it, ++i ) - { - double hue = starting_hue + 1./colors_.size() * i; - if ( hue > 1. ) { hue -= 1.; } - it->second = QColor::fromHsvF(hue, .75, .75); - } -} - -bool -Image_accessor:: -is_vertex_active(std::size_t i, std::size_t j, std::size_t k) const -{ - unsigned char v1 = image_data(i-dx_, j-dy_, k-dz_); - unsigned char v2 = image_data(i-dx_, j-dy_, k ); - unsigned char v3 = image_data(i-dx_, j , k-dz_); - unsigned char v4 = image_data(i-dx_, j , k ); - unsigned char v5 = image_data(i , j-dy_, k-dz_); - unsigned char v6 = image_data(i , j-dy_, k ); - unsigned char v7 = image_data(i , j , k-dz_); - unsigned char v8 = image_data(i , j , k ); - - // don't draw interior vertices - if ( v1 != 0 && v2 != 0 && v3 != 0 && v4 != 0 && - v5 != 0 && v6 != 0 && v7 != 0 && v8 != 0 ) - { - return false; - } - - return ( v1 != 0 || v2 != 0 || v3 != 0 || v4 != 0 || - v5 != 0 || v6 != 0 || v7 != 0 || v8 != 0 ); -} - -const QColor& -Image_accessor::vertex_color(std::size_t i, std::size_t j, std::size_t k) const -{ - unsigned char c = non_null_neighbor_data(i,j,k); - if ( 0 == c ) { return default_color_; } - - std::map::const_iterator color = colors_.find(c); - if ( colors_.end() == color ) { return default_color_; } - - return color->second; -} - -unsigned char -Image_accessor::image_data(std::size_t i, std::size_t j, std::size_t k) const -{ - if ( i(im_.image(),i,j,k); - else - return 0; -} - -unsigned char -Image_accessor:: -non_null_neighbor_data(std::size_t i, std::size_t j, std::size_t k) const -{ - unsigned char v = image_data(i-dx_, j-dy_, k-dz_); - if ( v != 0 ) { return v; } - - v = image_data(i-dx_, j-dy_, k ); - if ( v != 0 ) { return v; } - - v = image_data(i-dx_, j , k-dz_); - if ( v != 0 ) { return v; } - - v = image_data(i-dx_, j , k ); - if ( v != 0 ) { return v; } - - v = image_data(i , j-dy_, k-dz_); - if ( v != 0 ) { return v; } - - v = image_data(i , j-dy_, k ); - if ( v != 0 ) { return v; } - - v = image_data(i , j , k-dz_); - if ( v != 0 ) { return v; } - - v = image_data(i , j , k ); - if ( v != 0 ) { return v; } - - return 0; -} - -void -Image_accessor:: -normal(std::size_t i, std::size_t j, std::size_t k, - float& x, float& y, float& z) const -{ - unsigned char v = image_data(i-dx_, j-dy_, k-dz_); - add_to_normal(v,x,y,z, 1 , 1 , 1); - - v = image_data( i-dx_, j-dy_, k); - add_to_normal(v,x,y,z, 1 , 1 , -1); - - v = image_data( i-dx_, j , k-dz_); - add_to_normal(v,x,y,z, 1 , -1 , 1); - - v = image_data( i-dx_, j , k ); - add_to_normal(v,x,y,z, 1 , -1 , -1); - - v = image_data( i , j-dy_, k-dz_); - add_to_normal(v,x,y,z, -1 , 1 , 1); - - v = image_data( i , j-dy_, k ); - add_to_normal(v,x,y,z, -1 , 1 , -1); - - v = image_data( i , j , k-dz_); - add_to_normal(v,x,y,z, -1 , -1 , 1); - - v = image_data( i , j , k); - add_to_normal(v,x,y,z, -1 , -1 , -1); -} - -void -Image_accessor:: -add_to_normal(unsigned char v, - float& x, float& y, float& z, - int dx, int dy, int dz) const -{ - if ( 0 != v ) - { - x += dx; - y += dy; - z += dz; - } -} - - - -class Vertex_buffer_helper -{ -public: - Vertex_buffer_helper(const Image_accessor& data); - ~Vertex_buffer_helper(); - - void fill_buffer_data(); - - const GLfloat* colors() const { return color_array_; } - const GLfloat* normals() const { return normal_array_; } - const GLfloat* vertices() const { return vertex_array_; } - const GLuint* quads() const { return quad_array_; } - - std::size_t color_size() const { return color_size_*sizeof(GLfloat); } - std::size_t normal_size() const { return normal_size_*sizeof(GLfloat); } - std::size_t vertex_size() const { return vertex_size_*sizeof(GLfloat); } - std::size_t quad_size() const { return quad_size_*sizeof(GLuint); } - -private: - void treat_vertex(std::size_t i, std::size_t j, std::size_t k); - - void push_color(std::size_t i, std::size_t j, std::size_t k); - void push_normal(std::size_t i, std::size_t j, std::size_t k); - void push_vertex(std::size_t i, std::size_t j, std::size_t k); - void push_quads(std::size_t i, std::size_t j, std::size_t k); - void push_quad(int pos1, int pos2, int pos3, int pos4); - - int compute_position(std::size_t i, std::size_t j, std::size_t k) const; - int vertex_index(std::size_t i, std::size_t j, std::size_t k) const; - - void create_arrays(); - - template - void create_array(T*& destination, std::size_t& size, const std::vector& source); - - int dx() const { return data_.dx(); } - int dy() const { return data_.dy(); } - int dz() const { return data_.dz(); } - -private: - static int vertex_not_found_; - - const Image_accessor& data_; - typedef std::map Indices; - Indices indices_; - std::vector colors_, normals_, vertices_; - std::vector quads_; - - GLfloat *color_array_, *normal_array_, *vertex_array_; - GLuint* quad_array_; - std::size_t color_size_, normal_size_, vertex_size_, quad_size_; -}; - -int Vertex_buffer_helper::vertex_not_found_ = -1; - -Vertex_buffer_helper:: -Vertex_buffer_helper(const Image_accessor& data) -: data_(data) -, color_array_(NULL) -, normal_array_(NULL) -, vertex_array_(NULL) -, quad_array_(NULL) -, color_size_(0) -, normal_size_(0) -, vertex_size_(0) -, quad_size_(0) -{ -} - -Vertex_buffer_helper:: -~Vertex_buffer_helper() -{ - delete[] color_array_; - delete[] normal_array_; - delete[] vertex_array_; - delete[] quad_array_; -} - -void -Vertex_buffer_helper:: -fill_buffer_data() -{ - std::size_t i,j,k; - - for ( i = 0 ; i <= data_.xdim() ; i+=dx() ) - { - for ( j = 0 ; j <= data_.ydim() ; j+=dy() ) - { - for ( k = 0 ; k <= data_.zdim() ; k+=dz() ) - { - treat_vertex(i,j,k); - } - } - } - - create_arrays(); -} - -void -Vertex_buffer_helper::treat_vertex(std::size_t i, std::size_t j, std::size_t k) -{ - if ( data_.is_vertex_active(i,j,k) ) - { - push_vertex(i,j,k); - push_color(i,j,k); - push_normal(i,j,k); - push_quads(i,j,k); - } -} - -void -Vertex_buffer_helper::push_color(std::size_t i, std::size_t j, std::size_t k) -{ - const QColor& color = data_.vertex_color(i,j,k); - if ( ! color.isValid() ) { return; } - - colors_.push_back(color.red()/255.f); - colors_.push_back(color.green()/255.f); - colors_.push_back(color.blue()/255.f); -} - -void -Vertex_buffer_helper::push_normal(std::size_t i, std::size_t j, std::size_t k) -{ - float x=0.f, y=0.f, z=0.f; - data_.normal(i,j,k,x,y,z); - - float norm = std::sqrt(x*x+y*y+z*z); - x = x / norm; - y = y / norm; - z = z / norm; - - normals_.push_back(x); - normals_.push_back(y); - normals_.push_back(z); -} - -void -Vertex_buffer_helper::push_vertex(std::size_t i, std::size_t j, std::size_t k) -{ - indices_.insert(std::make_pair(compute_position(i,j,k), - vertices_.size()/3)); - - vertices_.push_back(i*data_.vx()); - vertices_.push_back(j*data_.vy()); - vertices_.push_back(k*data_.vz()); - -} - -void -Vertex_buffer_helper::push_quads(std::size_t i, std::size_t j, std::size_t k) -{ - int pos1 = vertex_index(i-dx(), j , k); - int pos2 = vertex_index(i-dx(), j-dy(), k); - int pos3 = vertex_index(i , j-dy(), k); - int pos4 = vertex_index(i ,j , k); - push_quad(pos1, pos2, pos3, pos4); - - pos1 = vertex_index(i-dx(), j, k); - pos2 = vertex_index(i-dx(), j, k-dz()); - pos3 = vertex_index(i , j, k-dz()); - push_quad(pos1, pos2, pos3, pos4); - - pos1 = vertex_index(i, j-dy(), k); - pos2 = vertex_index(i, j-dy(), k-dz()); - pos3 = vertex_index(i, j , k-dz()); - push_quad(pos1, pos2, pos3, pos4); -} - -void -Vertex_buffer_helper::push_quad(int pos1, int pos2, int pos3, int pos4) -{ - if ( pos1 != vertex_not_found_ - && pos2 != vertex_not_found_ - && pos3 != vertex_not_found_ ) - { - quads_.push_back(pos1); - quads_.push_back(pos2); - quads_.push_back(pos3); - quads_.push_back(pos1); - quads_.push_back(pos3); - quads_.push_back(pos4); - } -} - -int -Vertex_buffer_helper:: -compute_position(std::size_t i, std::size_t j, std::size_t k) const -{ - return static_cast( - i/dx() * (data_.ydim()/dy()+1) * (data_.zdim()/dz()+1) - + j/dy() * (data_.zdim()/dz()+1) - + k/dz()); -} - -int -Vertex_buffer_helper:: -vertex_index(std::size_t i, std::size_t j, std::size_t k) const -{ - if ( i > data_.xdim() || j > data_.ydim() || k > data_.zdim() ) - { - return vertex_not_found_; - } - - int vertex_key = compute_position(i,j,k); - Indices::const_iterator it = indices_.find(vertex_key); - if ( it != indices_.end() ) - { - return static_cast(it->second); - } - - return vertex_not_found_; -} - - -void -Vertex_buffer_helper:: -create_arrays() -{ - create_array(color_array_, color_size_, colors_); - create_array(normal_array_, normal_size_, normals_); - create_array(vertex_array_, vertex_size_, vertices_); - create_array(quad_array_, quad_size_, quads_); -} - -template -void -Vertex_buffer_helper:: -create_array(T*& destination, std::size_t& size, const std::vector& source) -{ - size = source.size(); - destination = new T[size]; - - int i=0; - for ( typename std::vector::const_iterator it = source.begin(), - end = source.end() ; it != end ; ++it ) - { - destination[i++] = *it; - } -} - -} // namespace internal - - -// ----------------------------------- -// Scene_segmented_image_item -// ----------------------------------- -Scene_segmented_image_item::Scene_segmented_image_item(Image* im, - int display_scale) - : m_image(im) - , m_initialized(false) - , m_voxel_scale(display_scale) - -{ - CGAL_USE(display_scale); - - v_box = new std::vector(); - compile_shaders(); - initialize_buffers(); - setRenderingMode(Flat); -} - - -Scene_segmented_image_item::~Scene_segmented_image_item() -{ - for(int i=0; icreate(); - //Vertex source code - const char vertex_source[] = - { - "#version 120 \n" - "attribute highp vec4 vertex;\n" - "attribute highp vec3 normal;\n" - "attribute highp vec4 inColor;\n" - - "uniform highp mat4 mvp_matrix;\n" - "uniform highp mat4 mv_matrix; \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 color; \n" - "void main(void)\n" - "{\n" - " color=inColor; \n" - " fP = mv_matrix * vertex; \n" - " fN = mat3(mv_matrix)* normal; \n" - " gl_Position = mvp_matrix * vertex; \n" - "}" - }; - //Fragment source code - const char fragment_source[] = - { - "#version 120 \n" - "varying highp vec4 fP; \n" - "varying highp vec3 fN; \n" - "varying highp vec4 color; \n" - "uniform bool is_two_side; \n" - "uniform highp vec4 light_pos; \n" - "uniform highp vec4 light_diff; \n" - "uniform highp vec4 light_spec; \n" - "uniform highp vec4 light_amb; \n" - "uniform float spec_power ; \n" - - "void main(void) { \n" - - " vec3 L = light_pos.xyz - fP.xyz; \n" - " vec3 V = -fP.xyz; \n" - - " vec3 N; \n" - " if(fN == vec3(0.0,0.0,0.0)) \n" - " N = vec3(0.0,0.0,0.0); \n" - " else \n" - " N = normalize(fN); \n" - " L = normalize(L); \n" - " V = normalize(V); \n" - - " vec3 R = reflect(-L, N); \n" - " vec4 diffuse; \n" - " if(!is_two_side) \n" - " diffuse = max(dot(N,L),0) * light_diff*color; \n" - " else \n" - " diffuse = max(abs(dot(N,L)),0) * light_diff*color; \n" - " vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n" - - "gl_FragColor = color*light_amb + diffuse + specular; \n" - "} \n" - "\n" - }; - QOpenGLShader *vertex_shader = new QOpenGLShader(QOpenGLShader::Vertex); - if(!vertex_shader->compileSourceCode(vertex_source)) - { - std::cerr<<"Compiling vertex source FAILED"<compileSourceCode(fragment_source)) - { - std::cerr<<"Compiling fragmentsource FAILED"<camera()->getModelViewProjectionMatrix(mat); - for(int i=0; i < 16; i++) - { - mvpMatrix.data()[i] = (float)mat[i]; - } - viewer->camera()->getModelViewMatrix(mat); - for(int i=0; i < 16; i++) - { - mvMatrix.data()[i] = (float)mat[i]; - } - QVector4D position(0.0f,0.0f,1.0f,1.0f ); - GLboolean isTwoSide; - viewer->glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE,&isTwoSide); - // define material - QVector4D ambient; - QVector4D diffuse; - QVector4D specular; - GLfloat shininess ; - // Ambient - ambient[0] = 0.29225f; - ambient[1] = 0.29225f; - ambient[2] = 0.29225f; - ambient[3] = 1.0f; - // Diffuse - diffuse[0] = 0.50754f; - diffuse[1] = 0.50754f; - diffuse[2] = 0.50754f; - diffuse[3] = 1.0f; - // Specular - specular[0] = 0.0f; - specular[1] = 0.0f; - specular[2] = 0.0f; - specular[3] = 0.0f; - // Shininess - shininess = 51.2f; - - - rendering_program.bind(); - colorLocation[0] = rendering_program.uniformLocation("color"); - twosideLocation = rendering_program.uniformLocation("is_two_side"); - mvpLocation[0] = rendering_program.uniformLocation("mvp_matrix"); - mvLocation[0] = rendering_program.uniformLocation("mv_matrix"); - lightLocation[0] = rendering_program.uniformLocation("light_pos"); - lightLocation[1] = rendering_program.uniformLocation("light_diff"); - lightLocation[2] = rendering_program.uniformLocation("light_spec"); - lightLocation[3] = rendering_program.uniformLocation("light_amb"); - lightLocation[4] = rendering_program.uniformLocation("spec_power"); - - rendering_program.setUniformValue(lightLocation[0], position); - rendering_program.setUniformValue(twosideLocation, isTwoSide); - rendering_program.setUniformValue(mvpLocation[0], mvpMatrix); - rendering_program.setUniformValue(mvLocation[0], mvMatrix); - rendering_program.setUniformValue(lightLocation[1], diffuse); - rendering_program.setUniformValue(lightLocation[2], specular); - rendering_program.setUniformValue(lightLocation[3], ambient); - rendering_program.setUniformValue(lightLocation[4], shininess); - - rendering_program.release(); -} - -void -Scene_segmented_image_item::compute_bbox()const -{ - if(!m_image) - { - _bbox = Bbox(); - return; - } - _bbox = Bbox(0, 0, 0, - m_image->xdim() * m_image->vx(), - m_image->ydim() * m_image->vy(), - m_image->zdim() * m_image->vz()); -} - -void -Scene_segmented_image_item::draw(Viewer_interface* viewer) const -{ - if(m_image) - { - - //m_image->gl_draw_bbox(3.0f,0,0,0); - draw_gl(viewer); - } -} - -QString -Scene_segmented_image_item::toolTip() const -{ - return tr("

Image %1

" - "

Word type: %2

" - "

Dimensions: %3 x %4 x %5

" - "

Spacings: ( %6 , %7 , %8 )

") - .arg(this->name()) - .arg("...") - .arg(m_image->xdim()) - .arg(m_image->ydim()) - .arg(m_image->zdim()) - .arg(m_image->vx()) - .arg(m_image->vy()) - .arg(m_image->vz()); -} - -bool -Scene_segmented_image_item::supportsRenderingMode(RenderingMode m) const -{ - switch ( m ) - { - case Gouraud: - return false; - - case Points: - case Wireframe: - case Flat: - case FlatPlusEdges: - return true; - - default: - return false; - } - - return false; -} - -void -Scene_segmented_image_item::initialize_buffers() -{ - internal::Image_accessor image_data_accessor (*m_image, - m_voxel_scale, - m_voxel_scale, - m_voxel_scale); - - internal::Vertex_buffer_helper helper (image_data_accessor); - helper.fill_buffer_data(); - - draw_Bbox(bbox(), v_box); - std::vector nul_vec(0); - for(std::size_t i=0; isize(); i++) - nul_vec.push_back(0.0); - - rendering_program.bind(); - vao[0].bind(); - m_vbo[0].bind(); - m_vbo[0].allocate(helper.vertices(), static_cast(helper.vertex_size())); - poly_vertexLocation[0] = rendering_program.attributeLocation("vertex"); - rendering_program.enableAttributeArray(poly_vertexLocation[0]); - rendering_program.setAttributeBuffer(poly_vertexLocation[0],GL_FLOAT,0,3); - m_vbo[0].release(); - - m_vbo[1].bind(); - m_vbo[1].allocate(helper.normals(), static_cast(helper.normal_size())); - normalsLocation[0] = rendering_program.attributeLocation("normal"); - rendering_program.enableAttributeArray(normalsLocation[0]); - rendering_program.setAttributeBuffer(normalsLocation[0],GL_FLOAT,0,3); - m_vbo[1].release(); - - m_vbo[2].bind(); - m_vbo[2].allocate(helper.colors(), static_cast(helper.color_size())); - colorLocation[0] = rendering_program.attributeLocation("inColor"); - rendering_program.enableAttributeArray(colorLocation[0]); - rendering_program.setAttributeBuffer(colorLocation[0],GL_FLOAT,0,3); - m_vbo[2].release(); - - m_ibo->bind(); - m_ibo->allocate(helper.quads(), static_cast(helper.quad_size())); - vao[0].release(); - - color.resize(0); - for(std::size_t i=0; idata(), static_cast(v_box->size()*sizeof(float))); - poly_vertexLocation[0] = rendering_program.attributeLocation("vertex"); - rendering_program.enableAttributeArray(poly_vertexLocation[0]); - rendering_program.setAttributeBuffer(poly_vertexLocation[0],GL_FLOAT,0,3); - m_vbo[3].release(); - - m_vbo[4].bind(); - m_vbo[3].allocate(nul_vec.data(), static_cast(nul_vec.size()*sizeof(float))); - normalsLocation[0] = rendering_program.attributeLocation("normal"); - rendering_program.enableAttributeArray(normalsLocation[0]); - rendering_program.setAttributeBuffer(normalsLocation[0],GL_FLOAT,0,3); - m_vbo[4].release(); - - m_vbo[5].bind(); - m_vbo[5].allocate(nul_vec.data(), static_cast(nul_vec.size()*sizeof(float))); - colorLocation[0] = rendering_program.attributeLocation("inColor"); - rendering_program.enableAttributeArray(colorLocation[0]); - rendering_program.setAttributeBuffer(colorLocation[0],GL_FLOAT,0,3); - m_vbo[5].release(); - - m_ibo->bind(); - vao[1].release(); - rendering_program.release(); - - m_initialized = true; -} - - -void -Scene_segmented_image_item::draw_gl(Viewer_interface* viewer) const -{ - attrib_buffers(viewer); - rendering_program.bind(); - vao[0].bind(); - viewer->glDrawElements(GL_TRIANGLES, m_ibo->size()/sizeof(GLuint), GL_UNSIGNED_INT, 0); - vao[0].release(); - - vao[1].bind(); - viewer->glLineWidth(3); - viewer->glDrawArrays(GL_LINES, 0, static_cast(v_box->size()/3)); - vao[1].release(); - rendering_program.release(); -} - -GLint -Scene_segmented_image_item::ibo_size() const -{ - m_ibo->bind(); - GLint nb_elts = m_ibo->size(); - m_ibo->release(); - - return nb_elts/sizeof(GLuint); - - return 0; -} - -void Scene_segmented_image_item::changed() -{ - initialize_buffers(); -} - -void Scene_segmented_image_item::draw_Bbox(Bbox bbox, std::vector *vertices) -{ - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmin); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmin); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymax); - vertices->push_back(bbox.zmax); - - vertices->push_back(bbox.xmax); - vertices->push_back(bbox.ymin); - vertices->push_back(bbox.zmax); - -} - diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.h deleted file mode 100644 index e1e9a649c25..00000000000 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef SCENE_SEGMENTED_IMAGE_ITEM_H -#define SCENE_SEGMENTED_IMAGE_ITEM_H - -#include -#include "Image_type_fwd.h" -#include "Scene_segmented_image_item_config.h" -#include - -#include -#include -#include - -#include -#include - -typedef CGAL::Image_3 Image; -using namespace CGAL::Three; -class SCENE_SEGMENTED_IMAGE_ITEM_EXPORT Scene_segmented_image_item - : public Scene_item -{ - Q_OBJECT -public: - - Scene_segmented_image_item(Image* im, int drawing_scale); - ~Scene_segmented_image_item(); - - bool isFinite() const { return true; } - bool isEmpty() const { return false; } - void compute_bbox() const; - - Scene_segmented_image_item* clone() const { return NULL; } - - // rendering mode - virtual bool supportsRenderingMode(RenderingMode m) const; - - // draw - virtual void direct_draw(CGAL::Three::Viewer_interface* viewer) const - { draw(viewer); } - virtual void direct_draw_edges(CGAL::Three::Viewer_interface* viewer) const - { draw_edges(viewer); } - virtual void draw(CGAL::Three::Viewer_interface*) const; - virtual void draw_edges(CGAL::Three::Viewer_interface* viewer) const - { draw_gl(viewer); } - - virtual QString toolTip() const; - - const Image* image() const { return m_image; } - -private: - void draw_gl(CGAL::Three::Viewer_interface* viewer) const; - - void initialize_buffers(); - GLint ibo_size() const; - -public: - Image* m_image; - -private: - bool m_initialized; -#ifdef SCENE_SEGMENTED_IMAGE_GL_BUFFERS_AVAILABLE - int m_voxel_scale; - static const int vaoSize = 2; - static const int vboSize = 6; - mutable int poly_vertexLocation[1]; - mutable int normalsLocation[1]; - mutable int mvpLocation[1]; - mutable int mvLocation[1]; - mutable int colorLocation[1]; - mutable int lightLocation[5]; - mutable int twosideLocation; - - std::vector *v_box; - std::vector color; - - - mutable QOpenGLBuffer m_vbo[vboSize]; - mutable QOpenGLBuffer *m_ibo; - mutable QOpenGLVertexArrayObject vao[vaoSize]; - mutable QOpenGLShaderProgram rendering_program; - void draw_bbox(); - void attrib_buffers(CGAL::Three::Viewer_interface*) const; - void compile_shaders(); - void draw_Bbox(Bbox bbox, std::vector *vertices); -public Q_SLOTS: - void changed(); -#endif // SCENE_SEGMENTED_IMAGE_GL_BUFFERS_AVAILABLE -}; - -#endif // SCENE_SEGMENTED_IMAGE_ITEM_H diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item_config.h b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item_config.h deleted file mode 100644 index 047f8380b19..00000000000 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3_plugin/Scene_segmented_image_item_config.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef SCENE_SEGMENTED_IMAGE_ITEM_CONFIG_H -#define SCENE_SEGMENTED_IMAGE_ITEM_CONFIG_H - -#ifdef scene_segmented_image_item_EXPORTS -# define SCENE_SEGMENTED_IMAGE_ITEM_EXPORT Q_DECL_EXPORT -#else -# define SCENE_SEGMENTED_IMAGE_ITEM_EXPORT Q_DECL_IMPORT -#endif - -#endif // SCENE_SEGMENTED_IMAGE_ITEM_CONFIG_H diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_modeling/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/Surface_modeling/CMakeLists.txt index 676bda2d516..e84acc5d5ab 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_modeling/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_modeling/CMakeLists.txt @@ -1,11 +1,6 @@ include( polyhedron_demo_macros ) if ( EIGEN3_FOUND AND "${EIGEN3_VERSION}" VERSION_GREATER "3.1.90" ) - qt5_wrap_ui( editionUI_FILES Deform_mesh.ui ) - add_item(scene_edit_polyhedron_item Scene_edit_polyhedron_item.cpp - ${editionUI_FILES}) - - target_link_libraries(scene_edit_polyhedron_item scene_polyhedron_item scene_polyhedron_item_k_ring_selection) - polyhedron_demo_plugin(edit_polyhedron_plugin Edit_polyhedron_plugin ${editionUI_FILES}) + polyhedron_demo_plugin(edit_polyhedron_plugin Edit_polyhedron_plugin Deform_mesh.ui) target_link_libraries(edit_polyhedron_plugin scene_polyhedron_item scene_edit_polyhedron_item) else() message(STATUS "NOTICE: The polyhedron edit plugin require Eigen 3.2 (or higher) and will not be available.") diff --git a/Polyhedron/demo/Polyhedron/Scene_segmented_image_item.h b/Polyhedron/demo/Polyhedron/Scene_segmented_image_item.h index c968baa8656..e1e9a649c25 100644 --- a/Polyhedron/demo/Polyhedron/Scene_segmented_image_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_segmented_image_item.h @@ -1,7 +1,7 @@ #ifndef SCENE_SEGMENTED_IMAGE_ITEM_H #define SCENE_SEGMENTED_IMAGE_ITEM_H -#include "Scene_item.h" +#include #include "Image_type_fwd.h" #include "Scene_segmented_image_item_config.h" #include