From c4c86f8dbec6e1b1451d48414603700f99722342 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Thu, 5 Jan 2012 16:47:50 +0100 Subject: [PATCH] update of toporendering (and picking) for gmap (onw OK) a define in tuto*.h allow testing with gmap --- Apps/Tuto/tuto1.h | 2 +- Apps/Tuto/tuto2.h | 2 +- Apps/Tuto/tuto3.cpp | 2 +- Apps/Tuto/tuto3.h | 12 +- Apps/Tuto/tuto4.cpp | 2 +- Apps/Tuto/tuto5.cpp | 45 +--- Apps/Tuto/tuto5.h | 48 +++- include/Algo/Render/GL2/topo3Render.h | 2 +- include/Algo/Render/GL2/topo3Render.hpp | 293 ++---------------------- include/Algo/Render/GL2/topoRender.h | 2 +- include/Algo/Render/GL2/topoRender.hpp | 14 +- src/Algo/Render/topo3Render.cpp | 4 +- 12 files changed, 99 insertions(+), 329 deletions(-) diff --git a/Apps/Tuto/tuto1.h b/Apps/Tuto/tuto1.h index bf65684f..4942662f 100644 --- a/Apps/Tuto/tuto1.h +++ b/Apps/Tuto/tuto1.h @@ -25,7 +25,7 @@ #ifndef _TUTO1_ #define _TUTO1_ -#define USE_GMAP +//#define USE_GMAP #include "Utils/Qt/qtSimple.h" #include "Utils/cgognStream.h" diff --git a/Apps/Tuto/tuto2.h b/Apps/Tuto/tuto2.h index 58379280..523c1f8a 100644 --- a/Apps/Tuto/tuto2.h +++ b/Apps/Tuto/tuto2.h @@ -25,7 +25,7 @@ #ifndef _TUTO2_ #define _TUTO2_ -#define USE_GMAP +//#define USE_GMAP #include "Utils/Qt/qtSimple.h" diff --git a/Apps/Tuto/tuto3.cpp b/Apps/Tuto/tuto3.cpp index 851181de..6f62d56b 100644 --- a/Apps/Tuto/tuto3.cpp +++ b/Apps/Tuto/tuto3.cpp @@ -174,7 +174,7 @@ void MyQT::cb_mouseClick(int button, int x, int y) { if (button == Qt::LeftButton) { - Dart d = m_render_topo->picking(myMap,allDarts,x,y); + Dart d = m_render_topo->picking(myMap,x,y); if (d != NIL) CGoGNout << "Dart "<< d << CGoGNendl; diff --git a/Apps/Tuto/tuto3.h b/Apps/Tuto/tuto3.h index f220a9a4..f38a8968 100644 --- a/Apps/Tuto/tuto3.h +++ b/Apps/Tuto/tuto3.h @@ -28,8 +28,14 @@ #include "Utils/Qt/qtSimple.h" #include "Utils/cgognStream.h" +//#define USE_GMAP + #include "Topology/generic/parameters.h" -#include "Topology/map/embeddedMap2.h" +#ifdef USE_GMAP + #include "Topology/gmap/embeddedGMap2.h" +#else + #include "Topology/map/embeddedMap2.h" +#endif #include "Algo/Render/GL2/topoRender.h" @@ -43,7 +49,11 @@ using namespace CGoGN ; struct PFP: public PFP_STANDARD { // definition of the type of the map +#ifdef USE_GMAP + typedef EmbeddedGMap2 MAP; +#else typedef EmbeddedMap2 MAP; +#endif }; diff --git a/Apps/Tuto/tuto4.cpp b/Apps/Tuto/tuto4.cpp index dacdd04f..bea40039 100644 --- a/Apps/Tuto/tuto4.cpp +++ b/Apps/Tuto/tuto4.cpp @@ -61,7 +61,7 @@ void MyQT::cb_mouseClick(int button, int x, int y) if (button == Qt::LeftButton) { - Dart d = m_render_topo->picking(myMap,allDarts,x,y); + Dart d = m_render_topo->picking(myMap,x,y); if (d != NIL) { dart_selected.clear(); diff --git a/Apps/Tuto/tuto5.cpp b/Apps/Tuto/tuto5.cpp index bbf6f5c4..12a2cce7 100644 --- a/Apps/Tuto/tuto5.cpp +++ b/Apps/Tuto/tuto5.cpp @@ -22,50 +22,18 @@ * * *******************************************************************************/ -#define WITH_GMAP 1 - #include "tuto5.h" #include -#include "Topology/generic/parameters.h" -#ifdef WITH_GMAP - #include "Topology/gmap/embeddedGMap3.h" -#else - #include "Topology/map/embeddedMap3.h" -#endif - -#include "Geometry/vector_gen.h" -#include "Algo/Geometry/boundingbox.h" -#include "Algo/Render/GL2/mapRender.h" -#include "Utils/Shaders/shaderSimpleColor.h" #include "Algo/Modelisation/primitives3d.h" #include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/subdivision.h" #include "Algo/Render/GL2/topo3Render.h" - -#include "Topology/generic/cellmarker.h" -#include "Utils/text3d.h" - -#include "Utils/pointSprite.h" -#include "Utils/Shaders/shaderVectorPerVertex.h" -#include "Utils/cgognStream.h" - #include "Algo/Render/SVG/mapSVGRender.h" -using namespace CGoGN ; - -struct PFP: public PFP_STANDARD -{ - // definition de la carte -#ifdef WITH_GMAP - typedef EmbeddedGMap3 MAP; -#else - typedef EmbeddedMap3 MAP; -#endif -}; PFP::MAP myMap; PFP::TVEC3 position ; @@ -224,10 +192,13 @@ void MyQT::cb_redraw() if (render_topo) m_render_topo->drawTopo(); - Dart d = myMap.phi2(myMap.begin()); +/* Dart d = myMap.phi2(myMap.begin()); m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f); d = myMap.phi1(myMap.begin()); m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f); +*/ + m_render_topo->overdrawDart(m_selected, 5, 1.0f, 0.0f, 1.0f); + glDisable(GL_POLYGON_OFFSET_FILL); @@ -252,15 +223,18 @@ void MyQT::cb_mousePress(int button, int x, int y) { if (Shift()) { - Dart d = m_render_topo->picking(myMap, allDarts, x,y); + SelectorDartNoBoundary nb(myMap); + Dart d = m_render_topo->picking(myMap, x,y, nb); if (d != Dart::nil()) { CGoGNout << "Dart "<< d << " clicked" << CGoGNendl; + m_selected = d; } else { statusMsg(""); } + updateGL(); } } @@ -339,6 +313,9 @@ int main(int argc, char **argv) sqt.setCallBack( dock.slider_vectors, SIGNAL(valueChanged(int)), SLOT(slider_vectors(int)) ); sqt.setCallBack( dock.slider_text, SIGNAL(valueChanged(int)), SLOT(slider_text(int)) ); + + sqt.m_selected = myMap.begin(); + sqt.show(); sqt.slider_balls(50); diff --git a/Apps/Tuto/tuto5.h b/Apps/Tuto/tuto5.h index e2d9da58..08d83be1 100644 --- a/Apps/Tuto/tuto5.h +++ b/Apps/Tuto/tuto5.h @@ -27,6 +27,30 @@ #include +#define WITH_GMAP 1 + +#include "Topology/generic/parameters.h" +#ifdef WITH_GMAP + #include "Topology/gmap/embeddedGMap3.h" +#else + #include "Topology/map/embeddedMap3.h" +#endif + +#include "Geometry/vector_gen.h" +#include "Algo/Geometry/boundingbox.h" +#include "Algo/Render/GL2/mapRender.h" +#include "Utils/Shaders/shaderSimpleColor.h" + +#include "Algo/Render/GL2/topo3Render.h" + +#include "Topology/generic/cellmarker.h" +#include "Utils/text3d.h" + +#include "Utils/pointSprite.h" +#include "Utils/Shaders/shaderVectorPerVertex.h" +#include "Utils/cgognStream.h" + + #include "Utils/Qt/qtSimple.h" @@ -34,14 +58,19 @@ // inclure qtui.h juste après le ui_xxx.h #include "Utils/Qt/qtui.h" -// forward definitions (minimize includes) -namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; } } } } -namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class Topo3Render; } } } } -namespace CGoGN { namespace Utils { class VBO; } } -namespace CGoGN { namespace Utils { class ShaderSimpleColor; } } -namespace CGoGN { namespace Utils { class Strings3D; } } -namespace CGoGN { namespace Utils { class PointSprite; } } -namespace CGoGN { namespace Utils { class ShaderVectorPerVertex; } } + +using namespace CGoGN ; + +struct PFP: public PFP_STANDARD +{ + // definition de la carte +#ifdef WITH_GMAP + typedef EmbeddedGMap3 MAP; +#else + typedef EmbeddedMap3 MAP; +#endif +}; + using namespace CGoGN ; @@ -74,7 +103,7 @@ class MyQT: public Utils::QT::SimpleQT Utils::PointSprite* m_sprite; QTimer *m_timer; - + public: MyQT(): render_text(true), @@ -92,6 +121,7 @@ public: m_timer(NULL) {} + Dart m_selected; protected: void storeVerticesInfo(); diff --git a/include/Algo/Render/GL2/topo3Render.h b/include/Algo/Render/GL2/topo3Render.h index 5292deb5..d98b3d02 100644 --- a/include/Algo/Render/GL2/topo3Render.h +++ b/include/Algo/Render/GL2/topo3Render.h @@ -256,7 +256,7 @@ public: * @return the dart or NIL */ template - Dart picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y); + Dart picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good=allDarts); /** * update all drawing buffers to render a dual map diff --git a/include/Algo/Render/GL2/topo3Render.hpp b/include/Algo/Render/GL2/topo3Render.hpp index 7611e744..5612a9f9 100644 --- a/include/Algo/Render/GL2/topo3Render.hpp +++ b/include/Algo/Render/GL2/topo3Render.hpp @@ -86,11 +86,16 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV std::vector vecDartFaces; vecDartFaces.reserve(map.getNbDarts()/4); + unsigned int posDBI=0; + DartMarker mark(map); // marker for darts for (Dart d = map.begin(); d != map.end(); map.next(d)) { if (good(d)) { + m_attIndex[d] = posDBI; + posDBI+=2; + CellMarkerStore markVert(map, VERTEX); //marker for vertices VEC3 center(0, 0, 0); unsigned int nbv = 0; @@ -148,7 +153,6 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); VEC3* positionDartBuf = reinterpret_cast(PositionDartsBuffer); - unsigned int posDBI=0; @@ -169,8 +173,6 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV { const VEC3& P = positions[d]; vecPos.push_back(P); - m_attIndex[d] = posDBI; - posDBI+=2; center += P; d = map.phi1(d); } while (d != dd); @@ -196,8 +198,8 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV *positionDartBuf++ = P; *positionDartBuf++ = Q; - *colorDartBuf++ = VEC3(1.,1.,1.); - *colorDartBuf++ = VEC3(1.,1.,1.); + *colorDartBuf++ = VEC3(1.,1.,1.0); + *colorDartBuf++ = VEC3(1.,1.,1.0); fv1[d] = P*0.1f + Q*0.9f; fv11[d] = P*0.9f + Q*0.1f; @@ -289,12 +291,13 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g for (Dart d = map.begin(); d != map.end(); map.next(d)) { - if (nb < m_nbDarts) + if (good(d)) { - if (good(d)) + if (nb < m_nbDarts) { float r,g,b; dartToCol(d, r,g,b); + float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO *local++ = r; *local++ = g; @@ -305,18 +308,20 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g nb++; } - } - else - { - CGoGNerr << "Error buffer too small for color picking (change the good parameter ?)" << CGoGNendl; - d = map.end(); + else + { + CGoGNerr << "Error buffer too small for color picking (change the good parameter ?)" << CGoGNendl; + d = map.end(); + } } } glUnmapBuffer(GL_ARRAY_BUFFER); + + std::cout << "NB DARTS="< -Dart Topo3Render::picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y) +Dart Topo3Render::picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good) { pushColors(); setDartsIdColor(map,good); @@ -353,11 +358,15 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const typename PFP::T std::vector vecDartFaces; vecDartFaces.reserve(map.getNbDarts()/4); + unsigned int posDBI=0; DartMarker mark(map); // marker for darts for (Dart d = map.begin(); d != map.end(); map.next(d)) { if (good(d)) { + m_attIndex[d] = posDBI; + posDBI+=2; + CellMarkerStore markVert(map, VERTEX); //marker for vertices VEC3 center(0, 0, 0); unsigned int nbv = 0; @@ -383,6 +392,7 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const typename PFP::T nbv++; } mark.mark(dNext); // Mark + mark.mark(map.beta0(dNext)); m_nbDarts++; Dart adj = map.phi2(dNext); // Get adjacent face if (adj != dNext && !mark.isMarked(adj)) @@ -414,7 +424,6 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const typename PFP::T glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); VEC3* positionDartBuf = reinterpret_cast(PositionDartsBuffer); - unsigned int posDBI=0; std::vector::iterator face = vecDartFaces.begin(); for (unsigned int iVol=0; iVolbind(); glUnmapBuffer(GL_ARRAY_BUFFER); } -/*{ - GMap3& map = reinterpret_cast(mapx); - - float kd=0.95f; - - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - - AutoAttributeHandler posBeta1(map, DART); - AutoAttributeHandler posBeta2(map, DART); //beta 3 link is represented at the same location as beta2 - AutoAttributeHandler posBeta2x(map, DART); //beta 3 link is represented at the same location as beta2 - AutoAttributeHandler vert(map, DART); - - if (m_attIndex.map() != &map) - { - m_attIndex = map.template getAttribute(DART, "dart_index"); - if (!m_attIndex.isValid()) - m_attIndex = map.template addAttribute(DART, "dart_index"); - } - - m_nbDarts = 0; - - // table of face (one dart of each) - std::vector vecDartFaces; - vecDartFaces.reserve(map.getNbDarts()/6); //6 = nb of darts for tri mesh - - // table of nbfaces per volume - std::vector vecNbFaces; - vecNbFaces.reserve(vecDartFaces.size()); - - // table of center of volume - std::vector vecVolCenters; - vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh - - DartMarker mark(map); // marker for darts - CellMarker mVol(map, VOLUME); - for (Dart d = map.begin(); d != map.end(); map.next(d)) - { - if (good(d)) - { - if(!mVol.isMarked(d)) - { - mVol.mark(d); - CellMarkerStore markVert(map, VERTEX); //marker for vertices - VEC3 center(0); - unsigned int nbVertices = 0; - unsigned int nbFace = 0; - std::list visitedFaces; // Faces that are traversed - visitedFaces.push_back(d); // Start with the face of d - - // For every face added to the list - for (std::list::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face) - { - if (!mark.isMarked(*face)) // Face has not been visited yet - { - // store a dart of face - vecDartFaces.push_back(*face); - nbFace++; - Dart dNext = *face ; - do - { - mark.mark(dNext); // Mark - m_nbDarts++; - - if (!markVert.isMarked(dNext)) - { - markVert.mark(dNext); - center += positions[dNext]; - nbVertices++; - } - - Dart adj = map.phi2(dNext); // add adjacent face if not done already - if (adj != dNext && !mark.isMarked(adj)) - visitedFaces.push_back(adj); - - dNext = map.phi1(dNext); - } while(dNext != *face); - } - } - center /= typename PFP::REAL(nbVertices); - vecVolCenters.push_back(center); - vecNbFaces.push_back(nbFace); - } - } - } - - m_nbDarts *= 2; // x2 : only one orientation is used for the previous computation, multiply by 2 to get the number of darts - - //colors - m_vbo4->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); - GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3* colorDartBuf = reinterpret_cast(ColorDartsBuffer); - - //darts - m_vbo0->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); - GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3* positionDartBuf = reinterpret_cast(PositionDartsBuffer); - unsigned int posDBI=0; - - std::vector::iterator face = vecDartFaces.begin(); - for (unsigned int iVol=0; iVol vecPos; - vecPos.reserve(16); - - // store the face & center - VEC3 center(0); - Dart dd = d; - do - { - const VEC3& P = positions[dd]; - vecPos.push_back(P); - m_attIndex[dd] = posDBI; - posDBI+=2; - m_attIndex[map.beta0(dd)] = posDBI; //for gmap : also affect a number to the other orientation for picking - posDBI+=2; - - center += P; - dd = map.phi1(dd); - } while (dd != d); - center /= REAL(vecPos.size()); - - - //shrink the face - unsigned int nb = vecPos.size(); - float okf = 1.0f - kf; - float okv = 1.0f - kv; - for (unsigned int i = 0; i < nb; ++i) - { - vecPos[i] = vecVolCenters[iVol]*okv + vecPos[i]*kv; - vecPos[i] = center*okf + vecPos[i]*kf; - } - vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop - - // compute position of points to use for drawing topo - float oke = 1.0f - ke; - for (unsigned int i = 0; i < nb; ++i) - { - VEC3 P = vecPos[i]*ke + vecPos[i+1]*oke; - VEC3 Q = vecPos[i+1]*ke + vecPos[i]*oke; - - VEC3 P_mid = P+(Q-P)*kd*0.5f; - VEC3 Q_mid = Q+(P-Q)*kd*0.5f; - - vert[d] = P; - - *positionDartBuf++ = P; - *positionDartBuf++ = P_mid; - *colorDartBuf++ = VEC3(1.,1.,1.); - *colorDartBuf++ = VEC3(1.,1.,1.); - -// glColor3f(0.0f,0.0f,1.0f); -// glVertex3fv(P_mid.data()); -// glVertex3fv(Q_mid.data()); -// glColor3f(1.0f,1.0f,1.0f); - - *positionDartBuf++ = Q; - *positionDartBuf++ = Q_mid; - *colorDartBuf++ = VEC3(1.,1.,1.); - *colorDartBuf++ = VEC3(1.,1.,1.); - - posBeta1[d] = P*0.9f + P_mid*0.1f; - posBeta1[map.beta0(d)] = Q*0.9f + Q_mid*0.1f; - - posBeta2[d] = P*0.52f + P_mid*0.48f; - posBeta2x[d] = P*0.48f + P_mid*0.52f; - posBeta2[map.beta0(d)] = Q*0.52f + Q_mid*0.48f; - posBeta2x[map.beta0(d)] = Q*0.48f + Q_mid*0.52f; - - d = map.phi1(d); - } - } - } - - //beta1 - m_vbo1->bind(); - glBufferData(GL_ARRAY_BUFFER, m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); - GLvoid* PositionBuffer1 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); - - //beta2 - m_vbo2->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); - GLvoid* PositionBuffer2 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); - - //beta3 - m_vbo3->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); - GLvoid* PositionBuffer3 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); - - VEC3* positionF1 = reinterpret_cast(PositionBuffer1); - VEC3* positionF2 = reinterpret_cast(PositionBuffer2); - VEC3* positionF3 = reinterpret_cast(PositionBuffer3); - - m_nbRel2=0; - m_nbRel3=0; - - //draw beta1, beta2, beta3 if required - for(Dart d = map.begin(); d != map.end(); map.next(d)) - { - Dart e = map.beta2(d); - if ((dbind(); - glUnmapBufferARB(GL_ARRAY_BUFFER); - - m_vbo2->bind(); - glUnmapBufferARB(GL_ARRAY_BUFFER); - - m_vbo1->bind(); - glUnmapBuffer(GL_ARRAY_BUFFER); - - m_vbo0->bind(); - glUnmapBuffer(GL_ARRAY_BUFFER); - - m_vbo4->bind(); - glUnmapBuffer(GL_ARRAY_BUFFER); - -} -*/ - }//end namespace VBO diff --git a/include/Algo/Render/GL2/topoRender.h b/include/Algo/Render/GL2/topoRender.h index f3243e37..a158a0a0 100644 --- a/include/Algo/Render/GL2/topoRender.h +++ b/include/Algo/Render/GL2/topoRender.h @@ -198,7 +198,7 @@ public: * @return the dart or NIL */ template - Dart picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y); + Dart picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good=allDarts); template void updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good = allDarts); diff --git a/include/Algo/Render/GL2/topoRender.hpp b/include/Algo/Render/GL2/topoRender.hpp index f86c501d..4d3ca64e 100644 --- a/include/Algo/Render/GL2/topoRender.hpp +++ b/include/Algo/Render/GL2/topoRender.hpp @@ -28,7 +28,7 @@ #include "Topology/generic/parameters.h" #include "Topology/map/embeddedMap2.h" -#include "Topology/gmap/embeddedGmap2.h" +#include "Topology/gmap/embeddedGMap2.h" namespace CGoGN { @@ -77,6 +77,7 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC if (good(d)) { vecDarts.push_back(d); + m_attIndex[d] = (vecDarts.size()-1)*2; } } m_nbDarts = vecDarts.size(); @@ -97,7 +98,6 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); VEC3* positionDartBuf = reinterpret_cast(PositionDartsBuffer); - unsigned int posDBI = 0; std::vector vecPos; vecPos.reserve(16); @@ -117,8 +117,6 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC { const VEC3& P = positions[d]; vecPos.push_back(P); - m_attIndex[d] = posDBI; - posDBI+=2; center += P; d = map.phi1(d); } while (d != dd); @@ -224,6 +222,7 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE if (good(d)) { vecDarts.push_back(d); + m_attIndex[d] = (vecDarts.size()-1)*2; } } m_nbDarts = vecDarts.size(); @@ -244,7 +243,7 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE glBufferData(GL_ARRAY_BUFFER, 4*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); VEC3* positionDartBuf = reinterpret_cast(PositionDartsBuffer); - unsigned int posDBI = 0; + std::vector vecPos; vecPos.reserve(16); @@ -253,6 +252,7 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE for(std::vector::iterator id = vecDarts.begin(); id!= vecDarts.end(); id++) { Dart d = *id; + if (!mf.isMarked(d)) { vecPos.clear(); @@ -263,8 +263,6 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE { const VEC3& P = positions[d]; vecPos.push_back(P); - m_attIndex[d] = posDBI; - posDBI+=2; center += P; d = map.phi1(d); } while (d != dd); @@ -396,7 +394,7 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go } template -Dart TopoRender::picking(typename PFP::MAP& map, const FunctorSelect& good, int x, int y) +Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, const FunctorSelect& good) { pushColors(); setDartsIdColor(map,good); diff --git a/src/Algo/Render/topo3Render.cpp b/src/Algo/Render/topo3Render.cpp index 2a430264..5515d61a 100644 --- a/src/Algo/Render/topo3Render.cpp +++ b/src/Algo/Render/topo3Render.cpp @@ -355,7 +355,9 @@ Dart Topo3Render::pickColor(unsigned int x, unsigned int y) glReadPixels(x,y,1,1,GL_RGB,GL_FLOAT,color); glClearColor(cc[0], cc[1], cc[2], cc[3]); - + + + std::cout << color[0] << ", "<