Commit 6041ef2b authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~cgogn/CGoGN

parents c227798f 2959efd3
......@@ -73,3 +73,14 @@ add_executable( ter_meshesD ../ter_meshes.cpp)
target_link_libraries( ter_meshesD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( polyhedronsViewD ../polyhedronsView.cpp)
target_link_libraries( polyhedronsViewD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( extrusionViewD ../extrusionView.cpp)
target_link_libraries( extrusionViewD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
add_executable( sceneD ../scene.cpp)
target_link_libraries( sceneD
containerD topologyD utilsD algoD ${COMMON_LIBS} )
......@@ -237,9 +237,9 @@ void MyGlutWin::init()
myMap.copyAttribute(originalPosition, position) ;
vbo_render = new Algo::Render::VBO::MapRender_VBO<PFP>(myMap, allDarts) ;
vbo_render->initPrimitives(Algo::Render::VBO::TRIANGLES) ;
vbo_render->initPrimitives(Algo::Render::VBO::LINES) ;
vbo_render = new Algo::Render::VBO::MapRender_VBO() ;
vbo_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES) ;
vbo_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
}
......
......@@ -27,6 +27,7 @@
#include "Utils/glutwin_atb.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
......@@ -44,23 +45,10 @@
using namespace CGoGN ;
struct PFP
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef Map2 MAP;
// definition of the type of real value
typedef float REAL;
// other types definitions
typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
};
......@@ -105,7 +93,7 @@ public:
PFP::TVEC3 faceNormal ;
PFP::TVEC3 faceCentroid ;
Algo::Render::VBO::MapRender_VBO<PFP>* vbo_render ;
Algo::Render::VBO::MapRender_VBO* vbo_render ;
GLuint dl_norm ;
MyGlutWin(int* argc, char **argv, int winX, int winY) ;
......
......@@ -236,8 +236,8 @@ void myGlutWin::initDL(void)
vbor = new VBORenderType(myMap,allDarts, my_vbo_cb);
vbor->initData(0,invertedNormals);
vbor->initPrimitives(Algo::Render::VBO::VBO_TRIANGLES);
vbor->initPrimitives(Algo::Render::VBO::VBO_LINES);
vbor->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::VBO_TRIANGLES);
vbor->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::VBO_LINES);
// vbor->initEmb_Flat_Exploded(myMap.getNbDarts() , true, invertedNormals,0.8f);
......
......@@ -141,3 +141,15 @@ target_link_libraries( triangulation
add_executable( ter_meshes ../ter_meshes.cpp)
target_link_libraries( ter_meshes
container topology utils algo ${COMMON_LIBS} )
add_executable( polyhedronsView ../polyhedronsView.cpp)
target_link_libraries( polyhedronsView
container topology utils algo ${COMMON_LIBS} )
add_executable( extrusionView ../extrusionView.cpp)
target_link_libraries( extrusionView
container topology utils algo ${COMMON_LIBS} )
add_executable( scene ../scene.cpp)
target_link_libraries( scene
container topology utils algo ${COMMON_LIBS} )
......@@ -4,6 +4,7 @@
#include <iostream>
// #include "Definitions.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
......@@ -23,28 +24,19 @@ using namespace CGoGN;
class Agent;
struct PFP {
struct PFP: public PFP_STANDARD
{
// definition de la carte
// typedef EmbeddedMap2<Map2> MAP;
typedef Algo::IHM::ImplicitHierarchicalMap MAP;
// definition du type de reel utilise
typedef float REAL;
// definition du type de vecteur (point) utilise
typedef Geom::Vec3f VEC3;
// definition des listes d'agent
// typedef std::vector<Agent *> AGENTS;
typedef std::vector<Agent * > AGENTS;
typedef NoMathIONameAttribute<AGENTS > AGENTVECT;
typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<AGENTVECT> TAB_AGENTVECT;
// definition des cellules abstraites
// typedef MAP::EVertex EVERTEX;
// typedef MAP::EEdge EEDGE;
// typedef MAP::EFace EFACE;
// typedef MAP::EVolume EVOLUME;
};
typedef PFP::VEC3 VEC3 ;
......
......@@ -72,8 +72,8 @@ public:
void myKeyboard(unsigned char keycode, int x, int y);
void myMouse(int button, int state, int x, int y);
Algo::Render::VBO::MapRender_VBO<PFP>* m_render;
Algo::Render::VBO::MapRender_VBO<PFP>* m_render_line ;
Algo::Render::VBO::MapRender_VBO* m_render;
Algo::Render::VBO::MapRender_VBO* m_render_line ;
// Algo::Render::VBO::topo_MD2_VBORender<PFP>* topo_render ;
// Algo::Render::VBO::topo_VBORenderMapD* topo_render ;
......
......@@ -63,15 +63,15 @@ void MyGlutWin::init()
// topo_render = new Algo::Render::VBO::topo_VBORenderMapD() ;
// m_render = new Algo::Render::VBO::MapRender_VBO<PFP>(sim->envMap.map, allDarts) ;
// m_render->initPrimitives(Algo::Render::VBO::TRIANGLES) ;
// m_render = new Algo::Render::VBO::MapRender_VBO(sim->envMap.map, allDarts) ;
// m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::TRIANGLES) ;
// m_render->updateData(Algo::Render::VBO::POSITIONS, sim->envMap.position) ;
// Algo::Geometry::computeNormalFaces<PFP>(sim->envMap.map, sim->envMap.position, sim->envMap.normal) ;
// m_render->updateData(Algo::Render::VBO::NORMALS, sim->envMap.normal) ;;
// m_render->initPrimitives(Algo::Render::VBO::TRIANGLES) ;
// m_render->initPrimitives(Algo::Render::VBO::LINES) ;
// m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::TRIANGLES) ;
// m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::LINES) ;
}
void MyGlutWin::initGUI()
......
......@@ -28,6 +28,7 @@
#include "Utils/GLSLShader.h"
#include "Utils/glutwin.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
......@@ -55,23 +56,10 @@
using namespace CGoGN;
struct PFP
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2<Map2> MAP;
// definition of the type of real value
typedef float REAL;
// other types definitions
typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
};
......@@ -149,7 +137,7 @@ public:
*/
int renderStyle;
Algo::Render::VBO::MapRender_VBO<PFP>* m_render;
Algo::Render::VBO::MapRender_VBO* m_render;
/**
* render mode enum
......@@ -165,13 +153,13 @@ public:
if (this->shaderOk) shaders[0].loadShaders("phong_vs.txt","phong_ps.txt");
// m_cb = new Algo::Render::VBO::VBO_CB_PositionNormal<PFP>(myMap);
// m_render = new Algo::Render::VBO::MapRender_VBO<PFP>(myMap, allDarts, m_cb);
// m_render = new Algo::Render::VBO::MapRender_VBO(myMap, allDarts, m_cb);
//
// m_render->initBuffers();
// m_render->updateData(Algo::Render::VBO::POSITIONS, position );
// m_render->updateData(Algo::Render::VBO::NORMALS, normal );
// m_render->initPrimitives(Algo::Render::VBO::TRIANGLES);
// m_render->initPrimitives(Algo::Render::VBO::LINES);
// m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::TRIANGLES);
// m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::LINES);
}
};
......
......@@ -40,7 +40,7 @@
gmtl::Vec3f gMax;
gmtl::Vec3f gMin;
struct PFP
struct PFP: public PFP_STANDARD
{
typedef DartObj<DP::DefaultDartParameters> DART;
typedef e0mapd2<DART> MAP;
......
......@@ -148,12 +148,12 @@ void MyGlutWin::myRedraw(void)
if(render_obj)
{
m_render->updateData(Algo::Render::VBO::POSITIONS, position );
//m_render->initPrimitives(Algo::Render::VBO::POINTS);
//m_render->initPrimitives<PFP>(myMap, good, Algo::Render::VBO::POINTS);
if(renderObjStyle == O_ALL)
{
m_render->initPrimitives(Algo::Render::VBO::TRIANGLES);
m_render->initPrimitives(Algo::Render::VBO::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES);
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f );
......@@ -171,7 +171,7 @@ void MyGlutWin::myRedraw(void)
}
else if(renderObjStyle == O_FACES)
{
m_render->initPrimitives(Algo::Render::VBO::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES);
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f );
......@@ -182,7 +182,7 @@ void MyGlutWin::myRedraw(void)
}
else if(renderObjStyle == O_LINE)
{
m_render->initPrimitives(Algo::Render::VBO::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES);
// on trace les ligne devant
glDisable( GL_POLYGON_OFFSET_FILL );
......@@ -277,8 +277,8 @@ void MyGlutWin::initRender()
std::cout << "updateData: "<< seconds << "sec" << std::endl;
// creation des primitives de rendu a partir de la carte
t1 = glutGet(GLUT_ELAPSED_TIME);
m_render->initPrimitives(Algo::Render::VBO::TRIANGLES);
m_render->initPrimitives(Algo::Render::VBO::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::TRIANGLES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::VBO::LINES);
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f;
std::cout << "initPrimitives: "<< seconds << "sec" << std::endl;
......@@ -414,7 +414,7 @@ int main(int argc, char **argv)
// allocation des objets necessaires pour le rendu
mgw->m_render = new Algo::Render::VBO::MapRender_VBO<PFP>(myMap, allDarts);
mgw->m_render = new Algo::Render::VBO::MapRender_VBO();
//mgw->m_render_topo = new Algo::Render::VBO::topo3_VBORenderMap<PFP::MAP>();
mgw->m_render_topo = new Algo::Render::VBO::topo3_VBORenderMapD();
......
......@@ -29,6 +29,7 @@
#include "Utils/glutwin_atb.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map3.h"
#include "Topology/generic/cellmarker.h"
......@@ -46,23 +47,11 @@
using namespace CGoGN ;
struct PFP
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef Map3 MAP;
// definition of the type of real value
typedef float REAL;
// other types definitions
typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
};
PFP::MAP myMap;
......@@ -143,7 +132,7 @@ public:
/*
* VBO Object rendering
*/
Algo::Render::VBO::MapRender_VBO<PFP>* m_render;
Algo::Render::VBO::MapRender_VBO* m_render;
/*
* VBO Topo rendering
......
/*******************************************************************************
* 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 "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Geometry/transfo.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/vbo_MapRender.h"
#include "Algo/Modelisation/extrusion.h"
#include "Topology/generic/parameters.h"
#include <vector>
using namespace CGoGN;
struct PFP: public PFP_STANDARD
{
// definition de la carte
typedef EmbeddedMap2<Map2> MAP;
};
PFP::MAP myMap;
class myGlutWin: public Utils::SimpleGlutWin
{
public:
/**
* position of object
*/
Geom::Vec3f gPosObj;
/**
* width of object
*/
float gWidthObj;
/**
* redraw CB
*/
void myRedraw();
/**
* keyboard CB
*/
void myKeyboard(unsigned char keycode, int x, int y);
/**
* Update VBO buffers for map
*/
void updateRender();
/**
* GL initialization
*/
void init();
// position handler
PFP::TVEC3 position ;
/**
* render object
*/
Algo::Render::VBO::MapRender_VBO* m_render;
myGlutWin( int* argc, char **argv, int winX, int winY) :
SimpleGlutWin(argc,argv,winX,winY),
m_render(NULL)
{ }
~myGlutWin();
};
myGlutWin::~myGlutWin()
{
if (m_render)
delete m_render;
}
void myGlutWin::init()
{
glClearColor(0.1f,0.1f,0.1f,0.0f);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition);
glEnable(GL_LIGHT0);
}
void myGlutWin::updateRender()
{
SelectorTrue allDarts;
// create the renderer (first call only)
if (m_render == NULL)
m_render = new Algo::Render::VBO::MapRender_VBO() ;
// update buffer op vertices positions
m_render->updateData(Algo::Render::VBO::POSITIONS, position);
// update flat faces primtives (warning need position buffer)
m_render->initPrimitives<PFP>(myMap, SelectorTrue(), Algo::Render::VBO::FLAT_TRIANGLES);
// update lines primitives
m_render->initPrimitives<PFP>(myMap, SelectorTrue(), Algo::Render::VBO::LINES);
}
void myGlutWin::myRedraw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
// center the scene
float sc = 50./gWidthObj;
glScalef(sc,sc,sc);
glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]);
// DRAW LINES OF OBJECTS
glDisable(GL_LIGHTING);
glColor3f(1.0f,1.0f,0.0f);
m_render->draw(Algo::Render::VBO::LINES) ;
//shit for nice line rendering
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f );
// DRAW FACES OF OBJECTS
glEnable(GL_LIGHTING);
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) ;
glDisable( GL_POLYGON_OFFSET_FILL );
glPopMatrix();
}
void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{
switch(keycode)
{
case 27:
exit(0);
default:
break;
}
}
int main(int argc, char **argv)
{
/// init glut interface and
myGlutWin mgw(&argc,argv,800,800);
mgw.init();
mgw.position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position") ;
// define the face extruded (here a cross)
std::vector<PFP::VEC3> objV;
objV.push_back(PFP::VEC3(-1, 0,-1));
objV.push_back(PFP::VEC3(-1, 0,-2));
objV.push_back(PFP::VEC3(+1, 0,-2));
objV.push_back(PFP::VEC3(+1, 0,-1));
objV.push_back(PFP::VEC3(+2, 0,-1));
objV.push_back(PFP::VEC3(+2, 0,+1));
objV.push_back(PFP::VEC3(+1, 0,+1));
objV.push_back(PFP::VEC3(+1, 0,+2));
objV.push_back(PFP::VEC3(-1, 0,+2));
objV.push_back(PFP::VEC3(-1, 0,+1));
objV.push_back(PFP::VEC3(-2, 0,+1));
objV.push_back(PFP::VEC3(-2, 0,-1));
// define a path (here an helicoid)
std::vector<PFP::VEC3> pathV;
// and a varying radius
std::vector<float> pathRadius;
for (int i=0; i < 200; ++ i)
{
PFP::REAL alpha = 3.141592/20.0 * i;
PFP::REAL rad = 20.0 - 0.2*i;
pathV.push_back(PFP::VEC3(rad*cos(alpha),rad*sin(alpha), 0.5*i));
pathRadius.push_back(1.5f+0.7*cos(alpha));
}
// extrusion
Dart d = Algo::Modelisation::extrusion_scale<PFP>(myMap, mgw.position, objV, PFP::VEC3(0.0,0.0,0.0), PFP::VEC3(0.0,1.0,0.0),true, pathV, false, pathRadius);
// update renderer
mgw.updateRender();
// compute BB and store it for object positionning in screen
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap,mgw.position) ;
mgw.gWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
mgw.gPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
mgw.mainLoop();
return 0;
}
......@@ -29,6 +29,7 @@
#include "Utils/GLSLShader.h"
#include "Utils/glutwin.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Geometry/vector_gen.h"
......@@ -82,23 +83,10 @@ inline X lerp( X u, X v, double a )
struct PFP
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef Map2 MAP;
// definition of the type of real value
typedef float REAL;
// other types definitions
typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
};
......@@ -526,7 +514,7 @@ int main(int argc, char **argv)
// Algo::Render::VBO::mapRender<PFP> mr(myMap, allDarts, &vbocb) ;
//
// mr.initBuffers();
// mr.initPrimitives(Algo::Render::VBO::TRIANGLES);
// mr.initPrimitives<PFP>(myMap, good, Algo::Render::VBO::TRIANGLES);
// mr.updateData(Algo::Render::VBO::POSITIONS, codePositions);
// mr.updateData(Algo::Render::VBO::NORMALS, codeNormals);
// mr.draw(Algo::Render::VBO::TRIANGLES);
......
......@@ -26,6 +26,7 @@
#include "Utils/glutwin_atb.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h"
#include "Algo/ImplicitHierarchicalMesh/ihm.h"
......@@ -43,20 +44,11 @@