Commit 7caafd0a authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

Conflicts:
	SCHNApps/Plugins/surface_renderVector/src/surface_renderVector_dockTab.cpp
parents 783a4e91 acfee411
...@@ -37,95 +37,95 @@ namespace Geom ...@@ -37,95 +37,95 @@ namespace Geom
template <typename VEC> template <typename VEC>
class BoundingBox class BoundingBox
{ {
public: public:
/**********************************************/ /**********************************************/
/* CONSTRUCTORS */ /* CONSTRUCTORS */
/**********************************************/ /**********************************************/
BoundingBox() ; BoundingBox() ;
// initialize the bounding box with one first point // initialize the bounding box with one first point
BoundingBox(const VEC& p) ; BoundingBox(const VEC& p) ;
/**********************************************/ /**********************************************/
/* ACCESSORS */ /* ACCESSORS */
/**********************************************/ /**********************************************/
VEC& min() ; VEC& min() ;
const VEC& min() const ; const VEC& min() const ;
VEC& max() ; VEC& max() ;
const VEC& max() const ; const VEC& max() const ;
typename VEC::DATA_TYPE size(unsigned int coord) const ; typename VEC::DATA_TYPE size(unsigned int coord) const ;
typename VEC::DATA_TYPE maxSize() const ; typename VEC::DATA_TYPE maxSize() const ;
typename VEC::DATA_TYPE minSize() const ; typename VEC::DATA_TYPE minSize() const ;
VEC diag() const ; VEC diag() const ;
typename VEC::DATA_TYPE diagSize() const ; typename VEC::DATA_TYPE diagSize() const ;
VEC center() const ; VEC center() const ;
bool isInitialized() const ; bool isInitialized() const ;
/**********************************************/ /**********************************************/
/* FUNCTIONS */ /* FUNCTIONS */
/**********************************************/ /**********************************************/
// reinitialize the bounding box // reinitialize the bounding box
void reset() ; void reset() ;
// add a point to the bounding box // add a point to the bounding box
void addPoint(const VEC& p) ; void addPoint(const VEC& p) ;
// return true if bb intersects the bounding box // return true if bb intersects the bounding box
bool intersects(const BoundingBox<VEC>& bb) ; bool intersects(const BoundingBox<VEC>& bb) ;
// fusion with the given bounding box // fusion with the given bounding box
void fusion(const BoundingBox<VEC>& bb) ; void fusion(const BoundingBox<VEC>& bb) ;
// return true if the point belongs strictly to a bounding box // return true if the point belongs strictly to a bounding box
bool contains(const VEC& p); bool contains(const VEC& p);
// return true if the segment belongs strictly to a bounding box // return true if the segment belongs strictly to a bounding box
bool contains(const VEC& a, const VEC& b); bool contains(const VEC& a, const VEC& b);
// return true if the bounding box belongs strictly to a bounding box // return true if the bounding box belongs strictly to a bounding box
bool contains(const BoundingBox<VEC> & bb); bool contains(const BoundingBox<VEC> & bb);
// scale the bounding box // scale the bounding box
void scale(typename VEC::DATA_TYPE size); void scale(typename VEC::DATA_TYPE size);
// 0-centered scale of the bounding box // 0-centered scale of the bounding box
void centeredScale(typename VEC::DATA_TYPE size); void centeredScale(typename VEC::DATA_TYPE size);
/// test if bb is intersected by a ray /// test if bb is intersected by a ray
bool rayIntersect(const VEC& P, const VEC& V) const; bool rayIntersect(const VEC& P, const VEC& V) const;
/**********************************************/ /**********************************************/
/* STREAM OPERATORS */ /* STREAM OPERATORS */
/**********************************************/ /**********************************************/
friend std::ostream& operator<<(std::ostream& out, const BoundingBox<VEC>& bb) friend std::ostream& operator<<(std::ostream& out, const BoundingBox<VEC>& bb)
{ {
out << bb.min() << " " << bb.max() ; out << bb.min() << " " << bb.max() ;
return out ; return out ;
} }
friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb) friend std::istream& operator>>(std::istream& in, BoundingBox<VEC>& bb)
{ {
in >> bb.min() >> bb.max() ; in >> bb.min() >> bb.max() ;
return in ; return in ;
} }
private: private:
bool m_initialized ; bool m_initialized ;
VEC m_pMin, m_pMax ; VEC m_pMin, m_pMax ;
} ; } ;
} // namespace Geom } // namespace Geom
......
// ShaderRadiancePerVertex::vertexShaderText // ShaderRadiancePerVertex::vertexShaderText
#extension GL_EXT_gpu_shader4 : enable // need GLSL v1.30 -> if not available, use a uniform for passing textureSize instead of calling textureSize2D //#extension GL_EXT_gpu_shader4 : enable // need GLSL v1.30 -> if not available, use a uniform for passing textureSize instead of calling textureSize2D
ATTRIBUTE vec3 VertexPosition; ATTRIBUTE vec3 VertexPosition;
ATTRIBUTE vec3 VertexNormal; ATTRIBUTE vec3 VertexNormal;
...@@ -69,7 +69,7 @@ void set_eval_direction (vec3 v) ...@@ -69,7 +69,7 @@ void set_eval_direction (vec3 v)
void main () void main ()
{ {
int size = (textureSize2D(texture,0)).x; // supposed square matrix int size = (textureSize(texture,0)).x; // supposed square matrix
//init_K_tab(); //init_K_tab();
vec3 eyeV = normalize(camera - VertexPosition); // normalized outgoing line-of-sight vector vec3 eyeV = normalize(camera - VertexPosition); // normalized outgoing line-of-sight vector
......
// ShaderRadiancePerVertex::fragmentShaderInterpText // ShaderRadiancePerVertex::fragmentShaderInterpText
#extension GL_EXT_gpu_shader4 : enable // need GLSL v1.30 -> if not available, use a uniform for passing textureSize instead of calling textureSize2D //#extension GL_EXT_gpu_shader4 : enable // need GLSL v1.30 -> if not available, use a uniform for passing textureSize instead of calling textureSize2D
PRECISION; PRECISION;
...@@ -75,7 +75,7 @@ void set_eval_direction (vec3 v) ...@@ -75,7 +75,7 @@ void set_eval_direction (vec3 v)
void main (void) void main (void)
{ {
int size = (textureSize2D(texture,0)).x; // supposed square matrix int size = (textureSize(texture,0)).x; // supposed square matrix
vec3 eyeV = normalize(camera - vxPos); // normalized outgoing line-of-sight vector vec3 eyeV = normalize(camera - vxPos); // normalized outgoing line-of-sight vector
eyeV = 2*dot(vxNorm,eyeV)*vxNorm-eyeV ; // symmetrize eyeV = 2*dot(vxNorm,eyeV)*vxNorm-eyeV ; // symmetrize
......
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#define CGoGN_UTILS_DLL_EXPORT 1 #define CGoGN_UTILS_DLL_EXPORT 1
#include "Utils/Shaders/shaderColorPerVertex.h" #include "Utils/Shaders/shaderColorPerVertex.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -36,7 +36,6 @@ namespace Utils ...@@ -36,7 +36,6 @@ namespace Utils
#include "shaderColorPerVertexClip.vert" #include "shaderColorPerVertexClip.vert"
#include "shaderColorPerVertexClip.frag" #include "shaderColorPerVertexClip.frag"
ShaderColorPerVertex::ShaderColorPerVertex(bool withClipping, bool black_is_transparent) ShaderColorPerVertex::ShaderColorPerVertex(bool withClipping, bool black_is_transparent)
{ {
if (withClipping) if (withClipping)
...@@ -102,7 +101,6 @@ unsigned int ShaderColorPerVertex::setAttributeColor(VBO* vbo) ...@@ -102,7 +101,6 @@ unsigned int ShaderColorPerVertex::setAttributeColor(VBO* vbo)
return id; return id;
} }
void ShaderColorPerVertex::restoreUniformsAttribs() void ShaderColorPerVertex::restoreUniformsAttribs()
{ {
bind(); bind();
...@@ -129,8 +127,6 @@ void ShaderColorPerVertex::setClippingPlane(const Geom::Vec4f& plane) ...@@ -129,8 +127,6 @@ void ShaderColorPerVertex::setClippingPlane(const Geom::Vec4f& plane)
unbind(); unbind();
} }
} // namespace Utils } // namespace Utils
} // namespace CGoGN } // namespace CGoGN
...@@ -92,7 +92,6 @@ void ShaderSimpleColor::setColor(const Geom::Vec4f& color) ...@@ -92,7 +92,6 @@ void ShaderSimpleColor::setColor(const Geom::Vec4f& color)
unbind(); unbind();
} }
void ShaderSimpleColor::setClippingPlane(const Geom::Vec4f& plane) void ShaderSimpleColor::setClippingPlane(const Geom::Vec4f& plane)
{ {
m_planeClip = plane; m_planeClip = plane;
...@@ -101,7 +100,6 @@ void ShaderSimpleColor::setClippingPlane(const Geom::Vec4f& plane) ...@@ -101,7 +100,6 @@ void ShaderSimpleColor::setClippingPlane(const Geom::Vec4f& plane)
unbind(); unbind();
} }
unsigned int ShaderSimpleColor::setAttributePosition(VBO* vbo) unsigned int ShaderSimpleColor::setAttributePosition(VBO* vbo)
{ {
m_vboPos = vbo; m_vboPos = vbo;
......
...@@ -35,6 +35,12 @@ IF (WIN32) ...@@ -35,6 +35,12 @@ IF (WIN32)
SET ( CGoGN_WITH_QTCREATOR OFF CACHE BOOL "use QtCreator to compile (Experimental" ) SET ( CGoGN_WITH_QTCREATOR OFF CACHE BOOL "use QtCreator to compile (Experimental" )
ENDIF() ENDIF()
IF (LINUX)
SET ( CGoGN_GCC_4_9 OFF CACHE BOOL "using gcc version > 4.9 (std::regex ok !)" )
ENDIF()
SET ( BUILD_SHARED_LIBS ON CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
checkCpp11Support() checkCpp11Support()
checkCpp11Feature("regex" HAS_CPP11_REGEX "False") checkCpp11Feature("regex" HAS_CPP11_REGEX "False")
...@@ -166,12 +172,8 @@ IF(WIN32) ...@@ -166,12 +172,8 @@ IF(WIN32)
ENDIF () ENDIF ()
IF (APPLE) IF (CGoGN_GCC_4_9)
LIST(APPEND CGoGN_DEFS -DCGOGN_APPLE) LIST(APPEND CGoGN_DEFS -DCGOGN_GCC_4_9)
ENDIF ()
IF (HAS_CPP11_REGEX)
LIST(APPEND CGoGN_DEFS -DHAS_CPP11_REGEX)
ENDIF () ENDIF ()
......
...@@ -28,6 +28,8 @@ ADD_SUBDIRECTORY(surface_modelisation) ...@@ -28,6 +28,8 @@ ADD_SUBDIRECTORY(surface_modelisation)
ADD_SUBDIRECTORY(surface_distance) ADD_SUBDIRECTORY(surface_distance)
ADD_SUBDIRECTORY(surface_radiance) ADD_SUBDIRECTORY(surface_radiance)
ADD_SUBDIRECTORY(cage2D_deformation)
ADD_SUBDIRECTORY(volume_import) ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render) #ADD_SUBDIRECTORY(volume_render)
......
...@@ -113,7 +113,7 @@ void MapParameters::stop(MapHandlerGen* mh) ...@@ -113,7 +113,7 @@ void MapParameters::stop(MapHandlerGen* mh)
bool Surface_Deformation_Plugin::enable() bool Surface_Deformation_Plugin::enable()
{ {
// magic line that init static variables of GenericMap in the plugins // magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers()); GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Deformation_DockTab(m_schnapps, this); m_dockTab = new Surface_Deformation_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Deformation"); m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Deformation");
...@@ -380,16 +380,16 @@ void Surface_Deformation_Plugin::toggleMapDeformation(MapHandlerGen* map) ...@@ -380,16 +380,16 @@ void Surface_Deformation_Plugin::toggleMapDeformation(MapHandlerGen* map)
if(map) if(map)
{ {
MapParameters& p = h_parameterSet[map]; MapParameters& p = h_parameterSet[map];
if(!p.initialized) if (!p.initialized)
{ {
p.start(map); p.start(map);
if(p.initialized && map->isSelectedMap()) if (p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(true); m_dockTab->mapParametersInitialized(true);
} }
else else
{ {
p.stop(map); p.stop(map);
if(!p.initialized && map->isSelectedMap()) if (!p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(false); m_dockTab->mapParametersInitialized(false);
} }
} }
...@@ -401,9 +401,9 @@ void Surface_Deformation_Plugin::matchDiffCoord(MapHandlerGen* mh) ...@@ -401,9 +401,9 @@ void Surface_Deformation_Plugin::matchDiffCoord(MapHandlerGen* mh)
MapParameters& p = h_parameterSet[mh]; MapParameters& p = h_parameterSet[mh];
nlMakeCurrent(p.nlContext); nlMakeCurrent(p.nlContext);
if(nlGetCurrentState() == NL_STATE_INITIAL) if (nlGetCurrentState() == NL_STATE_INITIAL)
nlBegin(NL_SYSTEM) ; nlBegin(NL_SYSTEM) ;
for(int coord = 0; coord < 3; ++coord) for (int coord = 0; coord < 3; ++coord)
{ {
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord); LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX); nlBegin(NL_MATRIX);
...@@ -421,13 +421,13 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -421,13 +421,13 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap(); PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap();
MapParameters& p = h_parameterSet[mh]; MapParameters& p = h_parameterSet[mh];
if(p.initialized) if (p.initialized)
{ {
CellMarkerNoUnmark<PFP2::MAP, VERTEX> m(*map) ; CellMarkerNoUnmark<PFP2::MAP, VERTEX> m(*map) ;
for(Dart d = map->begin(); d != map->end(); map->next(d)) for (Dart d = map->begin(); d != map->end(); map->next(d))
{ {
if(!m.isMarked(d)) if (!m.isMarked(d))
{ {
m.mark(d) ; m.mark(d) ;
...@@ -441,11 +441,11 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -441,11 +441,11 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
Dart neigh = map->phi1(it) ; Dart neigh = map->phi1(it) ;
PFP2::VEC3 v = p.positionAttribute[neigh] - pp ; PFP2::VEC3 v = p.positionAttribute[neigh] - pp ;
PFP2::VEC3 vv = p.positionInit[neigh] - ppInit ; PFP2::VEC3 vv = p.positionInit[neigh] - ppInit ;
for(unsigned int i = 0; i < 3; ++i) for (unsigned int i = 0; i < 3; ++i)
for(unsigned int j = 0; j < 3; ++j) for (unsigned int j = 0; j < 3; ++j)
cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[it] / area ; cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[it] / area ;
Dart dboundary = map->phi_1(it) ; Dart dboundary = map->phi_1(it) ;
if(map->phi2(dboundary) == dboundary) if (map->phi2(dboundary) == dboundary)
{ {
v = p.positionAttribute[dboundary] - pp ; v = p.positionAttribute[dboundary] - pp ;
vv = p.positionInit[dboundary] - pp ; vv = p.positionInit[dboundary] - pp ;
...@@ -454,15 +454,15 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -454,15 +454,15 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[dboundary] / area ; cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[dboundary] / area ;
} }
it = map->alpha1(it) ; it = map->alpha1(it) ;
} while(it != d) ; } while (it != d) ;
Eigen::JacobiSVD<Eigen::Matrix3f> svd(cov, Eigen::ComputeFullU | Eigen::ComputeFullV) ; Eigen::JacobiSVD<Eigen::Matrix3f> svd(cov, Eigen::ComputeFullU | Eigen::ComputeFullV) ;
Eigen::Matrix3f R = svd.matrixU() * svd.matrixV().transpose() ; Eigen::Matrix3f R = svd.matrixU() * svd.matrixV().transpose() ;
if(R.determinant() < 0) if (R.determinant() < 0)
{ {
Eigen::Matrix3f U = svd.matrixU() ; Eigen::Matrix3f U = svd.matrixU() ;
for(unsigned int i = 0; i < 3; ++i) for (unsigned int i = 0; i < 3; ++i)
U(i,2) *= -1 ; U(i,2) *= -1 ;
R = U * svd.matrixV().transpose() ; R = U * svd.matrixV().transpose() ;
} }
...@@ -471,9 +471,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -471,9 +471,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
} }
} }
for(Dart d = map->begin(); d != map->end(); map->next(d)) for (Dart d = map->begin(); d != map->end(); map->next(d))
{ {
if(m.isMarked(d)) if (m.isMarked(d))
{ {
m.unmark(d) ; m.unmark(d) ;
...@@ -491,7 +491,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -491,7 +491,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
++degree ; ++degree ;
} }
it = map->alpha1(it) ; it = map->alpha1(it) ;
} while(it != d) ; } while (it != d) ;
r += p.vertexRotationMatrix[d] ; r += p.vertexRotationMatrix[d] ;
r /= degree + 1 ; r /= degree + 1 ;
PFP2::VEC3& dc = p.diffCoord[d] ; PFP2::VEC3& dc = p.diffCoord[d] ;
...@@ -531,9 +531,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -531,9 +531,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
} }
nlMakeCurrent(p.nlContext); nlMakeCurrent(p.nlContext);
if(nlGetCurrentState() == NL_STATE_INITIAL) if (nlGetCurrentState() == NL_STATE_INITIAL)
nlBegin(NL_SYSTEM); nlBegin(NL_SYSTEM);
for(int coord = 0; coord < 3; ++coord) for (int coord = 0; coord < 3; ++coord)
{ {
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord); LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX); nlBegin(NL_MATRIX);
......
...@@ -29,11 +29,15 @@ private: ...@@ -29,11 +29,15 @@ private:
virtual void disable() {} virtual void disable() {}
public slots: public slots:
MapHandlerGen* importFromFile(const QString& fileName); MapHandlerGen* importMeshFromFile(const QString& fileName);
void importFromFileDialog(); void importMeshFromFileDialog();
MapHandlerGen* importImageFromFile(const QString& fileName);
void importImageFromFileDialog();
private: private:
QAction* importAction; QAction* importMeshAction;
QAction* importImageAction;
}; };
} // namespace SCHNApps } // namespace SCHNApps
...@@ -41,4 +45,3 @@ private: ...@@ -41,4 +45,3 @@ private:
} // namespace CGoGN } // namespace CGoGN
#endif #endif
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "mapHandler.h" #include "mapHandler.h"
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Tiling/Surface/square.h"
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
...@@ -19,13 +20,18 @@ bool Surface_Import_Plugin::enable() ...@@ -19,13 +20,18 @@ bool Surface_Import_Plugin::enable()
// magic line that init static variables of GenericMap in the plugins // magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers()); GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
importAction = new QAction("import", this); importMeshAction = new QAction("import mesh", this);
m_schnapps->addMenuAction(this, "Surface;Import", importAction); m_schnapps->addMenuAction(this, "Surface;Import Mesh", importMeshAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog())); connect(importMeshAction, SIGNAL(triggered()), this, SLOT(importMeshFromFileDialog()));
importImageAction = new QAction("import image", this);
m_schnapps->addMenuAction(this, "Surface;Import Image", importImageAction);
connect(importImageAction, SIGNAL(triggered()), this, SLOT(importImageFromFileDialog()));
return true; return true;
} }
MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName) MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& fileName)
{ {
QFileInfo fi(fileName); QFileInfo fi(fileName);
if(fi.exists()) if(fi.exists())
...@@ -58,12 +64,72 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName) ...@@ -58,12 +64,72 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName)
return NULL; return NULL;
} }