Commit a5aeb607 authored by Pierre Kraemer's avatar Pierre Kraemer

update test_traversor2

parent d574eb73
......@@ -29,25 +29,21 @@
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
using namespace CGoGN ;
int main(int argc, char **argv)
{
// // interface
QApplication app(argc, argv);
MyQT sqt;
sqt.setDock(& sqt.dock);
sqt.setCallBack( sqt.dock.listTravers, SIGNAL(currentRowChanged(int)), SLOT(traversors(int)) );
sqt.setCallBack( sqt.dock.withBoundary, SIGNAL(clicked()), SLOT(updateMap()) );
sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) );
sqt.setCallBack( sqt.dock.widthSlider, SIGNAL(valueChanged(int)), SLOT(width(int)) );
int n=3;
if (argc==2)
int n = 3;
if (argc == 2)
n = atoi(argv[1]);
// example code itself
......@@ -63,7 +59,6 @@ int main(int argc, char **argv)
return app.exec();
}
void MyQT::traversors(int x)
{
// update all color to grey
......@@ -189,11 +184,11 @@ void MyQT::createMap(int n)
m_render_topo->setInitialDartsColor(0.5f,0.5f,0.5f);
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);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
......@@ -204,10 +199,10 @@ void MyQT::createMap(int n)
void MyQT::updateMap()
{
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
m_render_topo->updateData(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
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];
if (C*C != 0.0f)
......@@ -221,7 +216,11 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
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)
......@@ -245,16 +244,14 @@ void MyQT::cb_mousePress(int button, int x, int y)
{
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 (d != Dart::nil())
m_selected = d;
if (d != Dart::nil())
std::cout << "DART="<<d.index << std::endl;
std::cout << "DART=" << d.index << std::endl;
}
if (button == Qt::RightButton)
{
......@@ -269,11 +266,10 @@ void MyQT::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked2(d))
if (!myMap.isBoundaryMarked<2>(d))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
......@@ -295,7 +291,7 @@ void MyQT::cb_keyPress(int keycode)
case 'h':
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);
m_render_topo->setDartColor(d,0.0f,0.0f,0.0f);
......@@ -387,9 +383,9 @@ void MyQT::importMesh(std::string& filename)
if (!colorDarts.isValid())
{
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();
float r = float(n&0x7f)/255.0f + 0.25f;
......@@ -412,11 +408,9 @@ void MyQT::importMesh(std::string& filename)
updateGLMatrices() ;
}
void MyQT::width(int w)
{
m_render_topo->setDartWidth(w);
m_render_topo->setRelationWidth(w);
updateGL();
}
......@@ -58,16 +58,22 @@ struct PFP: public PFP_STANDARD
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::MAP::IMPL MAP_IMPL ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
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_initGL();
......@@ -82,15 +88,19 @@ protected:
// declaration of the map
MAP myMap;
VertexAttribute<VEC3> position;
DartAttribute<VEC3> colorDarts;
VertexAttribute<VEC3, MAP_IMPL> position;
DartAttribute<VEC3, MAP_IMPL> colorDarts;
// 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_selected2;
DartMarker dm;
DartMarker<MAP> dm;
float m_shift;
// just for more compact writing
......
......@@ -316,7 +316,7 @@ Traversor2EF<MAP>::Traversor2EF(const MAP& map, Dart dart) : m(map), start(dart)
}
else
{
if(m.isBoundaryMarked2(start))
if(m.template isBoundaryMarked<2>(start))
start = m.phi2(start) ;
}
}
......@@ -350,7 +350,7 @@ Dart Traversor2EF<MAP>::next()
if(current != NIL)
{
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 ;
}
return current ;
......@@ -424,7 +424,7 @@ Traversor2EEaF<MAP>::Traversor2EEaF(const MAP& map, Dart dart) :
}
else
{
if (m.isBoundaryMarked2(dart))
if (m.template isBoundaryMarked<2>(dart))
stop1 = m.phi2(dart);
else
stop1 = dart;
......@@ -464,7 +464,7 @@ Dart Traversor2EEaF<MAP>::next()
current = m.phi1(current) ;
if (current == stop1)
{
if (!m.isBoundaryMarked2(stop2))
if (!m.template isBoundaryMarked<2>(stop2))
current = m.phi1(stop2) ;
else
current=NIL;
......@@ -615,7 +615,7 @@ Traversor2FFaE<MAP>::Traversor2FFaE(const MAP& map, Dart dart) : m(map),m_QLT(NU
else
{
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))) ;
if(start == m.phi2(dart))
......@@ -655,7 +655,7 @@ Dart Traversor2FFaE<MAP>::next()
do
{
current = m.phi2(m.phi1(m.phi2(current))) ;
} while(m.isBoundaryMarked2(current)) ;
} while(m.template isBoundaryMarked<2>(current)) ;
if(current == start)
current = NIL ;
}
......
......@@ -423,7 +423,7 @@ VTraversor2EEaF<MAP>::VTraversor2EEaF(const MAP& map, Dart dart) : m(map),m_QLT(
}
else
{
if (m.isBoundaryMarked2(dart))
if (m.template isBoundaryMarked<2>(dart))
stop1 = m.phi2(dart);
else
stop1 = dart;
......@@ -463,7 +463,7 @@ Dart VTraversor2EEaF<MAP>::next()
current = m.phi1(current) ;
if (current == stop1)
{
if (!m.isBoundaryMarked2(stop2))
if (!m.template isBoundaryMarked<2>(stop2))
current = m.phi1(stop2) ;
else
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