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

update test_traversor2

parent d574eb73
...@@ -29,25 +29,21 @@ ...@@ -29,25 +29,21 @@
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Export/export.h" #include "Algo/Export/export.h"
using namespace CGoGN ; using namespace CGoGN ;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// // interface // // interface
QApplication app(argc, argv); QApplication app(argc, argv);
MyQT sqt; MyQT sqt;
sqt.setDock(& sqt.dock); sqt.setDock(& sqt.dock);
sqt.setCallBack( sqt.dock.listTravers, SIGNAL(currentRowChanged(int)), SLOT(traversors(int)) ); sqt.setCallBack( sqt.dock.listTravers, SIGNAL(currentRowChanged(int)), SLOT(traversors(int)) );
sqt.setCallBack( sqt.dock.withBoundary, SIGNAL(clicked()), SLOT(updateMap()) ); sqt.setCallBack( sqt.dock.withBoundary, SIGNAL(clicked()), SLOT(updateMap()) );
sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) ); sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) );
sqt.setCallBack( sqt.dock.widthSlider, SIGNAL(valueChanged(int)), SLOT(width(int)) ); sqt.setCallBack( sqt.dock.widthSlider, SIGNAL(valueChanged(int)), SLOT(width(int)) );
int n=3; int n = 3;
if (argc==2) if (argc == 2)
n = atoi(argv[1]); n = atoi(argv[1]);
// example code itself // example code itself
...@@ -63,7 +59,6 @@ int main(int argc, char **argv) ...@@ -63,7 +59,6 @@ int main(int argc, char **argv)
return app.exec(); return app.exec();
} }
void MyQT::traversors(int x) void MyQT::traversors(int x)
{ {
// update all color to grey // update all color to grey
...@@ -189,11 +184,11 @@ void MyQT::createMap(int n) ...@@ -189,11 +184,11 @@ void MyQT::createMap(int n)
m_render_topo->setInitialDartsColor(0.5f,0.5f,0.5f); m_render_topo->setInitialDartsColor(0.5f,0.5f,0.5f);
m_render_topo->setInitialBoundaryDartsColor(0.3f,0.3f,0.3f); m_render_topo->setInitialBoundaryDartsColor(0.3f,0.3f,0.3f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked()); m_render_topo->updateData(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{ {
colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f); colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f); m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
...@@ -204,10 +199,10 @@ void MyQT::createMap(int n) ...@@ -204,10 +199,10 @@ void MyQT::createMap(int n)
void MyQT::updateMap() void MyQT::updateMap()
{ {
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f); m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked()); m_render_topo->updateData(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{ {
const Geom::Vec3f& C = colorDarts[d]; const Geom::Vec3f& C = colorDarts[d];
if (C*C != 0.0f) if (C*C != 0.0f)
...@@ -221,7 +216,11 @@ void MyQT::updateMap() ...@@ -221,7 +216,11 @@ void MyQT::updateMap()
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
glClearColor(1.0f,1.0f,1.0f,1.0f); glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ; #ifdef USE_GMAP
m_render_topo = new Algo::Render::GL2::TopoRenderGMap<PFP>(0.01f) ;
#else
m_render_topo = new Algo::Render::GL2::TopoRenderMap<PFP>(0.01f) ;
#endif
} }
// redraw GL callback (clear and swap already done) // redraw GL callback (clear and swap already done)
...@@ -245,16 +244,14 @@ void MyQT::cb_mousePress(int button, int x, int y) ...@@ -245,16 +244,14 @@ void MyQT::cb_mousePress(int button, int x, int y)
{ {
if (Shift()) if (Shift())
{ {
Dart d = m_render_topo->picking<PFP>(myMap, x,y); // nb Dart d = m_render_topo->picking(myMap, x,y); // nb
if (button == Qt::LeftButton) if (button == Qt::LeftButton)
{ {
if (d != Dart::nil()) if (d != Dart::nil())
m_selected = d; m_selected = d;
if (d != Dart::nil()) if (d != Dart::nil())
std::cout << "DART="<<d.index << std::endl; std::cout << "DART=" << d.index << std::endl;
} }
if (button == Qt::RightButton) if (button == Qt::RightButton)
{ {
...@@ -269,11 +266,10 @@ void MyQT::cb_keyPress(int keycode) ...@@ -269,11 +266,10 @@ void MyQT::cb_keyPress(int keycode)
{ {
switch(keycode) switch(keycode)
{ {
case 'c': case 'c':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (!myMap.isBoundaryMarked2(d)) if (!myMap.isBoundaryMarked<2>(d))
{ {
int n = rand(); int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f; float r = float(n&0x7f)/255.0f + 0.25f;
...@@ -295,7 +291,7 @@ void MyQT::cb_keyPress(int keycode) ...@@ -295,7 +291,7 @@ void MyQT::cb_keyPress(int keycode)
case 'h': case 'h':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (!myMap.isBoundaryMarked2(d)) if (!myMap.isBoundaryMarked<2>(d))
{ {
colorDarts[d] = Geom::Vec3f(0.0f,0.0f,0.0f); colorDarts[d] = Geom::Vec3f(0.0f,0.0f,0.0f);
m_render_topo->setDartColor(d,0.0f,0.0f,0.0f); m_render_topo->setDartColor(d,0.0f,0.0f,0.0f);
...@@ -387,9 +383,9 @@ void MyQT::importMesh(std::string& filename) ...@@ -387,9 +383,9 @@ void MyQT::importMesh(std::string& filename)
if (!colorDarts.isValid()) if (!colorDarts.isValid())
{ {
colorDarts = myMap.addAttribute<VEC3, DART>("color"); colorDarts = myMap.addAttribute<VEC3, DART>("color");
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{ {
int n = rand(); int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f; float r = float(n&0x7f)/255.0f + 0.25f;
...@@ -412,11 +408,9 @@ void MyQT::importMesh(std::string& filename) ...@@ -412,11 +408,9 @@ void MyQT::importMesh(std::string& filename)
updateGLMatrices() ; updateGLMatrices() ;
} }
void MyQT::width(int w) void MyQT::width(int w)
{ {
m_render_topo->setDartWidth(w); m_render_topo->setDartWidth(w);
m_render_topo->setRelationWidth(w); m_render_topo->setRelationWidth(w);
updateGL(); updateGL();
} }
...@@ -58,16 +58,22 @@ struct PFP: public PFP_STANDARD ...@@ -58,16 +58,22 @@ struct PFP: public PFP_STANDARD
#endif #endif
}; };
typedef PFP::MAP MAP ; typedef PFP::MAP MAP ;
typedef PFP::MAP::IMPL MAP_IMPL ;
typedef PFP::VEC3 VEC3 ; typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT class MyQT: public Utils::QT::SimpleQT
{ {
Q_OBJECT Q_OBJECT
public: public:
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f) {} MyQT() :
m_render_topo(NULL),
m_selected(NIL),
m_selected2(NIL),
dm(myMap),
m_shift(0.01f)
{}
void cb_redraw(); void cb_redraw();
void cb_initGL(); void cb_initGL();
...@@ -82,15 +88,19 @@ protected: ...@@ -82,15 +88,19 @@ protected:
// declaration of the map // declaration of the map
MAP myMap; MAP myMap;
VertexAttribute<VEC3> position; VertexAttribute<VEC3, MAP_IMPL> position;
DartAttribute<VEC3> colorDarts; DartAttribute<VEC3, MAP_IMPL> colorDarts;
// render (for the topo) // render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo; #ifdef USE_GMAP
Algo::Render::GL2::TopoRenderGMap<PFP>* m_render_topo;
#else
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo;
#endif
Dart m_selected; Dart m_selected;
Dart m_selected2; Dart m_selected2;
DartMarker dm; DartMarker<MAP> dm;
float m_shift; float m_shift;
// just for more compact writing // just for more compact writing
......
...@@ -316,7 +316,7 @@ Traversor2EF<MAP>::Traversor2EF(const MAP& map, Dart dart) : m(map), start(dart) ...@@ -316,7 +316,7 @@ Traversor2EF<MAP>::Traversor2EF(const MAP& map, Dart dart) : m(map), start(dart)
} }
else else
{ {
if(m.isBoundaryMarked2(start)) if(m.template isBoundaryMarked<2>(start))
start = m.phi2(start) ; start = m.phi2(start) ;
} }
} }
...@@ -350,7 +350,7 @@ Dart Traversor2EF<MAP>::next() ...@@ -350,7 +350,7 @@ Dart Traversor2EF<MAP>::next()
if(current != NIL) if(current != NIL)
{ {
current = m.phi2(current) ; current = m.phi2(current) ;
if(current == start || m.isBoundaryMarked2(current)) // do not consider a boundary face if(current == start || m.template isBoundaryMarked<2>(current)) // do not consider a boundary face
current = NIL ; current = NIL ;
} }
return current ; return current ;
...@@ -424,7 +424,7 @@ Traversor2EEaF<MAP>::Traversor2EEaF(const MAP& map, Dart dart) : ...@@ -424,7 +424,7 @@ Traversor2EEaF<MAP>::Traversor2EEaF(const MAP& map, Dart dart) :
} }
else else
{ {
if (m.isBoundaryMarked2(dart)) if (m.template isBoundaryMarked<2>(dart))
stop1 = m.phi2(dart); stop1 = m.phi2(dart);
else else
stop1 = dart; stop1 = dart;
...@@ -464,7 +464,7 @@ Dart Traversor2EEaF<MAP>::next() ...@@ -464,7 +464,7 @@ Dart Traversor2EEaF<MAP>::next()
current = m.phi1(current) ; current = m.phi1(current) ;
if (current == stop1) if (current == stop1)
{ {
if (!m.isBoundaryMarked2(stop2)) if (!m.template isBoundaryMarked<2>(stop2))
current = m.phi1(stop2) ; current = m.phi1(stop2) ;
else else
current=NIL; current=NIL;
...@@ -615,7 +615,7 @@ Traversor2FFaE<MAP>::Traversor2FFaE(const MAP& map, Dart dart) : m(map),m_QLT(NU ...@@ -615,7 +615,7 @@ Traversor2FFaE<MAP>::Traversor2FFaE(const MAP& map, Dart dart) : m(map),m_QLT(NU
else else
{ {
start = m.phi2(dart) ; start = m.phi2(dart) ;
while(start != NIL && m.isBoundaryMarked2(start)) while(start != NIL && m.template isBoundaryMarked<2>(start))
{ {
start = m.phi2(m.phi1(m.phi2(start))) ; start = m.phi2(m.phi1(m.phi2(start))) ;
if(start == m.phi2(dart)) if(start == m.phi2(dart))
...@@ -655,7 +655,7 @@ Dart Traversor2FFaE<MAP>::next() ...@@ -655,7 +655,7 @@ Dart Traversor2FFaE<MAP>::next()
do do
{ {
current = m.phi2(m.phi1(m.phi2(current))) ; current = m.phi2(m.phi1(m.phi2(current))) ;
} while(m.isBoundaryMarked2(current)) ; } while(m.template isBoundaryMarked<2>(current)) ;
if(current == start) if(current == start)
current = NIL ; current = NIL ;
} }
......
...@@ -423,7 +423,7 @@ VTraversor2EEaF<MAP>::VTraversor2EEaF(const MAP& map, Dart dart) : m(map),m_QLT( ...@@ -423,7 +423,7 @@ VTraversor2EEaF<MAP>::VTraversor2EEaF(const MAP& map, Dart dart) : m(map),m_QLT(
} }
else else
{ {
if (m.isBoundaryMarked2(dart)) if (m.template isBoundaryMarked<2>(dart))
stop1 = m.phi2(dart); stop1 = m.phi2(dart);
else else
stop1 = dart; stop1 = dart;
...@@ -463,7 +463,7 @@ Dart VTraversor2EEaF<MAP>::next() ...@@ -463,7 +463,7 @@ Dart VTraversor2EEaF<MAP>::next()
current = m.phi1(current) ; current = m.phi1(current) ;
if (current == stop1) if (current == stop1)
{ {
if (!m.isBoundaryMarked2(stop2)) if (!m.template isBoundaryMarked<2>(stop2))
current = m.phi1(stop2) ; current = m.phi1(stop2) ;
else else
current=NIL; current=NIL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment