mirror of https://github.com/CGAL/cgal
- Rename several actions, to remove all "_" in their names.
- Add several "&" in action texts.
- NEW files:
- "Polyhedron_type.h" defines the Kernel and Polyhedron types,
- "Polyhedron_type_fwd.h" can be used for a forward declaration of the
type "Polyhedron".
- New functions in Scene:
int selectionAndex();
int selectionBindex();
Boolean operations now use those functions to get the indices of the
polyhedra.
- The Exact_polyhedron is now only defined in
MainWindow_boolean_operations.cp, to reduce compilation times.
- The min/max problem is handled better, in MainWindow_pca.cpp (quote the
macros with () instead of using #undef).
- MainWindow_simplify.cpp now works!!
- Scene.h and Scene.cpp has been splitted in several parts, to decrease
compilation times:
- Scene_rendering.h declares:
void gl_render_facets(Polyhedron* poly);
void gl_render_edges(Polyhedron *poly);
- Scene_rendering.cpp defines those two functions by using
<CGAL/gl_render.h>
- Scene_polyhedron_operations.cpp contains operations that
create/delete/load/save polyhedra.
That way, Scene.h and Scene.cpp are CGAL-agnostic.
This commit is contained in:
parent
96a229ad3c
commit
c5654c95e3
|
|
@ -237,6 +237,8 @@ Optimisation_doc/doc_ps
|
||||||
Polyhedron/demo/Polyhedron/*.cpp_parameters
|
Polyhedron/demo/Polyhedron/*.cpp_parameters
|
||||||
Polyhedron/demo/Polyhedron/*.dir
|
Polyhedron/demo/Polyhedron/*.dir
|
||||||
Polyhedron/demo/Polyhedron/*.exe
|
Polyhedron/demo/Polyhedron/*.exe
|
||||||
|
Polyhedron/demo/Polyhedron/*.ii
|
||||||
|
Polyhedron/demo/Polyhedron/*.s
|
||||||
Polyhedron/demo/Polyhedron/*.sln
|
Polyhedron/demo/Polyhedron/*.sln
|
||||||
Polyhedron/demo/Polyhedron/*.ui
|
Polyhedron/demo/Polyhedron/*.ui
|
||||||
Polyhedron/demo/Polyhedron/*.vcproj
|
Polyhedron/demo/Polyhedron/*.vcproj
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ endif(COMMAND cmake_policy)
|
||||||
|
|
||||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||||
|
|
||||||
foreach(INCDIR ./include ../../../GraphicsView/include)
|
foreach(INCDIR ./include ../../../GraphicsView/include ../../../Nef_3/include)
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR})
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR})
|
||||||
include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR})
|
include_directories (BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -52,7 +52,19 @@ add_file_dependencies( Scene_moc.cpp Scene.h )
|
||||||
|
|
||||||
qt4_add_resources ( RESOURCE_FILES Polyhedron_3.qrc )
|
qt4_add_resources ( RESOURCE_FILES Polyhedron_3.qrc )
|
||||||
|
|
||||||
add_executable ( Polyhedron_3 MainWindow_moc.cpp Scene_moc.cpp Viewer_moc.cpp main.cpp Viewer.cpp ${UI_FILES} ${RESOURCE_FILES} )
|
add_executable ( Polyhedron_3 MainWindow.cpp
|
||||||
|
MainWindow_boolean_operations.cpp
|
||||||
|
main.cpp
|
||||||
|
Viewer.cpp
|
||||||
|
Scene.cpp
|
||||||
|
Scene_polyhedron_operations.cpp
|
||||||
|
Scene_rendering.cpp
|
||||||
|
|
||||||
|
MainWindow_moc.cpp
|
||||||
|
Scene_moc.cpp
|
||||||
|
Viewer_moc.cpp
|
||||||
|
|
||||||
|
${UI_FILES} ${RESOURCE_FILES} )
|
||||||
|
|
||||||
# Link with Qt libraries
|
# Link with Qt libraries
|
||||||
target_link_libraries( Polyhedron_3 ${QT_LIBRARIES} )
|
target_link_libraries( Polyhedron_3 ${QT_LIBRARIES} )
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ void MainWindow::on_actionLoadPolyhedron_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionSave_as_triggered()
|
void MainWindow::on_actionSaveAs_triggered()
|
||||||
{
|
{
|
||||||
if(!onePolygonIsSelected())
|
if(!onePolygonIsSelected())
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,9 @@
|
||||||
class QDragEnterEvent;
|
class QDragEnterEvent;
|
||||||
class QDropEvent;
|
class QDropEvent;
|
||||||
class Scene;
|
class Scene;
|
||||||
struct Polyhedron;
|
|
||||||
|
#include "Polyhedron_type_fwd.h"
|
||||||
|
// #include "Scene.h"
|
||||||
|
|
||||||
class MainWindow :
|
class MainWindow :
|
||||||
public CGAL::Qt::DemosMainWindow,
|
public CGAL::Qt::DemosMainWindow,
|
||||||
|
|
@ -18,10 +20,6 @@ class MainWindow :
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget* parent = 0);
|
MainWindow(QWidget* parent = 0);
|
||||||
|
|
||||||
enum { BOOLEAN_UNION,
|
|
||||||
BOOLEAN_INTERSECTION,
|
|
||||||
BOOLEAN_DIFFERENCE};
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateViewerBBox();
|
void updateViewerBBox();
|
||||||
void open(QString filename);
|
void open(QString filename);
|
||||||
|
|
@ -43,7 +41,7 @@ protected slots:
|
||||||
|
|
||||||
// save
|
// save
|
||||||
// TODO: save all, save current (do we store the current file name?)
|
// TODO: save all, save current (do we store the current file name?)
|
||||||
void on_actionSave_as_triggered(); // save selected polyhedron as...
|
void on_actionSaveAs_triggered(); // save selected polyhedron as...
|
||||||
|
|
||||||
// merge (TODO)
|
// merge (TODO)
|
||||||
|
|
||||||
|
|
@ -66,20 +64,23 @@ protected slots:
|
||||||
void on_actionIntersection_triggered();
|
void on_actionIntersection_triggered();
|
||||||
void on_actionDifference_triggered();
|
void on_actionDifference_triggered();
|
||||||
|
|
||||||
// curvature estimation
|
// curvature estimation, in MainWindow_curvature_estimation.cpp
|
||||||
void on_actionEstimateCurvature_triggered();
|
void on_actionEstimateCurvature_triggered();
|
||||||
|
|
||||||
// PCA
|
// PCA, in MainWindow_pca.cpp
|
||||||
void on_actionFitPlane_triggered();
|
void on_actionFitPlane_triggered();
|
||||||
void on_actionFitLine_triggered();
|
void on_actionFitLine_triggered();
|
||||||
|
|
||||||
// self intersection
|
// self intersection, in MainWindow_self_intersection.cpp
|
||||||
void on_actionSelf_intersection_triggered();
|
void on_actionSelfIntersection_triggered();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void boolean_operation(const int operation);
|
enum Boolean_operation { BOOLEAN_UNION,
|
||||||
|
BOOLEAN_INTERSECTION,
|
||||||
|
BOOLEAN_DIFFERENCE };
|
||||||
|
// define in MainWindow_boolean_operations.cpp
|
||||||
|
void boolean_operation(const Boolean_operation operation);
|
||||||
|
|
||||||
protected:
|
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>24</y>
|
<y>29</y>
|
||||||
<width>978</width>
|
<width>978</width>
|
||||||
<height>548</height>
|
<height>540</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" >
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>22</y>
|
<y>23</y>
|
||||||
<width>354</width>
|
<width>354</width>
|
||||||
<height>508</height>
|
<height>499</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2" >
|
<layout class="QGridLayout" name="gridLayout_2" >
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>978</width>
|
<width>978</width>
|
||||||
<height>24</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile" >
|
<widget class="QMenu" name="menuFile" >
|
||||||
|
|
@ -131,11 +131,11 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionLoadPolyhedron" />
|
<addaction name="actionLoadPolyhedron" />
|
||||||
<addaction name="actionErasePolyhedron" />
|
<addaction name="actionErasePolyhedron" />
|
||||||
<addaction name="actionErase_all" />
|
<addaction name="actionEraseAll" />
|
||||||
<addaction name="actionDuplicatePolyhedron" />
|
<addaction name="actionDuplicatePolyhedron" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="actionMerge_all" />
|
<addaction name="actionMergeAll" />
|
||||||
<addaction name="actionSave_as" />
|
<addaction name="actionSaveAs" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="actionQuit" />
|
<addaction name="actionQuit" />
|
||||||
</widget>
|
</widget>
|
||||||
|
|
@ -156,7 +156,7 @@
|
||||||
<addaction name="actionFitPlane" />
|
<addaction name="actionFitPlane" />
|
||||||
<addaction name="actionFitLine" />
|
<addaction name="actionFitLine" />
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionSelf_intersection" />
|
<addaction name="actionSelfIntersection" />
|
||||||
<addaction name="menu_Principale_components_analysis" />
|
<addaction name="menu_Principale_components_analysis" />
|
||||||
<addaction name="actionEstimateCurvature" />
|
<addaction name="actionEstimateCurvature" />
|
||||||
</widget>
|
</widget>
|
||||||
|
|
@ -210,9 +210,9 @@
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>572</y>
|
<y>569</y>
|
||||||
<width>978</width>
|
<width>978</width>
|
||||||
<height>22</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
@ -312,7 +312,7 @@
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Antialiasing</string>
|
<string>&Antialiasing</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="shortcut" >
|
<property name="shortcut" >
|
||||||
<string>Ctrl+A</string>
|
<string>Ctrl+A</string>
|
||||||
|
|
@ -325,72 +325,67 @@
|
||||||
</action>
|
</action>
|
||||||
<action name="actionConvexHull" >
|
<action name="actionConvexHull" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Convex hull</string>
|
<string>&Convex hull</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionErase_all" >
|
<action name="actionEraseAll" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Erase all</string>
|
<string>&Erase all</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionOptions" >
|
<action name="actionOptions" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Options...</string>
|
<string>&Options...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionLoop" >
|
<action name="actionLoop" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Loop</string>
|
<string>&Loop</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave_as" >
|
<action name="actionSaveAs" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Save as...</string>
|
<string>Save &as...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave" >
|
<action name="actionSave" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Save</string>
|
<string>&Save</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave_all" >
|
<action name="actionSaveAll" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Save all</string>
|
<string>Save a&ll</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionMerge_all" >
|
<action name="actionMergeAll" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Merge all</string>
|
<string>Mer&ge all</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionMerge" >
|
<action name="actionMerge" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Merge</string>
|
<string>&Merge</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSelf_intersection" >
|
<action name="actionSelfIntersection" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Self-intersection</string>
|
<string>Self-&intersection</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSelections" >
|
<action name="actionSelectAll" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Selections</string>
|
<string>Select &all</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSelect_all" >
|
<action name="actionSelectNone" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Select all</string>
|
<string>Select &none</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSelect_none" >
|
<action name="actionSelectInvert" >
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>Select none</string>
|
<string>&Invert selection</string>
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSelect_invert" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Invert selection</string>
|
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,17 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
#include "Polyhedron_type.h"
|
||||||
|
|
||||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||||
#include <CGAL/Nef_polyhedron_3.h>
|
#include <CGAL/Nef_polyhedron_3.h>
|
||||||
|
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
// Boolean operations work only with exact kernel
|
||||||
|
typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_Kernel;
|
||||||
|
typedef CGAL::Polyhedron_3<Exact_Kernel> Exact_polyhedron;
|
||||||
|
|
||||||
// quick hacks to convert polyhedra from exact to inexact and vice-versa
|
// quick hacks to convert polyhedra from exact to inexact and vice-versa
|
||||||
|
|
||||||
|
|
@ -39,22 +48,18 @@ void MainWindow::on_actionDifference_triggered()
|
||||||
boolean_operation(BOOLEAN_DIFFERENCE);
|
boolean_operation(BOOLEAN_DIFFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::boolean_operation(const int operation)
|
void MainWindow::boolean_operation(const Boolean_operation operation)
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
// PA: to be done by LR?
|
const int indexA = scene->selectionAindex();
|
||||||
//int indexA = scene->getPolygonAIndex();
|
const int indexB = scene->selectionBindex();
|
||||||
//int indexB = scene->getPolygonBIndex();
|
|
||||||
|
|
||||||
// to remove
|
|
||||||
int indexA = 0;
|
|
||||||
int indexB = 1;
|
|
||||||
|
|
||||||
Polyhedron* polyA = scene->polyhedron(indexA);
|
Polyhedron* polyA = scene->polyhedron(indexA);
|
||||||
Polyhedron* polyB = scene->polyhedron(indexB);
|
Polyhedron* polyB = scene->polyhedron(indexB);
|
||||||
if(!polyA) return;
|
if(!polyA) return;
|
||||||
if(!polyB) return;
|
if(!polyB) return;
|
||||||
|
if(polyA == polyB) return;
|
||||||
|
|
||||||
typedef CGAL::Nef_polyhedron_3<Exact_Kernel> Nef_polyhedron;
|
typedef CGAL::Nef_polyhedron_3<Exact_Kernel> Nef_polyhedron;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
#include "Polyhedron_type.h"
|
||||||
#include <CGAL/Monge_via_jet_fitting.h>
|
#include <CGAL/Monge_via_jet_fitting.h>
|
||||||
#include <CGAL/Make_quad_soup.h>
|
#include <CGAL/Make_quad_soup.h>
|
||||||
|
#include <CGAL/compute_normal.h>
|
||||||
|
|
||||||
void MainWindow::on_actionEstimateCurvature_triggered()
|
void MainWindow::on_actionEstimateCurvature_triggered()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
#include "Polyhedron_type.h"
|
||||||
#include <CGAL/centroid.h>
|
#include <CGAL/centroid.h>
|
||||||
#include <CGAL/bounding_box.h>
|
#include <CGAL/bounding_box.h>
|
||||||
#include <CGAL/linear_least_squares_fitting_3.h>
|
#include <CGAL/linear_least_squares_fitting_3.h>
|
||||||
#include <CGAL/Make_quad_soup.h> // for plane fitting
|
#include <CGAL/Make_quad_soup.h> // for plane fitting
|
||||||
#include <CGAL/Make_bar.h> // for line fitting
|
#include <CGAL/Make_bar.h> // for line fitting
|
||||||
|
|
||||||
// for Visual C++ (which defines min/max macros)
|
|
||||||
#undef min
|
|
||||||
#undef max
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionFitPlane_triggered()
|
void MainWindow::on_actionFitPlane_triggered()
|
||||||
{
|
{
|
||||||
if(onePolygonIsSelected())
|
if(onePolygonIsSelected())
|
||||||
|
|
@ -47,8 +43,8 @@ void MainWindow::on_actionFitPlane_triggered()
|
||||||
Iso_cuboid bbox = CGAL::bounding_box(pMesh->points_begin(),pMesh->points_end());
|
Iso_cuboid bbox = CGAL::bounding_box(pMesh->points_begin(),pMesh->points_end());
|
||||||
|
|
||||||
// compute scale for rendering using diagonal of bbox
|
// compute scale for rendering using diagonal of bbox
|
||||||
Point cmin = bbox.min();
|
Point cmin = (bbox.min)();
|
||||||
Point cmax = bbox.max();
|
Point cmax = (bbox.max)();
|
||||||
FT diag = std::sqrt(CGAL::squared_distance(cmin,cmax));
|
FT diag = std::sqrt(CGAL::squared_distance(cmin,cmax));
|
||||||
Vector u1 = plane.base1();
|
Vector u1 = plane.base1();
|
||||||
u1 = u1 / std::sqrt(u1*u1);
|
u1 = u1 / std::sqrt(u1*u1);
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include <CGAL/self_intersect.h>
|
#include <CGAL/self_intersect.h>
|
||||||
#include <CGAL/Make_triangle_soup.h>
|
#include <CGAL/Make_triangle_soup.h>
|
||||||
|
|
||||||
void MainWindow::on_actionSelf_intersection_triggered()
|
void MainWindow::on_actionSelfIntersection_triggered()
|
||||||
{
|
{
|
||||||
if(onePolygonIsSelected())
|
if(onePolygonIsSelected())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,13 @@ void MainWindow::on_actionSimplify_triggered()
|
||||||
Polyhedron* pMesh = scene->polyhedron(index);
|
Polyhedron* pMesh = scene->polyhedron(index);
|
||||||
|
|
||||||
// simplify
|
// simplify
|
||||||
unsigned int nb_edges = 1000; // TODO: should be an option
|
const unsigned int nb_edges = 1000; // TODO: should be an option
|
||||||
namespace SMS = CGAL::Surface_mesh_simplification;
|
namespace SMS = CGAL::Surface_mesh_simplification;
|
||||||
|
|
||||||
// DOES NOT COMPILE
|
SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges
|
||||||
//SMS::Count_stop_predicate< Polyhedron > stop(nb_edges); // target # edges
|
SMS::edge_collapse( *pMesh, stop,
|
||||||
//SMS::edge_collapse( *pMesh, stop,
|
CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh))
|
||||||
// CGAL::vertex_index_map(boost::get(CGAL::vertex_external_index,*pMesh))
|
.edge_index_map(boost::get(CGAL::edge_external_index,*pMesh)));
|
||||||
// .edge_index_map(boost::get(CGAL::edge_external_index,*pMesh)));
|
|
||||||
|
|
||||||
// update scene
|
// update scene
|
||||||
scene->polyhedronChanged(index);
|
scene->polyhedronChanged(index);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef POLYHEDRON_TYPE_H
|
||||||
|
#define POLYHEDRON_TYPE_H
|
||||||
|
|
||||||
|
// CGAL
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
|
||||||
|
// kernel
|
||||||
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||||
|
|
||||||
|
// surface mesh
|
||||||
|
#include <CGAL/Polyhedron_3.h>
|
||||||
|
|
||||||
|
#include "Polyhedron_type_fwd.h"
|
||||||
|
|
||||||
|
struct Kernel : public CGAL::Exact_predicates_inexact_constructions_kernel {};
|
||||||
|
typedef Kernel::FT FT;
|
||||||
|
typedef Kernel::Line_3 Line;
|
||||||
|
typedef Kernel::Point_3 Point;
|
||||||
|
typedef Kernel::Plane_3 Plane;
|
||||||
|
typedef Kernel::Sphere_3 Sphere;
|
||||||
|
typedef Kernel::Vector_3 Vector;
|
||||||
|
typedef Kernel::Triangle_3 Triangle;
|
||||||
|
typedef Kernel::Iso_cuboid_3 Iso_cuboid;
|
||||||
|
|
||||||
|
// struct Polyhedron : public CGAL::Polyhedron_3<Kernel> {};
|
||||||
|
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||||
|
|
||||||
|
#endif // POLYHEDRON_TYPE_H
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef POLYHEDRON_TYPE_FWD_H
|
||||||
|
#define POLYHEDRON_TYPE_FWD_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
struct Kernel;
|
||||||
|
namespace CGAL {
|
||||||
|
struct Polyhedron_items_3;
|
||||||
|
|
||||||
|
#ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM
|
||||||
|
template < class T, class I, class A>
|
||||||
|
#endif
|
||||||
|
struct HalfedgeDS_default;
|
||||||
|
|
||||||
|
template < class PolyhedronTraits_3,
|
||||||
|
class PolyhedronItems_3,
|
||||||
|
#ifndef CGAL_CFG_NO_TMPL_IN_TMPL_PARAM
|
||||||
|
template < class T, class I, class A>
|
||||||
|
#endif
|
||||||
|
class T_HDS,
|
||||||
|
class Alloc
|
||||||
|
>
|
||||||
|
class Polyhedron_3;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef CGAL::Polyhedron_3<Kernel,
|
||||||
|
CGAL::Polyhedron_items_3,
|
||||||
|
CGAL::HalfedgeDS_default,
|
||||||
|
std::allocator<int> > Polyhedron;
|
||||||
|
|
||||||
|
#endif // POLYHEDRON_TYPE_FWD_H
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -13,8 +12,9 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include <CGAL/gl_render.h>
|
#include "Scene_rendering.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void CGALglcolor(QColor c)
|
void CGALglcolor(QColor c)
|
||||||
|
|
@ -39,7 +39,7 @@ Scene::~Scene()
|
||||||
poly_it = polyhedra.begin(),
|
poly_it = polyhedra.begin(),
|
||||||
poly_end = polyhedra.end();
|
poly_end = polyhedra.end();
|
||||||
poly_it != poly_end; ++poly_it) {
|
poly_it != poly_end; ++poly_it) {
|
||||||
delete poly_it->polyhedron_ptr;
|
this->destroy(poly_it->polyhedron_ptr);
|
||||||
}
|
}
|
||||||
polyhedra.clear();
|
polyhedra.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -64,9 +64,9 @@ Scene::open(QString filename)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate new polyhedron
|
// allocate new polyhedron
|
||||||
Polyhedron* poly = new Polyhedron;
|
Polyhedron* poly = this->new_polyhedron();
|
||||||
in >> *poly;
|
this->load_polyhedron(poly, in);
|
||||||
if(!in)
|
if(!in)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(qobject_cast<QWidget*>(QObject::parent()),
|
QMessageBox::critical(qobject_cast<QWidget*>(QObject::parent()),
|
||||||
|
|
@ -74,14 +74,13 @@ Scene::open(QString filename)
|
||||||
tr("File %1 is not a valid OFF file.").arg(filename));
|
tr("File %1 is not a valid OFF file.").arg(filename));
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
cerr << QString("\n");
|
cerr << QString("\n");
|
||||||
delete poly;
|
destroy(poly);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
addPolyhedron(poly, fileinfo.baseName());
|
addPolyhedron(poly, fileinfo.baseName());
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
||||||
cerr << QString("ok (%1 vertices)\n").arg(poly->size_of_vertices());
|
|
||||||
return polyhedra.size() - 1;
|
return polyhedra.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,7 +108,7 @@ bool Scene::save(int index,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << *poly;
|
this->save_polyhedron(poly, out);
|
||||||
cerr << QString("ok\n");
|
cerr << QString("ok\n");
|
||||||
|
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
|
|
@ -140,7 +139,7 @@ void Scene::addPolyhedron(Polyhedron* p,
|
||||||
int
|
int
|
||||||
Scene::erase(int polyhedron_index)
|
Scene::erase(int polyhedron_index)
|
||||||
{
|
{
|
||||||
delete polyhedra[polyhedron_index].polyhedron_ptr;
|
this->destroy(polyhedra[polyhedron_index].polyhedron_ptr);
|
||||||
polyhedra.removeAt(polyhedron_index--);
|
polyhedra.removeAt(polyhedron_index--);
|
||||||
|
|
||||||
selected_item = -1;
|
selected_item = -1;
|
||||||
|
|
@ -158,7 +157,7 @@ int
|
||||||
Scene::duplicate(int polyhedron_index)
|
Scene::duplicate(int polyhedron_index)
|
||||||
{
|
{
|
||||||
const Polyhedron_entry& entry = polyhedra[polyhedron_index];
|
const Polyhedron_entry& entry = polyhedra[polyhedron_index];
|
||||||
Polyhedron* poly = new Polyhedron(*entry.polyhedron_ptr);
|
Polyhedron* poly = this->copy_polyhedron(entry.polyhedron_ptr);
|
||||||
|
|
||||||
addPolyhedron(poly,
|
addPolyhedron(poly,
|
||||||
tr("%1 (copy)").arg(entry.name),
|
tr("%1 (copy)").arg(entry.name),
|
||||||
|
|
@ -168,34 +167,6 @@ Scene::duplicate(int polyhedron_index)
|
||||||
return polyhedra.size() - 1;
|
return polyhedra.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL::Bbox_3
|
|
||||||
Scene::bbox()
|
|
||||||
{
|
|
||||||
if(polyhedra.empty()) {
|
|
||||||
return CGAL::Bbox_3(0.0, 0.0, 0.0,
|
|
||||||
1.0, 1.0, 1.0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Point p = polyhedra.begin()->polyhedron_ptr->vertices_begin()->point();
|
|
||||||
CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z());
|
|
||||||
for(Polyhedra::iterator
|
|
||||||
poly_it = polyhedra.begin(),
|
|
||||||
poly_end = polyhedra.end();
|
|
||||||
poly_it != poly_end; ++poly_it)
|
|
||||||
{
|
|
||||||
for(Polyhedron::Vertex_iterator
|
|
||||||
v = poly_it->polyhedron_ptr->vertices_begin(),
|
|
||||||
v_end = poly_it->polyhedron_ptr->vertices_end();
|
|
||||||
v != v_end; ++v)
|
|
||||||
{
|
|
||||||
bbox = bbox + v->point().bbox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bbox;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Scene::draw()
|
Scene::draw()
|
||||||
{
|
{
|
||||||
|
|
@ -213,7 +184,7 @@ Scene::draw()
|
||||||
else
|
else
|
||||||
CGALglcolor(entry.color);
|
CGALglcolor(entry.color);
|
||||||
|
|
||||||
gl_render_facets(*poly);
|
gl_render_facets(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(index == selected_item)
|
if(index == selected_item)
|
||||||
|
|
@ -223,7 +194,7 @@ Scene::draw()
|
||||||
|
|
||||||
// superimpose edges
|
// superimpose edges
|
||||||
::glDisable(GL_LIGHTING);
|
::glDisable(GL_LIGHTING);
|
||||||
gl_render_edges(*poly);
|
gl_render_edges(poly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -423,6 +394,14 @@ Scene::RenderingMode Scene::polyhedronRenderingMode(int index)
|
||||||
return polyhedra[index].rendering_mode;
|
return polyhedra[index].rendering_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Scene::selectionAindex() const {
|
||||||
|
return item_A;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Scene::selectionBindex() const {
|
||||||
|
return item_B;
|
||||||
|
}
|
||||||
|
|
||||||
QItemSelection Scene::createSelection(int i)
|
QItemSelection Scene::createSelection(int i)
|
||||||
{
|
{
|
||||||
return QItemSelection(QAbstractItemModel::createIndex(i, 0),
|
return QItemSelection(QAbstractItemModel::createIndex(i, 0),
|
||||||
|
|
|
||||||
|
|
@ -10,31 +10,10 @@
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
|
||||||
// CGAL
|
#include "Polyhedron_type_fwd.h"
|
||||||
#include <CGAL/basic.h>
|
#include <CGAL/Bbox_3.h>
|
||||||
|
|
||||||
// kernel
|
#include <iostream>
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
|
||||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
|
||||||
|
|
||||||
// surface mesh
|
|
||||||
#include <CGAL/Polyhedron_3.h>
|
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
|
||||||
typedef Kernel::FT FT;
|
|
||||||
typedef Kernel::Line_3 Line;
|
|
||||||
typedef Kernel::Point_3 Point;
|
|
||||||
typedef Kernel::Plane_3 Plane;
|
|
||||||
typedef Kernel::Sphere_3 Sphere;
|
|
||||||
typedef Kernel::Vector_3 Vector;
|
|
||||||
typedef Kernel::Triangle_3 Triangle;
|
|
||||||
typedef Kernel::Iso_cuboid_3 Iso_cuboid;
|
|
||||||
|
|
||||||
// Boolean operations work only with exact kernel
|
|
||||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Exact_Kernel;
|
|
||||||
typedef CGAL::Polyhedron_3<Exact_Kernel> Exact_polyhedron;
|
|
||||||
|
|
||||||
struct Polyhedron : public CGAL::Polyhedron_3<Kernel> {};
|
|
||||||
|
|
||||||
class QEvent;
|
class QEvent;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
|
|
@ -85,12 +64,16 @@ public:
|
||||||
QString polyhedronName(int);
|
QString polyhedronName(int);
|
||||||
bool isPolyhedronActivated(int);
|
bool isPolyhedronActivated(int);
|
||||||
RenderingMode polyhedronRenderingMode(int);
|
RenderingMode polyhedronRenderingMode(int);
|
||||||
|
int selectionAindex() const;
|
||||||
|
int selectionBindex() const;
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
Polyhedron* getPolyhedron(int i) { return polyhedron(i); }
|
Polyhedron* getPolyhedron(int i) { return polyhedron(i); }
|
||||||
|
|
||||||
// draw() is called by Viewer::draw()
|
// draw() is called by Viewer::draw()
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
|
// defined in Scene_polyhedron_operations.cpp
|
||||||
CGAL::Bbox_3 bbox();
|
CGAL::Bbox_3 bbox();
|
||||||
|
|
||||||
// QAbstractItemModel functions
|
// QAbstractItemModel functions
|
||||||
|
|
@ -115,6 +98,19 @@ signals:
|
||||||
void updated_bbox();
|
void updated_bbox();
|
||||||
void updated();
|
void updated();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// functions that need to know the type Polyhedron
|
||||||
|
// defined in Scene_polyhedron_operations.cpp
|
||||||
|
Polyhedron* new_polyhedron();
|
||||||
|
Polyhedron* copy_polyhedron(Polyhedron* poly);
|
||||||
|
void destroy(Polyhedron*);
|
||||||
|
bool load_polyhedron(Polyhedron* poly, std::istream& in); // return true
|
||||||
|
// iif the
|
||||||
|
// loading is ok.
|
||||||
|
bool save_polyhedron(Polyhedron* poly, std::ostream& out); // return true
|
||||||
|
// iif the
|
||||||
|
// save is ok.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QColor defaultColor; // defined in Scene.cpp
|
static const QColor defaultColor; // defined in Scene.cpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#include "Scene.h"
|
||||||
|
#include "Polyhedron_type.h"
|
||||||
|
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||||
|
|
||||||
|
Polyhedron* Scene::new_polyhedron()
|
||||||
|
{
|
||||||
|
return new Polyhedron;
|
||||||
|
}
|
||||||
|
|
||||||
|
Polyhedron* Scene::copy_polyhedron(Polyhedron* poly)
|
||||||
|
{
|
||||||
|
return new Polyhedron(*poly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::destroy(Polyhedron* poly)
|
||||||
|
{
|
||||||
|
delete poly;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Scene::load_polyhedron(Polyhedron* poly, std::istream& in)
|
||||||
|
{
|
||||||
|
in >> *poly;
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Scene::save_polyhedron(Polyhedron* poly, std::ostream& out)
|
||||||
|
{
|
||||||
|
out << *poly;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGAL::Bbox_3
|
||||||
|
Scene::bbox()
|
||||||
|
{
|
||||||
|
if(polyhedra.empty()) {
|
||||||
|
return CGAL::Bbox_3(0.0, 0.0, 0.0,
|
||||||
|
1.0, 1.0, 1.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Point p = polyhedra.begin()->polyhedron_ptr->vertices_begin()->point();
|
||||||
|
CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z());
|
||||||
|
for(Polyhedra::iterator
|
||||||
|
poly_it = polyhedra.begin(),
|
||||||
|
poly_end = polyhedra.end();
|
||||||
|
poly_it != poly_end; ++poly_it) {
|
||||||
|
for(Polyhedron::Vertex_iterator
|
||||||
|
v = poly_it->polyhedron_ptr->vertices_begin(),
|
||||||
|
v_end = poly_it->polyhedron_ptr->vertices_end();
|
||||||
|
v != v_end; ++v)
|
||||||
|
{
|
||||||
|
bbox = bbox + v->point().bbox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bbox;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "Polyhedron_type.h"
|
||||||
|
#include <CGAL/gl_render.h>
|
||||||
|
|
||||||
|
void gl_render_facets(Polyhedron* poly)
|
||||||
|
{
|
||||||
|
gl_render_facets(*poly);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gl_render_edges(Polyhedron *poly)
|
||||||
|
{
|
||||||
|
gl_render_edges(*poly);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "Polyhedron_type_fwd.h"
|
||||||
|
|
||||||
|
void gl_render_facets(Polyhedron* poly);
|
||||||
|
void gl_render_edges(Polyhedron *poly);
|
||||||
|
|
@ -24,11 +24,8 @@ int main(int argc, char **argv)
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "MainWindow.cpp"
|
|
||||||
#include "Scene.cpp"
|
|
||||||
#include "MainWindow_curvature_estimation.cpp"
|
#include "MainWindow_curvature_estimation.cpp"
|
||||||
#include "MainWindow_subdivision_methods.cpp"
|
#include "MainWindow_subdivision_methods.cpp"
|
||||||
#include "MainWindow_boolean_operations.cpp"
|
|
||||||
#include "MainWindow_self_intersection.cpp"
|
#include "MainWindow_self_intersection.cpp"
|
||||||
#include "MainWindow_convex_hull.cpp"
|
#include "MainWindow_convex_hull.cpp"
|
||||||
#include "MainWindow_simplify.cpp"
|
#include "MainWindow_simplify.cpp"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue