Commit a4d40b86 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

tout compile..

parent dcdcb3bb
...@@ -379,7 +379,7 @@ int main(int argc, char **argv) ...@@ -379,7 +379,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
Algo::Import::importTet<PFP>(myMap,argv[2],attrNames); Algo::Import::importTet<PFP>(myMap, argv[2], attrNames);
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ; position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
} }
else if(std::string(argv[1]) == "-ts") else if(std::string(argv[1]) == "-ts")
......
...@@ -45,26 +45,23 @@ using namespace CGoGN ; ...@@ -45,26 +45,23 @@ using namespace CGoGN ;
*/ */
struct PFP struct PFP
{ {
// definition of the type of the map // definition of the map
typedef EmbeddedMap2<Map2> MAP; typedef EmbeddedMap2<Map2> MAP;
// definition of the type of real value // definition of the type of real value
typedef float REAL; typedef float REAL;
// definition of the type of 3D vector
// other types definitions
typedef Geom::Vector<3,REAL> VEC3; 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;
// definition of the type of 3D vector attribute handler
typedef AttributeHandler<VEC3> TVEC3; typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
typedef TVEC3 TFRAME;
typedef TVEC3 TRGBFUNCS;
}; };
// some hidden initializations
INIT_STATICS_MAP();
/** /**
* A class for a little interface and rendering * A class for a little interface and rendering
*/ */
...@@ -130,8 +127,6 @@ void fonction_exemple(typename PFP::MAP& map, const AttributeHandler<typename PF ...@@ -130,8 +127,6 @@ void fonction_exemple(typename PFP::MAP& map, const AttributeHandler<typename PF
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// declaration of the map // declaration of the map
...@@ -141,28 +136,31 @@ int main(int argc, char **argv) ...@@ -141,28 +136,31 @@ int main(int argc, char **argv)
SelectorTrue allDarts; SelectorTrue allDarts;
// cree un handler d'attribut pour la position des points std::vector<std::string> attrNames ;
AttributeHandler<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position"); if(!Algo::Import::importMesh<PFP>(myMap, argv[1], attrNames))
{
std::cerr << "could not import " << argv[1] << std::endl ;
return 1 ;
}
// cree un handler d'attribut pour la position des points (créé lors de l'import)
AttributeHandler<PFP::VEC3> position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
// cree un handler pour les normales aux sommets // cree un handler pour les normales aux sommets
AttributeHandler<PFP::VEC3> normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal"); AttributeHandler<PFP::VEC3> normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal");
bool success = Algo::Import::importMesh<PFP>(myMap, argv[1], position, Algo::Import::ImportSurfacique::UNKNOWNSURFACE) ;
// // parcours de tous les brins de la carte: // // parcours de tous les brins de la carte:
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) // for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
// fonction_exemple<PFP>(myMap,position,d); // fonction_exemple<PFP>(myMap, position, d);
// parcours de toutes les faces de la carte: // parcours de toutes les faces de la carte:
DartMarker mf(myMap); DartMarker mf(myMap);
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (! mf.isMarked(d)) // si d non marque: if (! mf.isMarked(d)) // si d non marque:
{ {
fonction_exemple<PFP>(myMap,position,d); fonction_exemple<PFP>(myMap, position, d);
// marque tous les brins de la face de d // marque tous les brins de la face de d
mf.markOrbit(FACE_ORBIT,d); mf.markOrbit(FACE_ORBIT, d);
} }
} }
...@@ -170,7 +168,6 @@ int main(int argc, char **argv) ...@@ -170,7 +168,6 @@ int main(int argc, char **argv)
mf.unmarkAll(); mf.unmarkAll();
// instanciation of the interface // instanciation of the interface
MyGlutWin mgw(&argc, argv, 800, 800); MyGlutWin mgw(&argc, argv, 800, 800);
......
...@@ -45,23 +45,23 @@ using namespace CGoGN ; ...@@ -45,23 +45,23 @@ using namespace CGoGN ;
*/ */
struct PFP struct PFP
{ {
// definition of the type of the map // definition of the map
typedef EmbeddedMap2<Map2> MAP; typedef EmbeddedMap2<Map2> MAP;
// definition of the type of real value // definition of the type of real value
typedef float REAL; typedef float REAL;
// definition of the type of 3D vector
// other types definitions
typedef Geom::Vector<3,REAL> VEC3; 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;
// definition of the type of 3D vector attribute handler
typedef AttributeHandler<VEC3> TVEC3; typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL;
}; };
// some hidden initializations
INIT_STATICS_MAP();
/** /**
* A class for a little interface and rendering * A class for a little interface and rendering
*/ */
...@@ -163,7 +163,6 @@ int main(int argc, char **argv) ...@@ -163,7 +163,6 @@ int main(int argc, char **argv)
// a handler to this attribute is returned // a handler to this attribute is returned
AttributeHandler<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position"); AttributeHandler<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
// creation face 1 (convexe) // creation face 1 (convexe)
Dart d1 = myMap.newFace(5); Dart d1 = myMap.newFace(5);
......
...@@ -26,12 +26,9 @@ ...@@ -26,12 +26,9 @@
#include <time.h> #include <time.h>
#include <algorithm> #include <algorithm>
#include "Utils/GLSLShader.h" #include "Utils/GLSLShader.h"
#include "Utils/glutwin.h" #include "Utils/glutwin.h"
#include "Topology/map/map2.h" #include "Topology/map/map2.h"
#include "Topology/generic/embeddedMap2.h" #include "Topology/generic/embeddedMap2.h"
...@@ -47,20 +44,22 @@ ...@@ -47,20 +44,22 @@
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
/// pour simplifier l'ecriture du code /// pour simplifier l'ecriture du code
using namespace CGoGN; using namespace CGoGN;
/// definition de la structure qui decrit le type de carte utilise /// definition de la structure qui decrit le type de carte utilise
struct PFP struct PFP
{ {
// definition de la carte // definition of the map
typedef EmbeddedMap2<Map2> MAP; typedef EmbeddedMap2<Map2> MAP;
// definition du type de reel utilise // definition of the type of real value
typedef float REAL; typedef float REAL;
// other types definitions
typedef Geom::Vector<3,REAL> VEC3; typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<6,REAL> VEC6; typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33; typedef Geom::Matrix<3,3,REAL> MATRIX33;
...@@ -69,13 +68,8 @@ struct PFP ...@@ -69,13 +68,8 @@ struct PFP
typedef AttributeHandler<VEC3> TVEC3; typedef AttributeHandler<VEC3> TVEC3;
typedef AttributeHandler<REAL> TREAL; typedef AttributeHandler<REAL> TREAL;
typedef AttributeHandler<MATRIX33> TFRAME;
typedef AttributeHandler<MATRIX36> TRGBFUNCS;
}; };
// some hidden initializations
INIT_STATICS_MAP();
/// definition de la carte en global, plus facile /// definition de la carte en global, plus facile
PFP::MAP myMap; PFP::MAP myMap;
...@@ -86,17 +80,12 @@ AttributeHandler<PFP::VEC3> position; ...@@ -86,17 +80,12 @@ AttributeHandler<PFP::VEC3> position;
// handler d'attribut de normale par sommet // handler d'attribut de normale par sommet
AttributeHandler<PFP::VEC3> normal; AttributeHandler<PFP::VEC3> normal;
/// fonction qui renvoit vrai (appliquée à un brin) /// fonction qui renvoit vrai (appliquée à un brin)
SelectorTrue allDarts; SelectorTrue allDarts;
/// encore 1 typedef pour simplifier l'ecriture du code
/// encore 2 typedef pour simplifier l'ecriture du code
typedef PFP::VEC3 Point3D; typedef PFP::VEC3 Point3D;
/// pile des brins selectionnes (6 max) /// pile des brins selectionnes (6 max)
std::vector<Dart> selected_darts; std::vector<Dart> selected_darts;
...@@ -233,11 +222,6 @@ void coupe_carre(Dart dd) ...@@ -233,11 +222,6 @@ void coupe_carre(Dart dd)
class myGlutWin: public Utils::SimpleGlutWin class myGlutWin: public Utils::SimpleGlutWin
{ {
public: public:
...@@ -252,7 +236,6 @@ public: ...@@ -252,7 +236,6 @@ public:
*/ */
float gWidthObj; float gWidthObj;
Algo::Render::VBO::MapRender_VBO<PFP>* m_render; Algo::Render::VBO::MapRender_VBO<PFP>* m_render;
Algo::Render::VBO::topo_VBORenderMapD* m_render_topo; Algo::Render::VBO::topo_VBORenderMapD* m_render_topo;
...@@ -267,7 +250,6 @@ public: ...@@ -267,7 +250,6 @@ public:
*/ */
void myKeyboard(unsigned char keycode, int x, int y); void myKeyboard(unsigned char keycode, int x, int y);
/** /**
* GL initialization * GL initialization
*/ */
...@@ -298,8 +280,6 @@ public: ...@@ -298,8 +280,6 @@ public:
myGlutWin( int* argc, char **argv, int winX, int winY) : myGlutWin( int* argc, char **argv, int winX, int winY) :
SimpleGlutWin(argc,argv,winX,winY), SimpleGlutWin(argc,argv,winX,winY),
m_render(NULL),m_render_topo(NULL),aff_help(true) {} m_render(NULL),m_render_topo(NULL),aff_help(true) {}
}; };
...@@ -312,7 +292,7 @@ std::vector<Dart> d_edges; ...@@ -312,7 +292,7 @@ std::vector<Dart> d_edges;
std::vector<Dart> d_vertices; std::vector<Dart> d_vertices;
// fonction qui calcule la distance a utilisé pour la selection // fonction qui calcule la distance a utiliser pour la selection
float computeSelectRadius(int x, int y, int pixelRadius) float computeSelectRadius(int x, int y, int pixelRadius)
{ {
GLint viewport[4]; GLint viewport[4];
...@@ -350,7 +330,6 @@ float computeSelectRadius(int x, int y, int pixelRadius) ...@@ -350,7 +330,6 @@ float computeSelectRadius(int x, int y, int pixelRadius)
} }
void myGlutWin::drawSelected() void myGlutWin::drawSelected()
{ {
typedef Dart Dart; typedef Dart Dart;
...@@ -409,9 +388,6 @@ void myGlutWin::drawSelected() ...@@ -409,9 +388,6 @@ void myGlutWin::drawSelected()
} }
glEnd(); glEnd();
glLineWidth(7.0f); glLineWidth(7.0f);
for(unsigned int i=0; i < selected_darts.size(); ++i) for(unsigned int i=0; i < selected_darts.size(); ++i)
{ {
...@@ -443,24 +419,17 @@ void myGlutWin::drawSelected() ...@@ -443,24 +419,17 @@ void myGlutWin::drawSelected()
} }
} }
void myGlutWin::myInitGL() void myGlutWin::myInitGL()
{ {
glClearColor(0.2,0.2,0.2,0.); glClearColor(0.2,0.2,0.2,0.);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);
glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition); glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
} }
void myGlutWin::updateRender() void myGlutWin::updateRender()
...@@ -482,7 +451,6 @@ void myGlutWin::updateRender() ...@@ -482,7 +451,6 @@ void myGlutWin::updateRender()
m_render_topo->updateData<PFP>(myMap,position,0.9f,0.9f); m_render_topo->updateData<PFP>(myMap,position,0.9f,0.9f);
} }
void myGlutWin::myRedraw(void) void myGlutWin::myRedraw(void)
{ {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...@@ -493,7 +461,6 @@ void myGlutWin::myRedraw(void) ...@@ -493,7 +461,6 @@ void myGlutWin::myRedraw(void)
glScalef(sc,sc,sc); glScalef(sc,sc,sc);
glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]); glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]);
/// Affichage de la topologie si demande /// Affichage de la topologie si demande
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
...@@ -521,7 +488,6 @@ void myGlutWin::myRedraw(void) ...@@ -521,7 +488,6 @@ void myGlutWin::myRedraw(void)
//glColor3f(0.9f,0.3f,0.3f); //glColor3f(0.9f,0.3f,0.3f);
glColor3f(0.0f,0.9f,0.3f); glColor3f(0.0f,0.9f,0.3f);
/// decalage pour surlignage non clignotant /// decalage pour surlignage non clignotant
glEnable( GL_POLYGON_OFFSET_FILL ); glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f ); glPolygonOffset( 1.0f, 1.0f );
...@@ -542,7 +508,6 @@ void myGlutWin::myRedraw(void) ...@@ -542,7 +508,6 @@ void myGlutWin::myRedraw(void)
glDisable( GL_POLYGON_OFFSET_FILL ); glDisable( GL_POLYGON_OFFSET_FILL );
glPopMatrix(); glPopMatrix();
if (aff_help) if (aff_help)
...@@ -550,10 +515,8 @@ void myGlutWin::myRedraw(void) ...@@ -550,10 +515,8 @@ void myGlutWin::myRedraw(void)
glColor3f(1.0f,1.0f,1.0f); glColor3f(1.0f,1.0f,1.0f);
printString2D(10,20,"Keys:\nt: affichage topologie\nf: selection face (position souris)\na: selection aretes\ns: selection sommet\nd: selection brin\n0: vide la pile des brins selectionnes\nD: info brin"); printString2D(10,20,"Keys:\nt: affichage topologie\nf: selection face (position souris)\na: selection aretes\ns: selection sommet\nd: selection brin\n0: vide la pile des brins selectionnes\nD: info brin");
} }
} }
void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{ {
switch(keycode) switch(keycode)
...@@ -680,8 +643,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -680,8 +643,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
glScalef(sc,sc,sc); glScalef(sc,sc,sc);
glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]); glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]);
/// calcul du rayon /// calcul du rayon
getOrthoScreenRay(x,y,rayA,rayB); getOrthoScreenRay(x,y,rayA,rayB);
PFP::VEC3 AB = rayB-rayA; PFP::VEC3 AB = rayB-rayA;
...@@ -699,8 +660,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -699,8 +660,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
Algo::Selection::edgesRaySelection<PFP>(myMap, position, allDarts, rayA, AB, d_edges,dist); Algo::Selection::edgesRaySelection<PFP>(myMap, position, allDarts, rayA, AB, d_edges,dist);
glPopMatrix(); glPopMatrix();
if (!d_edges.empty()) if (!d_edges.empty())
...@@ -728,7 +687,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -728,7 +687,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
glScalef(sc,sc,sc); glScalef(sc,sc,sc);
glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]); glTranslatef(-gPosObj[0],-gPosObj[1],-gPosObj[2]);
/// Rayon /// Rayon
getOrthoScreenRay(x,y,rayA,rayB); getOrthoScreenRay(x,y,rayA,rayB);
PFP::VEC3 AB = rayB-rayA; PFP::VEC3 AB = rayB-rayA;
...@@ -761,11 +719,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -761,11 +719,6 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
break; break;
} }
glutPostRedisplay();
break;
case 'h': case 'h':
aff_help =!aff_help; aff_help =!aff_help;
glutPostRedisplay(); glutPostRedisplay();
...@@ -815,26 +768,24 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -815,26 +768,24 @@ void myGlutWin::myKeyboard(unsigned char keycode, int x, int y)
} }
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
/// init glut interface and /// init glut interface and
myGlutWin mgw(&argc,argv,800,800); myGlutWin mgw(&argc,argv,800,800);
mgw.init(); mgw.init();
// cree un handler d'attribut pour la position des points if (argc == 2)
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
// cree un handler pour les normales aux sommets
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal");
if (argc==2)
{ {
bool success = Algo::Import::importMesh<PFP>(myMap, argv[1], position, Algo::Import::ImportSurfacique::UNKNOWNSURFACE) ; std::vector<std::string> attrNames ;
Algo::Import::importMesh<PFP>(myMap, argv[1], attrNames) ;
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal");
mgw.updateRender(); mgw.updateRender();
} }
else else
{ {
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal");
createMap(); createMap();
mgw.updateRender(); // ne pas oublier de mettre à jour openGL après chaque modif dans la carte mgw.updateRender(); // ne pas oublier de mettre à jour openGL après chaque modif dans la carte
} }
...@@ -846,7 +797,6 @@ int main(int argc, char **argv) ...@@ -846,7 +797,6 @@ int main(int argc, char **argv)
mgw.gWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2)); 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.gPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
mgw.mainLoop(); mgw.mainLoop();
return 0; return 0;
......
...@@ -58,10 +58,6 @@ struct PFP ...@@ -58,10 +58,6 @@ struct PFP
}; };