Commit 42cca519 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:~kraemer/CGoGN

parents 0952c461 a1495866
......@@ -92,7 +92,7 @@ private:
// Assigne un nouveau plongement au sommet. Les anciens plongements sont libérés.
void newVertex(Dart d) {
embedNewCell<VERTEX>(d);
setOrbitEmbeddingOnNewCell<VERTEX>(d);
}
public:
......
......@@ -95,7 +95,7 @@ private:
// Assigne un nouveau plongement au sommet. Les anciens plongements sont libérés.
void newVertex(Dart d) {
embedNewCell(VERTEX,d);
setOrbitEmbeddingOnNewCell(VERTEX,d);
}
public:
......
cmake_minimum_required(VERSION 2.8)
project(SCHNApps)
SET( QT_USE_QTXML TRUE )
SET (QT_USE_QTDESIGNER TRUE)
SET (QT_USE_QTGUI TRUE)
SET(QT_USE_QTPLUGIN TRUE)
#========CGoGN========#
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt)
#=======QGLViewer=========#
find_package(QGLViewer REQUIRED)
#======Directories=======#
SET(INC_DIR ${CMAKE_SOURCE_DIR}/include)
SET(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
SET(FORMS_DIR ${CMAKE_SOURCE_DIR}/forms)
SET(RESOURCES_DIR ${CMAKE_SOURCE_DIR}/resources)
SET(PLUGIN_DIR ${CMAKE_SOURCE_DIR}/Plugins)
SET(PLUGIN_COMPILE_DIR ${EXECUTABLE_OUTPUT_PATH}/plugins)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release)
IF (NOT WIN32)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Debug Debug)
ENDIF (NOT WIN32)
configure_file(${CMAKE_SOURCE_DIR}/settings/state_save.xml ${EXECUTABLE_OUTPUT_PATH}/state_save.xml @ONLY)
#======Documentation=======#
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Doc
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_BUILD_TYPE Debug)
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)
INCLUDE_DIRECTORIES(
${CGoGN_ROOT_DIR}/include
${COMMON_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${QGLVIEWER_INCLUDE_DIR}
)
SET(SRC_FILES
${SRC_DIR}/main.cpp
${SRC_DIR}/interface/window.cpp
${SRC_DIR}/interface/system.cpp
${SRC_DIR}/interface/stateHandler.cpp
${SRC_DIR}/visualization/view.cpp
${SRC_DIR}/visualization/scene.cpp
${SRC_DIR}/visualization/camera.cpp
${SRC_DIR}/interface/splitArea.cpp
${SRC_DIR}/dialogs/newSceneDialog.cpp
${SRC_DIR}/dialogs/sceneSelector.cpp
${SRC_DIR}/interface/viewButtonArea.cpp
${SRC_DIR}/dialogs/cameraViewDialog.cpp
${SRC_DIR}/dialogs/cameraOptionDialog.cpp
${SRC_DIR}/dialogs/cameraSceneDialog.cpp
${SRC_DIR}/dialogs/globalCameraDialog.cpp
${SRC_DIR}/dialogs/pluginDialog.cpp
${SRC_DIR}/dialogs/linkViewDialog.cpp
${SRC_DIR}/visualization/vboHandler.cpp
${SRC_DIR}/visualization/mapHandler.cpp
${SRC_DIR}/visualization/context.cpp
${SRC_DIR}/dialogs/mapPluginDialog.cpp
)
SET(H_OBJECT_FILES
${INC_DIR}/interface/window.h
${INC_DIR}/interface/system.h
${INC_DIR}/visualization/view.h
${INC_DIR}/visualization/scene.h
${INC_DIR}/interface/splitArea.h
${INC_DIR}/dialogs/newSceneDialog.h
${INC_DIR}/dialogs/sceneSelector.h
${INC_DIR}/interface/viewButtonArea.h
${INC_DIR}/dialogs/cameraViewDialog.h
${INC_DIR}/dialogs/cameraOptionDialog.h
${INC_DIR}/dialogs/cameraSceneDialog.h
${INC_DIR}/dialogs/globalCameraDialog.h
${INC_DIR}/dialogs/pluginDialog.h
${INC_DIR}/dialogs/linkViewDialog.h
${INC_DIR}/dialogs/mapPluginDialog.h
)
SET(FORMS_FILES
${FORMS_DIR}/window.ui
${FORMS_DIR}/questionSessionDialog.ui
${FORMS_DIR}/infoDialog.ui
${FORMS_DIR}/newSceneDialog.ui
${FORMS_DIR}/cameraViewDialog.ui
${FORMS_DIR}/cameraOptionDialog.ui
${FORMS_DIR}/cameraSceneDialog.ui
${FORMS_DIR}/globalCameraDialog.ui
${FORMS_DIR}/pluginDialog.ui
${FORMS_DIR}/linkViewDialog.ui
${FORMS_DIR}/mapPluginDialog.ui
)
QT4_WRAP_UI(UI_H_FILES
${FORMS_FILES}
)
QT4_WRAP_CPP(MOC_FILES
${H_OBJECT_FILES}
)
QT4_ADD_RESOURCES(RCC_FILES
${RESOURCES_DIR}/resources.qrc
)
INCLUDE_DIRECTORIES(
${FORMS}
${INC_DIR}
${INC_DIR}/interface
${INC_DIR}/visualization
${INC_DIR}/dialogs
${INC_DIR}/plugins
)
ADD_EXECUTABLE(CGoGN_plugD
${SRC_FILES}
${UI_H_FILES}
${MOC_FILES}
${RCC_FILES}
)
TARGET_LINK_LIBRARIES(CGoGN_plugD
${CGoGN_LIBS_D}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
#ADD_SUBDIRECTORY(${PLUGIN_DIR} plugins)
#ifndef FIRSTPLUGIN_H_
#define FIRSTPLUGIN_H_
#include "visualPlugin.h"
/**---CGoGN includes **/
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
#include "Topology/generic/parameters.h"
#ifdef USE_GMAP
#include "Topology/gmap/embeddedGMap2.h"
#else
#include "Topology/map/embeddedMap2.h"
#endif
#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 type of the map
#ifdef USE_GMAP
typedef EmbeddedGMap2 MAP;
#else
typedef EmbeddedMap2 MAP;
#endif
};
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"
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;
}
}
void FirstPlugin::cb_redraw(Scene* scene){
m_render_topo->drawTopo();
}
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);
}
}
/**
* 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"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vboRender.h"
#include "Utils/Qt/qtInputs.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP ;
};
class ImportMap : public VisualPlugin{
Q_OBJECT
Q_INTERFACES(Plugin)
public:
ImportMap();
~ImportMap();
void cb_updateMatrix(View* view){}
void cb_redraw(Scene* scene){}
void cb_initGL(Scene* scene){}
bool activate();
void disable();
protected:
bool importMap(QString filename);
protected slots:
void saveMap();
};
#endif
#include "import.h"
#include <QMessageBox>
ImportMap::ImportMap(){}
ImportMap::~ImportMap(){}
bool ImportMap::activate(){
QAction* action= new QAction( m_window);
action->setIcon(QIcon(":icon/map.png"));
QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveMap()));
addMenuAction("Visu;Imorter une Map", action);
addToolbarAction(action);
waitingForScene(0);
return true;
}
void ImportMap::disable(){}
bool ImportMap::importMap(QString filename){
QFileInfo fileInfo(filename);
QString extension= fileInfo.suffix();
PFP::MAP* myMap= new PFP::MAP();
VertexAttribute<PFP::VEC3> position;
VertexAttribute<PFP::VEC3> normal;
if (extension == "map")
{
myMap->loadMapBin(filename.toStdString());
position = myMap->getAttribute<PFP::VEC3, VERTEX>("position") ;
}
else
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(*myMap, filename.toStdString().c_str(), attrNames))
{
return false;
}
position = myMap->getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
std::cout << "import map position ok? " << ((myMap->getAttribute<PFP::VEC3, VERTEX>(attrNames[0]).isValid())?"yes":"no") << std::endl;
std::cout << "import map position ok? " << ((myMap->getAttribute<PFP::VEC3, VERTEX>("position").isValid())?"yes":"no") << std::endl;
}
normal = myMap->getAttribute<PFP::VEC3, VERTEX>("normal") ;
if(!normal.isValid())
normal = myMap->addAttribute<PFP::VEC3, VERTEX>("normal") ;
Algo::Geometry::computeNormalVertices<PFP>(*myMap, position, normal) ;
std::cout << "import map normal ok? " << ((myMap->getAttribute<PFP::VEC3, VERTEX>("normal").isValid())?"yes":"no") << std::endl;
MapHandler* vizuHandler= new MapHandler(myMap);
if(!addReferencedMap(fileInfo.baseName()+"_map", vizuHandler)){
System::Error::showError();
delete vizuHandler;
return false;
}
// myMap->check();
return true;
}
void ImportMap::saveMap(){
QString fileName= QFileDialog::getOpenFileName(m_window, System::app_path+"../files", tr("3D files (*)"));
if(!fileName.isEmpty()){
if(!importMap(fileName)){
QMessageBox msg;
msg.setText(QString::fromUtf8("Une erreur est survenue lors de la