Commit f9dffbb9 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' into 'master'

Develop to master

See merge request !42
parents 7114af20 4dc1bdba
...@@ -89,7 +89,6 @@ IF(WIN32) ...@@ -89,7 +89,6 @@ IF(WIN32)
ENDIF(WIN32) ENDIF(WIN32)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
...@@ -130,7 +129,6 @@ SET (CGoGN_EXT_INCLUDES ...@@ -130,7 +129,6 @@ SET (CGoGN_EXT_INCLUDES
${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
) )
# define libs for external libs # define libs for external libs
...@@ -139,7 +137,6 @@ SET (CGoGN_EXT_LIBS ...@@ -139,7 +137,6 @@ SET (CGoGN_EXT_LIBS
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${Boost_REGEX_LIBRARY}
tinyxml2 tinyxml2
) )
......
English version bellow
Dpendences Linux Linux dependencies
================= ==================
installer les paquets suivants: install the following packages:
cmake cmake-curses-gui cmake-qt-gui libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev libqglviewer-dev cmake cmake-curses-gui cmake-qt-gui libXi-dev libXmu-dev libglew-dev zlib1g-dev libqt4-dev qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev libqglviewer-dev
Pour compiler CGoGN
===================
* on compile tout d'abord les bibliothques third-party :
```
cd CGoGN/ThirdParty/build
cmake ..
make (-j x si vous avez x cores)
make install
```
La mme chose en debug:
```
cd ../buildDebug
cmake ..
make (-j x si vous avez x cores)
```
On peut fixer certaines option pour ne pas tout compiler:
* WITH_ASSIMP -> compile et utilise la librairie Assimp
* WITH_ZINRI -> compile et utilise la librairie Zinri
* WITH_PYTHONQT -> pour SCHNApps
* ensuite on compile CGoGN :
```
cd CGoGN/build
cmake ..
make (-j x si vous avez x cores)
```
Et en Debug avec:
```
cd ../buildDebug
cmake ..
make (-j x si vous avez x cores)
```
Certaines options sont disponibles :
* BUILD_SHARED_LIBS -Q experimental !
* ONELIB -> compilation en une seule lib (libcgogn.a) au lieu de 4
* WITH_ASSIMP -> utilise Assimp (auto set par third party compil)
* WITH_ZINRI -> utilise Zinri (auto set par third party compil)
* WITH_QT -> minimize les dependence si pas besoin de Qt (VRJuggler)
* WITH_GLEWMX -> pour utiliser GLEWMX a la place de GELW (pour VRJuggler)
Les librairies sont generees dans lib/Release et lib/Debug
Les binaires sont generes dans bin/Release et bin/Debug
* on peut ensuite compiler SCHNApps ainsi que les plugins fournis :
```
cd CGoGN/SCHNApps/build
cmake ..
make (-j x si vous avez x cores)
```
Et en Debug avec:
```
cd ../buildDebug
cmake ..
make (-j x si vous avez x cores)
```
Mac Dependencies
=================
To compile CGoGN on MAC
Des exemples de donnes (fichiers trianbgz, off, etc..) sont accessible l'adresse suivante: * install XCode and command line tools.
https://iggservis.u-strasbg.fr/Data/data.zip * install Qt4 (4.8) and QtCreator
* install (or build) libQGLViewer
* install cmake (native or with homebrew)
* install with homebrew : lzlib, glew, suite-sparse
To install suite-sparse package, you must first
add the homebrew/science repository with the following command :
brew tap homebrew/science
ENGLISH VERSION Compilation is the same as on Linux for CGoGN
===============
Linux dependencies
==================
install the following packages:
cmake cmake-curses-gui cmake-qt-gui libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev libqglviewer-dev
To compile CGoGN To compile CGoGN
================ ================
...@@ -93,7 +28,7 @@ To compile CGoGN ...@@ -93,7 +28,7 @@ To compile CGoGN
``` ```
cd CGoGN/ThirdParty/build cd CGoGN/ThirdParty/build
cmake .. cmake ..
make (-j x if you have x cores) make (-j x if you have x cores)
make install make install
``` ```
...@@ -101,7 +36,8 @@ To compile CGoGN ...@@ -101,7 +36,8 @@ To compile CGoGN
``` ```
cd ../buildDebug cd ../buildDebug
cmake .. cmake ..
make make (-j x if you have x cores)
make install
``` ```
Some options are available to not compile everything: Some options are available to not compile everything:
...@@ -133,6 +69,7 @@ To compile CGoGN ...@@ -133,6 +69,7 @@ To compile CGoGN
* WITH_QT -> to minimize dependencies and compilation time * WITH_QT -> to minimize dependencies and compilation time
* WITH_GLEWMX -> to use GLEWMX (for VRJuggler users) * WITH_GLEWMX -> to use GLEWMX (for VRJuggler users)
* we can then compile SCHNApps and the provided plugins : * we can then compile SCHNApps and the provided plugins :
``` ```
......
...@@ -21,7 +21,6 @@ SET( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not wo ...@@ -21,7 +21,6 @@ SET( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not wo
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex system REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
...@@ -31,6 +30,8 @@ find_package(SuiteSparse REQUIRED) ...@@ -31,6 +30,8 @@ find_package(SuiteSparse REQUIRED)
#find_package(SuperLU REQUIRED) #find_package(SuperLU REQUIRED)
add_definitions(-DWITH_QT)
SET( QT_USE_QTOPENGL TRUE ) SET( QT_USE_QTOPENGL TRUE )
SET( QT_USE_QTXML TRUE ) SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE ) SET( QT_USE_QTDESIGNER TRUE )
...@@ -72,7 +73,6 @@ SET (EXT_INCLUDES ...@@ -72,7 +73,6 @@ SET (EXT_INCLUDES
${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${QT_INCLUDE_DIR} ${QT_INCLUDE_DIR}
${QGLVIEWER_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}
...@@ -88,8 +88,6 @@ SET (EXT_LIBS ...@@ -88,8 +88,6 @@ SET (EXT_LIBS
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
${QT_LIBRARIES} ${QT_LIBRARIES}
${PYTHON_LIBRARIES} ${PYTHON_LIBRARIES}
${SUITESPARSE_LIBRARIES} ${SUITESPARSE_LIBRARIES}
......
...@@ -12,8 +12,9 @@ ADD_SUBDIRECTORY(surface_deformation) ...@@ -12,8 +12,9 @@ ADD_SUBDIRECTORY(surface_deformation)
ADD_SUBDIRECTORY(surface_modelisation) ADD_SUBDIRECTORY(surface_modelisation)
#ADD_SUBDIRECTORY(surface_tilings) #ADD_SUBDIRECTORY(surface_tilings)
ADD_SUBDIRECTORY(surface_distance) ADD_SUBDIRECTORY(surface_distance)
ADD_SUBDIRECTORY(surface_radiance)
ADD_SUBDIRECTORY(volume_import) ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render) #ADD_SUBDIRECTORY(volume_render)
ADD_SUBDIRECTORY(volumetric) #ADD_SUBDIRECTORY(volumetric)
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME Surface_Radiance )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_radiance )
INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
)
file(
GLOB_RECURSE
PLUGIN_FILES
${PLUGIN_ROOT_DIR}/src/*.cpp
${PLUGIN_ROOT_DIR}/include/*.h
${PLUGIN_ROOT_DIR}/include/*.hpp
)
file(
GLOB_RECURSE
PLUGIN_UI_FILES
${PLUGIN_ROOT_DIR}/forms/*.ui
)
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/surface_radiance.h
${PLUGIN_ROOT_DIR}/include/surface_radiance_dockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Surface_Radiance_TabWidget</class>
<widget class="QWidget" name="Surface_Radiance_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="combo_normalVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#ifndef _SURFACE_RADIANCE_PLUGIN_H_
#define _SURFACE_RADIANCE_PLUGIN_H_
#include "plugin_interaction.h"
#include "surface_radiance_dockTab.h"
#include "Utils/sphericalHarmonics.h"
#include "Utils/Shaders/shaderRadiancePerVertex.h"
#include "Algo/Import/import.h"
#include "Algo/Import/import2tables.h"
namespace CGoGN
{
namespace SCHNApps
{
typedef SphericalHarmonics<PFP2::REAL, PFP2::VEC3> SH_TYPE;
struct MapParameters
{
MapParameters() :
positionVBO(NULL),
normalVBO(NULL),
radianceTexture(NULL),
paramVBO(NULL)
{}
Utils::VBO* positionVBO;
Utils::VBO* normalVBO;
CGoGN::Utils::ShaderRadiancePerVertex* radiancePerVertexShader;
VertexAttribute<SH_TYPE, PFP2::MAP> radiance;
Utils::Texture<2, Geom::Vec3f>* radianceTexture;
VertexAttribute<Geom::Vec2i, PFP2::MAP> param;
Utils::VBO* paramVBO;
};
class Surface_Radiance_Plugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class Surface_Radiance_DockTab;
public:
Surface_Radiance_Plugin()
{}
~Surface_Radiance_Plugin()
{}
virtual bool enable();
virtual void disable();
virtual void draw(View *view) {}
virtual void drawMap(View* view, MapHandlerGen* map);
virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event) {}
virtual void mouseRelease(View* view, QMouseEvent* event) {}
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
virtual void viewLinked(View *view) {}
virtual void viewUnlinked(View *view) {}
private slots:
// slots called from SCHNApps signals
void selectedViewChanged(View* prev, View* cur);
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
// slots called from MapHandler signals
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
void attributeModified(unsigned int orbit, QString nameAttr);
void importFromFileDialog();
public slots:
// slots for Python calls
void changePositionVBO(const QString& map, const QString& vbo);
void changeNormalVBO(const QString& map, const QString& vbo);
MapHandlerGen* importFromFile(const QString& fileName);
protected:
Surface_Radiance_DockTab* m_dockTab;
QHash<MapHandlerGen*, MapParameters> h_mapParameterSet;
QAction* m_importAction;
};
class MeshTablesSurface_Radiance : public CGoGN::Algo::Surface::Import::MeshTablesSurface<PFP2>
{
public:
MeshTablesSurface_Radiance(MAP& m) : MeshTablesSurface<PFP2>(m)
{}
/**
* @brief importPLY
* @param filename: the ply file to be imported. This file is supposed to have a three position, three normal and at least three radiance scalars per vertex.
* @return succeeded
*/
template <typename SH_TYPE>
bool importPLY(const std::string& filename)
{
// Open file
std::ifstream fp(filename, std::ios::in | std::ios::binary) ;
if (!fp.good())
{
CGoGNerr << "Unable to open file " << filename << CGoGNendl ;
return false ;
}
// Read quantities : #vertices, #faces, #properties, degree of polynomials
std::string tag ;
fp >> tag;
if (tag != std::string("ply")) // verify file type
{
CGoGNerr << filename << " is not a ply file !" << CGoGNout ;
return false ;
}
do // go to "format"
{
fp >> tag ;
} while (tag != std::string("format")) ;
fp >> tag ;
bool binary = (tag != "ascii") ;
do // go to #vertices
{
fp >> tag ;
} while (tag != std::string("vertex")) ;
unsigned int nbVertices ;
fp >> nbVertices ; // Read #vertices
bool position = false ;
bool normal = false ;
bool radiance = false ;
unsigned int propSize = 0 ; // for binary read
unsigned int nbProps = 0 ; // # properties
unsigned int nbCoefs = 0 ; // # coefficients
do // go to #faces and count #properties
{
fp >> tag ;
if (tag == std::string("property"))
{
++nbProps ;
}
else if (tag == std::string("int8") || tag == std::string("uint8"))
{
if (propSize < 2)
{
propSize = 1 ;
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
else
{
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
}
else if (tag == std::string("int16") || tag == std::string("uint16"))
{
if (propSize == 0 || propSize == 2)
{
propSize = 2 ;
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
else
{
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
}
else if (tag == std::string("int32") || tag == std::string("float32") || tag == std::string("uint32"))
{
if (propSize == 0 || propSize == 4)
{
propSize = 4 ;
}
else
{
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
}
else if (tag == std::string("int64") || tag == std::string("float64"))
{
if (propSize == 0 || propSize == 8)
{
propSize = 8 ;
}
else
{
std::cerr << "only float32 of float64 is yet handled" << std::endl ;
assert(!"only float32 or float64 is yet handled") ;
}
}
else if (tag == std::string("x") || tag == std::string("y") || tag == std::string("z"))
position = true ;
else if (tag == std::string("nx") || tag == std::string("ny") || tag == std::string("nz"))
normal = true ;
else if (tag.substr(0,6) == std::string("SHcoef"))
{
radiance = true ;
++nbCoefs ;
}
} while (tag != std::string("face")) ;
assert((nbCoefs % 3) == 0 || !"Import only supports RGB SphericalHarmonics (i.e. Tcoef==VEC3)") ;
nbCoefs /= 3 ;
SH_TYPE::set_nb_coefs(nbCoefs) ;
fp >> this->m_nbFaces ; // Read #vertices
do // go to end of header
{
fp >> tag ;
} while (tag != std::string("end_header")) ;
if (binary)
{
char* endline = new char[1] ;
fp.read(endline, sizeof(char)) ;
if (*endline == '\r') // for windows
fp.read(endline, sizeof(char)) ;
assert(*endline == '\n') ;
delete[] endline ;
}
// Define containers
assert((position && normal && radiance) || !"Import: position, normal and radiance attributs should be provided") ;
if (!(position && normal && radiance))
return false ;
VertexAttribute<VEC3, MAP> positions = this->m_map.template checkAttribute<VEC3, VERTEX, MAP>("position") ;
VertexAttribute<VEC3, MAP> normals = this->m_map.template checkAttribute<VEC3, VERTEX, MAP>("normal") ;
VertexAttribute<SH_TYPE, MAP> radiances = this->m_map.template checkAttribute<SH_TYPE, VERTEX, MAP>("radiance") ;
// Read vertices
std::vector<unsigned int> verticesID ;
if (propSize == 4)
{
this->m_nbVertices = readVerticesPLY<float, SH_TYPE>(fp, binary, nbVertices, nbProps, propSize, positions, normals, radiances, verticesID) ;
}
else if (propSize == 8)
{
this->m_nbVertices = readVerticesPLY<double, SH_TYPE>(fp, binary, nbVertices, nbProps, propSize, positions, normals, radiances, verticesID) ;
}
// Read faces index