Commit eff3eec9 authored by Sauvage's avatar Sauvage

Merge remote-tracking branch 'CGoGNcentral/develop' into develop

Conflicts:
	include/Algo/Selection/collector.hpp
parents 5818c801 679b508c
# ignore QtCreator files
CMakeLists.txt.user
\ No newline at end of file
CMakeLists.txt.user
bin/
ThirdParty/bin/
SCHNApps/bin
\ No newline at end of file
......@@ -2,7 +2,7 @@
IF (ONELIB)
SET(CGoGN_LIBS cgogn)
ELSE (ONELIB)
SET(CGoGN_LIBS topology algo container utils)
SET(CGoGN_LIBS algo topology container utils)
ENDIF (ONELIB)
......
......@@ -837,9 +837,6 @@ void Clipping::importMesh(std::string& filename)
void Clipping::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
m_render_topo = new Algo::Render::GL2::Topo3RenderMap<PFP>();
......
......@@ -139,9 +139,6 @@ unsigned int nb_ears;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
......
......@@ -59,9 +59,6 @@ MAP myMap;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
......
......@@ -57,9 +57,6 @@ PFP::MAP myMap;
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_frame = new Utils::FrameManipulator();
// frame is rendered twice the size of normal
......
......@@ -49,8 +49,6 @@ void MCMesh::cb_initGL()
Geom::Vec4f colDif(0.8f, 0.9f, 0.7f, 1.0f);
Geom::Vec4f colSpec(0.9f, 0.9f, 0.9f, 1.0f);
Utils::GLSLShader::setCurrentOGLVersion(2);
m_render = new Algo::Render::GL2::MapRender();
m_positionVBO = new Utils::VBO();
......
......@@ -60,8 +60,6 @@ void SimpleGMap2::initGUI()
void SimpleGMap2::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(1) ;
Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......
......@@ -122,8 +122,6 @@ void SimpleGMap3::cb_keyPress(int code)
void SimpleGMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......
......@@ -95,8 +95,6 @@ void SimpleMap3::initGUI()
void SimpleMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
......@@ -110,10 +108,10 @@ void SimpleMap3::cb_initGL()
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f);
m_render_topo_boundary = new Algo::Render::GL2::TopoRenderMap<PFP>();
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setDartWidth(2.0f);
m_render_topo_boundary->setInitialDartsColor(0.4f,0.8f,0.4f);
m_render_topo_boundary->updateDataBoundary(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_primal = new Algo::Render::GL2::Topo3PrimalRender<PFP>();
m_render_topo_primal->setDartWidth(2.0f);
......
......@@ -58,7 +58,7 @@ public:
VertexAttribute<VEC3, MAP> position ;
Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo;
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo_boundary;
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Algo::Render::GL2::Topo3PrimalRender<PFP>* m_render_topo_primal;
SimpleMap3() ;
......
......@@ -48,9 +48,6 @@ TexView::~TexView()
void TexView::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create VBO for position
m_positionVBO = new Utils::VBO;
m_texcoordVBO = new Utils::VBO;
......
......@@ -23,7 +23,6 @@
*******************************************************************************/
#include "viewer.h"
#include "Utils/chrono.h"
Viewer::Viewer() :
m_renderStyle(FLAT),
......@@ -38,7 +37,8 @@ Viewer::Viewer() :
m_flatShader(NULL),
m_vectorShader(NULL),
m_simpleColorShader(NULL),
m_pointSprite(NULL)
m_pointSprite(NULL),
m_nbFrames(0)
{
normalScaleFactor = 1.0f ;
vertexScaleFactor = 0.1f ;
......@@ -78,10 +78,14 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
int major = 0;
int minor = 0;
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
CGoGNout <<"Using GL "<< major <<"."<< minor << CGoGNendl;
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -96,11 +100,12 @@ void Viewer::cb_initGL()
m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ;
m_flatShader = new Utils::ShaderFlat() ;
m_flatShader = new Utils::ShaderSimpleFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ;
m_flatShader->setExplode(faceShrinkage) ;
// m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
// m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ;
......@@ -127,12 +132,14 @@ void Viewer::cb_redraw()
{
if(m_drawVertices)
{
glDepthFunc(GL_LEQUAL);
m_pointSprite->setSize(vertexScaleFactor) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
}
if(m_drawEdges)
{
glDepthFunc(GL_LEQUAL);
glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
}
......@@ -143,10 +150,10 @@ void Viewer::cb_redraw()
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
glDepthFunc(GL_LESS);
switch(m_renderStyle)
{
case FLAT :
m_flatShader->setExplode(faceShrinkage) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
break ;
case PHONG :
......@@ -158,6 +165,7 @@ void Viewer::cb_redraw()
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
......@@ -168,6 +176,14 @@ void Viewer::cb_redraw()
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
m_nbFrames++;
if (m_nbFrames >=100)
{
std::cout << 100000.0/m_frame_ch.elapsed()<< " fps"<<std::endl;
m_nbFrames = 0;
m_frame_ch.start();
}
}
void Viewer::cb_Open()
......@@ -540,7 +556,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -42,12 +42,13 @@
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
#include "Utils/text3d.h"
#include "Utils/vbo.h"
#include "Utils/chrono.h"
#include "Utils/Qt/qtInputs.h"
......@@ -104,17 +105,20 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
Utils::ShaderPhong* m_phongShader ;
Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleFlat* m_flatShader ;
Utils::ShaderVectorPerVertex* m_vectorShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::PointSprite* m_pointSprite ;
Utils::Chrono m_frame_ch;
unsigned int m_nbFrames;
Viewer() ;
void initGUI() ;
......
......@@ -96,9 +96,6 @@ void ObjView::cb_keyPress(int k)
void ObjView::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
m_dr = new Utils::Drawer;
// create VBO for position
......
......@@ -169,7 +169,6 @@ void MyQT::cb_Open()
color = myMap.addAttribute<VEC3, VOLUME, MAP>("color");
TraversorCell<MAP, VOLUME> tra(myMap);
float maxV = 0.0f;
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
{
// float v = Algo::Geometry::tetrahedronVolume<PFP>(myMap, d, position);
......@@ -205,9 +204,6 @@ void MyQT::cb_Save()
void MyQT::cb_initGL()
{
// choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the renders
m_topo_render = new Algo::Render::GL2::Topo3RenderMap<PFP>();
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
......@@ -446,13 +442,13 @@ int main(int argc, char **argv)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
int nb = 8;
int nb = 32;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i = position.begin(); i != position.end(); position.next(i))
{
VEC3 pert(float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0));
VEC3 pert(float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0));
position[i]+= pert;
}
......@@ -503,11 +499,11 @@ int main(int argc, char **argv)
Utils::Chrono ch;
Vertex v(myMap.begin());
VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position);
// Vertex v(myMap.begin());
// VEC3 p = Algo::Volume::Geometry::vertexNeighborhoodCentroid<PFP>(myMap,v,position);
Vol w(myMap.begin());
VEC3 q = Algo::Surface::Geometry::volumeCentroid<PFP>(myMap,w,position);
// Vol w(myMap.begin());
// VEC3 q = Algo::Surface::Geometry::volumeCentroid<PFP>(myMap,w,position);
ch.start();
float vol = Algo::Geometry::Parallel::totalVolume<PFP>(myMap, position);
......
......@@ -24,6 +24,9 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(multi_att multi_att.cpp)
target_link_libraries(multi_att ${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
add_executable(trav3_test trav3_test.cpp)
target_link_libraries(trav3_test ${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
IF (WITH_QT)
QT4_WRAP_CPP(tilings_moc tilings.h)
add_executable(tilings tilings.cpp ${tilings_moc})
......
......@@ -82,10 +82,8 @@ void Viewer::initGUI()
void Viewer::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2) ;
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -232,7 +230,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -267,7 +265,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -338,7 +336,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -103,7 +103,7 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
......
......@@ -75,8 +75,7 @@ void MyQT::traversors(int x)
// update all color to grey
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
m_render_topo->addColoredDart(d,0.5f,0.5f,0.5f);
}
switch(x)
......@@ -85,7 +84,7 @@ void MyQT::traversors(int x)
{
Traversor2VVaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
......@@ -94,14 +93,14 @@ void MyQT::traversors(int x)
Traversor2VVaF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 2:
{
Traversor2EEaV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}