Commit cd7ac54e authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

Merge cgogn:~kraemer/CGoGN

parents 2cf8cf83 4bbd6fba
......@@ -146,6 +146,7 @@ IF(WIN32)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
add_subdirectory(Release)
add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
......@@ -8,12 +8,15 @@ SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
#========CGoGN========#
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt)
find_package(Qt4 REQUIRED)
#=======QGLViewer=========#
find_package(QGLViewer REQUIRED)
......
......@@ -20,34 +20,45 @@ INCLUDE_DIRECTORIES(
file(
GLOB
SCHNApps_SRC_FILES
${SCHNApps_ROOT_DIR}/src/camera.cpp
${SCHNApps_ROOT_DIR}/src/context.cpp
${SCHNApps_ROOT_DIR}/src/main.cpp
${SCHNApps_ROOT_DIR}/src/interface/*.cpp
${SCHNApps_ROOT_DIR}/src/visualization/*.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/*.cpp
${SCHNApps_ROOT_DIR}/src/mapHandler.cpp
${SCHNApps_ROOT_DIR}/src/plugin.cpp
${SCHNApps_ROOT_DIR}/src/system.cpp
${SCHNApps_ROOT_DIR}/src/view.cpp
${SCHNApps_ROOT_DIR}/src/window.cpp
${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/camerasDialog.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/pluginsDialog.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/mapsDialog.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/cameraViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/pluginsViewDialog.cpp
${SCHNApps_ROOT_DIR}/src/dialogs/mapsViewDialog.cpp
)
SET(SCHNApps_H_OBJECT_FILES
${SCHNApps_ROOT_DIR}/include/interface/window.h
${SCHNApps_ROOT_DIR}/include/interface/system.h
${SCHNApps_ROOT_DIR}/include/interface/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/interface/splitArea.h
${SCHNApps_ROOT_DIR}/include/visualization/view.h
${SCHNApps_ROOT_DIR}/include/visualization/scene.h
${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/window.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/dialogs/camerasDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraOptionDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraSceneDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/globalCameraDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/linkViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapPluginDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h
)
file(
GLOB
SCHNApps_FORM_FILES
${SCHNApps_ROOT_DIR}/forms/*.ui
${SCHNApps_ROOT_DIR}/forms/window.ui
${SCHNApps_ROOT_DIR}/forms/camerasDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsDialog.ui
${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui
${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui
)
QT4_WRAP_UI( UI_H_FILES
......
cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(firstPlugin)
ADD_SUBDIRECTORY(importSurface)
ADD_SUBDIRECTORY(differentialProperties)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(subdivideSurface)
cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include
${CMAKE_CURRENT_BINARY_DIR}
)
SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/differentialProperties.cpp
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/src/computeNormalsDialog.cpp
)
SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/differentialProperties.h
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/include/computeNormalsDialog.h
)
SET( PLUGIN_FORM
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/forms/computeNormalsDialog.ui
)
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
ADD_DEFINITIONS(-DDEBUG)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DifferentialPropertiesPluginD SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DifferentialPropertiesPluginD
${CGoGN_LIBS_D}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DifferentialPropertiesPluginD SCHNAppsD )
SET_TARGET_PROPERTIES( DifferentialPropertiesPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" )
ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DifferentialPropertiesPlugin SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DifferentialPropertiesPlugin
${CGoGN_LIBS_R}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DifferentialPropertiesPlugin SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QSDialog</class>
<widget class="QDialog" name="QSDialog">
<class>ComputeNormalsDialog</class>
<widget class="QDialog" name="ComputeNormalsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>118</height>
<width>282</width>
<height>265</height>
</rect>
</property>
<property name="windowTitle">
<string>Restauration</string>
<string>Compute Normals</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Normal attribute name :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="attributeName"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_createVBO">
<property name="text">
<string>Charger les vues, scènes et caméra de la dernière session sauvegardée?</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
<string>create VBO</string>
</property>
<property name="wordWrap">
<property name="checked">
<bool>true</bool>
</property>
</widget>
......@@ -33,7 +68,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
......@@ -44,7 +79,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>QSDialog</receiver>
<receiver>ComputeNormalsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
......@@ -60,7 +95,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>QSDialog</receiver>
<receiver>ComputeNormalsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
......
#ifndef _DIFFERENTIALPROPERTIES_PLUGIN_H_
#define _DIFFERENTIALPROPERTIES_PLUGIN_H_
#include "plugin.h"
#include "computeNormalsDialog.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/attributeHandler.h"
using namespace CGoGN;
using namespace SCHNApps;
struct PFP: public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class DifferentialPropertiesPlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
DifferentialPropertiesPlugin()
{
setProvidesRendering(false);
}
~DifferentialPropertiesPlugin()
{}
virtual bool enable();
virtual void disable() {}
virtual void redraw(View *view) {}
virtual void keyPress(View* view, int key) {}
virtual void keyRelease(View* view, int key) {}
virtual void mousePress(View* view, int button, int x, int y) {}
virtual void mouseRelease(View* view, int button, int x, int y) {}
virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void wheelEvent(View* view, int delta, int x, int y) {}
virtual void viewLinked(View* view) {}
virtual void viewUnlinked(View* view) {}
virtual void currentViewChanged(View* view) {}
virtual void mapLinked(View* view, MapHandlerGen* m) {}
virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
public slots:
void cb_openComputeNormalsDialog();
void cb_computeNormals();
private:
ComputeNormalsDialog* m_computeNormalsDialog;
QAction* computeNormalsAction;
};
#endif
#include "differentialProperties.h"
#include "mapHandler.h"
#include "Algo/Geometry/normal.h"
bool DifferentialPropertiesPlugin::enable()
{
m_computeNormalsDialog = new ComputeNormalsDialog(m_window);
computeNormalsAction = new QAction("import", this);
addMenuAction("Surface;DifferentialProperties;Compute Normals", computeNormalsAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_openComputeNormalsDialog()));
connect(m_computeNormalsDialog, SIGNAL(accepted()), this, SLOT(cb_computeNormals()));
return true;
}
void DifferentialPropertiesPlugin::cb_openComputeNormalsDialog()
{
m_computeNormalsDialog->init();
m_computeNormalsDialog->show();
}
void DifferentialPropertiesPlugin::cb_computeNormals()
{
QList<QListWidgetItem*> currentItems = m_computeNormalsDialog->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
std::string positionName = m_computeNormalsDialog->combo_positionAttribute->currentText().toUtf8().constData();
std::string normalName = m_computeNormalsDialog->attributeName->text().toUtf8().constData();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>(positionName);
VertexAttribute<VEC3> normal = map->getAttribute<VEC3, VERTEX>(normalName);
if(!normal.isValid())
normal = map->addAttribute<VEC3, VERTEX>(normalName);
Algo::Geometry::computeNormalVertices<PFP>(*map, position, normal);
if(m_computeNormalsDialog->check_createVBO->checkState() == Qt::Checked)
mh->createVBO(normal);
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(DifferentialPropertiesPlugin, DifferentialPropertiesPlugin)
#else
Q_EXPORT_PLUGIN2(DifferentialPropertiesPluginD, DifferentialPropertiesPlugin)
#endif
#ifndef _FIRSTPLUGIN_H_
#define _FIRSTPLUGIN_H_
#include "plugins/visualPlugin.h"
/**---CGoGN includes **/
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Render/GL2/topoRender.h"
/**---CGoGN includes **/
/**---Definitions specific to CGoGN ---*/
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
/**---Definitions specific to CGoGN ---*/
/**
* This class is a basic minimal plugin.
* All the methods in this class are overloaded methods.
* In order to create a valid plugin, all the method in this
* needs to be declared (they are actually overloaded methods
* from VisualPlugin), even if your plugin doesn't make any
* drawing.
*/
/**
* Our plugin must inherit from VisualPlugin,
* that is a class that itself is an implementation
* of the Plugin interface (virtual class). It contains
* many useful and essantial methods.
*/
class FirstPlugin : public VisualPlugin
{
/**
* Essential Qt macros.
*/
Q_OBJECT
Q_INTERFACES(Plugin)
public:
FirstPlugin() {}
~FirstPlugin() {}
/**
* The classical call back for the initGL method
* When a scene will be link to this plugin, it will call
* back this method with itself as a parameter.
*/
void cb_initGL(Scene *scene);
/**
* The drawing method that needs to be overloaded.
* Each time a scene (that is to say, at least one of the
* views that is contains) needs to be refresh, it calls back
* this method with itself as a parameter
*/
void cb_redraw(Scene *scene);
/**
* The plugin's activation method
* Each time the main application loads this plugin,
* it call this method. Writing this method is
* the occasion to initialize the plugin and check certain
* conditions.
* If this methods return 'false', the plugin load will be aborted.
*/
bool activate();
/**
* The plugin's disabling method
* Each time the main application will unload the plugin
* it will call this method.
*/
void disable();
protected:
/** Attributes that are specific to this plugin **/
MAP myMap;
// attribute for vertices positions
VertexAttribute<VEC3> position;
// render (for the topo)
Algo::Render::GL2::TopoRender *m_render_topo;
// just for more compact writing
inline Dart PHI1(Dart d)
{
return myMap.phi1(d);
}
inline Dart PHI_1(Dart d)
{
return myMap.phi_1(d);
}
inline Dart PHI2(Dart d)
{
return myMap.phi2(d);
}
template<int X>
Dart PHI(Dart d)
{
return myMap.phi<X>(d);
}
/** Attributes that are specific to this plugin **/
};
#endif // _FIRSTPLUGIN_H_
#include "firstPlugin.h"
#include "Algo/Geometry/boundingbox.h"
void FirstPlugin::cb_initGL(Scene *scene)
{
if (scene)
{
// we fit the first (possibly the only) view of the newly liked
// scene to the content of our map
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize());
m_render_topo = new Algo::Render::GL2::TopoRender() ;
// render the topo of the map without boundary darts
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
}
}
void FirstPlugin::cb_redraw(Scene *scene)
{
m_render_topo->drawTopo();
}
bool FirstPlugin::activate()
{
// creation of 2 new faces: 1 triangle and 1 square
Dart d1 = myMap.newFace(3);
Dart d2 = myMap.newFace(4);
// sew these faces along one of their edge
myMap.sewFaces(d1, d2);
// creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned
position = myMap.addAttribute<VEC3, VERTEX>("position");
// affect position by moving in the map
position[d1] = VEC3(0, 0, 0);
position[PHI1(d1)] = VEC3(2, 0, 0);
position[PHI_1(d1)] = VEC3(1, 2, 0);
position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = VEC3(2, -2, 0);
m_render_topo = NULL;
return true;
}
void FirstPlugin::disable()
{
if (m_render_topo)
{
delete m_render_topo;
}
}
/**
* If we want to compile this plugin in debug mode,
* we also define a DEBUG macro at the compilation
*/
#ifndef DEBUG
// essential Qt function:
// arguments are
// - the complied name of the plugin
// - the main class of our plugin (that extends VisualPlugin)
Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin)
#else
Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin)
#endif
#ifndef _IMPORTMAP_H_
#define _IMPORTMAP_H_
#include "visualPlugin.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"