diff --git a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt b/Surface_mesher/demo/Surface_mesher/CMakeLists.txt deleted file mode 100644 index 96e3edb9472..00000000000 --- a/Surface_mesher/demo/Surface_mesher/CMakeLists.txt +++ /dev/null @@ -1,155 +0,0 @@ -set(prj Surface_mesher) - -cmake_minimum_required(VERSION 3.1...3.15) -project(Surface_mesher_Demo) - -if(NOT POLICY CMP0070 AND POLICY CMP0053) - # Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning. - cmake_policy(SET CMP0053 OLD) -endif() - -# Find includes in corresponding build directories -set(CMAKE_INCLUDE_CURRENT_DIR ON) -# Instruct CMake to run moc automatically when needed. -set(CMAKE_AUTOMOC ON) - -if(POLICY CMP0071) - cmake_policy(SET CMP0071 NEW) -endif() -if(POLICY CMP0072) - # About the use of OpenGL - cmake_policy(SET CMP0072 NEW) -endif() - -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() - -set(PACKAGE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) - -# Add several CGAL packages to the include and link paths, -# if they lie in ${PACKAGE_ROOT}/. - -foreach(LIB_DIR ${PACKAGE_ROOT}/../CGAL_ImageIO/src/CGAL_ImageIO - ${PACKAGE_ROOT}/../GraphicsView/src/CGALQt5) - if(EXISTS ${LIB_DIR}) - link_directories(${LIB_DIR}) - endif() -endforeach() - -include_directories(./) - -# QGLViewer needs Qt5 configured with QtOpenGL - -find_package(CGAL REQUIRED COMPONENTS ImageIO Qt5) -if(CGAL_Qt5_FOUND AND CGAL_ImageIO_FOUND) - - add_definitions(-DQT_NO_KEYWORDS) - - find_package(Qt5 QUIET COMPONENTS OpenGL Svg) - find_package(OpenGL) - - if(Qt5_FOUND - AND OPENGL_FOUND - AND OPENGL_GLU_FOUND) - - set(sources - Raw_image_dialog.cpp - colorlisteditor.cpp - values_list.cpp - mainwindow.cpp - Surface_mesher.cpp - viewer.cpp - volume.cpp) - - if(EXISTS ${PACKAGE_ROOT}/../Marching_cube) - option(SURFACE_MESH_DEMO_USE_MARCHING_CUBE - "Embed a marching cube implementation in the Surface Mesh demo." - ON) - mark_as_advanced(SURFACE_MESH_DEMO_USE_MARCHING_CUBE) - endif() - - if(EXISTS ${PACKAGE_ROOT}/include/CGAL/Polyhedral_surface_3.h) - option(SURFACE_MESH_DEMO_WITH_POLYHEDRAL_SURFACE - "Compile the support for polyhedral surfaces." OFF) - mark_as_advanced(SURFACE_MESH_DEMO_WITH_POLYHEDRAL_SURFACE) - endif() - - option( - SURFACE_MESH_DEMO_VERBOSE - "Set this option if you want the Surface Mesh demo to display messages on standard output." - OFF) - mark_as_advanced(SURFACE_MESH_DEMO_VERBOSE) - - if(SURFACE_MESH_DEMO_VERBOSE) - add_definitions(-DCGAL_SURFACE_MESHER_VERBOSE) - endif() - - if(SURFACE_MESH_DEMO_WITH_POLYHEDRAL_SURFACE) - set(sources ${sources} polyhedral_surface.cpp) - else(SURFACE_MESH_DEMO_WITH_POLYHEDRAL_SURFACE) - add_definitions(-DCGAL_DO_NOT_USE_POLYHEDRAL_SURFACE) - endif(SURFACE_MESH_DEMO_WITH_POLYHEDRAL_SURFACE) - - if(SURFACE_MESH_DEMO_USE_MARCHING_CUBE) - set(sources ${sources} ${PACKAGE_ROOT}/../Marching_cube/src/mc/ply.c) - add_definitions(-DCGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE) - endif() - - qt5_generate_moc("surface.h" "${CMAKE_CURRENT_BINARY_DIR}/moc_surface.cpp") - - set(sources ${sources} moc_surface.cpp) - - qt5_wrap_ui(uis ui/values_list.ui ui/mainwindow.ui ui/optionsdialog.ui - ui/raw_image.ui) - - qt5_add_resources(CGAL_Qt5_RESOURCE_FILES values_list.qrc - surface_mesher.qrc) - - add_executable(${prj} ${sources} ${uis} ${CGAL_Qt5_RESOURCE_FILES} - ${CGAL_Qt5_MOC_FILES}) - - add_to_cached_list(CGAL_EXECUTABLE_TARGETS ${prj}) - - find_package(VTK QUIET COMPONENTS vtkImagingGeneral vtkIOImage NO_MODULE) - if(VTK_FOUND) - if(VTK_USE_FILE) - include(${VTK_USE_FILE}) - endif() - if("${VTK_VERSION_MAJOR}" GREATER "5" OR VTK_VERSION VERSION_GREATER 5) - message(STATUS "VTK found") - add_definitions(-DCGAL_USE_VTK) - if(TARGET VTK::IOImage) - set(VTK_LIBRARIES VTK::IOImage VTK::ImagingGeneral) - endif() - else() - message(STATUS "Vtk must be at least Rel 6") - endif() - else() - message(STATUS "For reading Dicom files install VTK first") - endif() - - target_link_libraries( - ${prj} PRIVATE CGAL::CGAL CGAL::CGAL_Qt5 CGAL::CGAL_ImageIO - ${OPENGL_LIBRARIES} ${VTK_LIBRARIES}) - - include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) - cgal_add_compilation_test(${prj}) - - include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) - cgal_add_compilation_test(${prj}) - endif( - Qt5_FOUND - AND OPENGL_FOUND - AND OPENGL_GLU_FOUND) -else( - CGAL_Qt5_FOUND - AND CGAL_ImageIO_FOUND) - if(RUNNING_CGAL_AUTO_TEST) - # Just to avoid a warning from CMake if that variable is set on the command line... - endif() - - message(STATUS "NOTICE: This demo needs Qt5, and will not be compiled.") -endif( - CGAL_Qt5_FOUND - AND CGAL_ImageIO_FOUND) diff --git a/Surface_mesher/demo/Surface_mesher/File_XT.h b/Surface_mesher/demo/Surface_mesher/File_XT.h deleted file mode 100644 index 0b723bba749..00000000000 --- a/Surface_mesher/demo/Surface_mesher/File_XT.h +++ /dev/null @@ -1,211 +0,0 @@ -/********************************************************************* -* 25 - 02 - 97 -* gestion des fichiers image ELF -* -*********************************************************************/ - -#ifndef CGAL_FILE_XT_H -#define CGAL_FILE_XT_H - -#include -#include - -#include - -namespace CGAL { -namespace Total { -namespace internal { - -//To avoid "fopen may be unsafe" on Visual. -bool open_file(FILE **fin, const char* filename) -{ -#if defined(BOOST_MSVC) - return (fopen_s(fin, filename, "rw") == 0); -#else - *fin = fopen(filename, "rw"); - return (fin != NULL); -#endif -} - -} // namespace internal - -void permuteLong(char *a) -{ - char tmp; - -#ifdef CGAL_LITTLE_ENDIAN -tmp=a[0]; a[0]=a[3]; a[3]=tmp; -tmp=a[1]; a[1]=a[2]; a[2]=tmp; -#endif -} - -void permuteLongTab(long *a,int nb) -{ - int i; - -#ifdef CGAL_LITTLE_ENDIAN -for(i=0;isetNum((int)image_word_size() * - dim_x->value() * - dim_y->value() * - dim_z->value()); -} - -unsigned int Raw_image_dialog::image_word_size() const { - if(short_bt->isChecked()) - return 2; - if(int_bt->isChecked()) - return 4; - else if(float_bt->isChecked()) - return 4; - else if(double_bt->isChecked()) - return 8; - else - return 1; -} - diff --git a/Surface_mesher/demo/Surface_mesher/Raw_image_dialog.h b/Surface_mesher/demo/Surface_mesher/Raw_image_dialog.h deleted file mode 100644 index 7f191fecaf6..00000000000 --- a/Surface_mesher/demo/Surface_mesher/Raw_image_dialog.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RAW_IMAGE_DIALOG_H -#define RAW_IMAGE_DIALOG_H - -#include "ui_raw_image.h" - -class Raw_image_dialog : public QDialog, public Ui::Raw_image_dialog -{ - Q_OBJECT - -public: - Raw_image_dialog(QWidget* parent = 0); - - unsigned int image_word_size() const; - -private Q_SLOTS: - void update_image_size(); -}; - -#endif // RAW_IMAGE_DIALOG diff --git a/Surface_mesher/demo/Surface_mesher/Surface_mesher.cpp b/Surface_mesher/demo/Surface_mesher/Surface_mesher.cpp deleted file mode 100644 index b6c18695ab5..00000000000 --- a/Surface_mesher/demo/Surface_mesher/Surface_mesher.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "mainwindow.h" -#include -#include -#include - -int main(int argc, char** argv) -{ - QApplication application(argc,argv); - - application.setOrganizationDomain("geometryfactory.com"); - application.setOrganizationName("GeometryFactory"); - application.setApplicationName("Surface mesher Qt5 demo"); - - MainWindow w; - - if(argc>1) - w.surface_open(argv[1]); - - w.show(); - std::setlocale(LC_ALL, "C"); - return application.exec(); - std::cerr << "Exit\n"; -} diff --git a/Surface_mesher/demo/Surface_mesher/binary_image.h b/Surface_mesher/demo/Surface_mesher/binary_image.h deleted file mode 100644 index 591e6159744..00000000000 --- a/Surface_mesher/demo/Surface_mesher/binary_image.h +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright (c) 2005-2008 INRIA Sophia-Antipolis (France). -// Copyright (c) 2008 GeometryFactory (France) -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// Author(s) : Laurent RINEAU, Pierre ALLIEZ - -#ifndef BINARY_IMAGE_3 -#define BINARY_IMAGE_3 - -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -template -class CBinary_image_3 : public CGAL::Image_3 -{ - bool interpolate_; - bool labellized_; - -public: - double min_value; - double max_value; - - typedef FT_ FT; - -public: - CBinary_image_3() - : Image_3(), interpolate_(true) - { - } - - CBinary_image_3(const Image_3& bi) - : Image_3(bi), interpolate_(true) - { - } - - - CBinary_image_3(const CBinary_image_3& bi) - : Image_3(bi), interpolate_(bi.interpolate_),labellized_(bi.labellized_) - { - std::cerr << "CBinary_image_3::copy_constructor\n"; - min_value = bi.min_value; - max_value = bi.max_value; - } - - - void finish_open() { - CGAL_IMAGE_IO_CASE(image_ptr.get(), - Word *min; Word *max; - (boost::tie(min, max)) = - (CGAL::min_max_element((Word*)(data()), - (Word*)(data()) + - xdim() * ydim() * zdim())); - min_value = *min; - max_value = *max;) - } - - float xmax() const - { - return (float)(((image_ptr->xdim) - 1.0)*(image_ptr->vx)); - } - - float ymax() const - { - return (float)(((image_ptr->ydim) - 1.0)*(image_ptr->vy)); - } - - float zmax() const - { - return (float)(((image_ptr->zdim) - 1.0)*(image_ptr->vz)); - } - - Point center() - { - FT cx = 0.5 * xmax(); - FT cy = 0.5 * ymax(); - FT cz = 0.5 * zmax(); - return Point(cx,cy,cz); - } - - FT radius() - { - return (std::max)((std::max)(xmax(),ymax()),zmax()); - } - - Point point(const std::size_t i, - const std::size_t j, - const std::size_t k) const - { - return Point(i * (image_ptr->vx), - j * (image_ptr->vy), - k * (image_ptr->vz)); - } - -public: - bool inside(const float x, - const float y, - const float z) const - { - return ( x >= 0.0f && - y >= 0.0f && - z >= 0.0f && - x <= xmax() && - y <= ymax() && - z <= zmax() ); - } - - float rand_x() { return (float)rand() / (float)RAND_MAX * xmax(); } - float rand_y() { return (float)rand() / (float)RAND_MAX * ymax(); } - float rand_z() { return (float)rand() / (float)RAND_MAX * zmax(); } - - void set_interpolation(const bool b) - { - interpolate_ = b; - } - - bool interpolation() const { - return interpolate_; - } - - void set_labellized(const bool b) - { - labellized_ = b; - } - - bool labellized() const { - return labellized_; - } - - FT operator()(Point p) const - { - const float x = static_cast(CGAL::to_double(p.x())); - const float y = static_cast(CGAL::to_double(p.y())); - const float z = static_cast(CGAL::to_double(p.z())); - - if(interpolation()) { - if(labellized()) { - CGAL_IMAGE_IO_CASE(image_ptr.get(), - return (this->labellized_trilinear_interpolation(x, y, z, min_value));) - } - else { - CGAL_IMAGE_IO_CASE(image_ptr.get(), - return (this->trilinear_interpolation(x, y, z, min_value));) - } - } - else { - const std::ptrdiff_t i = static_cast(x/image()->vx + 0.5f); - const std::ptrdiff_t j = static_cast(y/image()->vy + 0.5f); - const std::ptrdiff_t k = static_cast(z/image()->vz + 0.5f); - if( i < 0 || - j < 0 || - k < 0 ) - { - return 0; - } - else - { - const std::size_t ui = static_cast(i); - const std::size_t uj = static_cast(j); - const std::size_t uk = static_cast(k); - if( ui >= image()->xdim || - uj >= image()->ydim || - uk >= image()->zdim ) - { - return 0; - } - else - { - return this->value(ui, uj, uk); - } - } - } - return FT(); - } -}; // end CBinary_image_3 - -#endif // BINARY_IMAGE_3 diff --git a/Surface_mesher/demo/Surface_mesher/colorlisteditor.cpp b/Surface_mesher/demo/Surface_mesher/colorlisteditor.cpp deleted file mode 100644 index 508b532c090..00000000000 --- a/Surface_mesher/demo/Surface_mesher/colorlisteditor.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2007-2007 Trolltech ASA. All rights reserved. -** -** This file is part of the example classes of the Qt Toolkit. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/ -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** In addition, as a special exception, Trolltech gives you certain -** additional rights. These rights are described in the Trolltech GPL -** Exception version 1.0, which can be found at -** http://www.trolltech.com/products/qt/gplexception/ and in the file -** GPL_EXCEPTION.txt in this package. -** -** In addition, as a special exception, Trolltech, as the sole copyright -** holder for Qt Designer, grants users of the Qt/Eclipse Integration -** plug-in the right for the Qt/Eclipse Integration to link to -** functionality provided by Qt Designer and its related libraries. -** -** Trolltech reserves all rights not expressly granted herein. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** SPDX-License-Identifier: LGPL-2.0-only -** -****************************************************************************/ - -#include - -#include "colorlisteditor.h" - -ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget) -{ - populateList(); -} - -QColor ColorListEditor::color() const -{ - return itemData(currentIndex(), Qt::DecorationRole).value(); -} - -void ColorListEditor::setColor(QColor color) -{ - setCurrentIndex(findData(color, int(Qt::DecorationRole))); -} - -void ColorListEditor::populateList() -{ - QStringList colorNames = QColor::colorNames(); - - for (int i = 0; i < colorNames.size(); ++i) { - QColor color(colorNames[i]); - - insertItem(i, colorNames[i]); - setItemData(i, color, Qt::DecorationRole); - } -} - diff --git a/Surface_mesher/demo/Surface_mesher/colorlisteditor.h b/Surface_mesher/demo/Surface_mesher/colorlisteditor.h deleted file mode 100644 index 4763d52b3b0..00000000000 --- a/Surface_mesher/demo/Surface_mesher/colorlisteditor.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2007-2007 Trolltech ASA. All rights reserved. -** -** This file is part of the example classes of the Qt Toolkit. -** -** This file may be used under the terms of the GNU General Public -** License version 2.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of -** this file. Please review the following information to ensure GNU -** General Public Licensing requirements will be met: -** http://trolltech.com/products/qt/licenses/licensing/opensource/ -** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://trolltech.com/products/qt/licenses/licensing/licensingoverview -** or contact the sales department at sales@trolltech.com. -** -** In addition, as a special exception, Trolltech gives you certain -** additional rights. These rights are described in the Trolltech GPL -** Exception version 1.0, which can be found at -** http://www.trolltech.com/products/qt/gplexception/ and in the file -** GPL_EXCEPTION.txt in this package. -** -** In addition, as a special exception, Trolltech, as the sole copyright -** holder for Qt Designer, grants users of the Qt/Eclipse Integration -** plug-in the right for the Qt/Eclipse Integration to link to -** functionality provided by Qt Designer and its related libraries. -** -** Trolltech reserves all rights not expressly granted herein. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** SPDX-License-Identifier: LGPL-2.0-only -** -****************************************************************************/ - -#ifndef COLORLISTEDITOR_H -#define COLORLISTEDITOR_H - -#include - -class QColor; -class QWidget; - -class ColorListEditor : public QComboBox -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor USER true) - -public: - ColorListEditor(QWidget *widget = 0); - -public: - QColor color() const; - void setColor(QColor c); - -private: - void populateList(); -}; - -#endif diff --git a/Surface_mesher/demo/Surface_mesher/get_polyhedral_surface.h b/Surface_mesher/demo/Surface_mesher/get_polyhedral_surface.h deleted file mode 100644 index 51ebed3272d..00000000000 --- a/Surface_mesher/demo/Surface_mesher/get_polyhedral_surface.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _GET_POLYHEDRAL_SURFACE_H -#define _GET_POLYHEDRAL_SURFACE_H - -#include "surface.h" - -Surface* get_polyhedral_surface(QObject*, double, double); - -#endif // _GET_POLYHEDRAL_SURFACE_H diff --git a/Surface_mesher/demo/Surface_mesher/icons/bbox-red.png b/Surface_mesher/demo/Surface_mesher/icons/bbox-red.png deleted file mode 100644 index 0da5c8fdde3..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/bbox-red.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/bbox-red.svg b/Surface_mesher/demo/Surface_mesher/icons/bbox-red.svg deleted file mode 100644 index 25be024f77e..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/bbox-red.svg +++ /dev/null @@ -1,209 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/icons/bbox.png b/Surface_mesher/demo/Surface_mesher/icons/bbox.png deleted file mode 100644 index 28c0d50c6b3..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/bbox.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/bbox.svg b/Surface_mesher/demo/Surface_mesher/icons/bbox.svg deleted file mode 100644 index e23b746c510..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/bbox.svg +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/icons/cgal_logo.xpm b/Surface_mesher/demo/Surface_mesher/icons/cgal_logo.xpm deleted file mode 100644 index 6a69b3d67e1..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/cgal_logo.xpm +++ /dev/null @@ -1,24 +0,0 @@ -/* XPM */ -const char * demoicon_xpm[] = { -/* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c None", -". c #FFFF00", -"+ c #000000", -/* pixels */ -"................", -"...++++...++++..", -"..+....+.+....+.", -"..+......+......", -"..+......+..+++.", -"..+......+....+.", -"..+....+.+....+.", -"...++++...++++..", -"................", -"...++++...+.....", -"..+....+..+.....", -"..+....+..+.....", -"..++++++..+.....", -"..+....+..+.....", -"..+....+..+++++.", -"................"}; diff --git a/Surface_mesher/demo/Surface_mesher/icons/fileopen.png b/Surface_mesher/demo/Surface_mesher/icons/fileopen.png deleted file mode 100644 index 82b79b7242b..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/fileopen.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/filesave.png b/Surface_mesher/demo/Surface_mesher/icons/filesave.png deleted file mode 100644 index 0c5a242bc58..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/filesave.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/flip.png b/Surface_mesher/demo/Surface_mesher/icons/flip.png deleted file mode 100644 index 3d28392a0f5..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/flip.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/flip.svg b/Surface_mesher/demo/Surface_mesher/icons/flip.svg deleted file mode 100644 index 293e82fc3a7..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/flip.svg +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - Go Next - - - go - next - right - arrow - pointer - > - - - - - - - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/icons/minus.png b/Surface_mesher/demo/Surface_mesher/icons/minus.png deleted file mode 100644 index d6f233d7399..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/minus.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/plus.png b/Surface_mesher/demo/Surface_mesher/icons/plus.png deleted file mode 100644 index 40df1134f84..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/plus.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/resize.png b/Surface_mesher/demo/Surface_mesher/icons/resize.png deleted file mode 100644 index b3d930f1d7b..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/resize.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/resize.svg b/Surface_mesher/demo/Surface_mesher/icons/resize.svg deleted file mode 100644 index ed30359a802..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/resize.svg +++ /dev/null @@ -1,297 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/icons/surface.png b/Surface_mesher/demo/Surface_mesher/icons/surface.png deleted file mode 100644 index e3585c5d816..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/surface.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/surface.svg b/Surface_mesher/demo/Surface_mesher/icons/surface.svg deleted file mode 100644 index b3ce5b253a7..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/surface.svg +++ /dev/null @@ -1,166 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/icons/twosides.png b/Surface_mesher/demo/Surface_mesher/icons/twosides.png deleted file mode 100644 index a2da1eb1b39..00000000000 Binary files a/Surface_mesher/demo/Surface_mesher/icons/twosides.png and /dev/null differ diff --git a/Surface_mesher/demo/Surface_mesher/icons/twosides.svg b/Surface_mesher/demo/Surface_mesher/icons/twosides.svg deleted file mode 100644 index e1effe1d026..00000000000 --- a/Surface_mesher/demo/Surface_mesher/icons/twosides.svg +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - Jakub Steiner - - - http://jimmac.musichall.cz - - Go Next - - - go - next - right - arrow - pointer - > - - - - - - - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/mainwindow.cpp b/Surface_mesher/demo/Surface_mesher/mainwindow.cpp deleted file mode 100644 index ebb1260a693..00000000000 --- a/Surface_mesher/demo/Surface_mesher/mainwindow.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "mainwindow.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include // std::max -#include // std::sqrt -#include - -#include "ui_mainwindow.h" -#include "volume.h" -#ifndef CGAL_DO_NOT_USE_POLYHEDRAL_SURFACE -# include "polyhedral_surface.h" -#endif - -MainWindow::MainWindow(MainWindow* other_window /* = 0 */) : - CGAL::Qt::DemosMainWindow(), - surface(0) -{ - setupUi(this); - setAcceptDrops(true); - - if(other_window != 0) - { - viewer->setCamera(other_window->viewer->camera()); - connect(other_window, SIGNAL(destroyed()), - this, SLOT(close())); - } - - this->addAboutCGAL(); - this->addRecentFiles(this->menu_File, - this->action_Quit); - connect(this, SIGNAL(openRecentFile(QString)), - this, SLOT(surface_open(QString))); - - this->readState(); - - show_only(""); -} - -void MainWindow::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("text/uri-list")) - event->acceptProposedAction(); -} - -void MainWindow::dropEvent(QDropEvent *event) -{ - QString filename = event->mimeData()->urls().at(0).toLocalFile(); - surface_open(filename); - event->acceptProposedAction(); -} - -void MainWindow::surface_open(const QString& filename) -{ - if(surface != 0) { - delete surface; - surface = 0; - } -#ifndef CGAL_DO_NOT_USE_POLYHEDRAL_SURFACE - surface = new Polyhedral_surface(this); - if(surface->open(filename)) { - this->addToRecentFiles(filename); - return; - } - delete surface; - surface = 0; -#endif - surface = new Volume(this); - if(surface->open(filename)) { - this->addToRecentFiles(filename); - } -} - -void MainWindow::show_only(QString tag) -{ -#if 0 - QTextStream err(stderr); -#else - QString dummy; - QTextStream err(&dummy); -#endif - err << "** Show only in \"" << tag << "\"\n"; - Q_FOREACH(QObject* object, - this->findChildren()) - { - QStringList show_only_in = object->property("show_only_in").toStringList(); - if(!show_only_in.isEmpty()) - { - err << object->metaObject()->className() - << " \"" << object->objectName() << "\" only in: "; - Q_FOREACH(QString s, show_only_in) - err << s << " "; - const bool visible = show_only_in.contains(tag); - err << (visible ? "(enabled)\n" : "(disabled)\n"); - if(QMenu* menu = qobject_cast(object)) { - menu->menuAction()->setVisible(visible); - } - else { - object->setProperty("visible", QVariant::fromValue(visible)); - } - } - } -} - -void MainWindow::on_action_Open_triggered() -{ - QSettings settings; - QString directory = settings.value("Open directory", - QDir::current().dirName()).toString(); - QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), - directory, - tr("all Files (*.*)")); - if(!filename.isEmpty()) { - QFileInfo fileinfo(filename); - if(fileinfo.isFile() && fileinfo.isReadable()) { - settings.setValue("Open directory", - fileinfo.absoluteDir().absolutePath()); - surface_open(filename); - } - } -} - -void MainWindow::on_action_OpenDirectory_triggered() -{ - QSettings settings; - QString start_dir = settings.value("Open directory", - QDir::current().dirName()).toString(); - QString dir = - QFileDialog::getExistingDirectory(this, - tr("Open directory"), - start_dir, - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - - if (!dir.isEmpty()) { - QFileInfo fileinfo(dir); - if (fileinfo.isDir() && fileinfo.isReadable()) - { - settings.setValue("Open directory", - fileinfo.absoluteDir().absolutePath()); - surface_open(dir); - } - } -} - -void MainWindow::on_action_Quit_triggered() -{ - this->writeState(); - qApp->exit(); -} - -void MainWindow::closeEvent(QCloseEvent *event) -{ - this->writeState(); - event->accept(); -} - -void MainWindow::on_action_Clone_triggered() -{ - MainWindow* other = new MainWindow(this); - other->show(); -} - diff --git a/Surface_mesher/demo/Surface_mesher/mainwindow.h b/Surface_mesher/demo/Surface_mesher/mainwindow.h deleted file mode 100644 index 36aa2db2138..00000000000 --- a/Surface_mesher/demo/Surface_mesher/mainwindow.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _MAINWINDOW_H -#define _MAINWINDOW_H - -#include -#include "ui_mainwindow.h" -#include - -class QDragEnterEvent; -class QDropEvent; -class Surface; -class QDoubleSpinBox; -class QCloseEvent; - -namespace CGAL{ -class QGLViewer; -} - -class MainWindow : public CGAL::Qt::DemosMainWindow, public Ui::MainWindow -{ - Q_OBJECT -public: - MainWindow(MainWindow* other_window = 0); - void dragEnterEvent(QDragEnterEvent *); - void dropEvent(QDropEvent *event); - -public Q_SLOTS: - void show_only(QString); - void surface_open(const QString& filename); - -private Q_SLOTS: - void on_action_Open_triggered(); - void on_action_OpenDirectory_triggered(); - void on_action_Quit_triggered(); - void on_action_Clone_triggered(); - -private: - void closeEvent(QCloseEvent *event); - Surface* surface; -}; - - -#endif // _MAINWINDOW_H diff --git a/Surface_mesher/demo/Surface_mesher/polyhedral_surface.cpp b/Surface_mesher/demo/Surface_mesher/polyhedral_surface.cpp deleted file mode 100644 index 2ac24c2b2c4..00000000000 --- a/Surface_mesher/demo/Surface_mesher/polyhedral_surface.cpp +++ /dev/null @@ -1,407 +0,0 @@ -#include "polyhedral_surface.h" -#include "get_polyhedral_surface.h" - -#include -#include -#include -#include -#include -#include -#include "ui_optionsdialog.h" -#include -#include -#include -#include -#include "mainwindow.h" - -typedef CGAL_polyhedral_surface::Polyhedron Polyhedron; - -Polyhedral_surface::Polyhedral_surface(QObject* parent, - double sharp_edges_angle_lower_bound, - double sharp_edges_angle_upper_bound) - : Surface(parent), - m_inverse_normals(false), - surface_ptr(0), - parent(parent), - display_octree(false), - display_edges_octree(false), - display_surface(true), - display_all_edges(true), - display_control_edges(false), - sharp_edges_angle_lower_bound(sharp_edges_angle_lower_bound), - sharp_edges_angle_upper_bound(sharp_edges_angle_upper_bound), - is_octree_initialized(false), - selected_edge(-1), - selected_facet(-1), - is_dirty(true), - list_id(0) -{ - connection_map["actionDisplay_octree"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(toggle_display_octree(bool))); - - connection_map["actionDisplay_edges_octree"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(toggle_display_edges_octree(bool))); - - connection_map["actionDisplay_surface"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(toggle_display_surface(bool))); - - connection_map["actionDisplay_all_edges"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(toggle_display_all_edges(bool))); - - connection_map["actionDisplay_control_edges"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(toggle_display_control_edges(bool))); - - connection_map["actionInverse_normals"] = - std::make_pair(SIGNAL(toggled(bool)), - SLOT(set_inverse_normals(bool))); - - connection_map["actionSubdivision"] = - std::make_pair(SIGNAL(triggered()), - SLOT(make_one_subdivision_step())); - connection_map["action_Options"] = - std::make_pair(SIGNAL(triggered()), - SLOT(on_action_Options_triggered())); -} - -Polyhedral_surface::~Polyhedral_surface() -{ - clear(); - delete surface_ptr; -} - -void Polyhedral_surface::on_action_Options_triggered() -{ - QDialog *options_dialog = new QDialog(qobject_cast(parent)); - Ui::OptionDialog ui; - ui.setupUi(options_dialog); - - QDoubleSpinBox* sb_upper = options_dialog->findChild("angle_upper_bound"); - QDoubleSpinBox* sb_lower = options_dialog->findChild("angle_lower_bound"); - - if(!sb_lower || !sb_upper) - return; - - sb_lower->setValue(sharp_edges_angle_lower_bound); - sb_upper->setValue(sharp_edges_angle_upper_bound); - if(options_dialog->exec() == QDialog::Accepted) - { - sharp_edges_angle_upper_bound = sb_upper->value(); - sharp_edges_angle_lower_bound = sb_lower->value(); - set_sharp_edges_angle_bounds(sharp_edges_angle_lower_bound, - sharp_edges_angle_upper_bound); - } -} - -void Polyhedral_surface::clear() { - for(Connection_map::const_iterator - it = connection_map.begin(), - end = connection_map.end(); - it != end; - ++it) - { - QAction* action = parent->findChild(it->first); - action->setVisible(false); - } -} - -void Polyhedral_surface::connect_actions() -{ - for(Connection_map::const_iterator - it = connection_map.begin(), - end = connection_map.end(); - it != end; - ++it) - { - QAction* action = parent->findChild(it->first); - action->setVisible(true); - if(action) - connect(action, it->second.first, - this, it->second.second); - } - MainWindow* mw = qobject_cast(parent); - if(mw) { -// mw->fix_menus_visibility(); - mw->show_only("polyhedral"); - } - - - connect(this, SIGNAL(changed()), this, SLOT(display_nb_elements_in_status_bar())); -} - -void Polyhedral_surface::display_nb_elements_in_status_bar() const -{ - QMainWindow* mw = qobject_cast(parent); - if(surface_ptr && mw) - { - mw->statusBar()->showMessage(QString("%1 vertices. %2 edges. %3 facets.") - .arg(surface_ptr->size_of_vertices()) - .arg(surface_ptr->size_of_halfedges()/2) - .arg(surface_ptr->size_of_facets())); - } -} - -void Polyhedral_surface::set_dirty() -{ - is_dirty = true; - Q_EMIT changed(); -} - -void Polyhedral_surface::busy() const -{ - QMainWindow* mw = qobject_cast(parent); - if(mw) - { - mw->statusBar()->showMessage(QString("Constructing octree...")); - } - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -} - -void Polyhedral_surface::not_busy() const -{ - QApplication::restoreOverrideCursor(); - QMainWindow* mw = qobject_cast(parent); - if(mw) - { - mw->statusBar()->clearMessage(); - } -} - -void Polyhedral_surface::set_sharp_edges_angle_bounds(const double lower_bound, - const double upper_bound) -{ - sharp_edges_angle_lower_bound = lower_bound; - sharp_edges_angle_upper_bound = upper_bound; - if(surface_ptr) { - surface_ptr->set_sharp_edges_angle_bounds(lower_bound, upper_bound); - surface_ptr->set_sharp_vertices_angle_bounds(lower_bound, upper_bound); - update_data_structures(); - Q_EMIT set_dirty(); - } -} - -void Polyhedral_surface::update_data_structures() -{ - surface_ptr->compute_sharp_edges_incidence_graph(); - if(display_octree || display_edges_octree) { - construct_octree(); - is_octree_initialized = true; - } - else - is_octree_initialized = false; -} - -void Polyhedral_surface::construct_octree() -{ - busy(); - surface_ptr->construct_octree(); - not_busy(); -} - -void Polyhedral_surface::toggle_display_octree(bool b) -{ - if(surface_ptr && b && !is_octree_initialized) { - is_octree_initialized = true; - construct_octree(); - } - display_octree = b; - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::toggle_display_edges_octree(bool b) -{ - if(surface_ptr && b && !is_octree_initialized) { - is_octree_initialized = true; - construct_octree(); - } - display_edges_octree = b; - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::toggle_display_surface(bool b) -{ - display_surface = b; - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::toggle_display_all_edges(bool b) -{ - display_all_edges = b; - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::toggle_display_control_edges(bool b) -{ - display_control_edges = b; - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::make_one_subdivision_step() -{ - if(surface_ptr) - { - Polyhedron output; - CSubdivider_loop pw_loop_subdiviser; - - pw_loop_subdiviser.subdivide(*surface_ptr, output); - static_cast(*surface_ptr) = output; - surface_ptr->compute_normals(); - surface_ptr->compute_type(); - update_data_structures(); - Q_EMIT set_dirty(); - } -} - -bool Polyhedral_surface::open(const QString& filename) -{ - clear(); - - std::cerr << "Opening file \"" << qPrintable(filename) << "\"..."; - std::ifstream in(filename.toUtf8()); - if(!in) return false; - - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - - if(surface_ptr) - delete surface_ptr; - surface_ptr = new CGAL_polyhedral_surface(in, - sharp_edges_angle_lower_bound, - sharp_edges_angle_upper_bound, - false /*do not construct - octree*/); - if(!in) { - QApplication::restoreOverrideCursor(); - return false; - } - is_octree_initialized = false; - selected_facet = selected_edge = -1; - update_data_structures(); - - connect_actions(); - std::cerr << " Done.\n"; - QApplication::restoreOverrideCursor(); - float xmin, ymin, zmin, xmax, ymax, zmax; - get_bbox(xmin, ymin, zmin, xmax, ymax, zmax); - const float xcenter = (xmin + xmax) / 2; - const float ycenter = (ymin + ymax) / 2; - const float zcenter = (zmin + zmax) / 2; - const float xdelta = (-xmin + xmax); - const float ydelta = (-ymin + ymax); - const float zdelta = (-zmin + zmax); -// const float radius = std::max(std::max(xdelta, ydelta), zdelta) * std::sqrt(3.)/ 2.; - std::cerr << boost::format("Bounding box: xmin=%1%, ymin=%2%, zmin=%3%\n" - " xmax=%4%, ymax=%5%, zmax=%6%\n" - " center=(%7%, %8%, %9%)\n") - % xmin % ymin % zmin % xmax % ymax % zmax - % xcenter % ycenter % zcenter - << boost::format(" span=(%1%,%2%,%3%)\n") - % xdelta % ydelta % zdelta; - viewer->camera()->setSceneBoundingBox(CGAL::qglviewer::Vec(xmin, ymin, zmin), - CGAL::qglviewer::Vec(xmax, ymax, zmax)); - viewer->setBackgroundColor(Qt::white); - viewer->showEntireScene(); - - QAction* actionInverse_normals = qFindChild(this, "actionInverse_normals"); - if(actionInverse_normals) actionInverse_normals->setChecked(false); - Q_EMIT set_dirty(); - return true; -} - -void Polyhedral_surface::close() -{ - delete surface_ptr; - surface_ptr = 0; -} - -void Polyhedral_surface::draw() { - draw(false); -} - -void Polyhedral_surface::drawWithNames() { - draw(true); -} - -void Polyhedral_surface::postSelection(const QPoint&) -{ - if(!surface_ptr) return; - - selected_facet = selected_edge = -1; - - const int nb_vertices = surface_ptr->incidence_graph.vertices.size(); - const int nb_edges = surface_ptr->incidence_graph.edges.size(); - if(viewer->selectedName() >= nb_edges + nb_vertices) - selected_facet = viewer->selectedName() - nb_edges - nb_vertices; - else if(viewer->selectedName() >= nb_vertices) - selected_edge = viewer->selectedName() - nb_vertices; - - std::cerr << boost::format("post-selection.\n" - "selectedName()=%1%\n" - "selected edge=%2%\n" - "selected facet=%3%\n") - % viewer->selectedName() % selected_edge % selected_facet; - - Q_EMIT set_dirty(); -} - -void Polyhedral_surface::draw(bool with_names) -{ - if(!list_id) - { - std::cerr << "Generating OpenGL display list ID: "; - std::cerr << (list_id = ::glGenLists(1)) << "\n"; - } - if(!with_names) - { - if(is_dirty) - ::glNewList(list_id, GL_COMPILE_AND_EXECUTE); - else if(::glIsList(list_id)) - { - ::glCallList(list_id); - return; - } - else - std::cerr << "Call list (" << list_id << ")failed.\n"; - } -} -void Polyhedral_surface::get_bbox(float& xmin, float& ymin, float& zmin, - float& xmax, float& ymax, float& zmax) -{ - if(surface_ptr) { - xmin=surface_ptr->bbox().xmin(); - ymin=surface_ptr->bbox().ymin(); - ymin=surface_ptr->bbox().zmin(); - xmax=surface_ptr->bbox().xmax(); - ymax=surface_ptr->bbox().ymax(); - zmax=surface_ptr->bbox().zmax(); - } - else - { - xmin = ymin = zmin = 0.f; - xmax = ymax = zmax = 1.f; - } -} - -void Polyhedral_surface::set_inverse_normals(const bool b) { - m_inverse_normals = b; - set_dirty(); -} - -bool Polyhedral_surface::inverse_normals() const { - return m_inverse_normals; -} - - -Surface* get_polyhedral_surface(QObject* parent, - double sharp_edges_angle_lower_bound, - double sharp_edges_angle_upper_bound = 180.) -{ - return new Polyhedral_surface(parent, - sharp_edges_angle_lower_bound, - sharp_edges_angle_upper_bound); -} - -#include "polyhedral_surface.moc" diff --git a/Surface_mesher/demo/Surface_mesher/polyhedral_surface.h b/Surface_mesher/demo/Surface_mesher/polyhedral_surface.h deleted file mode 100644 index 001eaee5fd6..00000000000 --- a/Surface_mesher/demo/Surface_mesher/polyhedral_surface.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef _POLYHEDRAL_SURFACE_H -#define _POLYHEDRAL_SURFACE_H - -#define CGAL_SURFACE_MESHER_DEBUG_POLYHEDRAL_SURFACE_CONSTRUCTION - -#include "surface.h" -#include "viewer.h" - -#include -#include - -typedef std::pair Signal_slot_pair; -typedef std::map Connection_map; - -// CGAL -#include - -// kernel -#include - -// surface -#include - -// piece-wise loop subdivision -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel Poly_kernel; -typedef Poly_kernel::FT FT; -typedef Poly_kernel::Point_3 Poly_point; -typedef Poly_kernel::Sphere_3 Sphere; -typedef Poly_kernel::Vector_3 Vector; -typedef Poly_kernel::Triangle_3 Triangle_3; - -typedef CGAL::Polyhedral_surface_3 CGAL_polyhedral_surface; - - -class Polyhedral_surface : public Surface -{ - Q_OBJECT; - -public: - Polyhedral_surface(QObject* parent, - double sharp_edges_angle_lower_bound = 90, - double sharp_edges_angle_upper_bound = 120); - - ~Polyhedral_surface(); -public Q_SLOTS: - void clear(); - void connect_actions(); - void display_nb_elements_in_status_bar() const; - void set_dirty(); - void busy() const; - void not_busy() const; - void set_sharp_edges_angle_bounds(const double lower_bound, - const double upper_bound); - void update_data_structures(); - void construct_octree(); - void toggle_display_octree(bool b); - void toggle_display_edges_octree(bool b); - void toggle_display_surface(bool b); - void toggle_display_all_edges(bool b); - void toggle_display_control_edges(bool b); - void make_one_subdivision_step(); - void on_action_Options_triggered(); - -public: - bool open(const QString& filename); - void close(); - void draw(); - void drawWithNames(); - void postSelection(const QPoint&); - void draw(bool with_names); - void get_bbox(float& xmin, float& ymin, float& zmin, - float& xmax, float& ymax, float& zmax); - -public Q_SLOTS: - void set_inverse_normals(const bool b); - -public: - bool inverse_normals() const; - -protected: - bool m_inverse_normals; - CGAL_polyhedral_surface* surface_ptr; - QObject* parent; - bool display_octree; - bool display_edges_octree; - bool display_surface; - bool display_all_edges; - bool display_control_edges; - double sharp_edges_angle_lower_bound; - double sharp_edges_angle_upper_bound; - bool is_octree_initialized; - int selected_edge; - int selected_facet; - bool is_dirty; - GLint list_id; - Connection_map connection_map; -}; - -#endif // _POLYHEDRAL_SURFACE_H diff --git a/Surface_mesher/demo/Surface_mesher/surface.h b/Surface_mesher/demo/Surface_mesher/surface.h deleted file mode 100644 index 62e4b597a24..00000000000 --- a/Surface_mesher/demo/Surface_mesher/surface.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _SURFACE_H -#define _SURFACE_H - -#include -#include -#include - -#include "viewer.h" - -class Surface : public QObject -{ - Q_OBJECT -protected: - Surface(QObject* parent) - { - viewer = parent->findChild("viewer"); - - if(viewer) - connect(this, SIGNAL(changed()), viewer, SLOT(updateGL())); - viewer->set_surface(this); - } -public Q_SLOTS: - virtual bool open(const QString& filename) = 0; - virtual void close() = 0; - virtual void draw() = 0; - virtual void get_bbox(float&, float&, float&, - float&, float&, float&) = 0; - virtual void drawWithNames() {}; - virtual void postSelection(const QPoint&) {}; -Q_SIGNALS: - void changed(); - -protected: - Viewer* viewer; -}; - -#endif // _SURFACE_H diff --git a/Surface_mesher/demo/Surface_mesher/surface_mesher.qrc b/Surface_mesher/demo/Surface_mesher/surface_mesher.qrc deleted file mode 100644 index 9592cad50a0..00000000000 --- a/Surface_mesher/demo/Surface_mesher/surface_mesher.qrc +++ /dev/null @@ -1,13 +0,0 @@ - - - icons/bbox-red.png - icons/bbox.png - icons/cgal_logo.xpm - icons/fileopen.png - icons/filesave.png - icons/flip.png - icons/resize.png - icons/surface.png - icons/twosides.png - - diff --git a/Surface_mesher/demo/Surface_mesher/ui/mainwindow.ui b/Surface_mesher/demo/Surface_mesher/ui/mainwindow.ui deleted file mode 100644 index 65b8a528fa8..00000000000 --- a/Surface_mesher/demo/Surface_mesher/ui/mainwindow.ui +++ /dev/null @@ -1,808 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 1147 - 648 - - - - CGAL Surface mesh generator - - - - :/icons/cgal_logo.xpm:/icons/cgal_logo.xpm - - - true - - - - - - - - 1 - 0 - - - - - - - - - - 0 - 0 - 1147 - 21 - - - - - &File - - - - - - - - - - - &Options - - - - volume - polyhedral - - - - - - - - - - - - - - - - - - - &Edit - - - - polyhedral - - - - - - - - - - - - Actions toolbar - - - Qt::AllToolBarAreas - - - TopToolBarArea - - - false - - - - - - - - - - - - - - - - true - - - Meshing toolbar - - - - volume - - - - TopToolBarArea - - - false - - - - - - - Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - - - Images options - - - - volume - - - - 1 - - - - - - - - - - 0 - 0 - - - - &Image type - - - - volume - - - - - - - - 0 - 0 - - - - Grayscale image - - - true - - - - - - - - 0 - 0 - - - - Segmented image - - - - - - - - - - &Operations - - - - - - Trilinear interpolation - - - true - - - - - - - Search for seeds - - - true - - - - - - - - - - - 0 - 0 - - - - C&riteria - - - - volume - - - - - - - Manifold - - - - - - - Facets vertices have same index - - - - - - - - - &Sizing bound: - - - spinBox_radius_bound - - - - - - - 5 - - - 9999.989999999999782 - - - - - - - &Distance bound: - - - spinBox_distance_bound - - - - - - - 5 - - - 9999.989999999999782 - - - - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - - - 0 - 0 - - - - Image sub-domaines - - - - volume - - - - 1 - - - - - 10 - 10 - - - - - - - - 0 - 5 - - - - - volume - - - - - - - - - - - :/icons/fileopen.png:/icons/fileopen.png - - - &Open... - - - Ctrl+O - - - - - &Quit - - - Ctrl+Q - - - QAction::QuitRole - - - - - true - - - - :/icons/flip.png:/icons/flip.png - - - &Inverse normals - - - Flip - - - Ctrl+I - - - - volume - polyhedral - - - - - - true - - - - :/icons/bbox.png:/icons/bbox.png - - - Display oc&tree - - - Ctrl+T - - - - polyhedral - - - - - - true - - - true - - - - :/icons/surface.png:/icons/surface.png - - - Display &surface - - - - polyhedral - - - - - - &Options... - - - - polyhedral - - - - - - Piecewise-smooth &subdivision - - - Ctrl+S - - - - polyhedral - - - - - - true - - - true - - - Display &all edges - - - Ctrl+A - - - - polyhedral - - - - - - true - - - false - - - Display &control edges - - - Ctrl+C - - - - polyhedral - - - - - - true - - - - :/icons/bbox-red.png:/icons/bbox-red.png - - - Display edges octree - - - - polyhedral - - - - - - Marching &cubes - - - Marching &cubes - - - - volume - - - - - - Surface &mesher - - - Surface &mesher - - - - volume - - - - - - true - - - true - - - - :/icons/twosides.png:/icons/twosides.png - - - Display facets with &front and back - - - Two-sides - - - Ctrl+F - - - - volume - polyhedral - - - - - - Clone - - - - - true - - - false - - - - :/icons/resize.png:/icons/resize.png - - - Auto-&resize - - - Auto-&resize - - - Automaticaly zoom in or out when the object change. - - - Ctrl+S - - - - volume - polyhedral - - - - - - true - - - true - - - Draw triangles &edges - - - Draw triangles &edges - - - Ctrl+E - - - - volume - - - - - - true - - - false - - - Use &Gouraud shading (marching cube only) - - - Use &Gouraud shading - - - Use Gouraud shading to display the marching cubes. - - - Ctrl+G - - - - volume - - - - - - true - - - Show the whole &triangulation (surface mesher only) - - - Ctrl+T - - - - volume - - - - - - Choose the triangulation edges &color... - - - - volume - - - - - - - :/icons/filesave.png:/icons/filesave.png - - - Export surface mesh to OFF... - - - - volume - - - - - - true - - - true - - - - :/icons/bbox.png:/icons/bbox.png - - - Show the image &bounding box - - - Ctrl+B - - - - volume - - - - - - - :/icons/filesave.png:/icons/filesave.png - - - Save the image as Inrimage... - - - - - - :/icons/fileopen.png:/icons/fileopen.png - - - Open directory... - - - - - - Values_list - QWidget -
values_list.h
- 1 -
- - Viewer - QWidget -
viewer.h
-
-
- - viewer - grayLevelRadioButton - labellizedRadioButton - manifoldCheckBox - sameIndexCheckBox - spinBox_radius_bound - spinBox_distance_bound - - - - - - - labellizedRadioButton - toggled(bool) - sameIndexCheckBox - setDisabled(bool) - - - 130 - 172 - - - 139 - 414 - - - - -
diff --git a/Surface_mesher/demo/Surface_mesher/ui/optionsdialog.ui b/Surface_mesher/demo/Surface_mesher/ui/optionsdialog.ui deleted file mode 100644 index 2ea13d120e1..00000000000 --- a/Surface_mesher/demo/Surface_mesher/ui/optionsdialog.ui +++ /dev/null @@ -1,128 +0,0 @@ - - OptionDialog - - - - 0 - 0 - 210 - 167 - - - - Set options - - - :/icons/cgal_logo.xpm - - - - - - Sharp edges angle bounds - - - - - - - - &Lower bound - - - angle_lower_bound - - - - - - - 180.000000000000000 - - - - - - - &Upper bound - - - angle_upper_bound - - - - - - - 180.000000000000000 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - OptionDialog - accept() - - - 227 - 215 - - - 157 - 90 - - - - - buttonBox - rejected() - OptionDialog - reject() - - - 243 - 221 - - - 252 - 90 - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/ui/raw_image.ui b/Surface_mesher/demo/Surface_mesher/ui/raw_image.ui deleted file mode 100644 index e270d1de917..00000000000 --- a/Surface_mesher/demo/Surface_mesher/ui/raw_image.ui +++ /dev/null @@ -1,454 +0,0 @@ - - Raw_image_dialog - - - - 0 - 0 - 585 - 342 - - - - Open raw image - - - - - - Image &value type - - - - - - Short (16 bits) - - - - - - - Float - - - - - - - Int (32 bits) - - - - - - - Double - - - - - - - Signed - - - - - - - char (8 bits) - - - - - - - - - - Image dimensions - - - - - - - - &Dimensions: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - dim_x - - - - - - - &Spacing: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - spacing_x - - - - - - - x: - - - 100000000 - - - - - - - y: - - - 100000000 - - - - - - - z: - - - 100000000 - - - - - - - vx: - - - 5 - - - 1.000000000000000 - - - - - - - vy: - - - 5 - - - 1.000000000000000 - - - - - - - vz: - - - 5 - - - 1.000000000000000 - - - - - - - &Offset: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - offset - - - - - - - bytes - - - 999999999 - - - - - - - Image size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - - - - - File size: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Open - - - - - - - int_bt - short_bt - signed_bt - float_bt - double_bt - dim_x - dim_y - dim_z - spacing_x - spacing_y - spacing_z - offset - buttonBox - - - - - float_bt - toggled(bool) - signed_bt - setDisabled(bool) - - - 47 - 112 - - - 553 - 94 - - - - - double_bt - toggled(bool) - signed_bt - setDisabled(bool) - - - 564 - 127 - - - 564 - 94 - - - - - buttonBox - accepted() - Raw_image_dialog - accept() - - - 191 - 316 - - - 183 - 313 - - - - - buttonBox - rejected() - Raw_image_dialog - reject() - - - 253 - 319 - - - 252 - 312 - - - - - dim_x - valueChanged(int) - Raw_image_dialog - update_image_size() - - - 178 - 187 - - - 99 - 141 - - - - - dim_z - valueChanged(int) - Raw_image_dialog - update_image_size() - - - 473 - 178 - - - 441 - 142 - - - - - char_bt - clicked() - Raw_image_dialog - update_image_size() - - - 71 - 52 - - - 137 - 3 - - - - - short_bt - clicked() - Raw_image_dialog - update_image_size() - - - 117 - 81 - - - 49 - 6 - - - - - float_bt - clicked() - Raw_image_dialog - update_image_size() - - - 137 - 111 - - - 67 - -5 - - - - - int_bt - clicked() - Raw_image_dialog - update_image_size() - - - 358 - 49 - - - 584 - 52 - - - - - dim_y - valueChanged(int) - Raw_image_dialog - update_image_size() - - - 332 - 186 - - - 271 - 142 - - - - - double_bt - clicked() - Raw_image_dialog - update_image_size() - - - 514 - 119 - - - 581 - 116 - - - - - - update_image_size() - - diff --git a/Surface_mesher/demo/Surface_mesher/ui/values_list.ui b/Surface_mesher/demo/Surface_mesher/ui/values_list.ui deleted file mode 100644 index 9e7e4372813..00000000000 --- a/Surface_mesher/demo/Surface_mesher/ui/values_list.ui +++ /dev/null @@ -1,118 +0,0 @@ - - Values_list - - - - 0 - 0 - 429 - 632 - - - - Form - - - - - - QFrame::StyledPanel - - - 1 - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::NoEditTriggers|QAbstractItemView::SelectedClicked - - - true - - - QAbstractItemView::ExtendedSelection - - - 0 - - - false - - - true - - - false - - - true - - - false - - - 3 - - - - Iso-value - - - - - Color - - - - - Name - - - - - - - - - - ... - - - :/values/plus.png - - - - - - - ... - - - :/values/minus.png - - - Del - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - diff --git a/Surface_mesher/demo/Surface_mesher/values_list.cpp b/Surface_mesher/demo/Surface_mesher/values_list.cpp deleted file mode 100644 index b2e8a41e86f..00000000000 --- a/Surface_mesher/demo/Surface_mesher/values_list.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "values_list.h" -#include "ui_values_list.h" -#include "colorlisteditor.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) -#include -#endif - -Values_delegate::Values_delegate(QWidget* parent) : QItemDelegate(parent) {} -void Values_delegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const -{ - switch(index.column()) - { - case Values_list::Color: { - painter->fillRect(option.rect, index.data().value()); - drawFocus(painter, option, option.rect); - break; - } - default: - QItemDelegate::paint(painter, option, index); - } -} - -QWidget *Values_delegate::createEditor(QWidget *parent, - const QStyleOptionViewItem & option, - const QModelIndex & index) const -{ - if(index.column() == Values_list::Color) - { - return new ColorListEditor(parent); - } - else if(index.column() == Values_list::Value) - { - QLineEdit* lineedit = new QLineEdit(parent); - lineedit->setAutoFillBackground(true); - lineedit->setValidator(new QDoubleValidator(lineedit)); - return lineedit; - } - else return QItemDelegate::createEditor(parent, option, index); -} - -void Values_delegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - if(index.column() == Values_list::Color) - { - ColorListEditor* coloreditor = qobject_cast(editor); - if(coloreditor) - coloreditor->setColor(index.data().value()); - } - else if(index.column() == Values_list::Value) - { - QLineEdit* lineedit = qobject_cast(editor); - if(lineedit) - lineedit->setText(index.data().toString()); - } - else QItemDelegate::setEditorData(editor, index); -} -void Values_delegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - if(index.column() == Values_list::Color) - { - ColorListEditor* coloreditor = qobject_cast(editor); - if(coloreditor) - { - model->setData(index, coloreditor->color()); - Q_EMIT new_color(index); - } - } - else if(index.column() == Values_list::Value) - { - QLineEdit* lineedit = qobject_cast(editor); - if(lineedit) - { - model->setData(index, lineedit->text().toDouble()); - Q_EMIT new_value(index); - } - } - else QItemDelegate::setModelData(editor, model, index); -} - -const double Values_list::default_value = 0.0; - -Values_list::Values_list(QWidget* parent): - QWidget(parent) -{ - Ui::Values_list().setupUi(this); - - treeWidget = parent->findChild("treeWidget"); - Q_ASSERT_X(treeWidget, "Values_list constructor", "cannot find widget \"treeWidget\""); - - treeWidget->sortByColumn(Value, Qt::AscendingOrder); - - treeWidget->header()->setSectionsClickable(false); - - - Values_delegate* values_delegate = new Values_delegate(parent); - - treeWidget->setItemDelegate(values_delegate); - connect(values_delegate, SIGNAL(new_value(const QModelIndex&)), - this, SIGNAL(values_changed())); - connect(values_delegate, SIGNAL(new_color(const QModelIndex&)), - this, SIGNAL(colors_changed())); - connect(this->treeWidget->model(), - SIGNAL(dataChanged (const QModelIndex &, const QModelIndex &)), - this, SIGNAL(changed())); - - connect(this, SIGNAL(changed()), - this, SLOT(update_items_cache())); -} - -QColor Values_list::color(const int i) const -{ - if(i < 0 || i > treeWidget->topLevelItemCount()) - return QColor(); - else - return treeWidget->topLevelItem(i)->data(Color, Qt::DisplayRole).value(); -} - -QColor Values_list::color(const QTreeWidgetItem* item) const -{ - return item->data(Color, Qt::DisplayRole).value(); -} - -int Values_list::numberOfValues() const -{ - return treeWidget->topLevelItemCount(); -} - -double Values_list::value(const int i) const -{ - if(i < 0 || i > numberOfValues()) - return 0.; - else - return treeWidget->topLevelItem(i)->data(Value, Qt::DisplayRole).toDouble(); -} - -QString Values_list::name(const int i) const -{ - if(i < 0 || i > treeWidget->topLevelItemCount()) - return QString(); - else - return treeWidget->topLevelItem(i)->data(Name, Qt::DisplayRole).toString(); -} - -bool Values_list::enabled(const int i) const -{ - if(i < 0 || i > treeWidget->topLevelItemCount()) - return false; - else - return treeWidget->topLevelItem(i)->data(Value, Qt::CheckStateRole).toInt() > 0; -} - -bool Values_list::enabled(const QTreeWidgetItem* item) const -{ - return item->data(Value, Qt::CheckStateRole).toInt() > 0; -} - -const QTreeWidgetItem* Values_list::item(const int i) const -{ - if(i < 0 || i > treeWidget->topLevelItemCount()) - return 0; - else - return treeWidget->topLevelItem(i); -} - -void Values_list::save_values(QString filename) const -{ - QSettings settings; - - settings.beginGroup(QUrl::toPercentEncoding(filename)); - settings.beginWriteArray("values"); - for (int i = 0; i < numberOfValues(); ++i) { - settings.setArrayIndex(i); - settings.setValue("value", value(i)); - settings.setValue("color", color(i)); - settings.setValue("name", name(i)); - settings.setValue("enabled", enabled(i)); - } - settings.endArray(); - settings.endGroup(); -} - -void Values_list::load_values(QString filename) -{ - QSettings settings; - - treeWidget->clear(); - settings.beginGroup(QUrl::toPercentEncoding(filename)); - int nb = settings.beginReadArray("values"); - for (int i = 0; i < nb; ++i) { - settings.setArrayIndex(i); - QTreeWidgetItem *newItem = new QTreeWidgetItem(treeWidget); - newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); - newItem->setData(Value, Qt::CheckStateRole, settings.value("enabled").toBool() ? Qt::Checked : Qt::Unchecked); - newItem->setData(Value, Qt::DisplayRole, settings.value("value").toDouble()); - newItem->setData(Color, Qt::DisplayRole, settings.value("color").value()); - newItem->setData(Name, Qt::DisplayRole, settings.value("name").toString()); - } - settings.endArray(); - settings.endGroup(); - update_items_cache(); -} - -void Values_list::on_minusButton_clicked() -{ - Q_FOREACH(QTreeWidgetItem* item, treeWidget->selectedItems()) - { - // treeWidget->invisibleRootItem()->removeChild(item); - delete item; - } - Q_EMIT values_changed(); -} - -void Values_list::on_plusButton_clicked() -{ - addValue(); -} - -void Values_list::addValue(const double i) -{ - QTreeWidgetItem *newItem = new QTreeWidgetItem(treeWidget); - newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); - newItem->setData(Value, Qt::CheckStateRole, Qt::Checked); - newItem->setData(Value, Qt::DisplayRole, i); - QStringList colors = QColor::colorNames(); -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - const int color_index = qrand() % colors.size(); -#else -const int color_index = QRandomGenerator::global()->generate() % colors.size(); -#endif - - QColor color = QColor(colors[color_index]); - newItem->setData(Color, Qt::DisplayRole, color); - newItem->setData(Name, Qt::DisplayRole, ""); - Q_EMIT values_changed(); -} - -void Values_list::update_items_cache() { - items_cache.clear(); - for(int i = 0, nb = numberOfValues(); i < nb; ++i) { - items_cache.insert(std::make_pair(value(i), item(i))); - } -} - -const QTreeWidgetItem* Values_list::search(const double value) const -{ - Items_cache::const_iterator it = items_cache.find(value); - if(it != items_cache.end()) { - return it->second; - } - else { - return 0; - } -} - -void Values_list::setHeaderTitle(QString title) -{ - treeWidget->headerItem()->setText(0, title); -} - diff --git a/Surface_mesher/demo/Surface_mesher/values_list.h b/Surface_mesher/demo/Surface_mesher/values_list.h deleted file mode 100644 index 03649fea0f0..00000000000 --- a/Surface_mesher/demo/Surface_mesher/values_list.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _VALUES_LIST_H -#define _VALUES_LIST_H - -#include -#include -#include -#include -#include - -class QTreeWidget; -class QTreeWidgetItem; - -class Values_delegate : public QItemDelegate -{ - Q_OBJECT -public: - Values_delegate(QWidget* parent); - -Q_SIGNALS: - void new_color(const QModelIndex&) const; - void new_value(const QModelIndex&) const; - -protected: - void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; - QWidget *createEditor(QWidget *parent, - const QStyleOptionViewItem & option, - const QModelIndex & index) const; - void setEditorData(QWidget *editor, - const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; -}; - -class Values_list : public QWidget -{ - Q_OBJECT -public: - enum Field { Value = 0 , Color = 1, Name = 2}; - Values_list(QWidget* parent); - - // const accessors - int numberOfValues() const; - QColor color(const int i) const; - QColor color(const QTreeWidgetItem* i) const; - double value(const int i) const; - QString name(const int i) const; - bool enabled(const int i) const; - bool enabled(const QTreeWidgetItem* i) const; - const QTreeWidgetItem* item(const int i) const; - const QTreeWidgetItem* search(const double value) const; - -public Q_SLOTS: - void save_values(QString) const; - void load_values(QString); - void on_plusButton_clicked(); - void on_minusButton_clicked(); - - // setters - void addValue(const double v = Values_list::default_value); - - void setHeaderTitle(QString); - -private Q_SLOTS: - void update_items_cache(); - -Q_SIGNALS: - void changed(); - void colors_changed(); - void values_changed(); -private: - QTreeWidget* treeWidget; - typedef std::map Items_cache; - Items_cache items_cache; - - static const double default_value; -}; - -#endif // _VALUES_LIST_H - diff --git a/Surface_mesher/demo/Surface_mesher/values_list.qrc b/Surface_mesher/demo/Surface_mesher/values_list.qrc deleted file mode 100644 index 8a78bb1688a..00000000000 --- a/Surface_mesher/demo/Surface_mesher/values_list.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - icons/minus.png - icons/plus.png - - diff --git a/Surface_mesher/demo/Surface_mesher/viewer.cpp b/Surface_mesher/demo/Surface_mesher/viewer.cpp deleted file mode 100644 index 0cde258c258..00000000000 --- a/Surface_mesher/demo/Surface_mesher/viewer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "viewer.h" -#include "surface.h" -#include -#include - -Viewer::Viewer(QWidget* parent) - : CGAL::QGLViewer(parent), surface(nullptr) -{ -} - -void Viewer::init() -{ - setBackgroundColor(Qt::white); - glLineStipple(5, 0xaaaa); - glDisable(GL_LINE_STIPPLE); - - // anti-aliasing - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -QString Viewer::helpString() const -{ - return "" - "

