Commit b6872481 authored by Sylvain Thery's avatar Sylvain Thery

ajout rendu bord (ALGO::RENDER::GL2::BOUNDARY)

test dans tuto1
functor SelectorEdgeNoBoundary/SelectorEdgeBoundary
parent 58858e5a
......@@ -88,6 +88,11 @@ void MyQT::cb_redraw()
m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
m_render->draw(m_shader, Algo::Render::GL2::LINES);
m_shader->setColor(Geom::Vec4f(0.,1.,1.,0.));
m_render->draw(m_shader, Algo::Render::GL2::BOUNDARY);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
......@@ -169,9 +174,10 @@ int main(int argc, char **argv)
// update des primitives du renderer
SelectorTrue allDarts;
// SelectorNoBoundary<PFP::MAP> allDarts(myMap);
SelectorEdgeNoBoundary<PFP::MAP> insideEdges(myMap);// just to draw only inside edges
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, insideEdges, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::BOUNDARY); // special primitive for boundary edges
// show final pour premier redraw
sqt.show();
......
......@@ -61,7 +61,8 @@ enum drawingType
POINTS = 4,
EXPLODED = 8,
FLAT_TRIANGLES = 16,
ERR = 32
BOUNDARY = 32,
ERR = 64
} ;
enum bufferIndex
......@@ -70,6 +71,7 @@ enum bufferIndex
LINE_INDICES = 1,
TRIANGLE_INDICES = 2,
FLAT_BUFFER = 3,
BOUNDARY_INDICES = 4,
SIZE_BUFFER
} ;
......@@ -204,6 +206,11 @@ public:
template <typename PFP>
void initPoints(typename PFP::MAP& map, const FunctorSelect& good,std::vector<GLuint>& tableIndices, unsigned int thread=0) ;
template <typename PFP>
void initBoundaries(typename PFP::MAP& map, const FunctorSelect& good,std::vector<GLuint>& tableIndices, unsigned int thread=0) ;
/**
* initialization of the VBO indices primitives
* computed by a traversal of the map
......@@ -212,6 +219,8 @@ public:
template <typename PFP>
void initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, bool optimized = true, unsigned int thread = 0) ;
/**
* initialization of the VBO indices primitives
* using the given table
......
......@@ -323,18 +323,6 @@ template<typename PFP>
void MapRender::initTriangles(typename PFP::MAP& map, const FunctorSelect& good, std::vector<GLuint>& tableIndices, unsigned int thread)
{
// DartMarker m(map, thread);
// tableIndices.reserve(4 * map.getNbDarts() / 3);
//
// for(Dart dd = map.begin(); dd != map.end(); map.next(dd))
// {
// if(!m.isMarked(dd) && good(dd))
// {
// addTri<PFP>(map, dd, tableIndices);
// m.markOrbit(FACE, dd);
// }
// }
DartMarker m(map, thread);
tableIndices.reserve(4 * map.getNbDarts() / 3);
TraversorF<typename PFP::MAP> trav(map);
......@@ -361,7 +349,7 @@ void MapRender::initTrianglesOptimized(typename PFP::MAP& map, const FunctorSele
{
std::list<Dart> bound;
if (good(dd))
if (good(dd) && !map.isBoundaryMarked(dd))
addTri<PFP>(map, dd, tableIndices);
m.markOrbit(FACE, dd);
bound.push_back(dd);
......@@ -377,7 +365,7 @@ void MapRender::initTrianglesOptimized(typename PFP::MAP& map, const FunctorSele
{
if (!m.isMarked(f))
{
if(good(f))
if (good(f) && !map.isBoundaryMarked(dd))
addTri<PFP>(map, f, tableIndices);
m.markOrbit(FACE, f);
bound.push_back(map.phi1(f));
......@@ -404,16 +392,42 @@ void MapRender::initTrianglesOptimized(typename PFP::MAP& map, const FunctorSele
template<typename PFP>
void MapRender::initLines(typename PFP::MAP& map, const FunctorSelect& good, std::vector<GLuint>& tableIndices, unsigned int thread)
{
DartMarker m(map, thread);
// DartMarker m(map, thread);
tableIndices.reserve(map.getNbDarts());
for(Dart d = map.begin(); d != map.end(); map.next(d))
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
// tableIndices.push_back(map.getEmbedding(VERTEX, d));
// tableIndices.push_back(map.getEmbedding(VERTEX, map.phi1(d)));
// m.markOrbit(EDGE, d);
// }
// }
TraversorE<typename PFP::MAP> trav(map);
for (Dart d = trav.begin(); d!= trav.end(); d = trav.next())
{
if(!m.isMarked(d) && good(d))
if (good(d) && map.isBoundaryEdge(d))
{
tableIndices.push_back(map.getEmbedding(VERTEX, d));
tableIndices.push_back(map.getEmbedding(VERTEX, map.phi2(d)));
m.markOrbit(EDGE, d);
tableIndices.push_back(map.getEmbedding(VERTEX, map.phi1(d)));
}
}
}
template<typename PFP>
void MapRender::initBoundaries(typename PFP::MAP& map, const FunctorSelect& good, std::vector<GLuint>& tableIndices, unsigned int thread)
{
TraversorE<typename PFP::MAP> trav(map);
tableIndices.reserve(map.getNbDarts()); //TODO optimisation ?
for (Dart d = trav.begin(); d!= trav.end(); d = trav.next())
{
if (good(d) && map.isBoundaryEdge(d))
{
tableIndices.push_back(map.getEmbedding(VERTEX, d));
tableIndices.push_back(map.getEmbedding(VERTEX, map.phi1(d)));
}
}
}
......@@ -518,6 +532,11 @@ void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good
break;
case FLAT_TRIANGLES:
break;
case BOUNDARY:
initBoundaries<PFP>(map, good, tableIndices, thread) ;
m_nbIndices[BOUNDARY_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[BOUNDARY_INDICES];
break;
default:
CGoGNerr << "problem initializing VBO indices" << CGoGNendl;
break;
......
......@@ -77,17 +77,41 @@ public:
};
//template <typename MAP>
//class SelectorNoBoundary : public FunctorSelect
//{
//public:
//protected:
// MAP& m_map;
//public:
// SelectorNoBoundary(MAP& m): m_map(m) {}
// bool operator()(Dart d) const { return !m_map.isBoundaryMarked(d); }
//};
template <typename MAP>
class SelectorNoBoundary : public FunctorSelect
class SelectorEdgeBoundary : public FunctorSelect
{
public:
protected:
MAP& m_map;
public:
SelectorNoBoundary(MAP& m): m_map(m) {}
bool operator()(Dart d) const { return !m_map.isBoundaryMarked(d); }
SelectorEdgeBoundary(MAP& m): m_map(m) {}
bool operator()(Dart d) const { return m_map.isBoundaryEdge(d); }
};
template <typename MAP>
class SelectorEdgeNoBoundary : public FunctorSelect
{
public:
protected:
MAP& m_map;
public:
SelectorEdgeNoBoundary(MAP& m): m_map(m) {}
bool operator()(Dart d) const { return !m_map.isBoundaryEdge(d); }
};
// Counting Functors : increment its value every time it is applied
/********************************************************/
......
......@@ -45,7 +45,7 @@ public:
Dart begin()
{
mark.unmarkAll() ;
mark.unmarkAll() ; // TODO ajouter test pour ne pas toujours faire le unmark !!
current = m.begin() ;
while(m.isBoundaryMarked(current))
m.next(current) ;
......
......@@ -40,8 +40,8 @@ namespace GL2
MapRender::MapRender()
{
glGenBuffersARB(4, m_indexBuffers) ;
for(unsigned int i = 0; i < 4; ++i)
glGenBuffersARB(SIZE_BUFFER, m_indexBuffers) ;
for(unsigned int i = 0; i < SIZE_BUFFER; ++i)
m_nbIndices[i] = 0 ;
}
......@@ -68,6 +68,10 @@ void MapRender::initPrimitives(int prim, std::vector<GLuint>& tableIndices)
m_nbIndices[TRIANGLE_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[TRIANGLE_INDICES];
break;
case BOUNDARY:
m_nbIndices[BOUNDARY_INDICES] = tableIndices.size();
vbo_ind = m_indexBuffers[BOUNDARY_INDICES];
break;
default:
CGoGNerr << "problem initializing VBO indices" << CGoGNendl;
break;
......@@ -97,6 +101,11 @@ void MapRender::draw(Utils::GLSLShader* sh, int prim)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[TRIANGLE_INDICES]);
glDrawElements(GL_TRIANGLES, m_nbIndices[TRIANGLE_INDICES], GL_UNSIGNED_INT, 0);
break;
case BOUNDARY:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffers[BOUNDARY_INDICES]);
glDrawElements(GL_LINES, m_nbIndices[BOUNDARY_INDICES], GL_UNSIGNED_INT, 0);
break;
default:
break;
}
......
......@@ -120,7 +120,6 @@ void Map2::deleteOrientedFace(Dart d)
Dart Map2::newFace(unsigned int nbEdges)
{
std::cout << "OUCHHH"<< std::endl;
Dart d = Map1::newFace(nbEdges);
Dart e = Map1::newBoundaryFace(nbEdges);
......
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