Commit c4c86f8d authored by Sylvain Thery's avatar Sylvain Thery

update of toporendering (and picking) for gmap (onw OK)

a define in tuto*.h allow testing with gmap
parent 94bef722
......@@ -25,7 +25,7 @@
#ifndef _TUTO1_
#define _TUTO1_
#define USE_GMAP
//#define USE_GMAP
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
......
......@@ -25,7 +25,7 @@
#ifndef _TUTO2_
#define _TUTO2_
#define USE_GMAP
//#define USE_GMAP
#include "Utils/Qt/qtSimple.h"
......
......@@ -174,7 +174,7 @@ void MyQT::cb_mouseClick(int button, int x, int y)
{
if (button == Qt::LeftButton)
{
Dart d = m_render_topo->picking<PFP>(myMap,allDarts,x,y);
Dart d = m_render_topo->picking<PFP>(myMap,x,y);
if (d != NIL)
CGoGNout << "Dart "<< d << CGoGNendl;
......
......@@ -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
};
......
......@@ -61,7 +61,7 @@ void MyQT::cb_mouseClick(int button, int x, int y)
if (button == Qt::LeftButton)
{
Dart d = m_render_topo->picking<PFP>(myMap,allDarts,x,y);
Dart d = m_render_topo->picking<PFP>(myMap,x,y);
if (d != NIL)
{
dart_selected.clear();
......
......@@ -22,50 +22,18 @@
* *
*******************************************************************************/
#define WITH_GMAP 1
#include "tuto5.h"
#include <iostream>
#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<PFP>(myMap, allDarts, x,y);
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
Dart d = m_render_topo->picking<PFP>(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);
......
......@@ -27,6 +27,30 @@
#include <iostream>
#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();
......
......@@ -256,7 +256,7 @@ public:
* @return the dart or NIL
*/
template<typename PFP>
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
......
This diff is collapsed.
......@@ -198,7 +198,7 @@ public:
* @return the dart or NIL
*/
template<typename PFP>
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 <typename PFP>
void updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good = allDarts);
......
......@@ -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<VEC3*>(PositionDartsBuffer);
unsigned int posDBI = 0;
std::vector<VEC3> 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<VEC3*>(PositionDartsBuffer);
unsigned int posDBI = 0;
std::vector<VEC3> vecPos;
vecPos.reserve(16);
......@@ -253,6 +252,7 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE
for(std::vector<Dart>::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<typename PFP>
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<PFP>(map,good);
......
......@@ -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] << ", "<<color[1] << ", "<<color[2] <<std::endl;
return colToDart(color);
}
......
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