Surface mesher demo

\n" - "

No help availlable for now.

"; -} - -void Viewer::interpolateToFitBoundingBox(double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) -{ - QAction* auto_resize = parent()->parent()->findChild("actionAuto_resize"); - Q_ASSERT_X(auto_resize, "Viewer::interpolateToFitBoundingBox", "cannot find action \"actionAuto_resize\""); - if(auto_resize && auto_resize->isChecked()) - { - CGAL::qglviewer::Camera new_camera = *(camera ()); - new_camera.fitBoundingBox(CGAL::qglviewer::Vec(xmin, ymin, zmin), - CGAL::qglviewer::Vec(xmax, ymax, zmax)); - camera()->interpolateTo(*new_camera.frame(), 1.); - } -} - -void Viewer::draw() -{ - if(surface) - surface->draw(); -} - -void Viewer::drawWithNames() -{ - if(surface) - surface->drawWithNames(); -} -void Viewer::postSelection(const QPoint& p) -{ - if(surface) - surface->postSelection(p); -} - -void Viewer::set_surface(Surface* s) -{ - surface = s; -} - diff --git a/Surface_mesher/demo/Surface_mesher/viewer.h b/Surface_mesher/demo/Surface_mesher/viewer.h deleted file mode 100644 index 8c40a6a6612..00000000000 --- a/Surface_mesher/demo/Surface_mesher/viewer.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _VIEWER_H -#define _VIEWER_H - -#include -#include - -class Surface; - -class Viewer : public CGAL::QGLViewer -{ - Q_OBJECT -public: - Viewer(QWidget* parent); - - void set_surface(Surface*); - -public Q_SLOTS: - void interpolateToFitBoundingBox(double, double, double, double, double, double); - -protected : - virtual void init(); - virtual void draw(); - virtual void drawWithNames(); - virtual void postSelection(const QPoint&); - virtual QString helpString() const; - - Surface* surface; -}; - -#endif // _VIEWER_H diff --git a/Surface_mesher/demo/Surface_mesher/volume.cpp b/Surface_mesher/demo/Surface_mesher/volume.cpp deleted file mode 100644 index 62424155ccd..00000000000 --- a/Surface_mesher/demo/Surface_mesher/volume.cpp +++ /dev/null @@ -1,1613 +0,0 @@ -#include - -#include "volume.h" - -#include // std::sort -#include -#include - -#include - -#include "viewer.h" -#include "mainwindow.h" -#include "values_list.h" - -#include "File_XT.h" // format XT from Total/ELF - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Raw_image_dialog.h" -#include -// #include -#include -#include -#include -#include -#include - -struct Threshold : public CGAL::cpp98::unary_function { - double isovalue; - bool is_identity; - - Threshold(double isovalue) : isovalue(isovalue), is_identity(false) {} - - result_type operator()(FT value) - { - if(is_identity) - return static_cast(value); - else if(value >= isovalue) - return 1; - else - return 0; - } -}; - -class Classify_from_isovalue_list : - public CGAL::cpp98::unary_function -{ - typedef std::pair Isovalue; - typedef std::vector Isovalues; - boost::shared_ptr isovalues; - bool is_identity; - - struct Sort_isovalues : CGAL::cpp98::binary_function - { - bool operator()(const Isovalue& isoval1, const Isovalue& isoval2) - { - return isoval1.first < isoval2.first; - } - }; -public: - Classify_from_isovalue_list(Values_list * list) - : is_identity(false) - { - isovalues = boost::shared_ptr(new Isovalues(list->numberOfValues())); - for(int i = 0, nbs = list->numberOfValues(); i < nbs; ++i ) - (*isovalues)[i] = std::make_pair(list->value(i), i); - std::sort(isovalues->begin(), isovalues->end(), Sort_isovalues()); - } - - void set_identity(bool b) { - is_identity = b; - } - - result_type operator()(FT value) - { - if(is_identity) { - return static_cast(value); - } - result_type result = 0; -// std::cerr << "isovalues: "; - for(result_type i = 1, end = static_cast(isovalues->size()); i <= end; ++i) - { -// std::cerr << (*isovalues)[i-1] << ", "; - if(value >= (*isovalues)[i-1].first && - i >= result) - { - result = i; - } - } -// if(result>1) -// std::cerr << "result = " << (int)result << "/" << list->numberOfValues() << std::endl; -// else -// std::cerr << std::endl; - if(result>0) - return (*isovalues)[result-1].second + 1; - else - return 0; - } -}; - -class Generate_surface_identifiers : - public CGAL::cpp98::binary_function -{ - Values_list* list; - bool labellized; - -public: - Generate_surface_identifiers(Values_list* list) - : list(list), labellized(false) {}; - - void set_labellized_image(bool b) - { - labellized = b; - } - - result_type operator()(const Classify_from_isovalue_list::result_type& a, - const Classify_from_isovalue_list::result_type& b) - { - if(labellized) - return list->search((std::max)(a, b)); - else - return list->item((std::min)(a, b)); - } -}; - -// class Classify_from_isovalue_list : -// public CGAL::cpp98::unary_function -// { -// typedef std::pair Isovalue; -// typedef std::vector Isovalues; -// boost::shared_ptr isovalues; - -// struct Sort_isovalues : CGAL::cpp98::binary_function -// { -// bool operator()(const Isovalue& isoval1, const Isovalue& isoval2) -// { -// return isoval1.first < isoval2.first; -// } -// }; -// public: -// Classify_from_isovalue_list(Isovalues_list * list) -// { -// isovalues = boost::shared_ptr(new Isovalues(list->numberOfIsoValues())); -// for(int i = 0, nbs = list->numberOfIsoValues(); i < nbs; ++i ) -// (*isovalues)[i] = std::make_pair(list->isovalue(i), list->item(i)); -// std::sort(isovalues->begin(), isovalues->end(), Sort_isovalues()); -// } - -// result_type operator()(FT value) -// { -// int result = 0; -// // std::cerr << "isovalues: "; -// for(int i = 1, end = isovalues->size(); i <= end; ++i) -// { -// // std::cerr << (*isovalues)[i-1] << ", "; -// if(value >= (*isovalues)[i-1].first && -// i >= result) -// { -// result = i; -// } -// } -// if(result>1) -// std::cerr << boost::format("result = %1%/%2%\n") % result % isovalues->size(); -// if(result>0) -// return (*isovalues)[result-1].second; -// else -// return 0; -// } -// }; -Volume::Volume(MainWindow* mw) : - Surface(mw), - m_sm_angle(30), - m_sm_radius(0), - m_sm_distance(0), - m_relative_precision(0.000000001), - m_view_surface(false), - m_triangulation_color(QColor(Qt::green)), - m_inverse_normals(false), - two_sides(false), - del(), - c2t3(del), - mw(mw), - lists_draw_surface(), - lists_draw_surface_is_valid(false), -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - list_draw_marching_cube(0), - list_draw_marching_cube_is_valid(false), - lists_draw_surface_mc(), -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - m_view_mc(false) -{ - spinBox_radius_bound = mw->findChild("spinBox_radius_bound"); - spinBox_distance_bound = mw->findChild("spinBox_distance_bound"); - Q_ASSERT_X(spinBox_radius_bound && spinBox_distance_bound, - "Volume::Volume()", "Cannot find spinboxes!"); - - values_list = mw->values; - - connect(spinBox_radius_bound, SIGNAL(valueChanged(double)), - this, SLOT(set_radius_bound(double))); - connect(spinBox_distance_bound, SIGNAL(valueChanged(double)), - this, SLOT(set_distance_bound(double))); - - connect(mw->actionSurface_mesher, SIGNAL(triggered()), - this, SLOT(display_surface_mesher_result())); - - connect(mw->actionInverse_normals, SIGNAL(toggled(bool)), - this, SLOT(set_inverse_normals(bool))); - m_inverse_normals = mw->actionInverse_normals->isChecked(); - - connect(mw->actionDisplay_front_and_back, SIGNAL(toggled(bool)), - this, SLOT(set_two_sides(bool))); - two_sides = mw->actionDisplay_front_and_back->isChecked(); - - connect(mw->actionDraw_triangles_edges, SIGNAL(toggled(bool)), - this, SLOT(set_draw_triangles_edges(bool))); - draw_triangles_edges = mw->actionDraw_triangles_edges->isChecked(); - - connect(mw->actionUse_Gouraud_shading, SIGNAL(toggled(bool)), - this, SLOT(set_use_gouraud(bool))); - use_gouraud = mw->actionUse_Gouraud_shading->isChecked(); - - connect(mw->actionShow_the_image_bounding_box, SIGNAL(toggled(bool)), - this, SLOT(set_show_bbox(bool))); - show_bbox = mw->actionShow_the_image_bounding_box->isChecked(); - - connect(mw->actionShow_triangulation, SIGNAL(toggled(bool)), - this, SLOT(set_draw_triangulation(bool))); - m_draw_triangulation = mw->actionShow_triangulation->isChecked(); - - connect(mw->actionTriangulation_edges_color, SIGNAL(triggered()), - this, SLOT(set_triangulation_edges_color())); - - connect(this, SIGNAL(new_bounding_box(double, double, double, double, double, double)), - mw->viewer, SLOT(interpolateToFitBoundingBox(double, double, double, double, double, double))); - - connect(values_list, SIGNAL(values_changed()), - this, SLOT(changed_parameters())); - connect(values_list, SIGNAL(changed()), - mw->viewer, SLOT(updateGL())); - connect(this, SIGNAL(changed()), - this, SLOT(check_can_export_off())); - - connect(mw->labellizedRadioButton, SIGNAL(toggled(bool)), - this, SLOT(labellizedToogled(bool))); - - mw->actionExport_surface_mesh_to_OFF->setEnabled(false); - connect(mw->actionExport_surface_mesh_to_OFF, SIGNAL(triggered()), - this, SLOT(export_off())); - - connect(mw->actionSave, SIGNAL(triggered()), - this, SLOT(save_image_to_inr())); - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - connect(mw->actionMarching_cubes, SIGNAL(triggered()), - this, SLOT(display_marchin_cube())); -#endif -} - -void Volume::set_inverse_normals(const bool b) { - m_inverse_normals = b; - - list_draw_marching_cube = 0; // Invalidate the display list for the - // marching cube. See gl_draw_marchingcube() - // for an explanation. - - Q_EMIT changed(); -} - -void Volume::set_two_sides(const bool b) { - two_sides = b; - Q_EMIT changed(); -} - -void Volume::set_draw_triangles_edges(const bool b) { - draw_triangles_edges = b; - Q_EMIT changed(); -} - -void Volume::set_draw_triangulation(const bool b) { - m_draw_triangulation = b; - Q_EMIT changed(); -} - -void Volume::set_triangulation_edges_color() { - const QColor color = QColorDialog::getColor(m_triangulation_color, mw); - if (color.isValid()) { - m_triangulation_color = color; - Q_EMIT changed(); - } -} - -void Volume::set_use_gouraud(const bool b) { - use_gouraud = b; - Q_EMIT changed(); -} - -void Volume::set_show_bbox(const bool b) { - show_bbox = b; - Q_EMIT changed(); -} - -void Volume::only_in() -{ - mw->show_only("volume"); -#ifndef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - mw->actionMarching_cubes->setVisible(false); -#endif -} - -#ifdef CGAL_USE_VTK - -#include - -#include -#include -#include -#include -#include - -Volume::~Volume() -{ - if(vtk_reader) vtk_reader->Delete(); - if(vtk_image) vtk_image->Delete(); - if(dicom_reader) dicom_reader->Delete(); - if(executive) executive->Delete(); - if(smoother) smoother->Delete(); -} - -bool Volume::opendir(const QString& dirname) -{ - bool result = true; - if(!fileinfo.isReadable()) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Cannot read directory %1!").arg(dirname)); - status_message(tr("Opening of directory %1 failed!").arg(dirname)); - result = false; - } - else - { - dicom_reader = vtkDICOMImageReader::New(); - dicom_reader->SetDirectoryName(dirname.toUtf8()); - - executive = - vtkDemandDrivenPipeline::SafeDownCast(dicom_reader->GetExecutive()); - if (executive) - { - executive->SetReleaseDataFlag(0, 0); // where 0 is the port index - } - - smoother = vtkImageGaussianSmooth::New(); - smoother->SetStandardDeviations(1., 1., 1.); - smoother->SetInputConnection(dicom_reader->GetOutputPort()); - smoother->Update(); - vtk_image = smoother->GetOutput(); - vtk_image->Print(std::cerr); - m_image = CGAL::read_vtk_image_data(vtk_image); - if(m_image.image() == 0) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Error with file %1/:\nunknown file format!").arg(dirname)); - status_message(tr("Opening of file %1/ failed!").arg(dirname)); - result = false; - } - else - { - status_message(tr("File %1/ successfully opened.").arg(dirname)); - finish_open(); - result = true; - } - // if(executive) executive->Delete(); - // dicom_reader->Delete(); - // smoother->Delete(); - } - return result; -} - -bool Volume::open_vtk(const QString& filename) -{ - only_in(); - - fileinfo.setFile(filename); - - if(fileinfo.isDir()) - { - return opendir(filename); - } - - if(!fileinfo.isReadable()) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Cannot read file %1!").arg(filename)); - status_message(tr("Opening of file %1 failed!").arg(filename)); - return false; - } - else - { - vtk_reader = vtkImageReader::New(); - vtk_reader->SetFileName(filename.toUtf8()); - vtk_reader->SetDataScalarTypeToUnsignedChar(); - vtk_reader->SetDataExtent(0, 249, 0, 249, 0, 124); - vtk_reader->SetDataSpacing(1., 1., 1.); - vtk_reader->SetFileDimensionality(3); - vtk_reader->Update(); - vtk_reader->Print(std::cerr); - vtk_image = vtk_reader->GetOutput(); - vtk_image->Print(std::cerr); - m_image = CGAL::read_vtk_image_data(vtk_image); - if(m_image.image() == NULL) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Error with file %1:\nunknown file format!").arg(filename)); - status_message(tr("Opening of file %1 failed!").arg(filename)); - return false; - } - else - { - status_message(tr("File %1 successfully opened.").arg(filename)); - finish_open(); - return true; - } - } -} - -// Total 3D images (XT format, that is the old Inrimage format, 1994. -bool Volume::open_xt(const QString& filename) -{ - only_in(); - - fileinfo.setFile(filename); - - if(fileinfo.isDir()) - { - return false; - } - - if(!fileinfo.isReadable()) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Cannot read file %1!").arg(filename)); - status_message(tr("Opening of file %1 failed!").arg(filename)); - return false; - } - else - { - long dimx, dimy, dimz; - long word_dim; - long header_size; - const char* filename_stl = qPrintable(filename); - CGAL::Total::lire_longueur_entete(filename_stl, &header_size); - CGAL::Total::lire_nb_octet(filename_stl, &word_dim); - CGAL::Total::lire_longueur_trace(filename_stl, &dimx); - CGAL::Total::lire_nb_trace(filename_stl, &dimy); - CGAL::Total::lire_nb_plan(filename_stl, &dimz); - - vtkImageReader* vtk_reader = vtkImageReader::New(); - vtk_reader->SetFileName(filename_stl); - switch(word_dim) { - case 8: - vtk_reader->SetDataScalarTypeToUnsignedChar(); - break; - case 16: - vtk_reader->SetDataScalarTypeToUnsignedShort(); - break; - default: - return false; - } - vtk_reader->SetHeaderSize(header_size); - vtk_reader->SetDataExtent(1, int(dimx), 1, int(dimy), 1, int(dimz)); - vtk_reader->SetDataSpacing(1., 1., 1.); - vtk_reader->SetFileDimensionality(3); - vtk_reader->Update(); - vtk_reader->Print(std::cerr); - vtkImageData* vtk_image = vtk_reader->GetOutput(); - vtk_image->Print(std::cerr); - m_image = CGAL::read_vtk_image_data(vtk_image); - if(m_image.image() != NULL) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Error with file %1:\nunknown file format!").arg(filename)); - status_message(tr("Opening of file %1 failed!").arg(filename)); - return false; - } - else - { - status_message(tr("File %1 successfully opened.").arg(filename)); - finish_open(); - } - return true; - } -} - -#else // CGAL_USE_VTK -Volume::~Volume() -{ -} - -bool Volume::opendir(const QString&) -{ - return false; -} - -bool Volume::open_xt(const QString&) -{ - return false; -} -#endif // CGAL_USE_VTK - -bool Volume::open(const QString& filename) -{ - only_in(); - - fileinfo.setFile(filename); - - if(fileinfo.isDir()) - { - return opendir(filename); - } - - if(!fileinfo.isReadable()) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Cannot read file %1!").arg(filename)); - } - else - { - if(m_image.read(filename.toStdString().c_str())) - { - status_message(tr("File %1 successfully opened.").arg(filename)); - finish_open(); - return true; - } - else if(open_xt(filename)) { - return true; - } - else - { - QSettings settings; - settings.beginGroup(QUrl::toPercentEncoding(fileinfo.absoluteFilePath())); - if( settings.value("is_raw").toBool() && - m_image.read_raw(filename.toStdString().c_str(), - settings.value("dim_x").toInt(), - settings.value("dim_y").toInt(), - settings.value("dim_z").toInt(), - settings.value("spacing_x").toDouble(), - settings.value("spacing_y").toDouble(), - settings.value("spacing_z").toDouble(), - settings.value("offset").toInt()) ) - { - status_message(tr("File %1 successfully opened.").arg(filename)); - finish_open(); - return true; - } - else if(QMessageBox::warning(mw, mw->windowTitle(), - tr("Error with file %1:\n" - "unknown file format!\n" - "\n" - "Open it as a raw image?").arg(filename), - QMessageBox::Yes|QMessageBox::No) == QMessageBox::Yes) - { - Raw_image_dialog raw_dialog; - raw_dialog.label_file_size->setText(QString("%1 B").arg(fileinfo.size())); - if( raw_dialog.exec() && - m_image.read_raw(filename.toStdString().c_str(), - raw_dialog.dim_x->value(), - raw_dialog.dim_y->value(), - raw_dialog.dim_z->value(), - raw_dialog.spacing_x->value(), - raw_dialog.spacing_y->value(), - raw_dialog.spacing_z->value(), - raw_dialog.offset->value()) ) - { - status_message(tr("File %1 successfully opened.").arg(filename)); - QSettings settings; - settings.beginGroup(QUrl::toPercentEncoding(fileinfo.absoluteFilePath())); - settings.setValue("is_raw", true); - settings.setValue("dim_x", raw_dialog.dim_x->value()); - settings.setValue("dim_y", raw_dialog.dim_y->value()); - settings.setValue("dim_z", raw_dialog.dim_z->value()); - settings.setValue("spacing_x", raw_dialog.spacing_x->value()); - settings.setValue("spacing_y", raw_dialog.spacing_y->value()); - settings.setValue("spacing_z", raw_dialog.spacing_z->value()); - settings.setValue("offset", raw_dialog.offset->value()); - settings.endGroup(); - finish_open(); - return true; - } - } - } - } - status_message(tr("Opening of file %1 failed!").arg(filename)); - return false; -} - -void Volume::finish_open() -{ - m_image.finish_open(); - mw->viewer->camera()->setSceneBoundingBox(CGAL::qglviewer::Vec(0, 0, 0), - CGAL::qglviewer::Vec(m_image.xmax(), - m_image.ymax(), - m_image.zmax())); - - mw->viewer->showEntireScene(); - values_list->load_values(fileinfo.absoluteFilePath()); - load_image_settings(fileinfo.absoluteFilePath()); - changed_parameters(); - Q_EMIT changed(); -} - -void Volume::export_off() -{ - QFileDialog filedialog(mw, tr("Export surface to file")); - filedialog.setFileMode(QFileDialog::AnyFile); - - filedialog.setNameFilter(tr("OFF files (*.off);;" - "All files (*)")); - - filedialog.setAcceptMode(QFileDialog::AcceptSave); - filedialog.setDefaultSuffix("off"); - if(filedialog.exec()) - { - const QString filename = filedialog.selectedFiles().front(); - std::cerr << "Saving to file \"" << filename.toLocal8Bit().data() << "\"..."; - std::ofstream out(filename.toUtf8()); - CGAL::output_surface_facets_to_off(out, c2t3); - if(!out) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Export to the OFF file %1 failed!").arg(filename)); - status_message(tr("Export to the OFF file %1 failed!").arg(filename)); - std::cerr << " failed!\n"; - } - else - { - std::cerr << " done.\n"; - status_message(tr("Successfull export to the OFF file %1.").arg(filename)); - } - } -} - -void Volume::save_image_to_inr() -{ - QFileDialog filedialog(mw, tr("Export image to Inrimage format")); - filedialog.setFileMode(QFileDialog::AnyFile); - - filedialog.setNameFilter(tr("Inrimage files (*.inr);;" - "Compressed Inrimage files (*.inr.gz)")); - - - filedialog.setAcceptMode(QFileDialog::AcceptSave); - filedialog.setDefaultSuffix("inr.gz"); - if(filedialog.exec()) - { - const QString filename = filedialog.selectedFiles().front(); - std::cerr << "Saving image to file \"" << filename.toLocal8Bit().data() << "\"..."; - const int result = ::_writeImage(m_image.image(), filename.toUtf8()); - if(result != ImageIO_NO_ERROR) - { - QMessageBox::warning(mw, mw->windowTitle(), - tr("Export to the Inrimage file %1 failed!").arg(filename)); - status_message(tr("Export to the Inrimage file %1 failed!").arg(filename)); - std::cerr << " failed!\n"; - } - else - { - std::cerr << " done.\n"; - status_message(tr("Successfull export to the Inrimage file %1.").arg(filename)); - } - } -} - -void Volume::check_can_export_off() -{ - mw->actionExport_surface_mesh_to_OFF->setEnabled(m_view_surface);// || m_view_mc); -} - -void Volume::status_message(QString string) -{ - std::cerr << qPrintable(string) << std::endl; - mw->statusBar()->showMessage(string); -} - -void Volume::busy() const -{ - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -} - -void Volume::not_busy() const -{ - QApplication::restoreOverrideCursor(); -} - -void Volume::display_marchin_cube() -{ -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - if(m_surface_mc.empty()) - { - QElapsedTimer total_time; - total_time.start(); - - values_list->save_values(fileinfo.absoluteFilePath()); - - unsigned int nx = m_image.xdim(); - unsigned int ny = m_image.ydim(); - unsigned int nz = m_image.zdim(); - if(nx * ny * nz == 0) - { - status_message("No volume loaded."); - return; - } - - mc_timer.reset(); - busy(); - status_message("Marching cubes..."); - - mc_timer.start(); - m_surface_mc.clear(); - - if(mc.ntrigs()!=0) - mc.clean_all(); - mc.set_resolution(nx,ny,nz); - mc.init_all(); - mc.set_ext_data(static_cast(m_image.image()->data)); - - nbs_of_mc_triangles.resize(values_list->numberOfValues()); - - for(int value_id = 0; - value_id < values_list->numberOfValues(); - ++value_id) - { - status_message(tr("Marching cubes, isovalue #%1...").arg(value_id)); - - // set data -// for(unsigned int i=0;i 0) - mc.init_temps(); - mc.run(values_list->value(value_id), - m_image.vx(), - m_image.vy(), - m_image.vz()); - mc.clean_temps(); - - std::vector facets; - mc.get_facets(facets); - - mc_timer.stop(); - const unsigned int begin = value_id == 0 ? 0 : nbs_of_mc_triangles[value_id-1]; - const unsigned int nbt = facets.size() / 9; - for(unsigned int i=begin;iitem(value_id))); - } - nbs_of_mc_triangles[value_id]=m_surface_mc.size(); - mc_timer.start(); - } - mc_timer.stop(); - not_busy(); - mc_total_time = total_time.elapsed(); - - // invalidate the display list - lists_draw_surface_mc_is_valid = false; - list_draw_marching_cube_is_valid = false; - } - CGAL::Bbox_3 bbox(0,0,0,0,0,0); - for(std::vector::const_iterator - it = m_surface_mc.begin(), end = m_surface_mc.end(); - it != end; ++it) - { - bbox = bbox + it->get<0>().bbox(); - } - - m_view_mc = true; - m_view_surface = false; - Q_EMIT changed(); - if(!m_surface_mc.empty()) - { - Q_EMIT new_bounding_box(bbox.xmin(), - bbox.ymin(), - bbox.zmin(), - bbox.xmax(), - bbox.ymax(), - bbox.zmax()); - } - status_message(tr("Marching cubes done. %2 facets in %1s (CPU time), total time is %3s.") - .arg(mc_timer.time()) - .arg(m_surface_mc.size()) - .arg(mc_total_time/1000.)); - - save_image_settings(fileinfo.absoluteFilePath()); -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE -} - -void Volume::display_surface_mesher_result() -{ - if(m_surface.empty() || // Either the surface is not computed. - m_view_surface) // Or it is computed and displayed, and one want - // to recompute it. - { - QElapsedTimer total_time; - total_time.start(); - - values_list->save_values(fileinfo.absoluteFilePath()); - - std::size_t nx = m_image.xdim(); - std::size_t ny = m_image.ydim(); - std::size_t nz = m_image.zdim(); - if(nx * ny * nz == 0) - { - status_message("No volume loaded."); - return; - } - - m_surface.clear(); - sm_timer.reset(); - busy(); - - status_message("Surface meshing..."); - - sm_timer.start(); - - c2t3.clear(); - del.clear(); - Sphere bounding_sphere(m_image.center(),m_image.radius()*m_image.radius()); - - Classify_from_isovalue_list classify(values_list); - Generate_surface_identifiers generate_ids(values_list); - - m_image.set_interpolation(mw->interpolationCheckBox->isChecked()); - if(mw->labellizedRadioButton->isChecked()) { - std::cerr << "Labellized image\n"; - } - m_image.set_labellized(mw->labellizedRadioButton->isChecked()); - classify.set_identity(mw->labellizedRadioButton->isChecked()); - generate_ids.set_labellized_image(mw->labellizedRadioButton->isChecked()); - - // definition of the surface - Surface_3 surface(m_image, bounding_sphere, m_relative_precision); -// Threshold threshold(m_image.isovalue()); - - // surface mesh traits class - typedef CGAL::Surface_mesher::Implicit_surface_oracle_3 Oracle; - Oracle oracle(classify, generate_ids); - - if(mw->searchSeedsCheckBox->isChecked()) - { - typedef std::vector > Seeds; - Seeds seeds; - { - std::cerr << "Search seeds...\n"; - std::set domains; - search_for_connected_components(std::back_inserter(seeds), - CGAL::inserter(domains), - classify); - std::cerr << "Found " << seeds.size() << " seed(s).\n"; - - if(mw->labellizedRadioButton->isChecked() && - values_list->numberOfValues() == 0) - { - Q_FOREACH(unsigned char label, domains) { - if(label != 0) { - values_list->addValue(label); - } - } - } - } - std::ofstream seeds_out("seeds.off"); - std::ofstream segments_out("segments.txt"); - seeds_out.precision(18); - seeds_out << "OFF\n" << seeds.size() << " 0 0\n"; - segments_out.precision(18); - for(Seeds::const_iterator it = seeds.begin(), end = seeds.end(); - it != end; ++it) - { - seeds_out << it->first << std::endl; - CGAL::Random_points_on_sphere_3 random_points_on_sphere_3(it->second); - Oracle::Intersect_3 intersect = oracle.intersect_3_object(); - for(int i = 0; i < 20; ++i) - { - const Point_3 test = it->first + (*random_points_on_sphere_3++ - CGAL::ORIGIN); - CGAL::Object o = intersect(surface, Segment_3(it->first, test)); - if (const Point_3* intersection = CGAL::object_cast(&o)) { - segments_out << "2 " << it->first << " " << *intersection << std::endl; - del.insert(*intersection); - } - else - { - std::cerr << - boost::format("Error. Segment (%1%, %2%) does not intersect the surface! values=(%3%, %4%)\n") - % it->first % test - % surface(it->first) % surface(test); - } - } - } - } - else { - oracle.construct_initial_points_object()(surface, - CGAL::inserter(c2t3.triangulation()), - 20); - } - - std::ofstream points_out("initial-points.off"); - points_out.precision(18); - points_out << "OFF\n" << c2t3.triangulation().number_of_vertices() << " 0 0\n"; - for(const Tr::Vertex& v : - CGAL::make_range(c2t3.triangulation().vertices_begin(), - c2t3.triangulation().vertices_end())) - { - points_out << v.point() << std::endl; - } - - std::cerr << boost::format("Number of initial points: %1%\n") % del.number_of_vertices(); - - // defining meshing criteria - typedef CGAL::Surface_mesher::Refine_criterion Criterion; - CGAL::Surface_mesher::Curvature_size_criterion - curvature_size_criterion (m_sm_distance); - CGAL::Surface_mesher::Uniform_size_criterion - uniform_size_criterion (m_sm_radius); - CGAL::Surface_mesher::Aspect_ratio_criterion - aspect_ratio_criterion (m_sm_angle); - CGAL::Surface_mesher::Vertices_on_the_same_psc_element_criterion - vertices_on_the_same_psc_element_criterion(surface); - - std::vector criterion_vector; - criterion_vector.push_back(&aspect_ratio_criterion); - criterion_vector.push_back(&uniform_size_criterion); - criterion_vector.push_back(&curvature_size_criterion); - if(mw->sameIndexCheckBox->isChecked()) { - criterion_vector.push_back(&vertices_on_the_same_psc_element_criterion); - std::cerr << "vertices_on_the_same_psc_element_criterion is activated.\n"; - } - - typedef CGAL::Surface_mesher::Standard_criteria Criteria; - Criteria criteria(criterion_vector); - std::cerr << "Surface_mesher... angle=" << m_sm_angle << ", radius= " << m_sm_radius - << ", distance=" << m_sm_distance << "\n"; - - typedef CGAL::Surface_mesher_generator::type Surface_mesher_manifold; - - typedef CGAL::Surface_mesher_generator::type Surface_mesher_non_manifold; - - if(mw->manifoldCheckBox->isChecked()) { - // meshing surface - std::cerr << "manifold criteria is activated.\n"; -// make_surface_mesh(c2t3, surface, oracle, criteria, -// CGAL::Manifold_tag(), 0); - Surface_mesher_manifold manifold_mesher(c2t3, surface, oracle, criteria); - manifold_mesher.refine_mesh(); - } - else { -// m_view_surface = true; - Surface_mesher_non_manifold non_manifold_mesher(c2t3, surface, oracle, criteria); -#if 0 - int nb_steps = 0; -// direct_draw = true; - non_manifold_mesher.init(); - while(!non_manifold_mesher.is_algorithm_done()) { - CGAL::Null_mesh_visitor null_visitor; - non_manifold_mesher.one_step(null_visitor); - if(++nb_steps % 1000 == 0) { - CGAL::Timer timer; - std::cerr << "(process events..."; - timer.start(); - list_draw_marching_cube_is_valid = false; - lists_draw_surface_is_valid = false; - for(Tr::Finite_cells_iterator - cit = del.finite_cells_begin(), - end = del.finite_cells_end(); - cit != end; ++cit) - { - cit->info() = classify(surface(cit->circumcenter())); - } -// Q_EMIT changed(); - qApp->processEvents(); - timer.stop(); - std::cerr << timer.time() << " secondes)\n"; - } - } -#else - non_manifold_mesher.refine_mesh(); -#endif - } - sm_timer.stop(); - not_busy(); - direct_draw = false; - - for(Tr::Finite_cells_iterator - cit = del.finite_cells_begin(), - end = del.finite_cells_end(); - cit != end; ++cit) - { - cit->info() = classify(surface(cit->circumcenter())); - } - // get output surface - for(C2t3::Facet_iterator - fit = c2t3.facets_begin(), end = c2t3.facets_end(); - fit != end; ++fit) - { - const Tr::Cell_handle& cell = fit->first; - const int index = fit->second; - - // here "left" means nothing - const Point_3 left_circumcenter = cell->circumcenter(); - const Point_3 right_circumcenter = cell->neighbor(index)->circumcenter(); - - const Triangle_3 t = - Triangle_3(cell->vertex(del.vertex_triple_index(index, 0))->point(), - cell->vertex(del.vertex_triple_index(index, 1))->point(), - cell->vertex(del.vertex_triple_index(index, 2))->point()); - const Vector u = t[1] - t[0]; - const Vector v = t[2] - t[0]; - Vector n = CGAL::cross_product(u,v); - n = n / std::sqrt(n*n); - if(mw->labellizedRadioButton->isChecked()) - { - m_surface.push_back(Facet_(t, - n, - values_list->search((std::max)(surface(left_circumcenter), - surface(right_circumcenter))))); - } - else { - m_surface.push_back(Facet_(t,n,cell->vertex(del.vertex_triple_index(index, 0))->point().element_index())); - } - } - - // invalidate the display list - lists_draw_surface_is_valid = false; - sm_total_time = total_time.elapsed(); - } - - CGAL::Bbox_3 bbox(0,0,0,0,0,0); - for(std::vector::const_iterator - it = m_surface.begin(), end = m_surface.end(); - it != end; ++it) - { - bbox = bbox + it->get<0>().bbox(); - } - - // toggle visualization - m_view_mc = false; - m_view_surface = true; - Q_EMIT changed(); - if(!m_surface.empty()) - { - Q_EMIT new_bounding_box(bbox.xmin(), - bbox.ymin(), - bbox.zmin(), - bbox.xmax(), - bbox.ymax(), - bbox.zmax()); - } - status_message(tr("Surface meshing done. %1 facets in %2s (CPU time), total time is %3s.") - .arg(m_surface.size()) - .arg(sm_timer.time()) - .arg(sm_total_time/1000.)); - save_image_settings(fileinfo.absoluteFilePath()); -} - -void Volume::gl_draw_image_bbox(const float line_width, - const unsigned char red, - const unsigned char green, - const unsigned char blue) -{ - const _image* image_ptr = m_image.image(); - if(image_ptr == NULL) - return; - - glLineWidth(line_width); - glColor3ub(red,green,blue); - glBegin(GL_LINES); - - const double xmax = (image_ptr->xdim - 1.0)*(image_ptr->vx); - const double ymax = (image_ptr->ydim - 1.0)*(image_ptr->vy); - const double zmax = (image_ptr->zdim - 1.0)*(image_ptr->vz); - - glVertex3d(0.0,0.0,0.0); - glVertex3d(0.0,ymax,0.0); - - glVertex3d(0.0,ymax,0.0); - glVertex3d(0.0,ymax,zmax); - - glVertex3d(0.0,ymax,zmax); - glVertex3d(0.0,0.0,zmax); - - glVertex3d(0.0,0.0,zmax); - glVertex3d(0.0,0.0,0.0); - - glVertex3d(xmax,0.0,0.0); - glVertex3d(xmax,ymax,0.0); - - glVertex3d(xmax,ymax,0.0); - glVertex3d(xmax,ymax,zmax); - - glVertex3d(xmax,ymax,zmax); - glVertex3d(xmax,0.0,zmax); - - glVertex3d(xmax,0.0,zmax); - glVertex3d(xmax,0.0,0.0); - - glVertex3d(0.0,0.0,0.0); - glVertex3d(xmax,0.0,0.0); - - glVertex3d(0.0,0.0,zmax); - glVertex3d(xmax,0.0,zmax); - - glVertex3d(0.0,ymax,zmax); - glVertex3d(xmax,ymax,zmax); - - glVertex3d(0.0,ymax,0.0); - glVertex3d(xmax,ymax,0.0); - - glEnd(); -} - -void Volume::draw() -{ - float ambient[] = { 0.25f, - 0.20725f, - 0.20725f, - 0.922f }; - float diffuse[] = { 1.0f, - 0.829f, - 0.829f, - 0.922f }; - - float specular[] = { 0.296648f, - 0.296648f, - 0.296648f, - 0.522f }; - - float emission[] = { 0.3f, - 0.3f, - 0.3f, - 1.0f }; - float shininess[] = { 11.264f }; - - // apply - ::glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, ambient); - ::glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); - ::glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specular); - ::glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, shininess); - ::glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, emission); - - ::glEnable(GL_LINE_SMOOTH); - - if(two_sides) - ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); - else - ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); // default - - // draw surface mesh - if(m_view_surface) - { - ::glEnable(GL_LIGHTING); - ::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - ::glColor3f(0.2f, 0.2f, 1.f); - ::glEnable(GL_POLYGON_OFFSET_FILL); - ::glPolygonOffset(3.0f,-3.0f); - gl_draw_surface(); - - if(draw_triangles_edges) - { - ::glDisable(GL_LIGHTING); - ::glLineWidth(1.); - ::glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - ::glColor3ub(0,0,0); - ::glDisable(GL_POLYGON_OFFSET_FILL); - gl_draw_surface(); - } - } - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - // draw MC surface mesh - if(m_view_mc) - { - ::glEnable(GL_LIGHTING); - ::glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - ::glColor3f(0.2f, 0.2f, 1.f); - ::glEnable(GL_POLYGON_OFFSET_FILL); - ::glPolygonOffset(3.0f,-3.0f); - gl_draw_surface_mc(); - - if(draw_triangles_edges) - { - ::glDisable(GL_LIGHTING); - ::glLineWidth(1.); - ::glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - ::glColor3ub(0,0,0); - ::glDisable(GL_POLYGON_OFFSET_FILL); - gl_draw_surface_mc(); - } - } -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - - if(show_bbox) { - ::glDisable(GL_LIGHTING); - gl_draw_image_bbox(3.0f,0,0,0); - } - - if(!m_view_mc && m_draw_triangulation) - { - // draw the triangualtion - ::glColor3d(m_triangulation_color.redF(), - m_triangulation_color.greenF(), - m_triangulation_color.blueF()); - ::glLineWidth(1.0); - ::glBegin(GL_LINES); - for(Tr::Finite_edges_iterator - eit = del.finite_edges_begin(), - end = del.finite_edges_end(); - eit != end; ++eit) - { - const Point_3 p1 = eit->first->vertex(eit->second)->point(); - const Point_3 p2 = eit->first->vertex(eit->third)->point(); - ::glVertex3d(p1.x(),p1.y(),p1.z()); - ::glVertex3d(p2.x(),p2.y(),p2.z()); - } - ::glEnd(); - } -} - -void Volume::set_radius_bound(double d) -{ - m_sm_radius = FT(d); - changed_parameters(); -} - -void Volume::set_distance_bound(double d) -{ - m_sm_distance = FT(d); - changed_parameters(); -} - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE -void Volume::gl_draw_surface_mc() -{ - if(use_gouraud) - { - gl_draw_marchingcube(); - return; - } - - if(lists_draw_surface_mc_is_valid) - { - for(int i = 0, nbs = values_list->numberOfValues(); i < nbs; ++i ) - { - if(values_list->enabled(i)) - { - mw->viewer->qglColor(values_list->color(i)); - ::glCallList(lists_draw_surface_mc[i]); - } - } - } - else - { - lists_draw_surface_mc.resize(values_list->numberOfValues(), 0); - for(int i = 0, nbs = values_list->numberOfValues(); i < nbs; ++i ) - { - if(!lists_draw_surface_mc[i]) - { - lists_draw_surface_mc[i] = ::glGenLists(1); - } - - std::cerr << boost::format("(Re-)Generating list #%1% for marching cube surface #%2%" - " in gl_draw_surface(), ()\n") - % lists_draw_surface_mc[i] - % i; - - mw->viewer->qglColor(values_list->color(i)); - - if(lists_draw_surface_mc[i]) // If - ::glNewList(lists_draw_surface_mc[i], // lists_draw_surface[i]==0 then something - values_list->enabled(i) // got wrong in the list generation. - ? GL_COMPILE_AND_EXECUTE - : GL_COMPILE); - - - gl_draw_surface(m_surface_mc.begin(), - m_surface_mc.end(), - values_list->item(i)); - - if(lists_draw_surface_mc[i]) // If lists_draw_surface[i]==0 then - { // something got wrong in the list - ::glEndList(); // generation. - } - } - lists_draw_surface_mc_is_valid = (::glGetError() == GL_NO_ERROR); - } -} -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - -void Volume::gl_draw_surface() -{ -// if(mw->labellizedRadioButton->isChecked()) { -// mw->viewer->qglColor(::Qt::blue); -// gl_draw_surface(m_surface.begin(), -// m_surface.end(), -// 0); -// } -// else - if(direct_draw) { - ::glBegin(GL_TRIANGLES); - unsigned int counter = 0; - for(Tr::Finite_cells_iterator - cit = del.finite_cells_begin(), end = del.finite_cells_end(); - cit != end; ++cit) - { - for(int facet_index = 0; facet_index < 4; ++facet_index) - { - const Tr::Cell_handle& facet_cell = cit; - if(c2t3.face_status(facet_cell, facet_index) == C2t3::NOT_IN_COMPLEX) { - continue; - } - const Point_3& a = facet_cell->vertex(del.vertex_triple_index(facet_index, 0))->point(); - const Point_3& b = facet_cell->vertex(del.vertex_triple_index(facet_index, 1))->point(); - const Point_3& c = facet_cell->vertex(del.vertex_triple_index(facet_index, 2))->point(); - Vector n = CGAL::cross_product(b-a,c-a); - n = n / std::sqrt(n*n); // unit normal - if(m_inverse_normals) { - ::glNormal3d(-n.x(),-n.y(),-n.z()); - } else { - ::glNormal3d(n.x(),n.y(),n.z()); - } - ::glColor3d(values_list->color(values_list->search(facet_cell->info())).redF(), - values_list->color(values_list->search(facet_cell->info())).greenF(), - values_list->color(values_list->search(facet_cell->info())).blueF()); - ::glVertex3d(a.x(),a.y(),a.z()); - ::glVertex3d(b.x(),b.y(),b.z()); - ::glVertex3d(c.x(),c.y(),c.z()); - ++counter; - } - ::glEnd(); - } - return; - } - if(!direct_draw && lists_draw_surface_is_valid) - { - for(int i = 0, nbs = values_list->numberOfValues(); i < nbs; ++i ) - { - if(values_list->enabled(i)) - { - ::glColor3d(values_list->color(i).redF(), - values_list->color(i).greenF(), - values_list->color(i).blueF()); - ::glCallList(lists_draw_surface[i]); - } - } - } - else - { - lists_draw_surface.resize(values_list->numberOfValues(), 0); - for(int i = 0, nbs = values_list->numberOfValues(); i < nbs; ++i ) - { - if(!lists_draw_surface[i]) - { - lists_draw_surface[i] = ::glGenLists(1); - } - - std::cerr << boost::format("(Re-)Generating list #%1% for surface #%2%" - " in gl_draw_surface(), ()\n") - % lists_draw_surface[i] - % i; - - ::glColor3d(values_list->color(i).redF(), - values_list->color(i).greenF(), - values_list->color(i).blueF()); - - if(!direct_draw && lists_draw_surface[i]) // If - ::glNewList(lists_draw_surface[i], // lists_draw_surface[i]==0 - values_list->enabled(i) // then something got wrong - ? GL_COMPILE_AND_EXECUTE // in the list generation. - : GL_COMPILE); - - if(!mw->labellizedRadioButton->isChecked()) - { - gl_draw_surface(m_surface.begin(), - m_surface.end(), - values_list->item(i)); - } - else - { - const auto volume_index = static_cast(values_list->value(i)); - - ::glBegin(GL_TRIANGLES); - unsigned int counter = 0; - for(C2t3::Facet_iterator - fit = c2t3.facets_begin(), end = c2t3.facets_end(); - fit != end; ++fit) - { - Tr::Cell_handle facet_cell = fit->first; - int facet_index = fit->second; - Tr::Cell_handle opposite_cell = facet_cell->neighbor(facet_index); - int opposite_index = opposite_cell->index(facet_cell); - - if( facet_cell->info() != volume_index ) { - if( opposite_cell->info() == volume_index ) { - std::swap(facet_cell, opposite_cell); - std::swap(facet_index, opposite_index); - } - else - continue; // go to next facet - } - const Point_3& a = opposite_cell->vertex(del.vertex_triple_index(opposite_index, 0))->point(); - const Point_3& b = opposite_cell->vertex(del.vertex_triple_index(opposite_index, 1))->point(); - const Point_3& c = opposite_cell->vertex(del.vertex_triple_index(opposite_index, 2))->point(); - Vector n = CGAL::cross_product(b-a,c-a); - n = n / std::sqrt(n*n); // unit normal - if(m_inverse_normals) { - ::glNormal3d(-n.x(),-n.y(),-n.z()); - } else { - ::glNormal3d(n.x(),n.y(),n.z()); - } - ::glVertex3d(a.x(),a.y(),a.z()); - ::glVertex3d(b.x(),b.y(),b.z()); - ::glVertex3d(c.x(),c.y(),c.z()); - ++counter; - } - ::glEnd(); - std::cerr << boost::format("(c2t3) number of facets: %1%\n") - % counter; - } - - if(!direct_draw && lists_draw_surface[i]) - // If lists_draw_surface[i]==0 then - { // something got wrong in the list - ::glEndList(); // generation. - } - } - lists_draw_surface_is_valid = (::glGetError() == GL_NO_ERROR); - } -} - -template -void Volume::gl_draw_surface(Iterator begin, Iterator end, const QTreeWidgetItem* i) -{ - ::glBegin(GL_TRIANGLES); - unsigned int counter = 0; - for(Iterator it = begin; it != end; ++it) - { - const Facet_& f = *it; - - if(f.get<2>() != i) continue; - - const Vector& n = f.get<1>(); - - if(m_inverse_normals) - ::glNormal3d(-n.x(),-n.y(),-n.z()); - else - ::glNormal3d(n.x(),n.y(),n.z()); - - const Triangle_3& t = f.get<0>(); - const Point_3& a = t[0]; - const Point_3& b = t[1]; - const Point_3& c = t[2]; - - ::glVertex3d(a.x(),a.y(),a.z()); - ::glVertex3d(b.x(),b.y(),b.z()); - ::glVertex3d(c.x(),c.y(),c.z()); - ++counter; - } - ::glEnd(); - std::cerr << boost::format("number of facets: %1%\n") - % counter; -} - -void Volume::changed_parameters() -{ - m_surface.clear(); -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - m_surface_mc.clear(); -#endif - list_draw_marching_cube_is_valid = false; - lists_draw_surface_is_valid = false; - c2t3.clear(); - del.clear(); - m_view_mc = m_view_surface = false; - Q_EMIT changed(); -} - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE -void Volume::gl_draw_one_marching_cube_vertex(int i) -{ - if(!m_inverse_normals) - glArrayElement(i); - else - { - const Vertex* const vertex = mc.vert(i); - ::glNormal3d(-vertex->nx, -vertex->ny, -vertex->nz); - ::glVertex3d(vertex->x, vertex->y, vertex->z); - } -} - -void Volume::gl_draw_marchingcube() -{ - if(list_draw_marching_cube_is_valid) - ::glCallList(list_draw_marching_cube); - else - { - if(!list_draw_marching_cube) - list_draw_marching_cube = ::glGenLists(1); - std::cerr << boost::format("(Re-)Generating list #%1% for" - " gl_draw_marchingcube()\n") - % list_draw_marching_cube; - - if(list_draw_marching_cube) // If list_draw_marching_cube==0 then - ::glNewList(list_draw_marching_cube, // something got wrong in the list - GL_COMPILE_AND_EXECUTE); // generation. - - ::glVertexPointer(3, GL_DOUBLE, sizeof(Vertex), mc.vertices()); - ::glNormalPointer(GL_DOUBLE, sizeof(Vertex), &(mc.vertices()->nx)); - ::glEnableClientState(GL_VERTEX_ARRAY); - - // because of that conditionnal, the display list has to be - // reconstructed each time m_inverse_normals is toggled. - if(!m_inverse_normals) - ::glEnableClientState(GL_NORMAL_ARRAY); - - for(int i = 0, nbs = values_list->numberOfValues(); i < nbs; ++i) - { - const int begin = i == 0 ? 0 : nbs_of_mc_triangles[i-1]; - const int end = nbs_of_mc_triangles[i]; - mw->viewer->qglColor(values_list->color(i)); - ::glBegin(GL_TRIANGLES); - for(int i = begin; i < end; ++i) - { - const MC_Triangle* const trig = mc.trig(i); - gl_draw_one_marching_cube_vertex(trig->v1); - gl_draw_one_marching_cube_vertex(trig->v2); - gl_draw_one_marching_cube_vertex(trig->v3); - } - ::glEnd(); - } - if(list_draw_marching_cube > 0) // If list_draw_marching_cube==0 then - { // something got wrong in the list - ::glEndList(); // generation. - list_draw_marching_cube_is_valid = (::glGetError() == GL_NO_ERROR); - } - if(!list_draw_marching_cube_is_valid) - { - CGAL::Qt::opengl_check_errors(); - } - } -} -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - -void Volume::save_image_settings(QString filename) -{ - QSettings settings; - settings.beginGroup(QUrl::toPercentEncoding(filename)); - settings.setValue("labellized", mw->labellizedRadioButton->isChecked()); - settings.endGroup(); -} - -void Volume::load_image_settings(QString filename) -{ - QSettings settings; - settings.beginGroup(QUrl::toPercentEncoding(filename)); - mw->labellizedRadioButton->setChecked(settings.value("labellized").toBool()); - settings.endGroup(); -} - -void Volume::labellizedToogled(bool toggled) -{ - if(toggled) { - values_list->setHeaderTitle(tr("Label")); - } - else { - values_list->setHeaderTitle(tr("Iso-Value")); - } -} - diff --git a/Surface_mesher/demo/Surface_mesher/volume.h b/Surface_mesher/demo/Surface_mesher/volume.h deleted file mode 100644 index 09195f02d07..00000000000 --- a/Surface_mesher/demo/Surface_mesher/volume.h +++ /dev/null @@ -1,392 +0,0 @@ -#ifndef _VOLUME_H -#define _VOLUME_H - -#include -#include -#include - - -#include "surface.h" -#include "binary_image.h" - -#include -#include -#include -#include - -#include -#include -#include // std::back_inserter - -#include -#include - -#ifdef CGAL_USE_VTK -class vtkImageReader; -class vtkImageData; -class vtkDICOMImageReader; -class vtkDemandDrivenPipeline; -class vtkImageGaussianSmooth; -#endif // CGAL_USE_VTK - -class QTreeWidgetItem; - -// kernel -// #include -#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel1; - -#include -struct Kernel : public Kernel1 { - typedef CGAL::Point_with_psc_localisation Point_3; -}; - -typedef Kernel::FT FT; -typedef Kernel::Point_3 Point_3; -typedef Kernel::Sphere_3 Sphere; -typedef Kernel::Vector_3 Vector; -typedef Kernel::Triangle_3 Triangle_3; -typedef Kernel::Segment_3 Segment_3; - -// typedef CGAL::Triple Facet; - -typedef boost::tuple Facet_; - - -typedef CBinary_image_3 Binary_image; - -class QTreeWidgetItem; - -// surface mesher -// #define CGAL_MESHES_NO_OUTPUT -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef CGAL::Surface_mesh_vertex_base_3 Vb; -typedef CGAL::Triangulation_cell_base_with_info_3 Cb1; -typedef CGAL::Delaunay_triangulation_cell_base_3 Cb2; -typedef CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3 Cb3; -typedef CGAL::Surface_mesh_cell_base_3 Cb; -typedef CGAL::Triangulation_data_structure_3 Tds; -typedef CGAL::Delaunay_triangulation_3 Tr; -typedef CGAL::Surface_mesh_complex_2_in_triangulation_3 C2t3; -typedef CGAL::Implicit_surface_3 Surface_3; - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE -#include -#endif - -class MainWindow; -class QDoubleSpinBox; -class Viewer; -class Values_list; - -class Volume : public Surface -{ - Q_OBJECT -public: - Volume(MainWindow* mw); - ~Volume(); - -private: - Binary_image m_image; - - // options - FT m_sm_angle; - FT m_sm_radius; - FT m_sm_distance; - double m_relative_precision; - - // visualization - bool m_view_surface; - bool m_draw_triangulation; - QColor m_triangulation_color; - bool m_inverse_normals; - bool two_sides; - bool draw_triangles_edges; - bool use_gouraud; - bool show_bbox; - - std::vector m_surface; - Tr del; // 3D-Delaunay triangulation - C2t3 c2t3; // 2D complex in 3D triangulation - - MainWindow* mw; - QFileInfo fileinfo; - Values_list* values_list; - QDoubleSpinBox* spinBox_radius_bound; - QDoubleSpinBox* spinBox_distance_bound; - - bool direct_draw; // do not use display lists - std::vector lists_draw_surface; - bool lists_draw_surface_is_valid; - GLint list_draw_marching_cube; - bool list_draw_marching_cube_is_valid; - - CGAL::Timer sm_timer; - int sm_total_time; - -#ifdef CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - std::vector m_surface_mc; - MarchingCubes mc ; - std::vector nbs_of_mc_triangles; - std::vector lists_draw_surface_mc; - bool lists_draw_surface_mc_is_valid; - CGAL::Timer mc_timer; - int mc_total_time; -public: - void gl_draw_surface_mc(); - void gl_draw_marchingcube(); -private: - void gl_draw_one_marching_cube_vertex(int); - -#endif // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - - bool m_view_mc; // that boolean is here even with if - // CGAL_SURFACE_MESH_DEMO_USE_MARCHING_CUBE - // is not defined. - -#ifdef CGAL_USE_VTK - vtkImageReader* vtk_reader; - vtkImageData* vtk_image; - vtkDICOMImageReader* dicom_reader; - vtkDemandDrivenPipeline* executive; - vtkImageGaussianSmooth* smoother; -#endif // CGAL_USE_VTK - -public Q_SLOTS: -void display_marchin_cube(); - -private: - template - void gl_draw_surface(Iterator begin, Iterator end, const QTreeWidgetItem* = 0); - void gl_draw_image_bbox(const float line_width, - const unsigned char red, - const unsigned char green, - const unsigned char blue); - - template - void search_for_connected_components(PointsOutputIterator, - DomainsOutputIterator, - TransformOperator); - -public: - void gl_draw_surface(); - -Q_SIGNALS: - - void new_bounding_box(double, double, double, double, double, double); - -public Q_SLOTS: - void only_in(); - void set_inverse_normals(const bool); - void set_two_sides(const bool); - void set_draw_triangles_edges(const bool); - void set_triangulation_edges_color(); - void set_draw_triangulation(const bool); - void set_use_gouraud(const bool); - void set_show_bbox(const bool); - bool open(const QString& filename); -#ifdef CGAL_USE_VTK - bool open_vtk(const QString& filename); -#endif - bool open_xt(const QString& filename); - bool opendir(const QString& dirname); - void finish_open(); - void export_off(); - void save_image_to_inr(); - void check_can_export_off(); - void draw(); - void get_bbox(float& /*xmin*/, float& /*ymin*/, float& /*zmin*/, - float& /*xmax*/, float& /*ymax*/, float& /*zmax*/) {} - void close() {} - void display_surface_mesher_result(); - void set_radius_bound(double); - void set_distance_bound(double); - void changed_parameters(); - - void labellizedToogled(bool); - - void save_image_settings(QString); - void load_image_settings(QString); -private: - void status_message(QString); - void busy() const; - void not_busy() const; -}; - -template -void Volume::search_for_connected_components(PointsOutputIterator it, - DomainsOutputIterator dom_it, - TransformOperator transform) -{ - const std::size_t nx = m_image.xdim(); - const std::size_t ny = m_image.ydim(); - const std::size_t nz = m_image.zdim(); - - const double max_v = (std::max)((std::max)(m_image.vx(), - m_image.vy()), - m_image.vz()); - - typedef unsigned char Marker; - typedef typename TransformOperator::result_type Label; - - boost::multi_array visited(boost::extents[nx][ny][nz]); - typedef boost::tuple - Indices; - typedef std::queue Indices_queue; - typedef std::vector Border_vector; - - int number_of_connected_components = 0; - for(std::size_t i=0; i0) - continue; - const Label current_label = transform(m_image.value(i, j, k)); - *dom_it++ = current_label; - if(current_label == Label()) { - visited[i][j][k] = 3; - continue; - } - - // if we reach here, (i, j, k) is a new connected component - ++number_of_connected_components; - std::cerr << boost::format("Found new connected component (#%5%) " - "at voxel (%1%, %2%, %3%), value=%4%, volume id=%6%\n") - % i % j % k - % m_image.value(i, j, k) - % number_of_connected_components - % (int)current_label; - - int nb_voxels = 0; - - Indices_queue queue; - Indices indices(i, j ,k, 0); - queue.push(indices); - - Border_vector border; - - /* - * First pass is a BFS to retrieve all the connected component, and - * its border. - * Second pass is a BFS initialized with all voxel of the border. - * The last voxel of that BFS is used as the seed. - */ - Marker pass = 1; // pass will be equal to 2 in second pass - - Indices bbox_min = indices; - Indices bbox_max = indices; - - while(!queue.empty()) // walk through the connected component - { - Indices indices = queue.front(); - queue.pop(); - - // warning: those indices i, j and k are local to the while loop - const std::size_t i = boost::get<0>(indices); - const std::size_t j = boost::get<1>(indices); - const std::size_t k = boost::get<2>(indices); - const std::size_t depth = boost::get<3>(indices); - - if(visited[i][j][k] < pass) - { - visited[i][j][k] = pass; - if(pass == 1 ) - { - ++nb_voxels; - boost::get<0>(bbox_min) = (std::min)(i, boost::get<0>(bbox_min)); - boost::get<0>(bbox_max) = (std::max)(i, boost::get<0>(bbox_max)); - boost::get<1>(bbox_min) = (std::min)(j, boost::get<1>(bbox_min)); - boost::get<1>(bbox_max) = (std::max)(j, boost::get<1>(bbox_max)); - boost::get<2>(bbox_min) = (std::min)(k, boost::get<2>(bbox_min)); - boost::get<2>(bbox_max) = (std::max)(k, boost::get<2>(bbox_max)); - } - - static const int neighbors_offset[6][3] = { { +1, 0, 0 }, - { -1, 0, 0 }, - { 0, +1, 0 }, - { 0, -1, 0 }, - { 0, 0, +1 }, - { 0, 0, -1 } }; - bool voxel_is_on_border = false; - - // Visit neighbors. - // (i_n, j_n, k_n) are indices of neighbors. - for(int n = 0; n < 6; ++n) - { - const ptrdiff_t i_n = i + neighbors_offset[n][0]; - const ptrdiff_t j_n = j + neighbors_offset[n][1]; - const ptrdiff_t k_n = k + neighbors_offset[n][2]; - if(i_n < 0 || i_n >= static_cast(nx) || - j_n < 0 || j_n >= static_cast(ny) || - k_n < 0 || k_n >= static_cast(nz)) - { - voxel_is_on_border = true; - continue; - } - else - { - if(transform(m_image.value(i_n, j_n, k_n)) == current_label) - { - if(visited[i_n][j_n][k_n] < pass) { - Indices indices(i_n, j_n, k_n, depth+1); - queue.push(indices); - } - } - else - voxel_is_on_border = true; - } - } // end for neighbors - - if(pass == 1 && voxel_is_on_border) - border.push_back(indices); - } // end if voxel not already visited - - if(queue.empty()) { - if(pass == 1) - { // End of first pass. Begin second pass with the voxels of - // the border. - for(typename Border_vector::const_iterator - border_it = border.begin(), border_end = border.end(); - border_it != border_end; ++border_it) - queue.push(*border_it); - pass = 2; - } - else // end of second pass, return the last visited voxel - { -// if(nb_voxels >= 100) - { - *it++ = std::make_pair(m_image.point(i, j, k), (depth+1)*max_v); - std::cerr << boost::format("Found seed %5%, which is voxel (%1%, %2%, %3%), value=%4%\n") - % i % j % k % m_image.value(i, j, k) % m_image.point(i, j, k); - } - } - } // end if queue.empty() - } // end while !queue.empty() (with local indices i, j, k) - - std::cerr << boost::format("There was %1% voxel(s) in that component.\n" - "The bounding box is (%2% %3% %4%, %5% %6% %7%).\n" - "%8% voxel(s) on border\n") - % nb_voxels - % boost::get<0>(bbox_min) % boost::get<1>(bbox_min) % boost::get<2>(bbox_min) - % boost::get<0>(bbox_max) % boost::get<1>(bbox_max) % boost::get<2>(bbox_max) - % border.size(); - } // end for i,j,k -} // end function Volume::search_for_connected_components() - -#endif // _VOLUME_H diff --git a/Surface_mesher/doc/Surface_mesher/PackageDescription.txt b/Surface_mesher/doc/Surface_mesher/PackageDescription.txt index 90efa88c31c..bf46b3a6eba 100644 --- a/Surface_mesher/doc/Surface_mesher/PackageDescription.txt +++ b/Surface_mesher/doc/Surface_mesher/PackageDescription.txt @@ -38,7 +38,6 @@ \cgalPkgDependsOn{\ref PkgTriangulation3} \cgalPkgBib{cgal:ry-smg} \cgalPkgLicense{\ref licensesGPL} -\cgalPkgDemo{Surface Mesh Generator,surface_mesher.zip} \cgalPkgShortInfoEnd \cgalPkgDescriptionEnd