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()
show();
// 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
......
......@@ -191,9 +191,10 @@ void MyQT::createMap(int n)
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->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))
{
......@@ -211,7 +212,8 @@ void MyQT::createMap(int n)
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))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d)))
......@@ -227,7 +229,7 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
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)
......
......@@ -97,11 +97,18 @@ protected:
/// shifting along normals for 3-map boundary drawing
float m_normalShift;
float m_boundShift;
/**
* initial darts color (set in update)
*/
Geom::Vec3f m_dartsColor;
/**
* initial darts color (set in update)
*/
Geom::Vec3f m_dartsBoundaryColor;
float *m_color_save;
/**
......@@ -149,7 +156,7 @@ public:
/**
* Constructor
*/
TopoRender();
TopoRender(float bs = 0.01f);
/**
* Destructor
......@@ -187,6 +194,7 @@ public:
* draw all topo
*/
void drawTopo();
/**
* change dart drawing color
* @param d the dart
......@@ -207,6 +215,8 @@ public:
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)
* @param d the dart
......
......@@ -30,6 +30,7 @@
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Geometry/basic.h"
#include "Geometry/distances.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Geometry/normal.h"
......@@ -139,50 +140,96 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute<ty
if (!mf.isMarked(d))
{
vecPos.clear();
VEC3 center = Algo::Surface::Geometry::faceCentroidELW<PFP>(mapx,d,positions);
float k = 1.0f - kf;
Dart dd = d;
do
if (!map.isBoundaryMarked2(d))
{
vecPos.push_back(center*k + positions[dd]*kf);
dd = map.phi1(dd);
} while (dd != d);
VEC3 center = Algo::Surface::Geometry::faceCentroidELW<PFP>(mapx,d,positions);
float k = 1.0f - kf;
Dart dd = d;
do
{
vecPos.push_back(center*k + positions[dd]*kf);
dd = map.phi1(dd);
} while (dd != d);
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)
if (m_normalShift > 0.0f)
{
*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();
vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop
unsigned int nb = vecPos.size();
vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop
k = 1.0f - ke;
for (unsigned int i = 0; i < nb; ++i)
k = 1.0f - ke;
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;
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);
Dart dd = d;
do
{
Dart ee = mapx.phi2(dd);
VEC3 normal = Algo::Surface::Geometry::newellNormal<PFP>(mapx,ee,positions);
VEC3 vd = Algo::Surface::Geometry::vectorOutOfDart<PFP>(mapx,ee,positions);
VEC3 v = vd ^ normal;
v.normalize();
VEC3 P = positions[map.phi1(ee)] + v* m_boundShift;
vecPos.push_back(P);
dd = map.phi1(dd);
ee = mapx.phi2(dd);
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
namespace GL2
{
TopoRender::TopoRender():
TopoRender::TopoRender(float bs):
m_nbDarts(0),
m_nbRel2(0),
m_topo_dart_width(2.0f),
m_topo_relation_width(3.0f),
m_normalShift(0.0f),
m_boundShift(bs),
m_dartsColor(1.0f,1.0f,1.0f),
m_dartsBoundaryColor(0.7f,1.0f,0.7f),
m_bufferDartPosition(NULL)
{
m_vbo0 = new Utils::VBO();
......@@ -130,6 +132,12 @@ void TopoRender::setInitialDartsColor(float r, float g, float 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()
{
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