Commit bd3680d8 authored by Sylvain Thery's avatar Sylvain Thery

resolve bug in MapBrowserSelector

parent 1f381e91
......@@ -31,6 +31,7 @@
#include "Algo/Geometry/normal.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Topology/generic/mapBrowser.h"
using namespace CGoGN ;
......@@ -73,15 +74,15 @@ void MyQT::clipping_onoff(bool x)
Geom::Vec3f pos = m_PlanePick->getPosition();
float pipo;
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
}
else
{
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_render_topo->shader1()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_render_topo->shader2()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
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_sh1->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_sh2->setClipColorAttenuationFactorRelative(0.0f,0.0f);
}
updateMap();
updateGL();
......@@ -252,6 +253,8 @@ void MyQT::createMap(int n)
prim.hexaGrid_topo(n,n,n);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
myMap.check();
// bounding box of scene
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
......@@ -265,11 +268,21 @@ void MyQT::createMap(int n)
m_render_topo->setDartWidth(3.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// MapBrowserSelector mbs(myMap,sdb);
// myMap.setBrowser(&mbs);
// m_render_topo_boundary->updateData<PFP>(myMap,position,m_ex1,m_ex2);
// myMap.setBrowser(NULL);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
}
void MyQT::updateMap()
{
std::cout << "updateMap"<< std::endl;
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
}
// initialization GL callback
......@@ -278,18 +291,24 @@ void MyQT::cb_initGL()
glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::Topo3Render() ;
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setInitialDartsColor(0.0f,0.9f,0.0f);
m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
m_frame = new Utils::FrameManipulator();
m_frame->setSize(bb.maxSize());
m_render_topo->shader1()->insertClippingCode();
m_render_topo->shader2()->insertClippingCode();
m_sh1 = static_cast<Utils::ClippingShader*>(m_render_topo->shader1());
m_sh2 = static_cast<Utils::ClippingShader*>(m_render_topo->shader2());
m_sh1->insertClippingCode();
m_sh2->insertClippingCode();
clip_id1 = m_render_topo->shader1()->addClipPlane();
clip_id2 = m_render_topo->shader2()->addClipPlane();
clip_id1 = m_sh1->addClipPlane();
clip_id2 = m_sh2->addClipPlane();
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), bb.center());
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), bb.center());
m_sh1->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), bb.center());
m_sh2->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), bb.center());
}
......@@ -301,6 +320,8 @@ void MyQT::cb_redraw()
m_render_topo->drawTopo();
m_render_topo_boundary->drawTopo();
glDisable( GL_POLYGON_OFFSET_FILL );
if (m_selected != NIL)
......@@ -330,7 +351,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
{
if (d != Dart::nil())
m_selected = d;
std::cout << myMap.edgeCanCollapse(d) << std::endl;
}
if (button == Qt::RightButton)
{
......@@ -365,13 +385,37 @@ void MyQT::cb_mousePress(int button, int x, int y)
if (Control())
{
Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
// Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
// if (button == Qt::LeftButton)
// {
// if (d != Dart::nil())
// m_selecteds.push_back(d);
// }
// updateGL();
if (button == Qt::LeftButton)
{
Dart d = m_render_topo_boundary->picking<PFP>(myMap, x,y,true);
if (d != Dart::nil())
{
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
}
}
if (button == Qt::RightButton)
{
Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
if (d != Dart::nil())
m_selecteds.push_back(d);
{
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
}
}
updateGL();
}
}
......@@ -433,8 +477,8 @@ void MyQT::cb_mouseMove(int buttons, int x, int y)
float pipo;
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
m_sh1->setClipPlaneParamsAll(clip_id1, normal, pos);
m_sh2->setClipPlaneParamsAll(clip_id2, normal, pos);
m_begX = x;
m_begY = y;
......@@ -634,6 +678,13 @@ void MyQT::importMesh(std::string& filename)
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// MapBrowserSelector mbs(myMap,sdb);
// myMap.setBrowser(&mbs);
// m_render_topo_boundary->updateData<PFP>(myMap,position,m_ex1,m_ex2);
// myMap.setBrowser(NULL);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
m_shift = bb.maxSize()/200.0f;
......
......@@ -37,6 +37,7 @@
#endif
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Render/GL2/topoRender.h"
#include "Algo/Geometry/boundingbox.h"
#include "ui_tuto_oper3.h"
......@@ -70,7 +71,7 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT():nb(myMap),m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
void cb_redraw();
void cb_initGL();
......@@ -89,12 +90,13 @@ protected:
VertexAttribute<VEC3> position;
SelectorDartNoBoundary<PFP::MAP> nb;
// SelectorDartNoBoundary<PFP::MAP> nb;
Geom::BoundingBox<PFP::VEC3> bb;
// render (for the topo)
Algo::Render::GL2::Topo3Render* m_render_topo;
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Dart m_selected;
Dart m_selected2;
std::vector<Dart> m_selecteds;
......@@ -122,6 +124,10 @@ protected:
template<int X>
Dart PHI(Dart d) {return myMap.phi<X>(d);}
Utils::ClippingShader* m_sh1;
Utils::ClippingShader* m_sh2;
public:
// example of simple map creation
void createMap(int n);
......
......@@ -33,13 +33,16 @@
#include "Topology/generic/functor.h"
#include "Geometry/vector_gen.h"
#include "Utils/GLSLShader.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/vbo_base.h"
#include "Utils/svg.h"
// forward
namespace CGoGN { namespace Utils { class ShaderSimpleColor; } }
namespace CGoGN { namespace Utils { class ShaderColorPerVertex; } }
namespace CGoGN { namespace Utils { class ClippingShader; } }
namespace CGoGN
{
......@@ -156,8 +159,8 @@ public:
~Topo3Render();
Utils::ClippingShader* shader1() { return reinterpret_cast<Utils::ClippingShader*>(m_shader1);}
Utils::ClippingShader* shader2() { return reinterpret_cast<Utils::ClippingShader*>(m_shader2);}
Utils::GLSLShader* shader1() { return static_cast<Utils::GLSLShader*>(m_shader1);}
Utils::GLSLShader* shader2() { return static_cast<Utils::GLSLShader*>(m_shader2);}
/**
* set the with of line use to draw darts (default val is 2)
......
......@@ -41,11 +41,13 @@ class MapBrowserSelector : public MapBrowser
{
protected:
AttribMap& m_map ;
const FunctorSelect& m_selector ;
const FunctorSelect* m_selector ;
public:
MapBrowserSelector(AttribMap& m, const FunctorSelect& fs);
~MapBrowserSelector();
Dart begin() const;
Dart end() const;
......
......@@ -27,13 +27,20 @@ namespace CGoGN
inline MapBrowserSelector::MapBrowserSelector(AttribMap& m, const FunctorSelect& fs) :
m_map(m), m_selector(fs)
{}
m_map(m)
{
m_selector = fs.copy();
}
inline MapBrowserSelector::~MapBrowserSelector()
{
delete m_selector;
}
inline Dart MapBrowserSelector::begin() const
{
Dart d = m_map.realBegin() ;
while ( (d != m_map.realEnd()) && !m_selector(d) )
while ( (d != m_map.realEnd()) && !m_selector->operator()(d) )
m_map.realNext(d);
return d;
......@@ -50,7 +57,7 @@ inline void MapBrowserSelector::next(Dart& d) const
{
m_map.realNext(d) ;
}
while ( (d != m_map.realEnd()) && !m_selector(d) ) ;
while ( (d != m_map.realEnd()) && !m_selector->operator()(d) ) ;
}
......
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