diff --git a/CMakeLists.txt b/CMakeLists.txt index 532219b20..3eee8a19d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,14 +19,13 @@ set(CMAKE_COMPILE_WARNING_AS_ERROR ON) ### Options option(VCLIB_BUILD_EXAMPLES "Build VCLib examples" ON) -option(VCLIB_BUILD_AND_RUN_TESTS "Build and Run VCLib tests" ON) -option(VCLIB_IDE "Create an utility target to show the library tree on IDEs" ON) +option(VCLIB_BUILD_TESTS "Build VCLib tests" ON) # In case of building shared libraries, on windows we need to export all symbols set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -# Add the cmake folder for find_package scripts -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +# Flag that tells whether VCLIB has a parent scope +get_directory_property(VCLIB_HAS_PARENT_SCOPE PARENT_DIRECTORY) # external libraries message(STATUS "VCLib: external libraries") @@ -42,7 +41,9 @@ if (WIN32) endif() set(VCLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) -set(VCLIB_SRC_DIR ${VCLIB_INCLUDE_DIR}/vclib) +if (VCLIB_HAS_PARENT_SCOPE) + set(VCLIB_INCLUDE_DIR ${VCLIB_INCLUDE_DIR} PARENT_SCOPE) +endif() set(HEADERS include/vclib/algorithms.h @@ -274,11 +275,6 @@ set(HEADERS include/vclib/misc/logger/console_logger.h include/vclib/misc/logger/logger.h include/vclib/misc/logger/null_logger.h - include/vclib/render/drawable_object.h - include/vclib/render/drawable_object_vector.h - include/vclib/render/generic_drawable_mesh.h - include/vclib/render/mesh_render_buffers.h - include/vclib/render/mesh_render_settings.h include/vclib/space/array.h include/vclib/space/bit_set.h include/vclib/space/box.h @@ -341,92 +337,18 @@ set(HEADERS include/vclib/views/mesh/elements/vertex.h ) -set(HEADERS_LIB - ) - -set(SOURCES_LIB - ) - -set(FORMS_LIB - ) - -# headers and sources to include only if using OpenGL -if (TARGET vclib-external-opengl) - list(APPEND HEADERS - include/vclib/ext/opengl2/draw_objects2.h - include/vclib/ext/opengl2/draw_objects3.h - include/vclib/ext/opengl2/drawable_mesh.h) -endif() - -# headers and sources to include only if using qt -if (TARGET vclib-external-qt) - # header only sources - list(APPEND HEADERS - ) - - # sources that must be built - list(APPEND HEADERS_LIB - include/vclib/ext/qt/gui/drawable_object_frame.h - include/vclib/ext/qt/gui/drawable_object_vector_frame.h - include/vclib/ext/qt/gui/mesh_render_settings_frame.h - include/vclib/ext/qt/gui/q_clickable_label.h) - - list(APPEND SOURCES_LIB - include/vclib/ext/qt/gui/drawable_object_frame.cpp - include/vclib/ext/qt/gui/drawable_object_vector_frame.cpp - include/vclib/ext/qt/gui/mesh_render_settings_frame.cpp - include/vclib/ext/qt/gui/q_clickable_label.cpp) - - list(APPEND FORMS_LIB - include/vclib/ext/qt/gui/drawable_object_frame.ui - include/vclib/ext/qt/gui/drawable_object_vector_frame.ui - include/vclib/ext/qt/gui/mesh_render_settings_frame.ui) - - # headers and sources to include only if using QGLViewer - if (TARGET vclib-external-qglviewer) - # header only sources - list(APPEND HEADERS - include/vclib/ext/qglviewer/viewer.h) - - # sources that must be built - list(APPEND HEADERS_LIB - include/vclib/ext/qglviewer/viewer_main_window.h) - - list(APPEND SOURCES_LIB - include/vclib/ext/qglviewer/viewer_main_window.cpp) - - list(APPEND FORMS_LIB - include/vclib/ext/qglviewer/viewer_main_window.ui) - endif() -endif() - # headers and sources to include only if using VCG if (TARGET vclib-external-vcg) list(APPEND HEADERS include/vclib/ext/vcg/import.h) endif() -add_library(vclib-include INTERFACE) -target_include_directories(vclib-include INTERFACE ${VCLIB_INCLUDE_DIR}) -set_property(TARGET vclib-include PROPERTY COMPILE_WARNING_AS_ERROR ON) - add_library(vclib INTERFACE) -target_link_libraries(vclib INTERFACE vclib-include) target_include_directories(vclib INTERFACE ${VCLIB_INCLUDE_DIR}) +set_property(TARGET vclib PROPERTY COMPILE_WARNING_AS_ERROR ON) target_link_libraries(vclib INTERFACE ${VCLIB_EXTERNAL_LIBRARIES}) -if (TARGET vclib-external-qt) - add_library(vclib-qt SHARED ${HEADERS_LIB} ${SOURCES_LIB} ${FORMS_LIB}) - target_include_directories(vclib-qt PRIVATE ${VCLIB_INCLUDE_DIR}) - target_link_libraries(vclib-qt PRIVATE ${VCLIB_EXTERNAL_LIBRARIES}) - - target_link_libraries(vclib INTERFACE vclib-qt) -endif() - -if (VCLIB_IDE) - add_custom_target(vclib_ide SOURCES - ${HEADERS} ${HEADERS_LIB} ${SOURCES_LIB} ${FORMS_LIB}) -endif() +target_sources(vclib PRIVATE ${HEADERS}) if (WIN32 OR TARGET vclib-external-tbb OR TARGET vclib-external-pstld) message(STATUS "VCLib: using parallel algorithms") @@ -434,9 +356,14 @@ else() message(STATUS "VCLib: not using parallel algorithms") endif() -if (VCLIB_BUILD_EXAMPLES OR VCLIB_BUILD_AND_RUN_TESTS) +if (VCLIB_BUILD_EXAMPLES OR VCLIB_BUILD_TESTS) include(CTest) -add_subdirectory(test) + set(VCLIB_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) + if (VCLIB_HAS_PARENT_SCOPE) + set(VCLIB_TEST_DIR ${VCLIB_TEST_DIR} PARENT_SCOPE) + endif() + + add_subdirectory(test) endif() diff --git a/cmake/FindQGLViewer.cmake b/cmake/FindQGLViewer.cmake deleted file mode 100644 index 84e672bc2..000000000 --- a/cmake/FindQGLViewer.cmake +++ /dev/null @@ -1,74 +0,0 @@ -# Try to find libQGLViewer lib -# -# This module reads hints about search locations from the following -# environment or cmake variables: -# -# QGLVIEWER_ROOT -# QGLVIEWER_ROOT_DIR - -find_path(QGLVIEWER_INCLUDE_DIR qglviewer.h - /usr/include/QGLViewer - /usr/local/include/QGLViewer - /opt/local/include/QGLViewer - /usr/local/include/QGLViewer - /Library/Frameworks/QGLViewer.framework/Headers - /sw/include/QGLViewer - C:/libs/QGLViewer/include/QGLViewer - ${QGLVIEWER_ROOT} - ${QGLVIEWER_ROOT_DIR} - ENV QGLVIEWER_ROOT - ENV QGLVIEWER_ROOT_DIR) - -if (Qt6_FOUND) - set(QT_SUFFIX -qt6) -else() - set(QT_SUFFIX -qt5) -endif() - -if (WIN32) - get_filename_component(QGLVIEWER_INCLUDE_DIR ${QGLVIEWER_INCLUDE_DIR} DIRECTORY) -endif() - -find_library(QGLVIEWER_LIBRARY_RELEASE - NAMES qglviewer QGLViewer QGLViewer2 qglviewer${QT_SUFFIX} QGLViewer${QT_SUFFIX} - PATHS - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - C:/libs/QGLViewer/lib - ${QGLVIEWER_ROOT} - ${QGLVIEWER_ROOT_DIR} - ENV QGLVIEWER_ROOT - ENV QGLVIEWER_ROOT_DIR - ENV LD_LIBRARY_PATH - ENV LIBRARY_PATH - PATH_SUFFIXES QGLViewer QGLViewer/release) - -find_library(QGLVIEWER_LIBRARY_DEBUG - NAMES dqglviewer dQGLViewer QGLViewerd QGLViewerd2 dqglviewer${QT_SUFFIX} dQGLViewer${QT_SUFFIX} - PATHS - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - C:/libs/QGLViewer/lib - ${QGLVIEWER_ROOT} - ${QGLVIEWER_ROOT_DIR} - ENV QGLVIEWER_ROOT - ENV QGLVIEWER_ROOT_DIR - ENV LD_LIBRARY_PATH - ENV LIBRARY_PATH - PATH_SUFFIXES QGLViewer QGLViewer/debug -) - -if(QGLVIEWER_LIBRARY_RELEASE) - if(QGLVIEWER_LIBRARY_DEBUG) - set(QGLVIEWER_LIBRARY optimized ${QGLVIEWER_LIBRARY_RELEASE} debug ${QGLVIEWER_LIBRARY_DEBUG}) - else() - set(QGLVIEWER_LIBRARY ${QGLVIEWER_LIBRARY_RELEASE}) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(QGLViewer DEFAULT_MSG QGLVIEWER_INCLUDE_DIR QGLVIEWER_LIBRARY) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 52e942f1d..ccb6f2d4f 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -37,15 +37,6 @@ if (VCLIB_BUILD_AND_RUN_TESTS) option(VCLIB_ALLOW_SYSTEM_CATCH2 "Allow use of system-provided Catch2" ON) endif() -# OpenGL -option(VCLIB_ALLOW_SYSTEM_OPENGL "Allow use of system-provided OpenGL" ON) - -# Qt -option(VCLIB_ALLOW_SYSTEM_QT "Allow use of system-provided Qt" ON) - -# QGLViewer -option(VCLIB_ALLOW_SYSTEM_QGLVIEWER "Allow use of system-provided QGLViewer" ON) - # STB option(VCLIB_ALLOW_BUNDLED_STB "Allow use of bundled STB source" ON) @@ -80,15 +71,6 @@ endif() ### Catch2 include(catch2.cmake) -### OpenGL -include(opengl.cmake) - -### Qt -include(qt.cmake) - -### QGLViewer -include(qglviewer.cmake) - ### STB include(stb.cmake) diff --git a/external/opengl.cmake b/external/opengl.cmake deleted file mode 100644 index 40570d1f0..000000000 --- a/external/opengl.cmake +++ /dev/null @@ -1,29 +0,0 @@ -#***************************************************************************** -#* VCLib * -#* Visual Computing Library * -#* * -#* Copyright(C) 2021-2022 * -#* Alessandro Muntoni * -#* VCLab - ISTI - Italian National Research Council * -#* * -#* All rights reserved. * -#****************************************************************************/ - -find_package(OpenGL QUIET) - -if (VCLIB_ALLOW_SYSTEM_OPENGL) - if (OpenGL_FOUND) - message(STATUS "- OpenGL - using system-provided library") - - add_library(vclib-external-opengl INTERFACE) - target_link_libraries(vclib-external-opengl INTERFACE OpenGL::GL) - - if(APPLE) - target_compile_definitions(vclib-external-opengl INTERFACE GL_SILENCE_DEPRECATION) - endif() - - list(APPEND VCLIB_EXTERNAL_LIBRARIES vclib-external-opengl) - else() - message(STATUS "- OpenGL - not found, skipping") - endif() -endif() diff --git a/external/qglviewer.cmake b/external/qglviewer.cmake deleted file mode 100644 index 1c5798260..000000000 --- a/external/qglviewer.cmake +++ /dev/null @@ -1,49 +0,0 @@ -#***************************************************************************** -#* VCLib * -#* Visual Computing Library * -#* * -#* Copyright(C) 2021-2022 * -#* Alessandro Muntoni * -#* VCLab - ISTI - Italian National Research Council * -#* * -#* All rights reserved. * -#****************************************************************************/ - -# to install QGLViewer on Mac: -# - download libQGLViewer -# - be sure to have a Qt environment set up -# - cd libQGLViewer/QGLViewer -# - qmake LIB_DIR=/Library/Frameworks -# - make -# - sudo make install - -find_package(QGLViewer QUIET) - -if (VCLIB_ALLOW_SYSTEM_QGLVIEWER) - if (VCLIB_ALLOW_SYSTEM_QT AND QT_FOUND AND VCLIB_ALLOW_SYSTEM_OPENGL AND OpenGL_FOUND) - if (QGLViewer_FOUND) - message(STATUS "- QGLViewer - using system-provided library") - - add_library(vclib-external-qglviewer INTERFACE) - - target_include_directories(vclib-external-qglviewer INTERFACE ${QGLVIEWER_INCLUDE_DIR}) - target_link_libraries(vclib-external-qglviewer INTERFACE ${QGLVIEWER_LIBRARY}) - target_compile_definitions(vclib-external-qglviewer INTERFACE VCLIB_WITH_QGLVIEWER) - - list(APPEND VCLIB_EXTERNAL_LIBRARIES vclib-external-qglviewer) - else() - message(STATUS "- QGLViewer - not found, skipping") - endif() - else() - # message indicating why we jumped QGLViewer - set (MISSING_LIB) - if (NOT OpenGL_FOUND OR NOT VCLIB_ALLOW_SYSTEM_OPENGL) - list(APPEND MISSING_LIB OpenGL) - endif() - if (NOT QT_FOUND OR NOT VCLIB_ALLOW_SYSTEM_QT) - list(APPEND MISSING_LIB Qt) - endif() - - message(STATUS "- QGLViewer - ignored: missing ${MISSING_LIB}") - endif() -endif() diff --git a/external/qt.cmake b/external/qt.cmake deleted file mode 100644 index 3152fca5a..000000000 --- a/external/qt.cmake +++ /dev/null @@ -1,59 +0,0 @@ -#***************************************************************************** -#* VCLib * -#* Visual Computing Library * -#* * -#* Copyright(C) 2021-2022 * -#* Alessandro Muntoni * -#* VCLab - ISTI - Italian National Research Council * -#* * -#* All rights reserved. * -#****************************************************************************/ - -find_package(Qt5 COMPONENTS Core Xml OpenGL Gui Widgets QUIET) -find_package(Qt6 COMPONENTS Core Xml OpenGL Gui Widgets OpenGLWidgets QUIET) - -if (Qt6_FOUND OR Qt5_FOUND) - set(QT_FOUND TRUE) - if(Qt6_FOUND) - set(QT_VER 6) - else() - set(QT_VER 5) - endif() -endif() - -if (VCLIB_ALLOW_SYSTEM_QT) - if (QT_FOUND) - message(STATUS "- Qt${QT_VER} - using system-provided library") - - add_library(vclib-external-qt INTERFACE) - target_compile_definitions(vclib-external-qt INTERFACE - VCLIB_WITH_QT) - - # prefer Qt6 - if (Qt6_FOUND) - target_link_libraries(vclib-external-qt INTERFACE Qt6::Core Qt6::Widgets Qt6::Xml) - - if (OpenGL_FOUND) - target_link_libraries(vclib-external-qt INTERFACE Qt6::OpenGL Qt6::OpenGLWidgets) - endif() - endif() - - if (Qt5_FOUND AND NOT Qt6_FOUND) - target_link_libraries(vclib-external-qt INTERFACE Qt5::Core Qt5::Widgets Qt5::Xml) - - if (OpenGL_FOUND) - target_link_libraries(vclib-external-qt INTERFACE Qt5::OpenGL) - endif() - endif() - - set(CMAKE_AUTOMOC ON PARENT_SCOPE) - set(CMAKE_AUTORCC ON PARENT_SCOPE) - set(CMAKE_AUTOUIC ON PARENT_SCOPE) - - list(APPEND VCLIB_EXTERNAL_LIBRARIES vclib-external-qt) - else() - message(STATUS "- Qt - not found, skipping") - endif() -endif() - - diff --git a/include/vclib/ext/README.md b/include/vclib/ext/README.md index dadea176c..c199cb7a4 100644 --- a/include/vclib/ext/README.md +++ b/include/vclib/ext/README.md @@ -8,7 +8,4 @@ A list of the supported libraries, their paths and their namespaces is provided | Library(s) | Namespace | Path | Notes | |:----------:|:---------:|:----:|:-----:| -| [OpenGL 2.1](https://registry.khronos.org/OpenGL-Refpages/gl2.1/) | `vcl::gl2` | `ext/opengl2` | | -| [Qt 6](https://www.qt.io/) | `vcl::qt` | `ext/qt` | | -| [QGLViewer](http://libqglviewer.com/) | `vcl::qgl` | `ext/qglviewer` | This library requires Qt6 | | [VCG](http://vcg.isti.cnr.it/vcglib/) | `vcl::vc` | `ext/vcg` | | diff --git a/include/vclib/ext/opengl2/draw_objects2.h b/include/vclib/ext/opengl2/draw_objects2.h deleted file mode 100644 index c773be723..000000000 --- a/include/vclib/ext/opengl2/draw_objects2.h +++ /dev/null @@ -1,177 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_OPENGL2_DRAW_OBJECTS2_H -#define VCL_EXT_OPENGL2_DRAW_OBJECTS2_H - -#ifdef _WIN32 -#include -#endif - -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif - -#include -#include - -namespace vcl::gl2 { - -/** - * @brief drawPoint2 - * - * Draws a point on the plane (coord z = 0 if 3D). - * - * @param p: coordinates of the point - * @param c: color of the point - * @param size: size of the point (default: 8) - */ -inline void drawPoint2(const Point2d& p, const Color& c, int size = 8) -{ - glEnable(GL_POINT_SMOOTH); - glPointSize(size); - glBegin(GL_POINTS); - - glColor3f(c.redF(), c.greenF(), c.blueF()); - - glVertex2d(p.x(), p.y()); - - glEnd(); -} - -/** - * @brief drawLine2 - * - * Draws a line with opengl on the plane (z=0 if 3D). - * It links the two points passed as parameters. - * - * @param a: first point of the line - * @param b: second point of the line - * @param c: color of the line - * @param width: width of the line (default: 3) - */ -inline void drawLine2( - const Point2d& a, - const Point2d& b, - const Color& c, - int width = 3) -{ - glLineWidth(width); - - glBegin(GL_LINES); - - glColor3f(c.redF(), c.greenF(), c.blueF()); - - glVertex2d(a.x(), a.y()); - glVertex2d(b.x(), b.y()); - - glEnd(); -} - -inline void drawTriangle2( - const Point2d& p1, - const Point2d& p2, - const Point2d& p3, - const Color& c, - int width = 3, - bool fill = false) -{ - if (width != 0) { - vcl::drawLine2(p1, p2, c, width); - vcl::drawLine2(p2, p3, c, width); - vcl::drawLine2(p3, p1, c, width); - } - if (fill) { - glBegin(GL_TRIANGLES); // Begin triangle coordinates - glVertex2f(p1.x(), p1.y()); - glVertex2f(p2.x(), p2.y()); - glVertex2f(p3.x(), p3.y()); - glEnd(); // End triangle coordinates - } -} - -inline void drawTriangle2( - const std::array& arr, - const Color& c, - int width = 3, - bool fill = false) -{ - drawTriangle2(arr[0], arr[1], arr[2], c, width, fill); -} - -inline void drawQuad2( - const std::array& points, - const Color& c, - int width = 3, - bool fill = false) -{ - for (unsigned int i = 0; i < 4; i++) { - drawLine2(points[i], points[(i + 1) % 4], c, width); - } - if (fill) { - // find angle >=90° - int pivot = -1; - for (unsigned int i = 0; i < 4; i++) { - double angle = (points[(i - 1) % 4] - points[i]) - .dot(points[(i + 1) % 4] - points[i]); - if (angle <= 0) - pivot = i; - } - assert(pivot >= 0); - drawTriangle2( - points[pivot], - points[(pivot + 1) % 4], - points[(pivot + 2) % 4], - c, - 0, - true); - drawTriangle2( - points[(pivot + 2) % 4], - points[(pivot + 3) % 4], - points[pivot], - c, - 0, - true); - } -} - -inline void drawQuad2( - const Point2d& p1, - const Point2d& p2, - const Point2d& p3, - const Point2d& p4, - const Color& c, - int width = 3, - bool fill = false) -{ - std::array arr = {p1, p2, p3, p4}; - vcl::drawQuad2(arr, c, width, fill); -} - -} // namespace vcl::gl2 - -#endif // VCL_EXT_OPENGL2_DRAW_OBJECTS2_H diff --git a/include/vclib/ext/opengl2/draw_objects3.h b/include/vclib/ext/opengl2/draw_objects3.h deleted file mode 100644 index 7bb5b2e58..000000000 --- a/include/vclib/ext/opengl2/draw_objects3.h +++ /dev/null @@ -1,366 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_OPENGL2_DRAW_OBJECTS3_H -#define VCL_EXT_OPENGL2_DRAW_OBJECTS3_H - -#ifdef _WIN32 -#include -#endif - -#ifdef __APPLE__ -#include -#include -#else -#include -#include -#endif - -#include - -namespace vcl::gl2 { - -/** - * @brief Draws a point on the plane (coord z = 0 if 3D). - * - * @param p: coordinates of the point - * @param c: color of the point - * @param size: size of the point - */ -inline void drawPoint3(const Point3d& p, const Color& c, int size = 8) -{ - glEnable(GL_POINT_SMOOTH); - glPointSize(size); - glBegin(GL_POINTS); - - glColor3f(c.redF(), c.greenF(), c.blueF()); - - glVertex3d(p.x(), p.y(), p.z()); - - glEnd(); -} - -/** - * @brief Draws a sphere with opengl - * - * @param center: coordinates of the center of the sphere - * @param radius: radius of the sphere - * @param color: color of the sphere - * @param precision: precision of the rendered sphere - */ -inline void drawSphere( - const Point3d& center, - float radius, - const Color& color, - int precision = 4) -{ - glEnable(GL_LIGHTING); - glShadeModel(GL_SMOOTH); - glColor3f(color.redF(), color.greenF(), color.blueF()); - glPushMatrix(); - glTranslated(center.x(), center.y(), center.z()); - GLUquadric* sphere = gluNewQuadric(); - gluQuadricNormals(sphere, GLU_SMOOTH); - gluQuadricOrientation(sphere, GLU_OUTSIDE); - gluSphere(sphere, radius, precision, precision); - glPopMatrix(); -} - -/** - * @brief Draws a cylinder with opengl. - * The cylinder links the two points passed as parameters - * - * @param a: first point of the cylinder - * @param b: second point of the cylinder - * @param top_radius: radius at the "a" point - * @param bottom_radius: radius at the "b" point - * @param color: color of the cylinder - */ -inline void drawCylinder( - const Point3d& a, - const Point3d& b, - float top_radius, - float bottom_radius, - const Color& color, - unsigned int slices = 50, - unsigned int stacks = 10) -{ - Point3d dir = b - a; - dir.normalize(); - Point3d z = Point3d(0, 0, 1); - Point3d normal = dir.cross(z); - double angle = acos(dir.dot(z)) * 180 / M_PI; - - bool cull = glIsEnabled(GL_CULL_FACE); - glDisable(GL_CULL_FACE); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - // cylinder - glColor3f(color.redF(), color.greenF(), color.blueF()); - glPushMatrix(); - glTranslated(a.x(), a.y(), a.z()); - glRotatef(-angle, normal.x(), normal.y(), normal.z()); - - GLUquadric* cylinder = gluNewQuadric(); - gluQuadricNormals(cylinder, GLU_SMOOTH); - gluQuadricOrientation(cylinder, GLU_OUTSIDE); - gluCylinder( - cylinder, top_radius, bottom_radius, (a - b).norm(), slices, stacks); - - GLUquadric* disk1 = gluNewQuadric(); - gluQuadricNormals(disk1, GLU_SMOOTH); - gluQuadricOrientation(disk1, GLU_INSIDE); - gluDisk(disk1, 0, top_radius, slices, stacks); - - /*glTranslated((b-a).x(), (b-a).y(), (b-a).z()); - GLUquadric *disk2 = gluNewQuadric(); - gluQuadricNormals(disk2, GLU_SMOOTH); - gluQuadricOrientation(disk2, GLU_OUTSIDE); - gluDisk(disk2, 0, bottom_radius, slices, stacks);*/ - - glColor3f(0, 0, 0); - glPopMatrix(); - if (cull) - glEnable(GL_CULL_FACE); -} - -inline void drawArrow3( - const Point3d& a, - const Point3d& b, - float bottom_radius, - const Color& color, - unsigned int slices = 50, - unsigned int stacks = 10) -{ - Point3d midPoint = (a * 1 + b * 9) / 10; - drawCylinder( - a, midPoint, bottom_radius, bottom_radius, color, slices, stacks); - drawCylinder(midPoint, b, bottom_radius * 2, 0, color, slices, stacks); -} - -/** - * @brief Draws a line with opengl that links the two points passed as - * parameters. - * - * @param a: first point of the line - * @param b: second point of the line - * @param c: color of the line - * @param width: width of the line (default: 3) - */ -inline void drawLine3( - const Point3d& a, - const Point3d& b, - const Color& c, - int width = 3) -{ - glLineWidth(width); - glColor3f(c.redF(), c.greenF(), c.blueF()); - glBegin(GL_LINES); - glVertex3f(a.x(), a.y(), a.z()); - glVertex3f(b.x(), b.y(), b.z()); - glEnd(); - glColor3f(0, 0, 0); -} - -/** - * @brief - * @see drawLine3 - */ -inline void drawSegment3( - const Point3d& a, - const Point3d& b, - const Color& c, - int width = 3) -{ - drawLine3(a, b, c, width); -} - -/** - * @brief drawDashedLine - * - * Draws a dashed line with opengl that links the two points passed as - * parameters. - * - * @param a: first point of the dashed line - * @param b: second point of the dashed line - * @param c: color of the dashed line - * @param width: width of the dashed line (default: 3) - */ -inline void drawDashedLine3( - const Point3d& a, - const Point3d& b, - const Color& c, - int width = 3) -{ - glPushAttrib(GL_ENABLE_BIT); - - glColor3f(c.redF(), c.greenF(), c.blueF()); - glLineWidth(width); - glLineStipple(1, 0x00FF); - glEnable(GL_LINE_STIPPLE); - glBegin(GL_LINES); - glVertex3f(a.x(), a.y(), a.z()); - glVertex3f(b.x(), b.y(), b.z()); - glEnd(); - - glPopAttrib(); -} - -inline void drawTriangle( - const Point3d& p1, - const Point3d& p2, - const Point3d& p3, - const Color& c, - int width = 3, - bool fill = false) -{ - if (width != 0) { - drawLine3(p1, p2, c, width); - drawLine3(p2, p3, c, width); - drawLine3(p3, p1, c, width); - } - if (fill) { - glBegin(GL_TRIANGLES); // Begin triangle coordinates - glVertex3f(p1.x(), p1.y(), p1.z()); - glVertex3f(p2.x(), p2.y(), p2.z()); - glVertex3f(p3.x(), p3.y(), p3.z()); - glEnd(); // End triangle coordinates - } -} - -inline void drawQuad3( - const Point3d& a, - const Point3d& b, - const Point3d& c, - const Point3d& d, - int width = 3) -{ - glBegin(GL_QUADS); - glLineWidth(width); - glVertex3f(a.x(), a.y(), a.z()); - glVertex3f(b.x(), b.y(), b.z()); - glVertex3f(c.x(), c.y(), c.z()); - glVertex3f(d.x(), d.y(), d.z()); - glEnd(); -} - -/** - * @brief Draws an axis aligned 3D box using opengl lines. - * - * @param min - * @param max - * @param c - * @param width - */ -inline void drawBox3( - const Point3d& min, - const Point3d& max, - const Color& c, - int width = 3) -{ - drawLine3(min, Point3d(max.x(), min.y(), min.z()), c, width); - drawLine3( - Point3d(max.x(), min.y(), min.z()), - Point3d(max.x(), min.y(), max.z()), - c, - width); - drawLine3( - Point3d(max.x(), min.y(), max.z()), - Point3d(min.x(), min.y(), max.z()), - c, - width); - drawLine3(min, Point3d(min.x(), min.y(), max.z()), c, width); - - drawLine3( - Point3d(min.x(), max.y(), min.z()), - Point3d(max.x(), max.y(), min.z()), - c, - width); - drawLine3(Point3d(max.x(), max.y(), min.z()), max, c, width); - drawLine3(max, Point3d(min.x(), max.y(), max.z()), c, width); - drawLine3( - Point3d(min.x(), max.y(), min.z()), - Point3d(min.x(), max.y(), max.z()), - c, - width); - - drawLine3(min, Point3d(min.x(), max.y(), min.z()), c, width); - drawLine3( - Point3d(max.x(), min.y(), min.z()), - Point3d(max.x(), max.y(), min.z()), - c, - width); - drawLine3(Point3d(max.x(), min.y(), max.z()), max, c, width); - drawLine3( - Point3d(min.x(), min.y(), max.z()), - Point3d(min.x(), max.y(), max.z()), - c, - width); -} - -inline void drawBox3( - const Point3d& p0, - const Point3d& p1, - const Point3d& p2, - const Point3d& p3, - const Point3d& p4, - const Point3d& p5, - const Point3d& p6, - const Point3d& p7, - const Color& c, - int width = 3) -{ - drawLine3(p0, p1, c, width); - drawLine3(p1, p2, c, width); - drawLine3(p2, p3, c, width); - drawLine3(p0, p3, c, width); - - drawLine3(p4, p5, c, width); - drawLine3(p5, p6, c, width); - drawLine3(p6, p7, c, width); - drawLine3(p4, p7, c, width); - - drawLine3(p0, p4, c, width); - drawLine3(p1, p5, c, width); - drawLine3(p2, p6, c, width); - drawLine3(p3, p7, c, width); -} - -/** - * @brief Draws the box composed by the first 8 point contained on the vector - * passed as parameter. - * - * @param p - * @param c - * @param width - */ -inline void drawBox3( - const std::vector& p, - const Color& c, - int width = 3) -{ - drawBox3(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], c, width); -} - -} // namespace vcl::gl2 - -#endif // VCL_EXT_OPENGL2_DRAW_OBJECTS3_H diff --git a/include/vclib/ext/opengl2/drawable_mesh.cpp b/include/vclib/ext/opengl2/drawable_mesh.cpp deleted file mode 100644 index 635f6de12..000000000 --- a/include/vclib/ext/opengl2/drawable_mesh.cpp +++ /dev/null @@ -1,496 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#include "drawable_mesh.h" -#include "draw_objects3.h" - -#include - -namespace vcl { - -template -DrawableMesh::DrawableMesh() -{ -} - -template -DrawableMesh::DrawableMesh(const MeshType& m) -{ - if constexpr (HasName) { - name() = m.name(); - } - updateBuffers(m); - mrs.setDefaultSettingsFromCapability(); -} - -template -void DrawableMesh::updateBuffers(const MeshType& m) -{ - if constexpr (HasName) { - name() = m.name(); - } - unbindTextures(); - mrb = MeshRenderBuffers(m); - mrs.setRenderCapabilityFrom(m); - bindTextures(); -} - -template -void DrawableMesh::init() -{ - bindTextures(); -} - -template -void DrawableMesh::draw() const -{ - if (mrs.isVisible()) { - if (mrs.isWireframeVisible()) { - if (mrs.isPointCloudVisible()) { - glDisable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - renderPass(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - if (mrs.isSurfaceVisible()) { - if (mrs.isSurfaceShadingFlat()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glDepthRange(0.01, 1.0); - renderPass(); - - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - glDepthFunc(GL_LEQUAL); - renderPass(); - glDepthFunc(GL_LESS); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - else if (mrs.isSurfaceShadingSmooth()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_SMOOTH); - glDepthRange(0.01, 1.0); - renderPass(); - - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - glDepthFunc(GL_LEQUAL); - renderPass(); - glDepthFunc(GL_LESS); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - } - else { - glDisable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - renderPass(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - } - else { // no wireframe - if (mrs.isPointCloudVisible()) { - glDisable(GL_LIGHTING); - renderPass(); - } - if (mrs.isSurfaceVisible()) { - if (mrs.isSurfaceShadingFlat()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_FLAT); - renderPass(); - } - else if (mrs.isSurfaceShadingSmooth()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_SMOOTH); - renderPass(); - } - } - } - if (mrs.isBboxEnabled()) { - vcl::drawBox3(mrb.bbMin(), mrb.bbMax(), vcl::Color(0, 0, 0)); - } - } -} - -template -Point3d DrawableMesh::center() const -{ - return (mrb.bbMin() + mrb.bbMax()) / 2; -} - -template -double DrawableMesh::radius() const -{ - return (mrb.bbMax() - mrb.bbMin()).norm() / 2; -} - -template -DrawableMesh* DrawableMesh::clone() const -{ - return new DrawableMesh(*this); -} - -template -void DrawableMesh::renderPass() const -{ - uint nv = mrb.vertexNumber(); - uint nt = mrb.triangleNumber(); - - const float* coords = mrb.vertexBufferData(); - const int* triangles = mrb.triangleBufferData(); - const float* vertexNormals = mrb.vertexNormalBufferData(); - const float* vertexColors = mrb.vertexColorBufferData(); - const float* triangleNormals = mrb.triangleNormalBufferData(); - const float* triangleColors = mrb.triangleColorBufferData(); - const float* vertTexCoords = mrb.vertexTexCoordsBufferData(); - const float* wedgTexCoords = mrb.wedgeTexCoordsBufferData(); - - if (mrs.isPointCloudVisible()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - if (mrs.isPointCloudColorPerVertex()) { - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, vertexColors); - } - else if (mrs.isPointCloudColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else if (mrs.isPointCloudColorUserDefined()) { - glColor4fv(mrs.pointCloudUserColorData()); - } - - glPointSize(mrs.pointWidth()); - - glDrawArrays(GL_POINTS, 0, nv); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - - if (mrs.isSurfaceVisible()) { - // Old fashioned, verbose and slow rendering. - if (mrs.isSurfaceColorPerFace()) { - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - if (mrs.isSurfaceShadingSmooth()) { - glBegin(GL_TRIANGLES); - glColor3fv(&(triangleColors[tid_ptr])); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - else { - glBegin(GL_TRIANGLES); - glColor3fv(&(triangleColors[tid_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if (mrs.isSurfaceColorPerVertex()) { - if (mrs.isSurfaceShadingSmooth()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, vertexColors); - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - else { - glShadeModel(GL_SMOOTH); - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - glBegin(GL_TRIANGLES); - glColor3fv(&(vertexColors[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glColor3fv(&(vertexColors[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glColor3fv(&(vertexColors[vid2_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if (mrs.isSurfaceColorPerMesh() || mrs.isSurfaceColorUserDefined()) - { - if (mrs.isSurfaceShadingSmooth()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - if (mrs.isSurfaceColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.surfaceUserColorData()); - } - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - else { - if (mrs.isSurfaceColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.surfaceUserColorData()); - } - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - glBegin(GL_TRIANGLES); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if (mrs.isSurfaceColorPerVertexTexcoords()) { - if (mrs.isSurfaceShadingSmooth()) { - short texture = textID[0]; - glBindTexture(GL_TEXTURE_2D, texture); - glColor4f(1, 1, 1, 1); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, 0, vertTexCoords); - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glBindTexture(GL_TEXTURE_2D, 0); - } - else { - glShadeModel(GL_SMOOTH); - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - short texture = textID[0]; - glBindTexture(GL_TEXTURE_2D, texture); - glBegin(GL_TRIANGLES); - glColor4f(1, 1, 1, 1); - glTexCoord2f( - vertTexCoords[vid0 * 2 + 0], - vertTexCoords[vid0 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glTexCoord2f( - vertTexCoords[vid1 * 2 + 0], - vertTexCoords[vid1 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glTexCoord2f( - vertTexCoords[vid2 * 2 + 0], - vertTexCoords[vid2 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - } - } - } - else if (mrs.isSurfaceColorPerWedgeTexcoords()) { - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - short texture = textID[mrb.wedgeTextureIDsBufferData()[tid]]; - glBindTexture(GL_TEXTURE_2D, texture); - glBegin(GL_TRIANGLES); - glColor4f(1, 1, 1, 1); - glTexCoord2f( - wedgTexCoords[tid * 6 + 0], wedgTexCoords[tid * 6 + 1]); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glTexCoord2f( - wedgTexCoords[tid * 6 + 2], wedgTexCoords[tid * 6 + 3]); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glTexCoord2f( - wedgTexCoords[tid * 6 + 4], wedgTexCoords[tid * 6 + 5]); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - } - } - } - - if (mrs.isWireframeVisible()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glLineWidth(mrs.wireframeWidth()); - - if (mrs.isWireframeColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.wireframeUserColorData()); - } - - glDrawElements(GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_VERTEX_ARRAY); - } -} - -template -void DrawableMesh::bindTextures() -{ - textID.resize(mrb.textureNumber()); - glEnable(GL_TEXTURE_2D); - glGenTextures(mrb.textureNumber(), textID.data()); - - for (uint i = 0; i < mrb.textureNumber(); i++) { - glBindTexture(GL_TEXTURE_2D, textID[i]); - glTexImage2D( - GL_TEXTURE_2D, - 0, - GL_RGB, - mrb.textureSize(i).x(), - mrb.textureSize(i).y(), - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - mrb.textureBufferData(i)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } -} - -template -void DrawableMesh::unbindTextures() -{ - if (textID.size() > 0) { - glDeleteTextures(textID.size(), textID.data()); - textID.clear(); - } -} - -inline void _check_gl_error(const char* file, int line) -{ - GLenum err(glGetError()); - - while (err != GL_NO_ERROR) { - std::string error; - - switch (err) { - case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break; - case GL_INVALID_ENUM: error = "INVALID_ENUM"; break; - case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; - case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; -#ifdef unix - case GL_INVALID_FRAMEBUFFER_OPERATION: - error = "INVALID_FRAMEBUFFER_OPERATION"; - break; -#endif - } - - std::cerr << "GL_" << error.c_str() << " - " << file << ":" << line - << std::endl; - err = glGetError(); - } -} - -} // namespace vcl diff --git a/include/vclib/ext/opengl2/drawable_mesh.h b/include/vclib/ext/opengl2/drawable_mesh.h deleted file mode 100644 index 4cf09f02d..000000000 --- a/include/vclib/ext/opengl2/drawable_mesh.h +++ /dev/null @@ -1,511 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_OPENGL2_DRAWABLE_MESH_H -#define VCL_EXT_OPENGL2_DRAWABLE_MESH_H - -#ifdef _WIN32 -#include -#endif - -#ifdef __APPLE__ -#include -#else -#include -#endif - -#include - -#include -#include - -#include "draw_objects3.h" - -namespace vcl::gl2 { - -// From: -// https://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/ -inline void _check_gl_error(const char* file, int line) -{ - GLenum err(glGetError()); - - while (err != GL_NO_ERROR) { - std::string error; - - switch (err) { - case GL_INVALID_OPERATION: error = "INVALID_OPERATION"; break; - case GL_INVALID_ENUM: error = "INVALID_ENUM"; break; - case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; - case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; -#ifdef unix - case GL_INVALID_FRAMEBUFFER_OPERATION: - error = "INVALID_FRAMEBUFFER_OPERATION"; - break; -#endif - } - - std::cerr << "GL_" << error.c_str() << " - " << file << ":" << line - << std::endl; - err = glGetError(); - } -} - -/// -/// Usage -/// [... some opengl calls] -/// glCheckError(); -/// -#define check_gl_error() _check_gl_error(__FILE__, __LINE__) - -template -class DrawableMesh : public GenericDrawableMesh -{ - MeshRenderBuffers mrb; - - std::vector textID; - -public: - DrawableMesh() = default; - - DrawableMesh(const MeshType& m) - { - if constexpr (HasName) { - name() = m.name(); - } - updateBuffers(m); - mrs.setDefaultSettingsFromCapability(); - } - - void updateBuffers(const MeshType& m) - { - if constexpr (HasName) { - name() = m.name(); - } - unbindTextures(); - mrb = MeshRenderBuffers(m); - mrs.setRenderCapabilityFrom(m); - bindTextures(); - } - - // DrawableObject implementation - - void init() { bindTextures(); } - - void draw() const - { - if (mrs.isVisible()) { - if (mrs.isWireframeVisible()) { - if (mrs.isPointCloudVisible()) { - glDisable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - renderPass(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - if (mrs.isSurfaceVisible()) { - if (mrs.isSurfaceShadingFlat()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glDepthRange(0.01, 1.0); - renderPass(); - - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - glDepthFunc(GL_LEQUAL); - renderPass(); - glDepthFunc(GL_LESS); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - else if (mrs.isSurfaceShadingSmooth()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_SMOOTH); - glDepthRange(0.01, 1.0); - renderPass(); - - glDisable(GL_LIGHTING); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - glDepthFunc(GL_LEQUAL); - renderPass(); - glDepthFunc(GL_LESS); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - } - else { - glDisable(GL_LIGHTING); - glShadeModel(GL_FLAT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glDepthRange(0.0, 1.0); - renderPass(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - } - } - else { // no wireframe - if (mrs.isPointCloudVisible()) { - glDisable(GL_LIGHTING); - renderPass(); - } - if (mrs.isSurfaceVisible()) { - if (mrs.isSurfaceShadingFlat()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_FLAT); - renderPass(); - } - else if (mrs.isSurfaceShadingSmooth()) { - glEnable(GL_LIGHTING); - glShadeModel(GL_SMOOTH); - renderPass(); - } - } - } - if (mrs.isBboxEnabled()) { - drawBox3(mrb.bbMin(), mrb.bbMax(), vcl::Color(0, 0, 0)); - } - } - } - - vcl::Point3d center() const { return (mrb.bbMin() + mrb.bbMax()) / 2; } - - double radius() const { return (mrb.bbMax() - mrb.bbMin()).norm() / 2; } - - DrawableMesh* clone() const { return new DrawableMesh(*this); } - -private: - void renderPass() const - { - uint nv = mrb.vertexNumber(); - uint nt = mrb.triangleNumber(); - - const float* coords = mrb.vertexBufferData(); - const uint32_t* triangles = mrb.triangleBufferData(); - const float* vertexNormals = mrb.vertexNormalBufferData(); - const float* vertexColors = mrb.vertexColorBufferData(); - const float* triangleNormals = mrb.triangleNormalBufferData(); - const float* triangleColors = mrb.triangleColorBufferData(); - const float* vertTexCoords = mrb.vertexTexCoordsBufferData(); - const float* wedgTexCoords = mrb.wedgeTexCoordsBufferData(); - - if (mrs.isPointCloudVisible()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - if (mrs.isPointCloudColorPerVertex()) { - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, vertexColors); - } - else if (mrs.isPointCloudColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else if (mrs.isPointCloudColorUserDefined()) { - glColor4fv(mrs.pointCloudUserColorData()); - } - - glPointSize(mrs.pointWidth()); - - glDrawArrays(GL_POINTS, 0, nv); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - - if (mrs.isSurfaceVisible()) { - // Old fashioned, verbose and slow rendering. - if (mrs.isSurfaceColorPerFace()) { - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - if (mrs.isSurfaceShadingSmooth()) { - glBegin(GL_TRIANGLES); - glColor3fv(&(triangleColors[tid_ptr])); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - else { - glBegin(GL_TRIANGLES); - glColor3fv(&(triangleColors[tid_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if (mrs.isSurfaceColorPerVertex()) { - if (mrs.isSurfaceShadingSmooth()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - glEnableClientState(GL_COLOR_ARRAY); - glColorPointer(3, GL_FLOAT, 0, vertexColors); - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - else { - glShadeModel(GL_SMOOTH); - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - glBegin(GL_TRIANGLES); - glColor3fv(&(vertexColors[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glColor3fv(&(vertexColors[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glColor3fv(&(vertexColors[vid2_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if ( - mrs.isSurfaceColorPerMesh() || mrs.isSurfaceColorUserDefined()) - { - if (mrs.isSurfaceShadingSmooth()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - if (mrs.isSurfaceColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.surfaceUserColorData()); - } - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - } - else { - if (mrs.isSurfaceColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.surfaceUserColorData()); - } - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - - glBegin(GL_TRIANGLES); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glNormal3fv(&(triangleNormals[tid_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - } - } - } - else if (mrs.isSurfaceColorPerVertexTexcoords()) { - if (mrs.isSurfaceShadingSmooth()) { - short texture = textID[0]; - glBindTexture(GL_TEXTURE_2D, texture); - glColor4f(1, 1, 1, 1); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glEnableClientState(GL_NORMAL_ARRAY); - glNormalPointer(GL_FLOAT, 0, vertexNormals); - - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(2, GL_FLOAT, 0, vertTexCoords); - - glDrawElements( - GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glBindTexture(GL_TEXTURE_2D, 0); - } - else { - glShadeModel(GL_SMOOTH); - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - short texture = textID[0]; - glBindTexture(GL_TEXTURE_2D, texture); - glBegin(GL_TRIANGLES); - glColor4f(1, 1, 1, 1); - glTexCoord2f( - vertTexCoords[vid0 * 2 + 0], - vertTexCoords[vid0 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glTexCoord2f( - vertTexCoords[vid1 * 2 + 0], - vertTexCoords[vid1 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glTexCoord2f( - vertTexCoords[vid2 * 2 + 0], - vertTexCoords[vid2 * 2 + 1]); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - } - } - } - else if (mrs.isSurfaceColorPerWedgeTexcoords()) { - int n_tris = nt; - for (int tid = 0; tid < n_tris; ++tid) { - int tid_ptr = 3 * tid; - int vid0 = triangles[tid_ptr + 0]; - int vid1 = triangles[tid_ptr + 1]; - int vid2 = triangles[tid_ptr + 2]; - int vid0_ptr = 3 * vid0; - int vid1_ptr = 3 * vid1; - int vid2_ptr = 3 * vid2; - short texture = - textID[mrb.wedgeTextureIDsBufferData()[tid]]; - glBindTexture(GL_TEXTURE_2D, texture); - glBegin(GL_TRIANGLES); - glColor4f(1, 1, 1, 1); - glTexCoord2f( - wedgTexCoords[tid * 6 + 0], wedgTexCoords[tid * 6 + 1]); - glNormal3fv(&(vertexNormals[vid0_ptr])); - glVertex3fv(&(coords[vid0_ptr])); - glTexCoord2f( - wedgTexCoords[tid * 6 + 2], wedgTexCoords[tid * 6 + 3]); - glNormal3fv(&(vertexNormals[vid1_ptr])); - glVertex3fv(&(coords[vid1_ptr])); - glTexCoord2f( - wedgTexCoords[tid * 6 + 4], wedgTexCoords[tid * 6 + 5]); - glNormal3fv(&(vertexNormals[vid2_ptr])); - glVertex3fv(&(coords[vid2_ptr])); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); - } - } - } - - if (mrs.isWireframeVisible()) { - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, 0, coords); - - glLineWidth(mrs.wireframeWidth()); - - if (mrs.isWireframeColorPerMesh()) { - glColor4fv(mrb.meshColorBufferData()); - } - else { - glColor4fv(mrs.wireframeUserColorData()); - } - - glDrawElements(GL_TRIANGLES, nt * 3, GL_UNSIGNED_INT, triangles); - - glDisableClientState(GL_VERTEX_ARRAY); - } - } - - void bindTextures() - { - textID.resize(mrb.textureNumber()); - glEnable(GL_TEXTURE_2D); - glGenTextures(mrb.textureNumber(), textID.data()); - - for (uint i = 0; i < mrb.textureNumber(); i++) { - glBindTexture(GL_TEXTURE_2D, textID[i]); - glTexImage2D( - GL_TEXTURE_2D, - 0, - GL_RGB, - mrb.textureSize(i).x(), - mrb.textureSize(i).y(), - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - mrb.textureBufferData(i)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - } - - void unbindTextures() - { - if (textID.size() > 0) { - glDeleteTextures(textID.size(), textID.data()); - textID.clear(); - } - } -}; - -} // namespace vcl::gl2 - -#endif // VCL_EXT_OPENGL2_DRAWABLE_MESH_H diff --git a/include/vclib/ext/qglviewer/viewer.h b/include/vclib/ext/qglviewer/viewer.h deleted file mode 100644 index e08830d8c..000000000 --- a/include/vclib/ext/qglviewer/viewer.h +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_QGLVIEWER_VIEWER_H -#define VCL_EXT_QGLVIEWER_VIEWER_H - -#include - -#include - -#include -#include -#include - -namespace vcl::qgl { - -class Viewer : public QGLViewer -{ - // this GLArea does not normally own this drawList - std::shared_ptr drawList; - -public: - Viewer(QWidget* parent = nullptr) : QGLViewer(parent) - { - drawList = std::make_shared(); - } - - Viewer(std::shared_ptr v, QWidget* parent = nullptr) : - QGLViewer(parent), drawList(v) - { - } - - void init() - { - for (DrawableObject* d : *drawList) { - d->init(); - } - } - - void setDrawableObjectVector(std::shared_ptr v) - { - drawList = v; - } - - std::shared_ptr drawableObjectVector() - { - return drawList; - } - - std::shared_ptr drawableObjectVector() const - { - return drawList; - } - - void fitScene() - { - Box3d bb = fullBB(); - Point3d sceneCenter = bb.center(); - double sceneRadius = bb.diagonal() / 2; - - setSceneCenter( - qglviewer::Vec(sceneCenter.x(), sceneCenter.y(), sceneCenter.z())); - setSceneRadius(sceneRadius); - showEntireScene(); - } - -protected: - virtual void draw() - { - for (const DrawableObject* obj : *drawList) - obj->draw(); - } - -private: - uint firstVisibleObject() const - { - uint i = 0; - - // if the current object i is not visible, check the next one - while (i < drawList->size() && !drawList->at(i).isVisible()) - i++; - - return i; - } - - vcl::Box3d fullBB() const - { - Box3d bb(Point3d(-1, -1, -1), Point3d(1, 1, 1)); - if (drawList->size() > 0) { - uint i = firstVisibleObject(); - - if (i < drawList->size()) { - Point3d sc = drawList->at(i).center(); - bb.min() = sc - drawList->at(i).radius(); - bb.max() = sc + drawList->at(i).radius(); - - for (i = i + 1; i < drawList->size(); i++) { // rest of the list - Point3d sc = drawList->at(i).center(); - Point3d tmp = sc - drawList->at(i).radius(); - bb.min() = vcl::min(bb.min(), tmp); - tmp = sc + drawList->at(i).radius(); - bb.max() = vcl::max(bb.max(), tmp); - } - } - } - return bb; - } -}; - -} // namespace vcl::qgl - -#endif // VCL_EXT_QGLVIEWER_VIEWER_H diff --git a/include/vclib/ext/qglviewer/viewer_main_window.cpp b/include/vclib/ext/qglviewer/viewer_main_window.cpp deleted file mode 100644 index c6b5f8c80..000000000 --- a/include/vclib/ext/qglviewer/viewer_main_window.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#include "viewer_main_window.h" -#include "ui_viewer_main_window.h" - -#include - -namespace vcl::qgl { - -/** - * @brief ViewerMainWindow constructor. - * - * Creates a MainWindow having the given parent. - * It will manage initialize an empty vector of DrawableObjects, which owns. - * - * @param parent - */ -ViewerMainWindow::ViewerMainWindow(QWidget* parent) : - QMainWindow(parent), ui(new Ui::ViewerMainWindow) -{ - ui->setupUi(this); - - // create the vector of DrawableObjects - drawVector = std::make_shared(); - - // give the vector pointer to the contained widgets - ui->glArea->setDrawableObjectVector(drawVector); - ui->drawVectorFrame->setDrawableObjectVector(drawVector); - - // each time that the RenderSettingsFrame updates its settings, we call the - // renderSettingsUpdated() member function - connect( - ui->renderSettingsFrame, - SIGNAL(settingsUpdated()), - this, - SLOT(renderSettingsUpdated())); - - // each time that the drawVectorFrame changes the visibility of an object, - // we update the current settings of the RenderSettingsFrame, and we update - // the glArea - connect( - ui->drawVectorFrame, - SIGNAL(drawableObjectVisibilityChanged()), - this, - SLOT(visibilityDrawableObjectChanged())); - - // each time that the selected object is changed in the drawVectorFrame, we - // update the RenderSettingsFrame, updating its settings to the object - // render settings - connect( - ui->drawVectorFrame, - SIGNAL(drawableObjectSelectionChanged(uint)), - this, - SLOT(selectedDrawableObjectChanged(uint))); - - ui->rightArea->setVisible(false); -} - -ViewerMainWindow::~ViewerMainWindow() -{ - delete ui; -} - -/** - * @brief Sets the current DrawableObjectVector, and updates the GUI - * accordingly. - * @param v - */ -void ViewerMainWindow::setDrawableObjectVector( - std::shared_ptr v) -{ - drawVector = v; - - // order here is important: drawVectorFrame must have the drawVector before - // the renderSettingsFrame! - ui->glArea->setDrawableObjectVector(drawVector); - ui->drawVectorFrame->setDrawableObjectVector(drawVector); - if (drawVector->size() > 0) { - try { - GenericDrawableMesh& m = - dynamic_cast(drawVector->at(0)); - ui->renderSettingsFrame->setMeshRenderSettings(m.renderSettings()); - ui->renderSettingsFrame->setVisible(true); - } - catch (std::bad_cast exp) { - // the current object (the first one) is not a GenericDrawableMesh - // we hide the RenderSettingsFrame - ui->renderSettingsFrame->setVisible(false); - } - // right area is visible if there is at least one DrawableObject - ui->rightArea->setVisible(true); - } - else { - ui->rightArea->setVisible(false); - } - ui->glArea->fitScene(); -} - -/** - * @brief Slot called when the user changed the visibility of an object in the - * DrawableObjectVectorFrame - */ -void ViewerMainWindow::visibilityDrawableObjectChanged() -{ - // get the selected drawable object - uint i = ui->drawVectorFrame->selectedDrawableObject(); - try { - // if it is a GenericDrawableMesh, we must be sure that its render - // settings are updated accordingly. - GenericDrawableMesh& m = - dynamic_cast(drawVector->at(i)); - ui->renderSettingsFrame->setMeshRenderSettings(m.renderSettings()); - } - catch (std::bad_cast exp) { - } - ui->glArea->update(); -} - -/** - * @brief Slot called when the user selected a different DrawableObject in the - * DrawableObjectVectorFrame - * @param i - */ -void ViewerMainWindow::selectedDrawableObjectChanged(uint i) -{ - try { - // take the newly selected DrawableObject and check whether it is a - // GenericDrawableMesh - GenericDrawableMesh& m = - dynamic_cast(drawVector->at(i)); - // if it is a GenericDrawableMesh, update the RenderSettingsFrame, and - // set it visible - ui->renderSettingsFrame->setMeshRenderSettings(m.renderSettings()); - ui->renderSettingsFrame->setVisible(true); - } - catch (std::bad_cast exp) { - // it is not a GenericDrawableMesh, RenderSettingsFrame must be hidden - ui->renderSettingsFrame->setVisible(false); - } -} - -/** - * @brief Slot called every time that the MeshRenderSettingsFrame emits - * 'settingsUpdated()', that is when the user changes render settings of a - * GeneriDrawableMesh. - * - * We need to get the selected GeneriDrawableMesh first, and then update the - * settings to it. - */ -void ViewerMainWindow::renderSettingsUpdated() -{ - // The user changed the RenderSettings of the ith object. - uint i = ui->drawVectorFrame->selectedDrawableObject(); - if (drawVector->size() > 0) { - // The selected object must always be a GenericDrawableMesh, because the - // RenderSettingsFrame (which called this member function) is visible - // only when the selected Object is a GenericDrawableMesh - GenericDrawableMesh& m = - dynamic_cast(drawVector->at(i)); - // get RenderSettings from the RenderSettingsFrame, and set it to the - // GenericDrawableMesh - m.setRenderSettings(ui->renderSettingsFrame->meshRenderSettings()); - ui->glArea->update(); - } -} - -} // namespace vcl::qgl diff --git a/include/vclib/ext/qglviewer/viewer_main_window.h b/include/vclib/ext/qglviewer/viewer_main_window.h deleted file mode 100644 index a4f57f3d8..000000000 --- a/include/vclib/ext/qglviewer/viewer_main_window.h +++ /dev/null @@ -1,59 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_QGLVIEWER_VIEWER_MAIN_WINDOW_H -#define VCL_EXT_QGLVIEWER_VIEWER_MAIN_WINDOW_H - -#include - -#include - -namespace vcl::qgl { - -namespace Ui { -class ViewerMainWindow; -} // namespace Ui - -class ViewerMainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit ViewerMainWindow(QWidget* parent = nullptr); - ~ViewerMainWindow(); - - void setDrawableObjectVector(std::shared_ptr v); - -public slots: - void visibilityDrawableObjectChanged(); - void selectedDrawableObjectChanged(uint i); - void renderSettingsUpdated(); - -private: - Ui::ViewerMainWindow* ui; - std::shared_ptr drawVector; -}; - -} // namespace vcl::qgl - -#endif // VCL_EXT_QGLVIEWER_VIEWER_MAIN_WINDOW_H diff --git a/include/vclib/ext/qglviewer/viewer_main_window.ui b/include/vclib/ext/qglviewer/viewer_main_window.ui deleted file mode 100644 index 027db4eaf..000000000 --- a/include/vclib/ext/qglviewer/viewer_main_window.ui +++ /dev/null @@ -1,114 +0,0 @@ - - - vcl::qgl::ViewerMainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - - - - - - 0 - 0 - 800 - 22 - - - - - - - - vcl::qgl::Viewer - QWidget -
vclib/ext/qglviewer/viewer.h
- 1 -
- - vcl::qt::MeshRenderSettingsFrame - QFrame -
vclib/ext/qt/gui/mesh_render_settings_frame.h
- 1 -
- - vcl::qt::DrawableObjectVectorFrame - QFrame -
vclib/ext/qt/gui/drawable_object_vector_frame.h
- 1 -
-
- - -
diff --git a/include/vclib/ext/qt/gui/drawable_object_frame.ui b/include/vclib/ext/qt/gui/drawable_object_frame.ui deleted file mode 100644 index 0747eeb03..000000000 --- a/include/vclib/ext/qt/gui/drawable_object_frame.ui +++ /dev/null @@ -1,41 +0,0 @@ - - - vcl::qt::DrawableObjectFrame - - - - 0 - 0 - 400 - 41 - - - - Frame - - - - - - - - - - - - - - 0 - 0 - - - - DrawableObjectName - - - - - - - - diff --git a/include/vclib/ext/qt/gui/drawable_object_vector_frame.cpp b/include/vclib/ext/qt/gui/drawable_object_vector_frame.cpp deleted file mode 100644 index c8f07c2f5..000000000 --- a/include/vclib/ext/qt/gui/drawable_object_vector_frame.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#include "drawable_object_vector_frame.h" -#include "ui_drawable_object_vector_frame.h" - -#include - -namespace vcl::qt { - -DrawableObjectVectorFrame::DrawableObjectVectorFrame(QWidget* parent) : - QFrame(parent), ui(new Ui::DrawableObjectVectorFrame) -{ - ui->setupUi(this); -} - -DrawableObjectVectorFrame::DrawableObjectVectorFrame( - std::shared_ptr v, - QWidget* parent) : - DrawableObjectVectorFrame(parent) -{ - drawList = v; - updateDrawableVectorWidget(); -} - -DrawableObjectVectorFrame::~DrawableObjectVectorFrame() -{ - delete ui; -} - -void DrawableObjectVectorFrame::setDrawableObjectVector( - std::shared_ptr v) -{ - drawList = v; - updateDrawableVectorWidget(); -} - -uint DrawableObjectVectorFrame::selectedDrawableObject() const -{ - auto item = ui->listWidget->selectedItems().first(); - return ui->listWidget->row(item); -} - -void DrawableObjectVectorFrame::on_listWidget_itemSelectionChanged() -{ - if (ui->listWidget->selectedItems().size() > 0) { - emit drawableObjectSelectionChanged(selectedDrawableObject()); - } - else { - ui->listWidget->item(0)->setSelected(true); - } -} - -void DrawableObjectVectorFrame::updateDrawableVectorWidget() -{ - ui->listWidget->clear(); - for (auto* d : *drawList) { - QListWidgetItem* item = new QListWidgetItem(ui->listWidget); - DrawableObjectFrame* frame = new DrawableObjectFrame(d, ui->listWidget); - - item->setSizeHint(frame->sizeHint()); - ui->listWidget->addItem(item); - ui->listWidget->setItemWidget(item, frame); - connect( - frame, - SIGNAL(visibilityChanged()), - this, - SIGNAL(drawableObjectVisibilityChanged())); - } - if (drawList->size() > 0) { - ui->listWidget->item(0)->setSelected(true); - } -} - -} // namespace vcl::qt diff --git a/include/vclib/ext/qt/gui/drawable_object_vector_frame.h b/include/vclib/ext/qt/gui/drawable_object_vector_frame.h deleted file mode 100644 index 80b19bc9e..000000000 --- a/include/vclib/ext/qt/gui/drawable_object_vector_frame.h +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_QT_GUI_DRAWABLE_OBJECT_VECTOR_FRAME_H -#define VCL_EXT_QT_GUI_DRAWABLE_OBJECT_VECTOR_FRAME_H - -#include - -#include - -#include "drawable_object_frame.h" - -namespace vcl::qt { - -namespace Ui { -class DrawableObjectVectorFrame; -} // namespace Ui - -class DrawableObjectVectorFrame : public QFrame -{ - Q_OBJECT - -public: - explicit DrawableObjectVectorFrame(QWidget* parent = nullptr); - explicit DrawableObjectVectorFrame( - std::shared_ptr v, - QWidget* parent = nullptr); - ~DrawableObjectVectorFrame(); - - void setDrawableObjectVector(std::shared_ptr v); - - uint selectedDrawableObject() const; - -signals: - void drawableObjectVisibilityChanged(); - void drawableObjectSelectionChanged(uint i); - -private slots: - void on_listWidget_itemSelectionChanged(); - -private: - // this frame does not normally own this drawList - std::shared_ptr drawList; - Ui::DrawableObjectVectorFrame* ui; - - void updateDrawableVectorWidget(); -}; - -} // namespace vcl::qt - -#endif // VCL_EXT_QT_GUI_DRAWABLE_OBJECT_VECTOR_FRAME_H diff --git a/include/vclib/ext/qt/gui/drawable_object_vector_frame.ui b/include/vclib/ext/qt/gui/drawable_object_vector_frame.ui deleted file mode 100644 index d2926259c..000000000 --- a/include/vclib/ext/qt/gui/drawable_object_vector_frame.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - vcl::qt::DrawableObjectVectorFrame - - - - 0 - 0 - 400 - 300 - - - - Frame - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - diff --git a/include/vclib/ext/qt/gui/mesh_render_settings_frame.cpp b/include/vclib/ext/qt/gui/mesh_render_settings_frame.cpp deleted file mode 100644 index b04ed96bb..000000000 --- a/include/vclib/ext/qt/gui/mesh_render_settings_frame.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#include "mesh_render_settings_frame.h" -#include "ui_mesh_render_settings_frame.h" - -#include -#include - -namespace vcl::qt { - -MeshRenderSettingsFrame::MeshRenderSettingsFrame(QWidget* parent) : - QFrame(parent), ui(new Ui::MeshRenderSettingsFrame) -{ - ui->setupUi(this); -} - -MeshRenderSettingsFrame::~MeshRenderSettingsFrame() -{ - delete ui; -} - -const MeshRenderSettings& MeshRenderSettingsFrame::meshRenderSettings() const -{ - return mrs; -} - -void MeshRenderSettingsFrame::setMeshRenderSettings( - const MeshRenderSettings& settings) -{ - mrs = settings; - updateGuiFromSettings(); -} - -void MeshRenderSettingsFrame::on_pointVisibilityCheckBox_stateChanged(int arg1) -{ - mrs.setPointCloudVisibility(arg1 == Qt::Checked); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_pointColorComboBox_currentIndexChanged( - int index) -{ - switch (index) { - case P_VERT: mrs.setPointCloudColorPerVertex(); break; - case P_MESH: mrs.setPointCloudColorPerMesh(); break; - case P_USER: mrs.setPointCloudColorUserDefined(); break; - } - ui->pointUserColorFrame->setVisible(index == P_USER); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_pointColorDialogPushButton_clicked() -{ - QColor color = QColorDialog::getColor(); - - if (color.isValid()) { - setButtonBackGround(ui->pointColorDialogPushButton, color); - - mrs.setPointCloudUserColor( - color.redF(), color.greenF(), color.blueF(), color.alphaF()); - emit settingsUpdated(); - } -} - -void MeshRenderSettingsFrame::on_pointSizeSlider_valueChanged(int value) -{ - mrs.setPointWidth(value); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_surfaceVisibilityCheckBox_stateChanged( - int arg1) -{ - mrs.setSurfaceVisibility(arg1 == Qt::Checked); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_surfaceShadingSmoothRadioButton_toggled( - bool checked) -{ - if (checked) { - mrs.setSurfaceShadingSmooth(); - emit settingsUpdated(); - } -} - -void MeshRenderSettingsFrame::on_surfaceShadingFlatRadioButton_toggled( - bool checked) -{ - if (checked) { - mrs.setSurfaceShadingFlat(); - emit settingsUpdated(); - } -} - -void MeshRenderSettingsFrame::on_surfaceColorComboBox_currentIndexChanged( - int index) -{ - switch (index) { - case SC_FACE: mrs.setSurfaceColorPerFace(); break; - case SC_VERT: mrs.setSurfaceColorPerVertex(); break; - case SC_MESH: mrs.setSurfaceColorPerMesh(); break; - case SC_VERT_TEX: mrs.setSurfaceColorPerVertexTexcoords(); break; - case SC_WEDG_TEX: mrs.setSurfaceColorPerWedgeTexcoords(); break; - case SC_USER: mrs.setSurfaceColorUserDefined(); break; - } - ui->surfaceUserColorFrame->setVisible(index == SC_USER); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_surfaceColorDialogPushButton_clicked() -{ - QColor color = QColorDialog::getColor(); - - if (color.isValid()) { - setButtonBackGround(ui->surfaceColorDialogPushButton, color); - - mrs.setSurfaceUserColor( - color.redF(), color.greenF(), color.blueF(), color.alphaF()); - emit settingsUpdated(); - } -} - -void MeshRenderSettingsFrame::on_wireframeVisibilityCheckBox_stateChanged( - int arg1) -{ - mrs.setWireframeVisibility(arg1 == Qt::Checked); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_wireframeColorComboBox_currentIndexChanged( - int index) -{ - switch (index) { - case W_MESH: mrs.setWireframeColorPerMesh(); break; - case W_USER: mrs.setWireframeColorUserDefined(); break; - } - ui->wireframeUserColorFrame->setVisible(index == W_USER); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::on_wireframeColorDialogPushButton_clicked() -{ - QColor color = QColorDialog::getColor(); - if (color.isValid()) { - setButtonBackGround(ui->wireframeColorDialogPushButton, color); - - mrs.setWireframeUserColor( - color.redF(), color.greenF(), color.blueF(), color.alphaF()); - emit settingsUpdated(); - } -} - -void MeshRenderSettingsFrame::on_wireframeSizelSlider_valueChanged(int value) -{ - mrs.setWireframeWidth(value); - emit settingsUpdated(); -} - -void MeshRenderSettingsFrame::updateGuiFromSettings() -{ - if (mrs.canBeVisible()) { - ui->tabWidget->setEnabled(true); - updatePointsTabFromSettings(); - updateSurfaceTabFromSettings(); - updateWireframeTabFromSettings(); - } - else { - ui->tabWidget->setEnabled(false); - ui->pointVisibilityCheckBox->setChecked(false); - ui->surfaceVisibilityCheckBox->setChecked(false); - ui->wireframeVisibilityCheckBox->setChecked(false); - } -} - -void MeshRenderSettingsFrame::updatePointsTabFromSettings() -{ - if (mrs.canPointCloudBeVisible()) { - ui->tabWidget->setCurrentIndex(0); - ui->pointsTab->setEnabled(true); - ui->pointVisibilityCheckBox->setEnabled(true); - ui->pointVisibilityCheckBox->setChecked(mrs.isPointCloudVisible()); - - // todo - ui->pointShadingPixelRadioButton->setChecked(true); - ui->pointShadingCircleRadioButton->setEnabled(false); - - updatePointsColorComboBoxFromSettings(); - ui->pointSizeSlider->setValue(mrs.pointWidth()); - } - else { - ui->pointsTab->setEnabled(false); - ui->pointVisibilityCheckBox->setChecked(false); - } -} - -void MeshRenderSettingsFrame::updatePointsColorComboBoxFromSettings() -{ - QStandardItemModel* model = - qobject_cast(ui->pointColorComboBox->model()); - assert(model != nullptr); - QStandardItem* item = model->item(P_VERT); - if (mrs.canPointCloudBeColoredPerVertex()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - item = model->item(P_MESH); - if (mrs.canPointCloudBeColoredPerMesh()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - if (mrs.isPointCloudColorPerVertex()) - ui->pointColorComboBox->setCurrentIndex(P_VERT); - if (mrs.isPointCloudColorPerMesh()) - ui->pointColorComboBox->setCurrentIndex(P_MESH); - if (mrs.isPointCloudColorUserDefined()) - ui->pointColorComboBox->setCurrentIndex(P_USER); - ui->pointUserColorFrame->setVisible(mrs.isPointCloudColorUserDefined()); - vcl::Color vc = mrs.pointCloudUserColor(); - QColor c(vc.red(), vc.green(), vc.blue(), vc.alpha()); - setButtonBackGround(ui->pointColorDialogPushButton, c); -} - -void MeshRenderSettingsFrame::updateSurfaceTabFromSettings() -{ - if (mrs.canSurfaceBeVisible()) { - ui->tabWidget->setCurrentIndex(1); - ui->surfaceTab->setEnabled(true); - ui->surfaceVisibilityCheckBox->setEnabled(true); - ui->surfaceVisibilityCheckBox->setChecked(mrs.isSurfaceVisible()); - uptateSurfaceShadingRadioButtonsFromSettings(); - updateSurfaceColorComboBoxFromSettings(); - } - else { - ui->surfaceTab->setEnabled(false); - } -} - -void MeshRenderSettingsFrame::uptateSurfaceShadingRadioButtonsFromSettings() -{ - if (mrs.canSurfaceBeSmooth()) { - ui->surfaceShadingSmoothRadioButton->setEnabled(true); - } - else { - ui->surfaceShadingSmoothRadioButton->setEnabled(false); - } - ui->surfaceShadingFlatRadioButton->setChecked(mrs.isSurfaceShadingFlat()); - ui->surfaceShadingSmoothRadioButton->setChecked( - mrs.isSurfaceShadingSmooth()); -} - -void MeshRenderSettingsFrame::updateSurfaceColorComboBoxFromSettings() -{ - QStandardItemModel* model = - qobject_cast(ui->surfaceColorComboBox->model()); - assert(model != nullptr); - QStandardItem* item = model->item(SC_VERT); - if (mrs.canSurfaceBeColoredPerVertex()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - item = model->item(SC_FACE); - if (mrs.canSurfaceBeColoredPerFace()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - item = model->item(SC_MESH); - if (mrs.canSurfaceBeColoredPerMesh()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - item = model->item(SC_VERT_TEX); - if (mrs.canSurfaceBeColoredPerVertexTexcoords()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - item = model->item(SC_WEDG_TEX); - if (mrs.canSurfaceBeColoredPerWedgeTexcoords()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - - if (mrs.isSurfaceColorPerVertex()) - ui->surfaceColorComboBox->setCurrentIndex(SC_VERT); - if (mrs.isSurfaceColorPerFace()) - ui->surfaceColorComboBox->setCurrentIndex(SC_FACE); - if (mrs.isSurfaceColorPerMesh()) - ui->surfaceColorComboBox->setCurrentIndex(SC_MESH); - if (mrs.isSurfaceColorPerVertexTexcoords()) - ui->surfaceColorComboBox->setCurrentIndex(SC_VERT_TEX); - if (mrs.isSurfaceColorPerWedgeTexcoords()) - ui->surfaceColorComboBox->setCurrentIndex(SC_WEDG_TEX); - if (mrs.isSurfaceColorUserDefined()) - ui->surfaceColorComboBox->setCurrentIndex(SC_USER); - ui->surfaceUserColorFrame->setVisible(mrs.isSurfaceColorUserDefined()); - vcl::Color vc = mrs.surfaceUserColor(); - QColor c(vc.red(), vc.green(), vc.blue(), vc.alpha()); - setButtonBackGround(ui->surfaceColorDialogPushButton, c); -} - -void MeshRenderSettingsFrame::updateWireframeTabFromSettings() -{ - if (mrs.canSurfaceBeVisible()) { - ui->wireframeTab->setEnabled(true); - ui->wireframeVisibilityCheckBox->setEnabled(true); - ui->wireframeVisibilityCheckBox->setChecked(mrs.isWireframeVisible()); - updateWireframeComboBoxFromSettings(); - ui->wireframeSizelSlider->setValue(mrs.wireframeWidth()); - } - else { - ui->wireframeTab->setEnabled(false); - } -} - -void MeshRenderSettingsFrame::updateWireframeComboBoxFromSettings() -{ - QStandardItemModel* model = - qobject_cast(ui->wireframeColorComboBox->model()); - assert(model != nullptr); - QStandardItem* item = model->item(W_MESH); - if (mrs.canWireframeBeColoredPerMesh()) { - item->setFlags(item->flags() | Qt::ItemIsEnabled); - } - else { - item->setFlags(item->flags() & ~Qt::ItemIsEnabled); - } - if (mrs.isWireframeColorPerMesh()) - ui->wireframeColorComboBox->setCurrentIndex(W_MESH); - if (mrs.isWireframeColorUserDefined()) - ui->wireframeColorComboBox->setCurrentIndex(W_USER); - ui->wireframeUserColorFrame->setVisible(mrs.isWireframeColorUserDefined()); - vcl::Color vc = mrs.wireframeUserColor(); - QColor c(vc.red(), vc.green(), vc.blue(), vc.alpha()); - setButtonBackGround(ui->wireframeColorDialogPushButton, c); -} - -void MeshRenderSettingsFrame::setButtonBackGround( - QPushButton* b, - const QColor& c) -{ - QPalette px; - px.setColor(QPalette::Button, c); - b->setPalette(px); - b->update(); -} - -QColor MeshRenderSettingsFrame::getButtonBackGround(QPushButton* b) -{ - QPalette px = b->palette(); - return px.color(QPalette::Button); -} - -} // namespace vcl::qt diff --git a/include/vclib/ext/qt/gui/mesh_render_settings_frame.h b/include/vclib/ext/qt/gui/mesh_render_settings_frame.h deleted file mode 100644 index 7bcab983a..000000000 --- a/include/vclib/ext/qt/gui/mesh_render_settings_frame.h +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_QT_GUI_MESH_RENDER_SETTINGS_FRAME_H -#define VCL_EXT_QT_GUI_MESH_RENDER_SETTINGS_FRAME_H - -#include - -#include - -class QPushButton; - -namespace vcl::qt { - -namespace Ui { -class MeshRenderSettingsFrame; -} // namespace Ui - -class MeshRenderSettingsFrame : public QFrame -{ - Q_OBJECT - -public: - explicit MeshRenderSettingsFrame(QWidget* parent = nullptr); - ~MeshRenderSettingsFrame(); - - const MeshRenderSettings& meshRenderSettings() const; - void setMeshRenderSettings(const MeshRenderSettings& settings); - -signals: - void settingsUpdated(); - -private slots: - void on_pointVisibilityCheckBox_stateChanged(int arg1); - void on_pointColorComboBox_currentIndexChanged(int index); - void on_pointColorDialogPushButton_clicked(); - void on_pointSizeSlider_valueChanged(int value); - - void on_surfaceVisibilityCheckBox_stateChanged(int arg1); - void on_surfaceShadingSmoothRadioButton_toggled(bool checked); - void on_surfaceShadingFlatRadioButton_toggled(bool checked); - void on_surfaceColorComboBox_currentIndexChanged(int index); - void on_surfaceColorDialogPushButton_clicked(); - - void on_wireframeVisibilityCheckBox_stateChanged(int arg1); - void on_wireframeColorComboBox_currentIndexChanged(int index); - void on_wireframeColorDialogPushButton_clicked(); - void on_wireframeSizelSlider_valueChanged(int value); - -private: - enum POINT_COLOR { P_VERT = 0, P_MESH, P_USER }; - - enum SURF_COLOR { - SC_VERT = 0, - SC_FACE, - SC_MESH, - SC_VERT_TEX, - SC_WEDG_TEX, - SC_USER - }; - - enum WIRE_COLOR { W_MESH = 0, W_USER }; - - Ui::MeshRenderSettingsFrame* ui; - MeshRenderSettings mrs; - - void updateGuiFromSettings(); - void updatePointsTabFromSettings(); - void updatePointsColorComboBoxFromSettings(); - void updateSurfaceTabFromSettings(); - void uptateSurfaceShadingRadioButtonsFromSettings(); - void updateSurfaceColorComboBoxFromSettings(); - void updateWireframeTabFromSettings(); - void updateWireframeComboBoxFromSettings(); - - void setButtonBackGround(QPushButton* b, const QColor& c); - QColor getButtonBackGround(QPushButton* b); -}; - -} // namespace vcl::qt - -#endif // VCL_EXT_QT_GUI_MESH_RENDER_SETTINGS_FRAME_H diff --git a/include/vclib/ext/qt/gui/mesh_render_settings_frame.ui b/include/vclib/ext/qt/gui/mesh_render_settings_frame.ui deleted file mode 100644 index 055d21290..000000000 --- a/include/vclib/ext/qt/gui/mesh_render_settings_frame.ui +++ /dev/null @@ -1,537 +0,0 @@ - - - vcl::qt::MeshRenderSettingsFrame - - - - 0 - 0 - 400 - 300 - - - - Frame - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 1 - - - - Points - - - - - - - 0 - 0 - - - - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - User Color: - - - - - - - - - - - - - false - - - - - - - - - - - 0 - 0 - - - - Shading: - - - - - - - - 0 - 0 - - - - Pixel - - - true - - - - - - - - 0 - 0 - - - - Visible: - - - - - - - - 0 - 0 - - - - Color: - - - - - - - - 0 - 0 - - - - Circle - - - - - - - - Vertex - - - - - Mesh - - - - - User - - - - - - - - - 0 - 0 - - - - Size: - - - - - - - 1 - - - 10 - - - Qt::Horizontal - - - - - - - - Surface - - - - - - - 0 - 0 - - - - Visible: - - - - - - - - 0 - 0 - - - - - - - true - - - - - - - - 0 - 0 - - - - Shading: - - - - - - - - 0 - 0 - - - - - Vertex - - - - - Face - - - - - Mesh - - - - - Vertex TexCoords - - - - - Wedge TexCoords - - - - - User - - - - - - - - - 0 - 0 - - - - Color: - - - - - - - - 0 - 0 - - - - Flat - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - User Color: - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Smooth - - - true - - - - - - - - Wireframe - - - - - - - 0 - 0 - - - - Size: - - - - - - - - 0 - 0 - - - - Color: - - - - - - - - 0 - 0 - - - - Visible: - - - - - - - - 0 - 0 - - - - 1 - - - - Mesh - - - - - User - - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - UserColor: - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - 1 - - - 10 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - diff --git a/include/vclib/ext/qt/gui/q_clickable_label.h b/include/vclib/ext/qt/gui/q_clickable_label.h deleted file mode 100644 index ebe26681c..000000000 --- a/include/vclib/ext/qt/gui/q_clickable_label.h +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#ifndef VCL_EXT_QT_GUI_Q_CLICKABLE_LABEL_H -#define VCL_EXT_QT_GUI_Q_CLICKABLE_LABEL_H - -#include -#include -#include - -namespace vcl::qt { - -/** - * @brief The QClickableLabel class - * - * A QLabel class which can be clicked (clicked event). - * - * Usage: just Promote a QLabel to a vcl::QClickableLabel - * - * @link https://wiki.qt.io/Clickable_QLabel - */ -class QClickableLabel : public QLabel -{ - Q_OBJECT - -public: - explicit QClickableLabel( - QWidget* parent = Q_NULLPTR, - Qt::WindowFlags f = Qt::WindowFlags()); - ~QClickableLabel(); - -signals: - void clicked(); - -protected: - void mousePressEvent(QMouseEvent* event); -}; - -} // namespace vcl::qt - -#endif // VCL_EXT_QT_GUI_Q_CLICKABLE_LABEL_H diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7562ab0a3..1f91b03e5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,9 +12,13 @@ cmake_minimum_required(VERSION 3.13) project(vclib-test) -add_definitions(-DVCL_TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data") -add_definitions(-DVCL_TEST_MODELS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/models") -add_definitions(-DVCL_TEST_RESULTS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/results") +add_library(vclib-test-common INTERFACE) +target_compile_definitions(vclib-test-common INTERFACE + VCLIB_TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data") +target_compile_definitions(vclib-test-common INTERFACE + VCLIB_TEST_MODELS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/models") +target_compile_definitions(vclib-test-common INTERFACE + VCLIB_TEST_RESULTS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/data/results") # examples if (VCLIB_BUILD_EXAMPLES) @@ -28,7 +32,6 @@ if (VCLIB_BUILD_EXAMPLES) add_subdirectory(examples/mesh_create) add_subdirectory(examples/mesh_custom_components) add_subdirectory(examples/mesh_export_to_matrix) - add_subdirectory(examples/mesh_generate) add_subdirectory(examples/mesh_iterators) add_subdirectory(examples/mesh_io_obj) add_subdirectory(examples/mesh_io_off) @@ -39,20 +42,15 @@ if (VCLIB_BUILD_EXAMPLES) add_subdirectory(examples/mesh_principal_curvature) add_subdirectory(examples/mesh_sampling) add_subdirectory(examples/mesh_smooth) + add_subdirectory(examples/mesh_sphere_intersection) add_subdirectory(examples/mesh_stat) add_subdirectory(examples/mesh_topology) add_subdirectory(examples/mesh_transform) add_subdirectory(examples/polygon_earcut) add_subdirectory(examples/polymesh_basic) add_subdirectory(examples/static_asserts) - - if (TARGET vclib-external-qglviewer) - add_subdirectory(examples/ext/qglviewer/viewer) - endif() endif() - - # tests if (VCLIB_BUILD_AND_RUN_TESTS) add_subdirectory(tests/kd_tree) diff --git a/test/examples/distance/CMakeLists.txt b/test/examples/distance/CMakeLists.txt index d27ef1eac..1a6af26d0 100644 --- a/test/examples/distance/CMakeLists.txt +++ b/test/examples/distance/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-distance-example ${SOURCES}) -target_link_libraries(vclib-distance-example PUBLIC vclib) +target_link_libraries(vclib-distance-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/distance/main.cpp b/test/examples/distance/main.cpp index 005042a53..d1459250b 100644 --- a/test/examples/distance/main.cpp +++ b/test/examples/distance/main.cpp @@ -32,7 +32,7 @@ int main() { using PointType = vcl::TriMesh::VertexType::CoordType; vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); vcl::updatePerFaceNormals(m); @@ -51,9 +51,9 @@ int main() log.setPrintTimer(true); vcl::TriMesh m1 = - vcl::loadObj(VCL_TEST_MODELS_PATH "/bimba.obj"); + vcl::loadObj(VCLIB_TEST_MODELS_PATH "/bimba.obj"); vcl::TriMesh m2 = - vcl::loadObj(VCL_TEST_MODELS_PATH "/bunny.obj"); + vcl::loadObj(VCLIB_TEST_MODELS_PATH "/bunny.obj"); vcl::updateBoundingBox(m1); vcl::updateBoundingBox(m2); diff --git a/test/examples/edge_mesh_basic/CMakeLists.txt b/test/examples/edge_mesh_basic/CMakeLists.txt index 6b46d922f..a36dcb014 100644 --- a/test/examples/edge_mesh_basic/CMakeLists.txt +++ b/test/examples/edge_mesh_basic/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-edge-mesh-basic-example ${SOURCES}) -target_link_libraries(vclib-edge-mesh-basic-example PUBLIC vclib) +target_link_libraries(vclib-edge-mesh-basic-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/ext/qglviewer/viewer/CMakeLists.txt b/test/examples/ext/qglviewer/viewer/CMakeLists.txt deleted file mode 100644 index fa081b1f1..000000000 --- a/test/examples/ext/qglviewer/viewer/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -#***************************************************************************** -#* VCLib * -#* Visual Computing Library * -#* * -#* Copyright(C) 2021-2022 * -#* Alessandro Muntoni * -#* VCLab - ISTI - Italian National Research Council * -#* * -#* All rights reserved. * -#****************************************************************************/ - -project(vclib-ext-qglviewer-viewer) - -set(SOURCES - main.cpp) - -add_executable(vclib-ext-qglviewer-viewer ${SOURCES}) - -target_link_libraries(vclib-ext-qglviewer-viewer PUBLIC vclib) diff --git a/test/examples/ext/qglviewer/viewer/main.cpp b/test/examples/ext/qglviewer/viewer/main.cpp deleted file mode 100644 index 7ab8944ee..000000000 --- a/test/examples/ext/qglviewer/viewer/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * VCLib * - * Visual Computing Library * - * * - * Copyright(C) 2021-2023 * - * Alessandro Muntoni * - * Visual Computing Lab * - * ISTI - Italian National Research Council * - * * - * All rights reserved. * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * for more details. * - ****************************************************************************/ - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -int main(int argc, char** argv) -{ - // Read command lines arguments. - QApplication application(argc, argv); - - // Instantiate the viewer. - vcl::qgl::ViewerMainWindow viewer; - - vcl::MeshInfo loadedInfo; - - vcl::PolyMesh tm = vcl::load( - VCL_TEST_MODELS_PATH "/TextureDouble.ply", loadedInfo); - vcl::updatePerFaceNormals(tm); - vcl::updatePerVertexNormals(tm); - tm.enablePerVertexColor(); - tm.enablePerFaceColor(); - vcl::setPerVertexColor(tm, vcl::Color::DarkMagenta); - vcl::setPerFaceColor(tm, vcl::Color::LightGreen); - vcl::setMeshColor(tm, vcl::Color::Yellow); - - vcl::TriMesh m = - vcl::loadObj(VCL_TEST_MODELS_PATH "/bimba.obj"); - m.enablePerVertexColor(); - vcl::updatePerFaceNormals(m); - vcl::updatePerVertexNormals(m); - vcl::setPerVertexColor(m, vcl::Color::DarkGreen); - - vcl::gl2::DrawableMesh dtm(tm); - vcl::gl2::DrawableMesh dm(m); - - std::shared_ptr vector = - std::make_shared(); - vector->pushBack(dtm); - vector->pushBack(dm); - - viewer.setDrawableObjectVector(vector); - - viewer.setWindowTitle("simpleViewer"); - - // Make the viewer window visible on screen. - viewer.show(); - - // Run main loop. - return application.exec(); -} diff --git a/test/examples/grid/CMakeLists.txt b/test/examples/grid/CMakeLists.txt index 0e1c165df..794d176fc 100644 --- a/test/examples/grid/CMakeLists.txt +++ b/test/examples/grid/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-grid-example ${SOURCES}) -target_link_libraries(vclib-grid-example PUBLIC vclib) +target_link_libraries(vclib-grid-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/grid/main.cpp b/test/examples/grid/main.cpp index 25d1a220f..8464dcdbb 100644 --- a/test/examples/grid/main.cpp +++ b/test/examples/grid/main.cpp @@ -176,7 +176,7 @@ int main() std::cerr << "\nK closest values: \n"; - m = vcl::loadPly(VCL_TEST_MODELS_PATH "/bone.ply"); + m = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bone.ply"); vcl::StaticGrid vmsg(m.vertices() | vcl::views::constAddrOf); diff --git a/test/examples/mesh_basic/CMakeLists.txt b/test/examples/mesh_basic/CMakeLists.txt index 5cd7b857b..68c9e23bc 100644 --- a/test/examples/mesh_basic/CMakeLists.txt +++ b/test/examples/mesh_basic/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-basic-example ${SOURCES}) -target_link_libraries(vclib-mesh-basic-example PUBLIC vclib) +target_link_libraries(vclib-mesh-basic-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_clean/CMakeLists.txt b/test/examples/mesh_clean/CMakeLists.txt index ce0ff8b8b..13a436240 100644 --- a/test/examples/mesh_clean/CMakeLists.txt +++ b/test/examples/mesh_clean/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-clean ${SOURCES}) -target_link_libraries(vclib-mesh-clean PUBLIC vclib) +target_link_libraries(vclib-mesh-clean PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_clean/main.cpp b/test/examples/mesh_clean/main.cpp index 9b004e65f..fc8c25ee2 100644 --- a/test/examples/mesh_clean/main.cpp +++ b/test/examples/mesh_clean/main.cpp @@ -31,7 +31,7 @@ int main() { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/brain.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/brain.ply"); bool isWaterTight = vcl::isWaterTight(m); @@ -62,9 +62,9 @@ int main() m.compact(); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/brain_clean.ply"); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/brain_clean.ply"); - m = vcl::loadPly(VCL_TEST_MODELS_PATH "/bunny_textured.ply"); + m = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bunny_textured.ply"); m.enablePerFaceAdjacentFaces(); vcl::updatePerFaceAdjacentFaces(m); @@ -74,7 +74,7 @@ int main() std::cerr << "Bunny number holes: " << nHoles << "\n"; - m = vcl::loadPly(VCL_TEST_MODELS_PATH "/rangemap.ply"); + m = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/rangemap.ply"); vcl::updateBoundingBox(m); @@ -94,7 +94,7 @@ int main() vcl::setPerVertexColorPerlinNoise(m, vcl::Point(d, d, d)); - vcl::save(m, VCL_TEST_RESULTS_PATH "/rangemap_cc_colored.ply", false); + vcl::save(m, VCLIB_TEST_RESULTS_PATH "/rangemap_cc_colored.ply", false); return 0; } diff --git a/test/examples/mesh_conversion/CMakeLists.txt b/test/examples/mesh_conversion/CMakeLists.txt index e939de943..cc51319c1 100644 --- a/test/examples/mesh_conversion/CMakeLists.txt +++ b/test/examples/mesh_conversion/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-conversion ${SOURCES}) -target_link_libraries(vclib-mesh-conversion PUBLIC vclib) +target_link_libraries(vclib-mesh-conversion PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_conversion/main.cpp b/test/examples/mesh_conversion/main.cpp index bc61e7ca7..735ac3391 100644 --- a/test/examples/mesh_conversion/main.cpp +++ b/test/examples/mesh_conversion/main.cpp @@ -30,7 +30,7 @@ int main() { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/TextureDouble.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/TextureDouble.ply"); vcl::PolyMesh pm; @@ -41,9 +41,9 @@ int main() assert(pm.isPerFaceWedgeTexCoordsEnabled()); - vcl::save(pm, VCL_TEST_RESULTS_PATH "/TextureDouble_converted.ply", false); + vcl::save(pm, VCLIB_TEST_RESULTS_PATH "/TextureDouble_converted.ply", false); - pm = vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_poly.ply"); + pm = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); m.clear(); m.disableAllPerFaceOptionalComponents(); @@ -51,7 +51,7 @@ int main() m.enableSameOptionalComponentsOf(pm); m.importFrom(pm); - vcl::save(m, VCL_TEST_RESULTS_PATH "/cube_from_poly.ply", false); + vcl::save(m, VCLIB_TEST_RESULTS_PATH "/cube_from_poly.ply", false); return 0; } diff --git a/test/examples/mesh_create/CMakeLists.txt b/test/examples/mesh_create/CMakeLists.txt index 637b6c811..e449b3a8b 100644 --- a/test/examples/mesh_create/CMakeLists.txt +++ b/test/examples/mesh_create/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-create ${SOURCES}) -target_link_libraries(vclib-mesh-create PUBLIC vclib) +target_link_libraries(vclib-mesh-create PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_create/main.cpp b/test/examples/mesh_create/main.cpp index e6abdb386..55fe57efe 100644 --- a/test/examples/mesh_create/main.cpp +++ b/test/examples/mesh_create/main.cpp @@ -42,39 +42,39 @@ int main() assert(m.vertexNumber() == 4); assert(m.faceNumber() == 4); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/tetrahedron.ply", info); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/tetrahedron.ply", info); m = vcl::createIcosahedron(true); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/icosahedron.ply", info); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/icosahedron.ply", info); m = vcl::createHexahedron(); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/hexahedron.ply", info); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/hexahedron.ply", info); vcl::ConsoleLogger log; log.setPrintTimer(true); log.startTimer(); m = vcl::createDodecahedron(log); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/dodecahedron.ply", info); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/dodecahedron.ply", info); vcl::PolyMesh pm = vcl::createHexahedron(); - vcl::savePly(pm, VCL_TEST_RESULTS_PATH "/hexahedron_poly.ply", info); + vcl::savePly(pm, VCLIB_TEST_RESULTS_PATH "/hexahedron_poly.ply", info); pm = vcl::createDodecahedron(); - vcl::savePly(pm, VCL_TEST_RESULTS_PATH "/dodecahedron_poly.ply", info); + vcl::savePly(pm, VCLIB_TEST_RESULTS_PATH "/dodecahedron_poly.ply", info); pm = vcl::createCube(vcl::Point3d(0, 0, 0), 4); - vcl::savePly(pm, VCL_TEST_RESULTS_PATH "/cube_poly.ply", info); + vcl::savePly(pm, VCLIB_TEST_RESULTS_PATH "/cube_poly.ply", info); vcl::Sphere st(vcl::Point3(), 1.0); m = vcl::createSphereSpherifiedCube(st, 50); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/sphere_tri.ply"); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/sphere_tri.ply"); vcl::Sphere sp = st.cast(); pm = vcl::createSphereSpherifiedCube(sp, 50); - vcl::savePly(pm, VCL_TEST_RESULTS_PATH "/sphere_poly.ply"); + vcl::savePly(pm, VCLIB_TEST_RESULTS_PATH "/sphere_poly.ply"); m = vcl::createSphereIcosahedron(st, 5); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/sphere_ico.ply"); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/sphere_ico.ply"); return 0; } diff --git a/test/examples/mesh_custom_components/CMakeLists.txt b/test/examples/mesh_custom_components/CMakeLists.txt index 2981411a4..8c62239ca 100644 --- a/test/examples/mesh_custom_components/CMakeLists.txt +++ b/test/examples/mesh_custom_components/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-custom-components ${SOURCES}) -target_link_libraries(vclib-mesh-custom-components PUBLIC vclib) +target_link_libraries(vclib-mesh-custom-components PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_custom_components/main.cpp b/test/examples/mesh_custom_components/main.cpp index 228b64a37..d01af8fa4 100644 --- a/test/examples/mesh_custom_components/main.cpp +++ b/test/examples/mesh_custom_components/main.cpp @@ -30,7 +30,7 @@ int main() { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/bone.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bone.ply"); m.addPerVertexCustomComponent("flag"); diff --git a/test/examples/mesh_export_to_matrix/CMakeLists.txt b/test/examples/mesh_export_to_matrix/CMakeLists.txt index 639b8a7e5..b5a2702e7 100644 --- a/test/examples/mesh_export_to_matrix/CMakeLists.txt +++ b/test/examples/mesh_export_to_matrix/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-export-to-matrix ${SOURCES}) -target_link_libraries(vclib-mesh-export-to-matrix PUBLIC vclib) +target_link_libraries(vclib-mesh-export-to-matrix PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_export_to_matrix/main.cpp b/test/examples/mesh_export_to_matrix/main.cpp index f6dbef78e..270f4b6ea 100644 --- a/test/examples/mesh_export_to_matrix/main.cpp +++ b/test/examples/mesh_export_to_matrix/main.cpp @@ -31,7 +31,7 @@ int main() { vcl::TriMesh tm = - vcl::load(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::load(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); Eigen::MatrixXd v = vcl::vertexMatrix(tm); Eigen::MatrixXi f = vcl::faceMatrix(tm); @@ -41,7 +41,7 @@ int main() std::cerr << "Faces:\n" << f << "\n\n"; vcl::PolyMesh pm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_poly.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); vcl::Array2 va = vcl::vertexMatrix>(pm); vcl::Array2 fa = vcl::faceMatrix>(pm); diff --git a/test/examples/mesh_io_obj/CMakeLists.txt b/test/examples/mesh_io_obj/CMakeLists.txt index 84aa9b47a..f6aeae64c 100644 --- a/test/examples/mesh_io_obj/CMakeLists.txt +++ b/test/examples/mesh_io_obj/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-io-obj ${SOURCES}) -target_link_libraries(vclib-mesh-io-obj PUBLIC vclib) +target_link_libraries(vclib-mesh-io-obj PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_io_obj/main.cpp b/test/examples/mesh_io_obj/main.cpp index 991e8cc1d..5fb40a9a4 100644 --- a/test/examples/mesh_io_obj/main.cpp +++ b/test/examples/mesh_io_obj/main.cpp @@ -30,7 +30,7 @@ int main() { vcl::MeshInfo loadedInfo; vcl::TriMesh m = vcl::loadObj( - VCL_TEST_MODELS_PATH "/TextureDouble.obj", loadedInfo); + VCLIB_TEST_MODELS_PATH "/TextureDouble.obj", loadedInfo); return 0; } diff --git a/test/examples/mesh_io_off/CMakeLists.txt b/test/examples/mesh_io_off/CMakeLists.txt index 5f31a5818..98ae45405 100644 --- a/test/examples/mesh_io_off/CMakeLists.txt +++ b/test/examples/mesh_io_off/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-io-off ${SOURCES}) -target_link_libraries(vclib-mesh-io-off PUBLIC vclib) +target_link_libraries(vclib-mesh-io-off PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_io_off/main.cpp b/test/examples/mesh_io_off/main.cpp index a510a1d88..c3c892d74 100644 --- a/test/examples/mesh_io_off/main.cpp +++ b/test/examples/mesh_io_off/main.cpp @@ -30,7 +30,7 @@ int main() { vcl::MeshInfo loadedInfo; vcl::TriMesh m = vcl::loadOff( - VCL_TEST_MODELS_PATH "/bone.off", loadedInfo); + VCLIB_TEST_MODELS_PATH "/bone.off", loadedInfo); assert(loadedInfo.hasVertices()); assert(m.vertexNumber() == 1872); @@ -40,7 +40,7 @@ int main() assert(loadedInfo.hasFaceColors()); m = vcl::loadOff( - VCL_TEST_MODELS_PATH "/trim-star.off", loadedInfo); + VCLIB_TEST_MODELS_PATH "/trim-star.off", loadedInfo); assert(loadedInfo.hasVertices()); assert(m.vertexNumber() == 5192); diff --git a/test/examples/mesh_io_ply/CMakeLists.txt b/test/examples/mesh_io_ply/CMakeLists.txt index 284642a1e..e70f70a4d 100644 --- a/test/examples/mesh_io_ply/CMakeLists.txt +++ b/test/examples/mesh_io_ply/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-io-ply ${SOURCES}) -target_link_libraries(vclib-mesh-io-ply PUBLIC vclib) +target_link_libraries(vclib-mesh-io-ply PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_io_ply/main.cpp b/test/examples/mesh_io_ply/main.cpp index 27bc83ab8..3c8fef0eb 100644 --- a/test/examples/mesh_io_ply/main.cpp +++ b/test/examples/mesh_io_ply/main.cpp @@ -32,7 +32,7 @@ int main() { vcl::MeshInfo loadedInfo; vcl::TriMesh m = vcl::loadPly( - VCL_TEST_MODELS_PATH "/brain.ply", loadedInfo); + VCLIB_TEST_MODELS_PATH "/brain.ply", loadedInfo); assert(loadedInfo.hasVertices()); assert(m.vertexNumber() == 18844); @@ -41,7 +41,7 @@ int main() assert(m.faceNumber() == 36752); m = vcl::loadPly( - VCL_TEST_MODELS_PATH "/bunny_textured.ply", loadedInfo); + VCLIB_TEST_MODELS_PATH "/bunny_textured.ply", loadedInfo); assert(loadedInfo.hasVertices()); assert(m.vertexNumber() == 5051); @@ -55,7 +55,7 @@ int main() assert(!vcl::isPerFaceAdjacentFacesAvailable(m)); m = vcl::loadPly( - VCL_TEST_MODELS_PATH "/TextureDouble.ply", loadedInfo); + VCLIB_TEST_MODELS_PATH "/TextureDouble.ply", loadedInfo); assert(loadedInfo.hasVertices()); assert(m.vertexNumber() == 8); @@ -67,7 +67,7 @@ int main() // try to load a polygonal mesh into a trimesh m = vcl::loadPly( - VCL_TEST_MODELS_PATH "/cube_poly.ply", loadedInfo); + VCLIB_TEST_MODELS_PATH "/cube_poly.ply", loadedInfo); for (const vcl::TriMesh::Face& f : m.faces()) { assert(!f.edgeFaux(0)); assert(!f.edgeFaux(1)); @@ -86,12 +86,12 @@ int main() // save again the mesh vcl::savePly( m, - VCL_TEST_RESULTS_PATH "/triangulated_cube.ply", + VCLIB_TEST_RESULTS_PATH "/triangulated_cube.ply", vcl::nullLogger, false); vcl::TriMesh mm = vcl::loadPly( - VCL_TEST_RESULTS_PATH "/triangulated_cube.ply", loadedInfo); + VCLIB_TEST_RESULTS_PATH "/triangulated_cube.ply", loadedInfo); assert(loadedInfo.hasFaceCustomComponents()); std::cerr << "Loaded custom component areas: \n"; diff --git a/test/examples/mesh_io_stl/CMakeLists.txt b/test/examples/mesh_io_stl/CMakeLists.txt index d3ca583fa..c8146f99e 100644 --- a/test/examples/mesh_io_stl/CMakeLists.txt +++ b/test/examples/mesh_io_stl/CMakeLists.txt @@ -11,9 +11,12 @@ project(vclib-mesh-io-stl) +set(HEADERS + load_bimba_and_bunny.h) + set(SOURCES main.cpp) -add_executable(vclib-mesh-io-stl ${SOURCES}) +add_executable(vclib-mesh-io-stl ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-mesh-io-stl PUBLIC vclib) +target_link_libraries(vclib-mesh-io-stl PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_io_stl/load_bimba_and_bunny.h b/test/examples/mesh_io_stl/load_bimba_and_bunny.h new file mode 100644 index 000000000..f5a1fddd0 --- /dev/null +++ b/test/examples/mesh_io_stl/load_bimba_and_bunny.h @@ -0,0 +1,22 @@ +#ifndef LOAD_BIMBA_AND_BUNNY_H +#define LOAD_BIMBA_AND_BUNNY_H + +#include +#include +#include + +void loadBimbaAndBunnyMeshes(vcl::TriMesh& m1, vcl::TriMesh& m2) +{ + vcl::ConsoleLogger log; + vcl::MeshInfo loadedInfo; + + log.startTimer(); + m1 = vcl::load( + VCLIB_TEST_MODELS_PATH "/bimba_bin.stl", loadedInfo, log); + + log.startTimer(); + m2 = vcl::load( + VCLIB_TEST_MODELS_PATH "/bunny_simplified.stl", loadedInfo, log); +} + +#endif // LOAD_BIMBA_AND_BUNNY_H diff --git a/test/examples/mesh_io_stl/main.cpp b/test/examples/mesh_io_stl/main.cpp index 2950607c0..492a6832f 100644 --- a/test/examples/mesh_io_stl/main.cpp +++ b/test/examples/mesh_io_stl/main.cpp @@ -23,57 +23,14 @@ #include -#include -#include -#include +#include "load_bimba_and_bunny.h" -#ifdef VCLIB_WITH_QGLVIEWER -#include - -#include -#include -#endif - -int main(int argc, char** argv) +int main() { - vcl::ConsoleLogger log; - vcl::MeshInfo loadedInfo; - - log.startTimer(); - vcl::TriMesh m1 = vcl::load( - VCL_TEST_MODELS_PATH "/bimba_bin.stl", loadedInfo, log); - m1.enablePerVertexColor(); - vcl::updateBoundingBox(m1); - vcl::updatePerVertexNormals(m1); - vcl::setPerVertexColor(m1, vcl::Color::DarkMagenta); - - log.startTimer(); - vcl::TriMesh m2 = vcl::load( - VCL_TEST_MODELS_PATH "/bunny_simplified.stl", loadedInfo, log); - m2.enablePerVertexColor(); - vcl::updateBoundingBox(m2); - vcl::updatePerVertexNormals(m2); - vcl::setPerVertexColor(m2, vcl::Color::DarkMagenta); + vcl::TriMesh m1, m2; -#ifdef VCLIB_WITH_QGLVIEWER - QApplication application(argc, argv); + loadBimbaAndBunnyMeshes(m1, m2); - vcl::qgl::ViewerMainWindow viewer; - vcl::gl2::DrawableMesh dm1(m1); - vcl::gl2::DrawableMesh dm2(m2); - - std::shared_ptr vector = - std::make_shared(); - vector->pushBack(dm1); - vector->pushBack(dm2); - viewer.setDrawableObjectVector(vector); - - viewer.show(); - - return application.exec(); -#else - (void) argc; // unused - (void) argv; return 0; -#endif + } diff --git a/test/examples/mesh_iterators/CMakeLists.txt b/test/examples/mesh_iterators/CMakeLists.txt index fd2cdb423..085223c9d 100644 --- a/test/examples/mesh_iterators/CMakeLists.txt +++ b/test/examples/mesh_iterators/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-iterators ${SOURCES}) -target_link_libraries(vclib-mesh-iterators PUBLIC vclib) +target_link_libraries(vclib-mesh-iterators PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_iterators/main.cpp b/test/examples/mesh_iterators/main.cpp index d53b0b86b..40ca906bb 100644 --- a/test/examples/mesh_iterators/main.cpp +++ b/test/examples/mesh_iterators/main.cpp @@ -32,7 +32,7 @@ int main() { vcl::TriMesh m = - vcl::load(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::load(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); m.enablePerFaceAdjacentFaces(); vcl::updatePerFaceAdjacentFaces(m); diff --git a/test/examples/mesh_new_user_component/CMakeLists.txt b/test/examples/mesh_new_user_component/CMakeLists.txt index 7d9343865..9a55898fe 100644 --- a/test/examples/mesh_new_user_component/CMakeLists.txt +++ b/test/examples/mesh_new_user_component/CMakeLists.txt @@ -21,4 +21,4 @@ set(SOURCES add_executable(vclib-mesh-new-user-component ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-mesh-new-user-component PUBLIC vclib) +target_link_libraries(vclib-mesh-new-user-component PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_normal/CMakeLists.txt b/test/examples/mesh_normal/CMakeLists.txt index 8b32b8a7c..de5b6f2a1 100644 --- a/test/examples/mesh_normal/CMakeLists.txt +++ b/test/examples/mesh_normal/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-normal ${SOURCES}) -target_link_libraries(vclib-mesh-normal PUBLIC vclib) +target_link_libraries(vclib-mesh-normal PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_normal/main.cpp b/test/examples/mesh_normal/main.cpp index 7bfd61650..ff546d581 100644 --- a/test/examples/mesh_normal/main.cpp +++ b/test/examples/mesh_normal/main.cpp @@ -120,7 +120,7 @@ int main() { vcl::TriMesh tm; - vcl::loadPly(tm, VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(tm, VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); std::cerr << "========= TriMesh =========\n\n"; @@ -128,7 +128,7 @@ int main() vcl::PolyMesh pm; - vcl::loadPly(pm, VCL_TEST_MODELS_PATH "/cube_poly.ply"); + vcl::loadPly(pm, VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); std::cerr << "========= PolyMesh =========\n\n"; diff --git a/test/examples/mesh_principal_curvature/CMakeLists.txt b/test/examples/mesh_principal_curvature/CMakeLists.txt index 6c48aabab..545085265 100644 --- a/test/examples/mesh_principal_curvature/CMakeLists.txt +++ b/test/examples/mesh_principal_curvature/CMakeLists.txt @@ -11,9 +11,12 @@ project(vclib-mesh-principal-curvature) +set(HEADERS + mesh_curvature.h) + set(SOURCES main.cpp) -add_executable(vclib-mesh-principal-curvature ${SOURCES}) +add_executable(vclib-mesh-principal-curvature ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-mesh-principal-curvature PUBLIC vclib) +target_link_libraries(vclib-mesh-principal-curvature PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_principal_curvature/main.cpp b/test/examples/mesh_principal_curvature/main.cpp index 22e36955f..2c6714e92 100644 --- a/test/examples/mesh_principal_curvature/main.cpp +++ b/test/examples/mesh_principal_curvature/main.cpp @@ -21,75 +21,17 @@ * for more details. * ****************************************************************************/ -#include +#include "mesh_curvature.h" -#include -#include -#include -#include - -#ifdef VCLIB_WITH_QGLVIEWER -#include - -#include -#include -#endif - -int main(int argc, char** argv) +int main() { - vcl::ConsoleLogger log; - log.setPrintTimer(true); - vcl::TriMesh m = - vcl::loadObj(VCL_TEST_MODELS_PATH "/bimba.obj"); - - m.enablePerVertexAdjacentFaces(); - m.enablePerFaceAdjacentFaces(); - m.enablePerVertexPrincipalCurvature(); - m.enablePerVertexColor(); - m.enablePerVertexQuality(); - - vcl::updatePerFaceNormals(m); - vcl::updatePerFaceAdjacentFaces(m); - vcl::updatePerVertexAdjacentFaces(m); - - double radius = vcl::boundingBox(m).diagonal() * 0.1; - log.startTimer(); - vcl::updatePrincipalCurvaturePCA(m, radius, true, log); - - vcl::setPerVertexQualityFromPrincipalCurvatureMean(m); - vcl::Histogramd h = vcl::vertexQualityHistogram(m); + vcl::loadObj(VCLIB_TEST_MODELS_PATH "/bimba.obj"); - vcl::setPerVertexColorFromQuality( - m, vcl::Color::RedBlue, h.percentile(0.1), h.percentile(0.9)); + updateCurvature(m); - std::cout << "Curvature range: " << h.minRangeValue() << " " - << h.maxRangeValue() << "\n"; - std::cout << "Used 90 percentile: " << h.percentile(0.1) << " " - << h.percentile(0.9) << "\n"; + vcl::saveStl(m, VCLIB_TEST_RESULTS_PATH "/bimba_curvature.stl"); - m.enablePerFaceColor(); - vcl::setPerFaceColorFromVertexColor(m); - - vcl::saveStl(m, VCL_TEST_RESULTS_PATH "/bimba_curvature.stl"); - -#ifdef VCLIB_WITH_QGLVIEWER - QApplication application(argc, argv); - - vcl::qgl::ViewerMainWindow viewer; - vcl::gl2::DrawableMesh dm(m); - - std::shared_ptr vector = - std::make_shared(); - vector->pushBack(dm); - viewer.setDrawableObjectVector(vector); - - viewer.show(); - - return application.exec(); -#else - (void) argc; // unused - (void) argv; return 0; -#endif + } diff --git a/test/examples/mesh_generate/main.cpp b/test/examples/mesh_principal_curvature/mesh_curvature.h similarity index 59% rename from test/examples/mesh_generate/main.cpp rename to test/examples/mesh_principal_curvature/mesh_curvature.h index 8f968ca6f..fde400120 100644 --- a/test/examples/mesh_generate/main.cpp +++ b/test/examples/mesh_principal_curvature/mesh_curvature.h @@ -21,58 +21,49 @@ * for more details. * ****************************************************************************/ +#ifndef MESH_CURVATURE_H +#define MESH_CURVATURE_H + #include #include #include #include +#include -#ifdef VCLIB_WITH_QGLVIEWER -#include - -#include -#include -#endif -int main(int argc, char** argv) +void updateCurvature(vcl::TriMesh& m) { - vcl::TriMesh m = - vcl::loadObj(VCL_TEST_MODELS_PATH "/bimba.obj"); + vcl::ConsoleLogger log; + log.setPrintTimer(true); + + m.enablePerVertexAdjacentFaces(); + m.enablePerFaceAdjacentFaces(); + m.enablePerVertexPrincipalCurvature(); m.enablePerVertexColor(); + m.enablePerVertexQuality(); - using ScalarType = vcl::TriMesh::ScalarType; vcl::updatePerFaceNormals(m); - vcl::updatePerVertexNormals(m); - vcl::setPerVertexColor(m, vcl::Color::Gray); + vcl::updatePerFaceAdjacentFaces(m); + vcl::updatePerVertexAdjacentFaces(m); - vcl::Sphere s({0, 0, 0}, 0.3); - vcl::TriMesh m1 = vcl::meshSphereIntersection(m, s); + double radius = vcl::boundingBox(m).diagonal() * 0.1; + log.startTimer(); + vcl::updatePrincipalCurvaturePCA(m, radius, true, log); - vcl::TriMesh sm = vcl::createSphere(s); - sm.enablePerVertexColor(); - vcl::updatePerFaceNormals(sm); - vcl::updatePerVertexNormals(sm); - vcl::setPerVertexColor(sm, vcl::Color::Gray); + vcl::setPerVertexQualityFromPrincipalCurvatureMean(m); + vcl::Histogramd h = vcl::vertexQualityHistogram(m); -#ifdef VCLIB_WITH_QGLVIEWER - QApplication application(argc, argv); + vcl::setPerVertexColorFromQuality( + m, vcl::Color::RedBlue, h.percentile(0.1), h.percentile(0.9)); - vcl::qgl::ViewerMainWindow viewer; - vcl::gl2::DrawableMesh dm(m1); - vcl::gl2::DrawableMesh sdm(sm); + std::cout << "Curvature range: " << h.minRangeValue() << " " + << h.maxRangeValue() << "\n"; + std::cout << "Used 90 percentile: " << h.percentile(0.1) << " " + << h.percentile(0.9) << "\n"; - std::shared_ptr vector = - std::make_shared(); - vector->pushBack(dm); - vector->pushBack(sdm); - viewer.setDrawableObjectVector(vector); - - viewer.show(); - - return application.exec(); -#else - (void) argc; // unused - (void) argv; - return 0; -#endif + m.enablePerFaceColor(); + vcl::setPerFaceColorFromVertexColor(m); } + +#endif // MESH_CURVATURE_H diff --git a/test/examples/mesh_sampling/CMakeLists.txt b/test/examples/mesh_sampling/CMakeLists.txt index 0563a882c..bd93525a9 100644 --- a/test/examples/mesh_sampling/CMakeLists.txt +++ b/test/examples/mesh_sampling/CMakeLists.txt @@ -11,9 +11,12 @@ project(vclib-mesh-sampling) +set(HEADERS + montecarlo_sampling.h) + set(SOURCES main.cpp) -add_executable(vclib-mesh-sampling ${SOURCES}) +add_executable(vclib-mesh-sampling ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-mesh-sampling PUBLIC vclib) +target_link_libraries(vclib-mesh-sampling PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_sampling/main.cpp b/test/examples/mesh_sampling/main.cpp index d6a57e06e..e4f76f41c 100644 --- a/test/examples/mesh_sampling/main.cpp +++ b/test/examples/mesh_sampling/main.cpp @@ -23,63 +23,18 @@ #include -#include - #include -#include - -#ifdef VCLIB_WITH_QGLVIEWER -#include -#include -#include -#endif +#include "montecarlo_sampling.h" int main(int argc, char** argv) { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/bunny_textured.ply"); - m.enablePerVertexColor(); - vcl::updatePerFaceNormals(m); - vcl::updatePerVertexNormals(m); - vcl::setPerVertexColor(m, vcl::Color::LightBlue); - m.enablePerFaceColor(); - vcl::setPerFaceColor(m, vcl::Color::LightBlue); - - uint nSamples = 50; - - vcl::MeshSampler s = - vcl::montecarloPointSampling>( - m, nSamples); - - vcl::TriMesh samples = s.samples(); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bunny_textured.ply"); - for (const vcl::TriMesh::Vertex& v : samples.vertices()) { - m.face(v.customComponent("birthFace")).color() = - vcl::Color::LightRed; - } + vcl::TriMesh samples; -#ifdef VCLIB_WITH_QGLVIEWER - QApplication application(argc, argv); - - vcl::qgl::ViewerMainWindow viewer; - vcl::gl2::DrawableMesh dm(m); - vcl::gl2::DrawableMesh sm(samples); - - std::shared_ptr vector = - std::make_shared(); - vector->pushBack(dm); - vector->pushBack(sm); - viewer.setDrawableObjectVector(vector); - - viewer.show(); - - return application.exec(); -#else - (void) argc; // unused - (void) argv; - return 0; -#endif + montecarloSampling(m, samples); return 0; } diff --git a/include/vclib/ext/qt/gui/drawable_object_frame.cpp b/test/examples/mesh_sampling/montecarlo_sampling.h similarity index 73% rename from include/vclib/ext/qt/gui/drawable_object_frame.cpp rename to test/examples/mesh_sampling/montecarlo_sampling.h index eaad052e3..7ae449066 100644 --- a/include/vclib/ext/qt/gui/drawable_object_frame.cpp +++ b/test/examples/mesh_sampling/montecarlo_sampling.h @@ -21,29 +21,21 @@ * for more details. * ****************************************************************************/ -#include "drawable_object_frame.h" -#include "ui_drawable_object_frame.h" +#ifndef MONTECARLO_SAMPLING_H +#define MONTECARLO_SAMPLING_H -namespace vcl::qt { +#include +#include -DrawableObjectFrame::DrawableObjectFrame(DrawableObject* obj, QWidget* parent) : - QFrame(parent), ui(new Ui::DrawableObjectFrame), obj(obj) +void montecarloSampling(const vcl::TriMesh& m, vcl::TriMesh& samples) { - ui->setupUi(this); - assert(obj); - ui->objNameLabel->setText(QString::fromStdString(obj->name())); - ui->visibilityCheckBox->setChecked(obj->isVisible()); -} + uint nSamples = 50; -DrawableObjectFrame::~DrawableObjectFrame() -{ - delete ui; -} + vcl::MeshSampler s = + vcl::montecarloPointSampling>( + m, nSamples); -void DrawableObjectFrame::on_visibilityCheckBox_stateChanged(int arg1) -{ - obj->setVisibility(arg1 == Qt::Checked); - emit visibilityChanged(); + samples = s.samples(); } -} // namespace vcl::qt +#endif // MONTECARLO_SAMPLING_H diff --git a/test/examples/mesh_smooth/CMakeLists.txt b/test/examples/mesh_smooth/CMakeLists.txt index 23cce0b51..ec6d4ebd0 100644 --- a/test/examples/mesh_smooth/CMakeLists.txt +++ b/test/examples/mesh_smooth/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-smooth ${SOURCES}) -target_link_libraries(vclib-mesh-smooth PUBLIC vclib) +target_link_libraries(vclib-mesh-smooth PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_smooth/main.cpp b/test/examples/mesh_smooth/main.cpp index b1ab6379a..bd38fa73a 100644 --- a/test/examples/mesh_smooth/main.cpp +++ b/test/examples/mesh_smooth/main.cpp @@ -31,7 +31,7 @@ int main() { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/bunny_textured.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bunny_textured.ply"); vcl::TriMesh mSmooth(m); @@ -40,14 +40,14 @@ int main() vcl::laplacianSmoothing(mSmooth, 30); t1.stopAndPrint(); - vcl::savePly(mSmooth, VCL_TEST_RESULTS_PATH "/bunny_lapl_smooth.ply"); + vcl::savePly(mSmooth, VCLIB_TEST_RESULTS_PATH "/bunny_lapl_smooth.ply"); vcl::Timer t2("Taubin Smoothing"); vcl::taubinSmoothing(m, 300, 0.5, -0.53); t2.stopAndPrint(); - vcl::savePly(m, VCL_TEST_RESULTS_PATH "/bunny_taub_smooth.ply"); + vcl::savePly(m, VCLIB_TEST_RESULTS_PATH "/bunny_taub_smooth.ply"); return 0; } diff --git a/test/examples/mesh_generate/CMakeLists.txt b/test/examples/mesh_sphere_intersection/CMakeLists.txt similarity index 77% rename from test/examples/mesh_generate/CMakeLists.txt rename to test/examples/mesh_sphere_intersection/CMakeLists.txt index 441d33de4..9a791918a 100644 --- a/test/examples/mesh_generate/CMakeLists.txt +++ b/test/examples/mesh_sphere_intersection/CMakeLists.txt @@ -9,11 +9,14 @@ #* All rights reserved. * #****************************************************************************/ -project(vclib-mesh-generate) +project(vclib-mesh-sphere-intersection) + +set(HEADERS + bimba_sphere_intersection.h) set(SOURCES main.cpp) -add_executable(vclib-mesh-generate ${SOURCES}) +add_executable(vclib-mesh-sphere-intersection ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-mesh-generate PUBLIC vclib) +target_link_libraries(vclib-mesh-sphere-intersection PUBLIC vclib vclib-test-common) diff --git a/include/vclib/ext/qt/gui/drawable_object_frame.h b/test/examples/mesh_sphere_intersection/bimba_sphere_intersection.h similarity index 71% rename from include/vclib/ext/qt/gui/drawable_object_frame.h rename to test/examples/mesh_sphere_intersection/bimba_sphere_intersection.h index 9d9950263..15c7a4b47 100644 --- a/include/vclib/ext/qt/gui/drawable_object_frame.h +++ b/test/examples/mesh_sphere_intersection/bimba_sphere_intersection.h @@ -21,40 +21,19 @@ * for more details. * ****************************************************************************/ -#ifndef VCL_EXT_QT_GUI_DRAWABLE_OBJECT_FRAME_H -#define VCL_EXT_QT_GUI_DRAWABLE_OBJECT_FRAME_H +#ifndef BIMBA_SPHERE_INTERSECTION_H +#define BIMBA_SPHERE_INTERSECTION_H -#include +#include +#include +#include -#include - -namespace vcl::qt { - -namespace Ui { -class DrawableObjectFrame; -} // namespace Ui - -class DrawableObjectFrame : public QFrame +vcl::TriMesh bimbaSphereIntersection(vcl::Sphere s = {{0, 0, 0}, 0.3}) { - Q_OBJECT - -public: - explicit DrawableObjectFrame( - DrawableObject* obj, - QWidget* parent = nullptr); - ~DrawableObjectFrame(); - -signals: - void visibilityChanged(); - -private slots: - void on_visibilityCheckBox_stateChanged(int arg1); - -private: - Ui::DrawableObjectFrame* ui; - DrawableObject* obj; -}; + vcl::TriMesh m = + vcl::loadObj(VCLIB_TEST_MODELS_PATH "/bimba.obj"); -} // namespace vcl::qt + return vcl::meshSphereIntersection(m, s); +} -#endif // VCL_EXT_QT_GUI_DRAWABLE_OBJECT_FRAME_H +#endif // BIMBA_SPHERE_INTERSECTION_H diff --git a/include/vclib/ext/qt/gui/q_clickable_label.cpp b/test/examples/mesh_sphere_intersection/main.cpp similarity index 86% rename from include/vclib/ext/qt/gui/q_clickable_label.cpp rename to test/examples/mesh_sphere_intersection/main.cpp index ab3e1bd4e..36035e66e 100644 --- a/include/vclib/ext/qt/gui/q_clickable_label.cpp +++ b/test/examples/mesh_sphere_intersection/main.cpp @@ -21,22 +21,13 @@ * for more details. * ****************************************************************************/ -#include "q_clickable_label.h" +#include "bimba_sphere_intersection.h" -namespace vcl::qt { - -QClickableLabel::QClickableLabel(QWidget* parent, Qt::WindowFlags) : - QLabel(parent) +int main() { -} + vcl::TriMesh m1 = bimbaSphereIntersection(); -QClickableLabel::~QClickableLabel() -{ -} + vcl::save(m1, VCLIB_TEST_RESULTS_PATH "/bimba_sphere_intersection.ply"); -void QClickableLabel::mousePressEvent(QMouseEvent*) -{ - emit clicked(); + return 0; } - -} // namespace vcl::qt diff --git a/test/examples/mesh_stat/CMakeLists.txt b/test/examples/mesh_stat/CMakeLists.txt index eab4d4c77..106df3dee 100644 --- a/test/examples/mesh_stat/CMakeLists.txt +++ b/test/examples/mesh_stat/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-stat ${SOURCES}) -target_link_libraries(vclib-mesh-stat PUBLIC vclib) +target_link_libraries(vclib-mesh-stat PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_stat/main.cpp b/test/examples/mesh_stat/main.cpp index fe3addc75..015ece8bf 100644 --- a/test/examples/mesh_stat/main.cpp +++ b/test/examples/mesh_stat/main.cpp @@ -30,7 +30,7 @@ int main() { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/bunny_textured.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bunny_textured.ply"); auto bar = vcl::barycenter(m); @@ -40,7 +40,7 @@ int main() std::cerr << "Shell Barycenter: " << bar << "\n"; - m = vcl::loadPly(VCL_TEST_MODELS_PATH "/bone.ply"); + m = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/bone.ply"); double vol = vcl::volume(m); diff --git a/test/examples/mesh_topology/CMakeLists.txt b/test/examples/mesh_topology/CMakeLists.txt index c14777c6e..1a7c7c34b 100644 --- a/test/examples/mesh_topology/CMakeLists.txt +++ b/test/examples/mesh_topology/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-topology ${SOURCES}) -target_link_libraries(vclib-mesh-topology PUBLIC vclib) +target_link_libraries(vclib-mesh-topology PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_topology/main.cpp b/test/examples/mesh_topology/main.cpp index 8892c6695..d2d8f6fec 100644 --- a/test/examples/mesh_topology/main.cpp +++ b/test/examples/mesh_topology/main.cpp @@ -31,7 +31,7 @@ int main() { vcl::TriMesh m; - vcl::loadPly(m, VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(m, VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); m.enablePerVertexAdjacentFaces(); vcl::updatePerVertexAdjacentFaces(m); diff --git a/test/examples/mesh_transform/CMakeLists.txt b/test/examples/mesh_transform/CMakeLists.txt index 2734ebd21..34c0183a1 100644 --- a/test/examples/mesh_transform/CMakeLists.txt +++ b/test/examples/mesh_transform/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-mesh-transform ${SOURCES}) -target_link_libraries(vclib-mesh-transform PUBLIC vclib) +target_link_libraries(vclib-mesh-transform PUBLIC vclib vclib-test-common) diff --git a/test/examples/mesh_transform/main.cpp b/test/examples/mesh_transform/main.cpp index 91978f13a..1b35a0d5a 100644 --- a/test/examples/mesh_transform/main.cpp +++ b/test/examples/mesh_transform/main.cpp @@ -31,7 +31,7 @@ int main() { vcl::TriMesh tm; - vcl::loadPly(tm, VCL_TEST_MODELS_PATH "/bunny_textured.ply"); + vcl::loadPly(tm, VCLIB_TEST_MODELS_PATH "/bunny_textured.ply"); vcl::TriMesh m = tm; @@ -41,7 +41,7 @@ int main() vcl::applyTransformMatrix(tm, m44); - vcl::savePly(tm, VCL_TEST_RESULTS_PATH "/rotated_bunny.ply"); + vcl::savePly(tm, VCLIB_TEST_RESULTS_PATH "/rotated_bunny.ply"); return 0; } diff --git a/test/examples/misc/CMakeLists.txt b/test/examples/misc/CMakeLists.txt index 5ecdd29d4..6019e03b3 100644 --- a/test/examples/misc/CMakeLists.txt +++ b/test/examples/misc/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-misc-example ${SOURCES}) -target_link_libraries(vclib-misc-example PUBLIC vclib) +target_link_libraries(vclib-misc-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/polygon_earcut/CMakeLists.txt b/test/examples/polygon_earcut/CMakeLists.txt index f2a3162f0..69157814a 100644 --- a/test/examples/polygon_earcut/CMakeLists.txt +++ b/test/examples/polygon_earcut/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-polygon-earcut-example ${SOURCES}) -target_link_libraries(vclib-polygon-earcut-example PUBLIC vclib) +target_link_libraries(vclib-polygon-earcut-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/polymesh_basic/CMakeLists.txt b/test/examples/polymesh_basic/CMakeLists.txt index 7b13a7cc3..d9038eaa4 100644 --- a/test/examples/polymesh_basic/CMakeLists.txt +++ b/test/examples/polymesh_basic/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES add_executable(vclib-polymesh-basic-example ${SOURCES}) -target_link_libraries(vclib-polymesh-basic-example PUBLIC vclib) +target_link_libraries(vclib-polymesh-basic-example PUBLIC vclib vclib-test-common) diff --git a/test/examples/static_asserts/CMakeLists.txt b/test/examples/static_asserts/CMakeLists.txt index 0129a0c6e..718012eb0 100644 --- a/test/examples/static_asserts/CMakeLists.txt +++ b/test/examples/static_asserts/CMakeLists.txt @@ -28,4 +28,4 @@ set(SOURCES add_executable(vclib-static-asserts ${HEADERS} ${SOURCES}) -target_link_libraries(vclib-static-asserts PUBLIC vclib) +target_link_libraries(vclib-static-asserts PUBLIC vclib vclib-test-common) diff --git a/test/tests/ext/vcg/mesh_import_vcg/CMakeLists.txt b/test/tests/ext/vcg/mesh_import_vcg/CMakeLists.txt index b3d045dcd..ab54f43d1 100644 --- a/test/tests/ext/vcg/mesh_import_vcg/CMakeLists.txt +++ b/test/tests/ext/vcg/mesh_import_vcg/CMakeLists.txt @@ -18,7 +18,7 @@ set(SOURCES add_executable(vclib-ext-mesh-import-from-vcg-test ${SOURCES}) -target_link_libraries(vclib-ext-mesh-import-from-vcg-test PUBLIC vclib) +target_link_libraries(vclib-ext-mesh-import-from-vcg-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-import-from-vcg COMMAND vclib-ext-mesh-import-from-vcg-test) diff --git a/test/tests/ext/vcg/mesh_import_vcg/main.cpp b/test/tests/ext/vcg/mesh_import_vcg/main.cpp index 3fb9503db..773b3a13e 100644 --- a/test/tests/ext/vcg/mesh_import_vcg/main.cpp +++ b/test/tests/ext/vcg/mesh_import_vcg/main.cpp @@ -35,7 +35,7 @@ TEST_CASE("Import TriMesh from VCG") VCGMesh vcgMesh; vcg::tri::io::ImporterPLY::Open( - vcgMesh, VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcgMesh, VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); REQUIRE(vcgMesh.VN() == 8); REQUIRE(vcgMesh.FN() == 12); @@ -60,7 +60,7 @@ TEST_CASE("Import PolyMesh from VCG") VCGMesh vcgMesh; vcg::tri::io::ImporterPLY::Open( - vcgMesh, VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcgMesh, VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); REQUIRE(vcgMesh.VN() == 8); REQUIRE(vcgMesh.FN() == 12); diff --git a/test/tests/kd_tree/CMakeLists.txt b/test/tests/kd_tree/CMakeLists.txt index 2b1cd2f0c..f54ab49b3 100644 --- a/test/tests/kd_tree/CMakeLists.txt +++ b/test/tests/kd_tree/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-kd-tree-test ${SOURCES}) -target_link_libraries(vclib-kd-tree-test PUBLIC vclib) +target_link_libraries(vclib-kd-tree-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME kd-tree COMMAND vclib-kd-tree-test) diff --git a/test/tests/kd_tree/main.cpp b/test/tests/kd_tree/main.cpp index 82c48add6..b3224fd8f 100644 --- a/test/tests/kd_tree/main.cpp +++ b/test/tests/kd_tree/main.cpp @@ -37,7 +37,7 @@ std::vector getKNearestNeighbors( std::string mesh = "bone.ply") { vcl::TriMesh m = - vcl::loadPly(VCL_TEST_MODELS_PATH "/" + mesh); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/" + mesh); vcl::KDTree tree(m); diff --git a/test/tests/mesh_clean/CMakeLists.txt b/test/tests/mesh_clean/CMakeLists.txt index b451ac1c5..b8f7ee4ef 100644 --- a/test/tests/mesh_clean/CMakeLists.txt +++ b/test/tests/mesh_clean/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-clean-test ${SOURCES}) -target_link_libraries(vclib-mesh-clean-test PUBLIC vclib) +target_link_libraries(vclib-mesh-clean-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-clean COMMAND vclib-mesh-clean-test) diff --git a/test/tests/mesh_clean/main.cpp b/test/tests/mesh_clean/main.cpp index 93c51c4e0..fdf2e76ca 100644 --- a/test/tests/mesh_clean/main.cpp +++ b/test/tests/mesh_clean/main.cpp @@ -141,7 +141,7 @@ TEST_CASE("WaterTightness") SECTION("A TriMesh that is not watertight") { vcl::TriMesh t = - vcl::load(VCL_TEST_MODELS_PATH "/brain.ply"); + vcl::load(VCLIB_TEST_MODELS_PATH "/brain.ply"); REQUIRE(t.vertexNumber() == 18844); REQUIRE(t.faceNumber() == 36752); @@ -152,7 +152,7 @@ TEST_CASE("WaterTightness") SECTION("A TriMesh that is watertight") { vcl::TriMesh t = - vcl::load(VCL_TEST_MODELS_PATH "/bone.ply"); + vcl::load(VCLIB_TEST_MODELS_PATH "/bone.ply"); REQUIRE(t.vertexNumber() == 1872); REQUIRE(t.faceNumber() == 3022); @@ -203,7 +203,7 @@ TEST_CASE("Unreferenced Vertices") TEST_CASE("Duplicated Vertices brain.ply") { - vcl::TriMesh t = vcl::load(VCL_TEST_MODELS_PATH "/brain.ply"); + vcl::TriMesh t = vcl::load(VCLIB_TEST_MODELS_PATH "/brain.ply"); uint nv = vcl::removeDuplicatedVertices(t); diff --git a/test/tests/mesh_conversions/CMakeLists.txt b/test/tests/mesh_conversions/CMakeLists.txt index b3e58269d..5c8f440bd 100644 --- a/test/tests/mesh_conversions/CMakeLists.txt +++ b/test/tests/mesh_conversions/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-conversions-test ${SOURCES}) -target_link_libraries(vclib-mesh-conversions-test PUBLIC vclib) +target_link_libraries(vclib-mesh-conversions-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-conversions COMMAND vclib-mesh-conversions-test) diff --git a/test/tests/mesh_conversions/main.cpp b/test/tests/mesh_conversions/main.cpp index f3a8d76dd..156d7a3c4 100644 --- a/test/tests/mesh_conversions/main.cpp +++ b/test/tests/mesh_conversions/main.cpp @@ -29,7 +29,7 @@ SCENARIO("Mesh Conversions") { GIVEN("The TextureDouble mesh loaded on TriMesh") { - vcl::TriMesh tm = vcl::loadPly(VCL_TEST_MODELS_PATH + vcl::TriMesh tm = vcl::loadPly(VCLIB_TEST_MODELS_PATH "/TextureDouble.ply"); tm.addCustomComponent("cust_comp", 4); @@ -103,7 +103,7 @@ SCENARIO("Mesh Conversions") GIVEN("The polygonal cube mesh loaded on TriMesh") { vcl::TriMesh tm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_poly.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); THEN("The loaded TriMesh has 8 vertices and 12 faces") { @@ -115,7 +115,7 @@ SCENARIO("Mesh Conversions") GIVEN("The polygonal cube mesh loaded on PolyMesh") { vcl::PolyMesh pm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_poly.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); THEN("The loaded PolyMesh has 8 vertices and 6 faces") { diff --git a/test/tests/mesh_custom_components/CMakeLists.txt b/test/tests/mesh_custom_components/CMakeLists.txt index 8a8ce8e45..b052ccc5c 100644 --- a/test/tests/mesh_custom_components/CMakeLists.txt +++ b/test/tests/mesh_custom_components/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-custom-components-test ${SOURCES}) -target_link_libraries(vclib-mesh-custom-components-test PUBLIC vclib) +target_link_libraries(vclib-mesh-custom-components-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-custom-components COMMAND vclib-mesh-custom-components-test) diff --git a/test/tests/mesh_filter/CMakeLists.txt b/test/tests/mesh_filter/CMakeLists.txt index 65424292f..a5aaed7c3 100644 --- a/test/tests/mesh_filter/CMakeLists.txt +++ b/test/tests/mesh_filter/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-filter-test ${SOURCES}) -target_link_libraries(vclib-mesh-filter-test PUBLIC vclib) +target_link_libraries(vclib-mesh-filter-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-filter COMMAND vclib-mesh-filter-test) diff --git a/test/tests/mesh_filter/main.cpp b/test/tests/mesh_filter/main.cpp index d0d803689..d05f118b4 100644 --- a/test/tests/mesh_filter/main.cpp +++ b/test/tests/mesh_filter/main.cpp @@ -29,7 +29,7 @@ TEST_CASE("TriMesh Filter") { vcl::TriMesh tm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); THEN("The mesh has 8 vertices, 12 triangles") { diff --git a/test/tests/mesh_new_user_component/CMakeLists.txt b/test/tests/mesh_new_user_component/CMakeLists.txt index 217a2f99a..80685d706 100644 --- a/test/tests/mesh_new_user_component/CMakeLists.txt +++ b/test/tests/mesh_new_user_component/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-new-user-component-test ${SOURCES}) -target_link_libraries(vclib-mesh-new-user-component-test PUBLIC vclib) +target_link_libraries(vclib-mesh-new-user-component-test PUBLIC vclib vclib-test-common) target_include_directories(vclib-mesh-new-user-component-test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../examples/mesh_new_user_component) diff --git a/test/tests/mesh_topology/CMakeLists.txt b/test/tests/mesh_topology/CMakeLists.txt index b289c160f..92e1d9ec2 100644 --- a/test/tests/mesh_topology/CMakeLists.txt +++ b/test/tests/mesh_topology/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-mesh-topology-test ${SOURCES}) -target_link_libraries(vclib-mesh-topology-test PUBLIC vclib) +target_link_libraries(vclib-mesh-topology-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME mesh-topology COMMAND vclib-mesh-topology-test) diff --git a/test/tests/mesh_topology/main.cpp b/test/tests/mesh_topology/main.cpp index b4b8ba2a7..71fa9fd40 100644 --- a/test/tests/mesh_topology/main.cpp +++ b/test/tests/mesh_topology/main.cpp @@ -29,7 +29,7 @@ TEST_CASE("TriMesh Topology") { vcl::TriMesh tm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); THEN("The mesh has 8 vertices, 12 triangles") { @@ -286,7 +286,7 @@ TEST_CASE("TriMesh Topology") TEST_CASE("PolyMesh Triangle Mesh Topology") { vcl::PolyMesh pm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_tri.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_tri.ply"); THEN("The mesh has 8 vertices, 12 triangles") { @@ -543,7 +543,7 @@ TEST_CASE("PolyMesh Triangle Mesh Topology") TEST_CASE("PolyMesh Polygon Mesh Topology") { vcl::PolyMesh pm = - vcl::loadPly(VCL_TEST_MODELS_PATH "/cube_poly.ply"); + vcl::loadPly(VCLIB_TEST_MODELS_PATH "/cube_poly.ply"); THEN("The mesh has 8 vertices, 6 faces") { diff --git a/test/tests/trimesh_base/CMakeLists.txt b/test/tests/trimesh_base/CMakeLists.txt index 52fb91800..b68ef4679 100644 --- a/test/tests/trimesh_base/CMakeLists.txt +++ b/test/tests/trimesh_base/CMakeLists.txt @@ -16,7 +16,7 @@ set(SOURCES add_executable(vclib-trimesh-base-test ${SOURCES}) -target_link_libraries(vclib-trimesh-base-test PUBLIC vclib) +target_link_libraries(vclib-trimesh-base-test PUBLIC vclib vclib-test-common) enable_testing() add_test(NAME trimesh-base COMMAND vclib-trimesh-base-test)