Commit 8d72c7e1 authored by untereiner's avatar untereiner

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

parents c3bafddc db4115a5
......@@ -15,6 +15,7 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
)
# define libs path
......
......@@ -16,6 +16,7 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
)
......
......@@ -246,7 +246,7 @@ void myGlutWin::myKeyboard(unsigned char keycode, int, int)
case 's':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::CatmullClarkSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "catmull-clark: "<< seconds << "sec" << std::endl;
......@@ -259,11 +259,11 @@ void myGlutWin::myKeyboard(unsigned char keycode, int, int)
case 'l':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "loop: "<< seconds << "sec" << std::endl;
......@@ -276,7 +276,7 @@ void myGlutWin::myKeyboard(unsigned char keycode, int, int)
case 'd':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::Sqrt3Subdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::Sqrt3Subdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "dual: "<< seconds << "sec" << std::endl;
......
......@@ -118,7 +118,7 @@ void myGlutWin::init()
glClearColor(0.1f,0.1f,0.1f,0.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
// glEnable(GL_NORMALIZE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
......
......@@ -433,7 +433,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 'l':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::LoopSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "loop: "<< seconds << "sec" << std::endl;
......@@ -454,7 +454,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 'c':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::CatmullClarkSubdivision<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position);
Algo::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "catmull-clark: "<< seconds << "sec" << std::endl;
......@@ -475,7 +475,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 't':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::trianguleFaces<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position) ;
Algo::Modelisation::trianguleFaces<PFP>(myMap, position) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "triangulation: "<< seconds << "sec" << std::endl;
......@@ -495,7 +495,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 'q':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::quadranguleFaces<PFP, AttributeHandler<PFP::VEC3>, PFP::VEC3>(myMap, position) ;
Algo::Modelisation::quadranguleFaces<PFP>(myMap, position) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "quadrangulation: "<< seconds << "sec" << std::endl;
......@@ -534,6 +534,99 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break ;
}
case 'd':
{
myMap.removeAttribute<PFP::VEC3>(normal) ;
myMap.removeAttribute<PFP::VEC3>(laplacian) ;
AttributeHandler<PFP::VEC3> newPosition = myMap.addAttribute<PFP::VEC3>(FACE_ORBIT, "position") ;
Algo::Geometry::computeCentroidFaces<PFP>(myMap, position, newPosition) ;
GLint t1 = glutGet(GLUT_ELAPSED_TIME);
Algo::Modelisation::computeDual<PFP>(myMap) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "dual computation: "<< seconds << "sec" << std::endl;
newPosition = myMap.getAttribute<PFP::VEC3>(FACE_ORBIT, "position") ;
myMap.removeAttribute<PFP::VEC3>(newPosition) ;
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "position") ;
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
laplacian = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ;
t1 = glutGet(GLUT_ELAPSED_TIME);
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f;
std::cout << "display update: "<< seconds << "sec" << std::endl;
glutPostRedisplay() ;
break ;
}
case '3':
{
CellMarker markVisit(myMap, VERTEX_CELL) ;
CellMarker markNoDelete(myMap, VERTEX_CELL) ;
std::vector<Dart> visited ;
visited.reserve(myMap.getNbCells(VERTEX_CELL)) ;
visited.push_back(myMap.begin()) ;
markVisit.mark(myMap.begin()) ;
for(std::vector<Dart>::iterator vertex = visited.begin(); vertex != visited.end(); ++vertex)
{
bool deleteV = true ;
if(markNoDelete.isMarked(*vertex))
deleteV = false ;
Dart vit = *vertex ;
do // add all vertex neighbors to the table
{
Dart nv = myMap.phi1(vit) ;
if(!markVisit.isMarked(nv))
{
visited.push_back(nv) ;
markVisit.mark(nv) ;
}
if(deleteV)
markNoDelete.mark(nv) ;
vit = myMap.alpha1(vit) ;
} while(vit != *vertex) ;
if(deleteV)
myMap.deleteVertex(*vertex) ;
}
// for(Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
// {
// if(!markVisit.isMarked(d))
// {
// Dart dd = myMap.phi1(d) ;
// myMap.deleteVertex(d) ;
// Dart fit = dd ;
// do
// {
// markVisit.mark(fit) ;
// fit = myMap.phi1(fit) ;
// } while(fit != dd) ;
// }
// }
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
glutPostRedisplay() ;
break ;
}
case 'a':
{
Algo::Geometry::computeLaplacianVertices<PFP>(myMap, Algo::Geometry::TOPOLOGICAL, position, laplacian) ;
......@@ -633,6 +726,7 @@ int main(int argc, char** argv)
std::cerr << "could not import " << filename << std::endl ;
return 1 ;
}
mgw->position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
......
......@@ -186,7 +186,7 @@ void myGlutWin::myRedraw(void)
// glEnable(GL_COLOR_MATERIAL);
// glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
// glColor3f(0.0f,0.0f,0.9f);
// m_render->draw(Algo::Render::VBO::FLAT_TRIANGLES) ;
// m_render->draw(Algo::Render::VBO::TRIANGLES) ;
//
// glDisable( GL_POLYGON_OFFSET_FILL );
......@@ -214,53 +214,83 @@ int main(int argc, char **argv)
mgw.position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position") ;
mgw.normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
glewInit();
if (! Utils::GLSLShader::areShadersSupported())
{
std::cerr << "Shaders not supported"<< std::endl;
exit(1);
}
Utils::GLSLShader* phong = new Utils::GLSLShader() ;
phong->loadShaders("phong_vs.txt", "phong_ps.txt") ;
Algo::Modelisation::Polyhedron<PFP> prim1(myMap, mgw.position);
prim1.cylinder_topo(16,15, true, true);
prim1.embedCylinder(30.0f,20.0f,50.0f);
CellMarker mark1(myMap,VERTEX_CELL);
prim1.mark(mark1);
// Algo::Modelisation::Polyhedron<PFP> prim1(myMap, mgw.position);
// prim1.cylinder_topo(16,16, true, true); // topo of sphere is a closed cylinder
// prim1.embedCylinder(40.0f,40.0f,30.0f);
//
// CellMarker mark1(myMap,VERTEX_CELL);
// prim1.mark(mark1);
//
// create a sphere
Algo::Modelisation::Polyhedron<PFP> prim2(myMap, mgw.position);
prim2.cylinder_topo(16,16, true, true); // topo of sphere is a closed cylinder
prim2.cylinder_topo(16,16, true, true);
prim2.embedSphere(40.0f);
//
// CellMarker mark2(myMap,VERTEX_CELL);
// prim2.mark(mark2);
//
// Algo::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
//
// Algo::Render::VBO::MapRender_VBO render1 = new Algo::Render::VBO::MapRender_VBO() ;
//
// render1->updateData(Algo::Render::VBO::POSITIONS, position);
// render1->updateData(Algo::Render::VBO::NORMALS, normal);
// // update flat faces primtives (warning need position buffer)
// render1->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::FLAT_TRIANGLES);
// // update smooth faces primtives
// render1->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES);
// // update lines primitives
// render1->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES);
//
//
CellMarker mark2(myMap,VERTEX_CELL);
prim2.mark(mark2);
// create a sphere
Algo::Modelisation::Polyhedron<PFP> prim3(myMap, mgw.position);
prim3.tore_topo(12,48);
prim3.embedTore(50.0f,10.0f);
CellMarker mark3(myMap,VERTEX_CELL);
prim3.mark(mark3);
Algo::Geometry::computeNormalVertices<PFP>(myMap, mgw.position, mgw.normal) ;
Algo::Render::VBO::MapRender_VBO* render1 = new Algo::Render::VBO::MapRender_VBO() ;
render1->updateData(Algo::Render::VBO::POSITIONS, mgw.position);
render1->updateData(Algo::Render::VBO::NORMALS, mgw.normal);
SelectorCellMarked cm1(mark1);
render1->initPrimitives<PFP>(myMap, cm1, Algo::Render::VBO::TRIANGLES);
render1->initPrimitives<PFP>(myMap, cm1, Algo::Render::VBO::FLAT_TRIANGLES);
render1->initPrimitives<PFP>(myMap, cm1, Algo::Render::VBO::LINES);
Algo::Render::VBO::MapRender_VBO* render2 = new Algo::Render::VBO::MapRender_VBO(*render1) ;
SelectorCellMarked cm2(mark2);
render2->initPrimitives<PFP>(myMap, cm2, Algo::Render::VBO::TRIANGLES);
render2->initPrimitives<PFP>(myMap, cm2, Algo::Render::VBO::FLAT_TRIANGLES);
render2->initPrimitives<PFP>(myMap, cm2, Algo::Render::VBO::POINTS);
Algo::Render::VBO::MapRender_VBO* render3 = new Algo::Render::VBO::MapRender_VBO(*render1) ;
SelectorCellMarked cm3(mark3);
render3->initPrimitives<PFP>(myMap, cm3, Algo::Render::VBO::FLAT_TRIANGLES);
render3->initPrimitives<PFP>(myMap, cm3, Algo::Render::VBO::TRIANGLES);
render3->initPrimitives<PFP>(myMap, cm3, Algo::Render::VBO::LINES);
// update renderer
mgw.updateRender();
mgw.root = new Utils::SceneGraph::Group_Node();
Utils::SceneGraph::Material_Node* mater = new Utils::SceneGraph::Material_Node();
mater->setDiffuse(Geom::Vec4f(0.3f, 1.0f, 0.0f, 1.0f));
mater->setAmbient(Geom::Vec4f(0.1f, 0.1f, 0.1f, 1.0f));
mater->setSpecular(Geom::Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
mater->setShininess(100.0f);
mater->setColor(Geom::Vec4f(0.0f, 0.0f, 0.0f, 1.0f));
mater->setShader(phong);
mgw.root->setMaterial(mater);
Utils::SceneGraph::VBO_Node* vbon = new Utils::SceneGraph::VBO_Node(mgw.m_render);
Utils::SceneGraph::VBO_Node* vbon = new Utils::SceneGraph::VBO_Node(render1);
vbon->setPrimitives(Algo::Render::VBO::FLAT_TRIANGLES);
vbon->setPrimitives(Algo::Render::VBO::LINES);
mgw.root->addChild(vbon);
......@@ -272,11 +302,10 @@ int main(int argc, char **argv)
mgw.root->addChild(group1);
vbon = new Utils::SceneGraph::VBO_Node(mgw.m_render);
vbon->setPrimitives(Algo::Render::VBO::TRIANGLES);
vbon->setPrimitives(Algo::Render::VBO::LINES);
group1->addChild(vbon);
Utils::SceneGraph::VBO_Node* vbon2 = new Utils::SceneGraph::VBO_Node(render2);
vbon2->setPrimitives(Algo::Render::VBO::TRIANGLES);
vbon2->setPrimitives(Algo::Render::VBO::POINTS);
group1->addChild(vbon2);
Utils::SceneGraph::Group_Node* group2 = new Utils::SceneGraph::Group_Node();
......@@ -289,18 +318,21 @@ int main(int argc, char **argv)
mater = new Utils::SceneGraph::Material_Node();
mater->setDiffuse(Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f));
mater->setAmbient(Geom::Vec4f(0.1f, 0.1f, 0.1f, 1.0f));
mater->setSpecular(Geom::Vec4f(1.0f, 1.0f, 1.0f, 1.0f));
mater->setShininess(100.0f);
mater->setColor(Geom::Vec4f(1.0f, 1.0f, 0.0f, 1.0f));
mater->setNoShader();
group2->setMaterial(mater);
vbon = new Utils::SceneGraph::VBO_Node(mgw.m_render);
vbon->setPrimitives(Algo::Render::VBO::FLAT_TRIANGLES);
vbon = new Utils::SceneGraph::VBO_Node(render3);
vbon->setPrimitives(Algo::Render::VBO::TRIANGLES);
vbon->setPrimitives(Algo::Render::VBO::LINES);
group2->addChild(vbon);
// compute BB and store it for object positionning in screen
// Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap,mgw.position) ;
// not possible here to compute a BB !!
mgw.gWidthObj = 200.0f;
mgw.gPosObj = Geom::Vec3f(100.0f,0.0f,0.0f);
......
......@@ -4,6 +4,8 @@ project(Tutos)
#SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm)
#SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
......@@ -14,6 +16,7 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/gzstream
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
${CGoGN_ROOT_DIR}/include
)
......@@ -49,3 +52,15 @@ target_link_libraries( tuto_subdivision
add_executable( tp_master tp_master.cpp)
target_link_libraries( tp_master
container topology utils algo ${COMMON_LIBS} )
add_executable( tuto_mt tuto_mt.cpp)
target_link_libraries( tuto_mt
container topology utils algo ${COMMON_LIBS} boost_thread-mt)
add_executable( tuto_ogl3 tuto_ogl3.cpp)
target_link_libraries( tuto_ogl3
container topology utils algo ${COMMON_LIBS} )
add_executable( tuto_ogl2 tuto_ogl2.cpp)
target_link_libraries( tuto_ogl2
container topology utils algo ${COMMON_LIBS} )
......@@ -100,6 +100,7 @@ Dart d_maison;
Dart Carre()
{
return Dart::nil();
}
......@@ -107,7 +108,7 @@ Dart Carre()
Dart Triangle()
{
return Dart::nil();
}
......@@ -141,7 +142,7 @@ void ColleMilieu(Dart d, Dart e)
Dart Maison()
{
return Dart::nil();
}
......@@ -634,7 +635,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
/// calcul du rayon
getOrthoScreenRay(x,y,rayA,rayB);
PFP::VEC3 AB = rayB-rayA;
float AB2 = AB.norm2();
d_faces.clear();
d_edges.clear();
......@@ -678,7 +678,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
/// Rayon
getOrthoScreenRay(x,y,rayA,rayB);
PFP::VEC3 AB = rayB-rayA;
float AB2 = AB.norm2();
d_faces.clear();
d_edges.clear();
......
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include "Utils/glutwin.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/vbo_MapRender.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Geometry/vector_gen.h"
#include "Algo/Geometry/normal.h"
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
*/