Commit 2e3d2fa2 authored by Sylvain Thery's avatar Sylvain Thery

topoRender + schnappsTopoRender

parent 99686812
......@@ -110,10 +110,10 @@ void SimpleMap3::cb_initGL()
m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f);
m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f);
m_render_topo_boundary = new Algo::Render::GL2::TopoRenderMap<PFP>();
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setDartWidth(2.0f);
m_render_topo_boundary->setInitialDartsColor(0.4f,0.8f,0.4f);
m_render_topo_boundary->updateDataBoundary(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap, position, 0.9f,0.9f,bb.maxSize()/50.0f);
m_render_topo_primal = new Algo::Render::GL2::Topo3PrimalRender<PFP>();
m_render_topo_primal->setDartWidth(2.0f);
......
......@@ -58,7 +58,7 @@ public:
VertexAttribute<VEC3, MAP> position ;
Algo::Render::GL2::Topo3RenderMap<PFP>* m_render_topo;
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo_boundary;
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Algo::Render::GL2::Topo3PrimalRender<PFP>* m_render_topo_primal;
SimpleMap3() ;
......
......@@ -83,7 +83,7 @@ void Viewer::cb_initGL()
Utils::GLSLShader::areShadersSupported();
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -98,12 +98,12 @@ void Viewer::cb_initGL()
m_phongShader->setSpecular(colSpec) ;
m_phongShader->setShininess(shininess) ;
m_flatShader = new Utils::ShaderFlat() ;
m_flatShader = new Utils::ShaderSimpleFlat() ;
m_flatShader->setAttributePosition(m_positionVBO) ;
m_flatShader->setAmbiant(colClear) ;
m_flatShader->setDiffuse(colDif) ;
m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
m_flatShader->setExplode(faceShrinkage) ;
// m_flatShader->setDiffuseBack(Geom::Vec4f(0,0,0,0)) ;
// m_flatShader->setExplode(faceShrinkage) ;
m_vectorShader = new Utils::ShaderVectorPerVertex() ;
m_vectorShader->setAttributePosition(m_positionVBO) ;
......@@ -130,12 +130,14 @@ void Viewer::cb_redraw()
{
if(m_drawVertices)
{
glDepthFunc(GL_LEQUAL);
m_pointSprite->setSize(vertexScaleFactor) ;
m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ;
}
if(m_drawEdges)
{
glDepthFunc(GL_LEQUAL);
glLineWidth(1.0f) ;
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
}
......@@ -146,10 +148,10 @@ void Viewer::cb_redraw()
glEnable(GL_LIGHTING) ;
glEnable(GL_POLYGON_OFFSET_FILL) ;
glPolygonOffset(1.0f, 1.0f) ;
glDepthFunc(GL_LESS);
switch(m_renderStyle)
{
case FLAT :
m_flatShader->setExplode(faceShrinkage) ;
m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ;
break ;
case PHONG :
......@@ -161,6 +163,7 @@ void Viewer::cb_redraw()
if(m_drawTopo)
{
glDepthFunc(GL_LEQUAL);
m_topoRender->drawTopo() ;
}
......@@ -543,7 +546,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -42,7 +42,7 @@
#include "Algo/Render/GL2/topoRender.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/pointSprite.h"
......@@ -104,13 +104,13 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
Utils::ShaderPhong* m_phongShader ;
Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleFlat* m_flatShader ;
Utils::ShaderVectorPerVertex* m_vectorShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::PointSprite* m_pointSprite ;
......
......@@ -447,13 +447,13 @@ int main(int argc, char **argv)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
int nb = 8;
int nb = 64;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i = position.begin(); i != position.end(); position.next(i))
{
VEC3 pert(float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0));
VEC3 pert(float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0),float(double(rand())/RAND_MAX/200.0));
position[i]+= pert;
}
......
......@@ -85,7 +85,7 @@ void Viewer::cb_initGL()
Utils::GLSLShader::setCurrentOGLVersion(2) ;
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRenderMap<PFP>() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
......@@ -232,7 +232,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -267,7 +267,7 @@ void Viewer::cb_keyPress(int keycode)
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
updateGL();
break;
......@@ -338,7 +338,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -103,7 +103,7 @@ public:
VertexAttribute<VEC3, MAP> normal ;
Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRenderMap<PFP>* m_topoRender ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO;
......
......@@ -75,8 +75,7 @@ void MyQT::traversors(int x)
// update all color to grey
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
m_render_topo->addColoredDart(d,0.5f,0.5f,0.5f);
}
switch(x)
......@@ -85,7 +84,7 @@ void MyQT::traversors(int x)
{
Traversor2VVaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
......@@ -94,14 +93,14 @@ void MyQT::traversors(int x)
Traversor2VVaF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 2:
{
Traversor2EEaV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 3:
......@@ -109,63 +108,63 @@ void MyQT::traversors(int x)
Traversor2EEaF<MAP> trav(myMap,m_selected);
float c=0.0f;
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,c);
m_render_topo->addColoredDart(b,0.0f,1.0f,c);
}
break;
case 4:
{
Traversor2FFaV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 5:
{
Traversor2FFaE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 6:
{
Traversor2FV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 7:
{
Traversor2FE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 8:
{
Traversor2EV<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 9:
{
Traversor2EF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 10:
{
Traversor2VE<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
case 11:
{
Traversor2VF<MAP> trav(myMap,m_selected);
for(Dart b=trav.begin(); b!= trav.end(); b=trav.next())
m_render_topo->setDartColor(b,0.0f,1.0f,0.0f);
m_render_topo->addColoredDart(b,0.0f,1.0f,0.0f);
}
break;
default:
......@@ -178,9 +177,8 @@ void MyQT::traversors(int x)
void MyQT::createMap(int n)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
colorDarts = myMap.addAttribute<VEC3, DART, MAP>("color");
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, n, n, true);
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, n, n, true);
grid.embedIntoGrid(position, 1.,1.,0.);
// bounding box of scene
......@@ -197,31 +195,28 @@ 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(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
std::cout << "markAll OK"<< std::endl;
#ifdef USE_GMAP
m_render_topo->updateDataGMap<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
#else
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
#endif
std::cout << "markAll OK"<< std::endl;
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(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);
}
}
}
void MyQT::updateMap()
{
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
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.isBoundaryMarked<2>(d)))
{
const Geom::Vec3f& C = colorDarts[d];
if (C*C != 0.0f)
m_render_topo->setDartColor(d,C[0],C[1],C[2]);
}
}
#ifdef USE_GMAP
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
#else
m_render_topo->updateDataGMap<PFP>(myMap, position, 0.9f, 0.9f, dock.withBoundary->isChecked());
#endif
updateGL();
}
......@@ -229,28 +224,24 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
#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
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
}
// redraw GL callback (clear and swap already done)
void MyQT::cb_redraw()
{
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f );
glDepthFunc(GL_LESS);
m_render_topo->drawTopo();
glDisable( GL_POLYGON_OFFSET_FILL );
glDepthFunc(GL_LEQUAL);
m_render_topo->drawColoredDarts(myMap);
if (m_selected != NIL)
m_render_topo->overdrawDart(m_selected, 11, 1.0f, 0.0f, 0.0f);
m_render_topo->overdrawDart(myMap, m_selected, 11, 1.0f, 0.0f, 0.0f);
if (m_selected2 != NIL)
m_render_topo->overdrawDart(m_selected2, 11, 0.0f, 1.0f, 0.0f);
m_render_topo->overdrawDart(myMap, m_selected2, 11, 0.0f, 1.0f, 0.0f);
}
void MyQT::cb_mousePress(int button, int x, int y)
......@@ -279,38 +270,6 @@ void MyQT::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked<2>(d))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f;
colorDarts[d] = Geom::Vec3f(r,g,b);
m_render_topo->setDartColor(d,r,g,b);
}
}
break;
case 'g':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
}
break;
case 'h':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(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);
}
}
break;
case Qt::Key_Up:
if (m_selected!=NIL)
position[m_selected][1] += m_shift;
......@@ -344,11 +303,6 @@ void MyQT::cb_keyPress(int keycode)
void MyQT::svg()
{
if (m_selected!=NIL)
m_render_topo->setDartColor(m_selected,0.8f,0.0f,0.0f);
if (m_selected2!=NIL)
m_render_topo->setDartColor(m_selected2,0.0f,0.8f,0.0f);
std::string filename = selectFileSave("snapshot file", ".", "(*.svg)");
m_render_topo->svgout2D(filename, modelViewMatrix(),projectionMatrix());
}
......@@ -392,23 +346,6 @@ void MyQT::importMesh(std::string& filename)
position = myMap.getAttribute<VEC3, VERTEX, MAP>(attrNames[0]) ;
}
colorDarts = myMap.getAttribute<VEC3, DART, MAP>("color");
if (!colorDarts.isValid())
{
colorDarts = myMap.addAttribute<VEC3, DART, MAP>("color");
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f;
colorDarts[d] = Geom::Vec3f(r,g,b);
m_render_topo->setDartColor(d,r,g,b);
}
}
}
m_selected = NIL;
m_selected2 = NIL;
......
......@@ -94,7 +94,7 @@ protected:
#ifdef USE_GMAP
Algo::Render::GL2::TopoRenderGMap<PFP>* m_render_topo;
#else
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo;
Algo::Render::GL2::TopoRender* m_render_topo;
#endif
Dart m_selected;
......
......@@ -169,7 +169,6 @@ void MyQT::operation(int x)
void MyQT::createMap(int n)
{
position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
colorDarts = myMap.addAttribute<VEC3, DART, MAP>("color");
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, n, n, true);
grid.embedIntoGrid(position, 1.,1.,0.);
......@@ -191,43 +190,22 @@ void MyQT::createMap(int n)
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
#ifdef PRIMAL_TOPO
m_render_topo->updateData(myMap, position, 0.9);
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData(myMap, position, 0.9f, 0.9f,true);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f;
colorDarts[d] = Geom::Vec3f(r,g,b);
m_render_topo->setDartColor(d,r,g,b);
}
}
}
void MyQT::updateMap()
{
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
#ifdef PRIMAL_TOPO
m_render_topo->updateData(myMap, position, 0.9);
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData(myMap, position, 0.9f, 0.9f,true);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{
const Geom::Vec3f& C = colorDarts[d];
if (C*C != 0.0f)
m_render_topo->setDartColor(d,C[0],C[1],C[2]);
}
}
}
// initialization GL callback
......@@ -235,27 +213,27 @@ void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
#ifdef PRIMAL_TOPO
m_render_topo = new Algo::Render::GL2::TopoPrimalRender<PFP>() ;
m_render_topo = new Algo::Render::GL2::TopoPrimalRender() ;
#else
m_render_topo = new Algo::Render::GL2::TopoRenderMap<PFP>(0.01f) ;
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
#endif
}
// redraw GL callback (clear and swap already done)
void MyQT::cb_redraw()
{
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 1.0f, 1.0f );
glDepthFunc(GL_LESS);
m_render_topo->drawTopo();
glDisable( GL_POLYGON_OFFSET_FILL );
glDepthFunc(GL_LEQUAL);
m_render_topo->drawColoredDarts<MAP>(myMap);
if (m_selected != NIL)
m_render_topo->overdrawDart(m_selected, 11, 1.0f, 0.0f, 0.0f);
m_render_topo->overdrawDart(myMap, m_selected, 11, 1.0f, 0.0f, 0.0f);
if (m_selected2 != NIL)
m_render_topo->overdrawDart(m_selected2, 11, 0.0f, 1.0f, 0.0f);
m_render_topo->overdrawDart(myMap, m_selected2, 11, 0.0f, 1.0f, 0.0f);
}
void MyQT::cb_mousePress(int button, int x, int y)
......@@ -281,41 +259,6 @@ void MyQT::cb_keyPress(int keycode)
{
switch(keycode)
{
case 'c':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked<2>(d))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f;
colorDarts[d] = Geom::Vec3f(r,g,b);
m_render_topo->setDartColor(d,r,g,b);
}
}
break;
case 'g':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!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);
}
}
break;
case 'b':
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(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);
}
}
break;
case Qt::Key_Up:
if (m_selected!=NIL)
position[m_selected][1] += m_shift;
......@@ -346,11 +289,6 @@ void MyQT::cb_keyPress(int keycode)
void MyQT::svg()
{
if (m_selected!=NIL)
m_render_topo->setDartColor(m_selected,0.8f,0.0f,0.0f);
if (m_selected2!=NIL)
m_render_topo->setDartColor(m_selected2,0.0f,0.8f,0.0f);
std::string filename = selectFileSave("snapshot file", ".", "(*.svg)");
m_render_topo->svgout2D(filename, modelViewMatrix(),projectionMatrix());
}
......@@ -394,23 +332,6 @@ void MyQT::importMesh(std::string& filename)
position = myMap.getAttribute<VEC3, VERTEX, MAP>(attrNames[0]) ;
}
colorDarts = myMap.getAttribute<VEC3, DART, MAP>("color");
if (!colorDarts.isValid())
{
colorDarts = myMap.addAttribute<VEC3, DART, MAP>("color");
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked<2>(d)))
{
int n = rand();
float r = float(n&0x7f)/255.0f + 0.25f;
float g = float((n>>8)&0x7f)/255.0f + 0.25f;
float b = float((n>>16)&0x7f)/255.0 + 0.25f;
colorDarts[d] = Geom::Vec3f(r,g,b);
m_render_topo->setDartColor(d,r,g,b);
}
}
}
m_selected = NIL;
m_selected2 = NIL;
......
......@@ -84,13 +84,12 @@ protected:
MAP myMap;
VertexAttribute<VEC3, MAP> position;
DartAttribute<VEC3, MAP> colorDarts;
// render (for the topo)
#ifdef PRIMAL_TOPO
Algo::Render::GL2::TopoPrimalRender<PFP>* m_render_topo;
#else
Algo::Render::GL2::TopoRenderMap<PFP>* m_render_topo;
Algo::Render::GL2::TopoRender* m_render_topo;
#endif
Dart m_selected;
Dart m_selected2;
......
......@@ -76,19 +76,16 @@ void MyQT::clipping_onoff(bool x)
m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
m_sh3->setClipPlaneParamsAll(clip_id3, normal, pos);
m_sh4->setClipPlaneParamsAll(clip_id4, normal, pos);
}
else
{
m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh3->setClipPlaneParamsAll(clip_id3, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh4->setClipPlaneParamsAll(clip_id4, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_sh3->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_sh4->setClipColorAttenuationFactorRelative(0.0f,0.0f);
}
updateMap();
......@@ -343,7 +340,7 @@ void MyQT::updateMap()
#else
m_render_topo->updateData(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
m_render_topo_boundary->updateDataBoundary(myMap,position,m_ex1,m_ex2,m_shift);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
}
// initialization GL callback
......@@ -356,7 +353,7 @@ void MyQT::cb_initGL()
#else