Commit b5d064c4 authored by Sylvain Thery's avatar Sylvain Thery

add nice render of boundary of map2

parent 0f0c1735
...@@ -77,7 +77,8 @@ void MyQT::createMap() ...@@ -77,7 +77,8 @@ void MyQT::createMap()
show(); show();
// render the topo of the map without boundary darts // render the topo of the map without boundary darts
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); m_render_topo->setInitialBoundaryDartsColor(0,1,0);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
} }
// initialization GL callback // initialization GL callback
......
...@@ -191,9 +191,10 @@ void MyQT::createMap(int n) ...@@ -191,9 +191,10 @@ void MyQT::createMap(int n)
dm.markAll(); dm.markAll();
m_render_topo->setDartWidth(5.0f); m_render_topo->setDartWidth(4.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f); m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{ {
...@@ -211,7 +212,8 @@ void MyQT::createMap(int n) ...@@ -211,7 +212,8 @@ void MyQT::createMap(int n)
void MyQT::updateMap() void MyQT::updateMap()
{ {
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d)))
...@@ -227,7 +229,7 @@ void MyQT::updateMap() ...@@ -227,7 +229,7 @@ void MyQT::updateMap()
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
glClearColor(1.0f,1.0f,1.0f,1.0f); glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::TopoRender() ; m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
} }
// redraw GL callback (clear and swap already done) // redraw GL callback (clear and swap already done)
......
...@@ -97,11 +97,18 @@ protected: ...@@ -97,11 +97,18 @@ protected:
/// shifting along normals for 3-map boundary drawing /// shifting along normals for 3-map boundary drawing
float m_normalShift; float m_normalShift;
float m_boundShift;
/** /**
* initial darts color (set in update) * initial darts color (set in update)
*/ */
Geom::Vec3f m_dartsColor; Geom::Vec3f m_dartsColor;
/**
* initial darts color (set in update)
*/
Geom::Vec3f m_dartsBoundaryColor;
float *m_color_save; float *m_color_save;
/** /**
...@@ -149,7 +156,7 @@ public: ...@@ -149,7 +156,7 @@ public:
/** /**
* Constructor * Constructor
*/ */
TopoRender(); TopoRender(float bs = 0.01f);
/** /**
* Destructor * Destructor
...@@ -187,6 +194,7 @@ public: ...@@ -187,6 +194,7 @@ public:
* draw all topo * draw all topo
*/ */
void drawTopo(); void drawTopo();
/** /**
* change dart drawing color * change dart drawing color
* @param d the dart * @param d the dart
...@@ -207,6 +215,8 @@ public: ...@@ -207,6 +215,8 @@ public:
void setInitialDartsColor(float r, float g, float b); void setInitialDartsColor(float r, float g, float b);
void setInitialBoundaryDartsColor(float r, float g, float b);
/** /**
* redraw one dart with specific width and color (not efficient use only for debug with small amount of call) * redraw one dart with specific width and color (not efficient use only for debug with small amount of call)
* @param d the dart * @param d the dart
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "Topology/map/embeddedMap2.h" #include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h" #include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Geometry/basic.h"
#include "Geometry/distances.h" #include "Geometry/distances.h"
#include "Algo/Geometry/centroid.h" #include "Algo/Geometry/centroid.h"
#include "Algo/Geometry/normal.h" #include "Algo/Geometry/normal.h"
...@@ -139,50 +140,96 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty ...@@ -139,50 +140,96 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
if (!mf.isMarked(d)) if (!mf.isMarked(d))
{ {
vecPos.clear(); vecPos.clear();
VEC3 center = Algo::Surface::Geometry::faceCentroidELW<PFP>(mapx,d,positions); if (!map.isBoundaryMarked2(d))
float k = 1.0f - kf;
Dart dd = d;
do
{ {
vecPos.push_back(center*k + positions[dd]*kf); VEC3 center = Algo::Surface::Geometry::faceCentroidELW<PFP>(mapx,d,positions);
dd = map.phi1(dd); float k = 1.0f - kf;
} while (dd != d); Dart dd = d;
do
{
vecPos.push_back(center*k + positions[dd]*kf);
dd = map.phi1(dd);
} while (dd != d);
if (m_normalShift > 0.0f) if (m_normalShift > 0.0f)
{
VEC3 normal = Algo::Surface::Geometry::newellNormal<PFP>(mapx,d,positions);
for (typename std::vector<VEC3>::iterator pit = vecPos.begin(); pit != vecPos.end(); ++pit)
{ {
*pit -= normal*m_normalShift; VEC3 normal = Algo::Surface::Geometry::newellNormal<PFP>(mapx,d,positions);
for (typename std::vector<VEC3>::iterator pit = vecPos.begin(); pit != vecPos.end(); ++pit)
{
*pit -= normal*m_normalShift;
}
} }
}
unsigned int nb = vecPos.size(); unsigned int nb = vecPos.size();
vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop
k = 1.0f - ke; k = 1.0f - ke;
for (unsigned int i = 0; i < nb; ++i) for (unsigned int i = 0; i < nb; ++i)
{
VEC3 P = vecPos[i]*ke + vecPos[i+1]*k;
VEC3 Q = vecPos[i+1]*ke + vecPos[i]*k;
m_attIndex[d] = indexDC;
indexDC+=2;
*positionDartBuf++ = P;
*positionDartBuf++ = Q;
*colorDartBuf++ = m_dartsColor;
*colorDartBuf++ = m_dartsColor;
VEC3 f = P*0.5f + Q*0.5f;
fv2[d] = f;
f = P*0.1f + Q*0.9f;
fv1[d] = f;
f = P*0.9f + Q*0.1f;
fv11[d] = f;
d = map.phi1(d);
}
mf.markOrbit<FACE>(d);
}
else if (withBoundary)
{ {
VEC3 P = vecPos[i]*ke + vecPos[i+1]*k;
VEC3 Q = vecPos[i+1]*ke + vecPos[i]*k;
m_attIndex[d] = indexDC; Dart dd = d;
indexDC+=2; do
*positionDartBuf++ = P; {
*positionDartBuf++ = Q; Dart ee = mapx.phi2(dd);
*colorDartBuf++ = m_dartsColor; VEC3 normal = Algo::Surface::Geometry::newellNormal<PFP>(mapx,ee,positions);
*colorDartBuf++ = m_dartsColor; VEC3 vd = Algo::Surface::Geometry::vectorOutOfDart<PFP>(mapx,ee,positions);
VEC3 f = P*0.5f + Q*0.5f; VEC3 v = vd ^ normal;
fv2[d] = f; v.normalize();
f = P*0.1f + Q*0.9f; VEC3 P = positions[map.phi1(ee)] + v* m_boundShift;
fv1[d] = f; vecPos.push_back(P);
f = P*0.9f + Q*0.1f; dd = map.phi1(dd);
fv11[d] = f; ee = mapx.phi2(dd);
d = map.phi1(d); P = positions[map.phi1(ee)] + v* m_boundShift;
vecPos.push_back(P);
} while (dd != d);
unsigned int nb = vecPos.size()/2;
float k = 1.0f - ke;
for (unsigned int i = 0; i < nb; ++i)
{
VEC3 P = vecPos[2*i]*ke + vecPos[2*i+1]*k;
VEC3 Q = vecPos[2*i+1]*ke + vecPos[2*i]*k;
m_attIndex[d] = indexDC;
indexDC+=2;
*positionDartBuf++ = P;
*positionDartBuf++ = Q;
*colorDartBuf++ = m_dartsBoundaryColor;
*colorDartBuf++ = m_dartsBoundaryColor;
VEC3 f = P*0.5f + Q*0.5f;
fv2[d] = f;
f = P*0.1f + Q*0.9f;
fv1[d] = f;
f = P*0.9f + Q*0.1f;
fv11[d] = f;
d = map.phi1(d);
}
mf.markOrbit<FACE>(d);
} }
mf.markOrbit<FACE>(d);
} }
} }
......
...@@ -38,13 +38,15 @@ namespace Render ...@@ -38,13 +38,15 @@ namespace Render
namespace GL2 namespace GL2
{ {
TopoRender::TopoRender(): TopoRender::TopoRender(float bs):
m_nbDarts(0), m_nbDarts(0),
m_nbRel2(0), m_nbRel2(0),
m_topo_dart_width(2.0f), m_topo_dart_width(2.0f),
m_topo_relation_width(3.0f), m_topo_relation_width(3.0f),
m_normalShift(0.0f), m_normalShift(0.0f),
m_boundShift(bs),
m_dartsColor(1.0f,1.0f,1.0f), m_dartsColor(1.0f,1.0f,1.0f),
m_dartsBoundaryColor(0.7f,1.0f,0.7f),
m_bufferDartPosition(NULL) m_bufferDartPosition(NULL)
{ {
m_vbo0 = new Utils::VBO(); m_vbo0 = new Utils::VBO();
...@@ -130,6 +132,12 @@ void TopoRender::setInitialDartsColor(float r, float g, float b) ...@@ -130,6 +132,12 @@ void TopoRender::setInitialDartsColor(float r, float g, float b)
m_dartsColor = Geom::Vec3f(r,g,b); m_dartsColor = Geom::Vec3f(r,g,b);
} }
void TopoRender::setInitialBoundaryDartsColor(float r, float g, float b)
{
m_dartsBoundaryColor = Geom::Vec3f(r,g,b);
}
void TopoRender::drawDarts() void TopoRender::drawDarts()
{ {
if (m_nbDarts==0) if (m_nbDarts==0)
......
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