Commit ef3ac359 authored by untereiner's avatar untereiner

add draw topo 3-maps opengl 1

parent e7511757
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
//#include <gmtl/Output.h> //#include <gmtl/Output.h>
#include <GL/gl.h> #include <GL/gl.h>
#include "Topology/generic/functor.h"
// OpenGL direct mode rendering of darts of maps // OpenGL direct mode rendering of darts of maps
namespace CGoGN namespace CGoGN
...@@ -76,7 +78,11 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -76,7 +78,11 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
* @param kv exploding coefficient for volumes (0.0 normal draw) * @param kv exploding coefficient for volumes (0.0 normal draw)
*/ */
template <typename PFP> template <typename PFP>
void renderTopoMD3(typename PFP::MAP& the_map, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv, FunctorType& good); void renderTopoMD3(typename PFP::MAP& the_map, const typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv, FunctorType& good);
template <typename PFP>
void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv);
}// end namespace }// end namespace
}// end namespace }// end namespace
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <limits> #include <limits>
#include "Topology/generic/autoAttributeHandler.h" #include "Topology/generic/autoAttributeHandler.h"
#include "Geometry/vector_gen.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -119,35 +121,35 @@ namespace GL1 ...@@ -119,35 +121,35 @@ namespace GL1
//}; //};
// //
//template <typename PFP> //template <typename PFP>
//void renderTopoGM2(typename PFP::MAP& the_map, Marker m) //void renderTopoGM2(typename PFP::MAP& map, Marker m)
//{ //{
// //
// //
// std::vector<gmtl::Vec3f> fv1; // std::vector<gmtl::Vec3f> fv1;
// std::vector<gmtl::Vec3f> fv2; // std::vector<gmtl::Vec3f> fv2;
// fv1.reserve(the_map.getNbDarts()); // fv1.reserve(map.getNbDarts());
// fv2.reserve(the_map.getNbDarts()); // fv2.reserve(map.getNbDarts());
// //
// // first pass render the triangles // // first pass render the triangles
// FunctorGM2Face<PFP> fgl_gc(the_map,fv1,fv2,m); // FunctorGM2Face<PFP> fgl_gc(map,fv1,fv2,m);
// //
// glLineWidth(1.0f); // glLineWidth(1.0f);
// glBegin(GL_LINES); // glBegin(GL_LINES);
// glColor3f(1.0,1.0,1.0); // glColor3f(1.0,1.0,1.0);
// //
// the_map.foreach_orbit(2,fgl_gc); // map.foreach_orbit(2,fgl_gc);
// glEnd(); // glEnd();
// glLineWidth(2.0f); // glLineWidth(2.0f);
// glBegin(GL_LINES); // glBegin(GL_LINES);
// for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) // for(Dart d = map.begin(); d!= map.end(); map.next(d))
// { // {
// glColor3f(0.0,1.0,1.0); // glColor3f(0.0,1.0,1.0);
// int i=d->getLabel(); // int i=d->getLabel();
// int j=(the_map.alpha1(d))->getLabel(); // int j=(map.alpha1(d))->getLabel();
// glVertex3fv(fv1[i].getData()); // glVertex3fv(fv1[i].getData());
// glVertex3fv(fv1[j].getData()); // glVertex3fv(fv1[j].getData());
// glColor3f(1.0,0.0,0.0); // glColor3f(1.0,0.0,0.0);
// j=(the_map.alpha(2,d))->getLabel(); // j=(map.alpha(2,d))->getLabel();
// glVertex3fv(fv2[i].getData()); // glVertex3fv(fv2[i].getData());
// glVertex3fv(fv2[j].getData()); // glVertex3fv(fv2[j].getData());
// } // }
...@@ -157,22 +159,22 @@ namespace GL1 ...@@ -157,22 +159,22 @@ namespace GL1
template <typename PFP> template <typename PFP>
void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, float ke, float kf) void renderTopoMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, float ke, float kf)
{ {
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL; typedef typename PFP::REAL REAL;
AutoAttributeHandler<Geom::Vec3f> fv1(the_map, DART); AutoAttributeHandler<Geom::Vec3f> fv1(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv11(the_map, DART); AutoAttributeHandler<Geom::Vec3f> fv11(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv2(the_map, DART); AutoAttributeHandler<Geom::Vec3f> fv2(map, DART);
AutoAttributeHandler<Geom::Vec3f> vert(the_map, DART); AutoAttributeHandler<Geom::Vec3f> vert(map, DART);
glLineWidth(2.0f); glLineWidth(2.0f);
glColor3f(0.9f,0.9f,0.9f); glColor3f(0.9f,0.9f,0.9f);
glBegin(GL_LINES); glBegin(GL_LINES);
DartMarker mf(the_map); DartMarker mf(map);
for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) for(Dart d = map.begin(); d!= map.end(); map.next(d))
{ {
if (!mf.isMarked(d)) if (!mf.isMarked(d))
{ {
...@@ -190,7 +192,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -190,7 +192,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
const VEC3& P = positions[d]; const VEC3& P = positions[d];
vecPos.push_back(positions[d]); vecPos.push_back(positions[d]);
center += P; center += P;
d = the_map.phi1(d); d = map.phi1(d);
}while (d!=dd); }while (d!=dd);
center /= REAL(vecPos.size()); center /= REAL(vecPos.size());
...@@ -217,15 +219,15 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -217,15 +219,15 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
fv1[d] = f; fv1[d] = f;
f = P*0.9f + Q*0.1f; f = P*0.9f + Q*0.1f;
fv11[d] = f; fv11[d] = f;
d = the_map.phi1(d); d = map.phi1(d);
} }
mf.markOrbit(FACE, d); mf.markOrbit(FACE, d);
} }
} }
for(Dart d = the_map.begin(); d != the_map.end(); the_map.next(d)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
Dart e = the_map.phi2(d); Dart e = map.phi2(d);
if ((d<e) && drawPhi2) if ((d<e) && drawPhi2)
{ {
glColor3f(1.0,0.0,0.0); glColor3f(1.0,0.0,0.0);
...@@ -234,7 +236,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -234,7 +236,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
} }
if (drawPhi1) if (drawPhi1)
{ {
e = the_map.phi1(d); e = map.phi1(d);
glColor3f(0.0f,1.0f,1.0f); glColor3f(0.0f,1.0f,1.0f);
glVertex3fv(fv1[d].data()); glVertex3fv(fv1[d].data());
glVertex3fv(fv11[e].data()); glVertex3fv(fv11[e].data());
...@@ -246,7 +248,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -246,7 +248,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
glPointSize(5.0f); glPointSize(5.0f);
glColor3f(0.0f,0.0f,0.0f); glColor3f(0.0f,0.0f,0.0f);
glBegin(GL_POINTS); glBegin(GL_POINTS);
for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) for(Dart d = map.begin(); d!= map.end(); map.next(d))
{ {
glVertex3fv(vert[d].data()); glVertex3fv(vert[d].data());
} }
...@@ -254,54 +256,55 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -254,54 +256,55 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
} }
//
//
//template<typename PFP> //template<typename PFP>
//class FunctorMD3Face : public FunctorMap<typename PFP::MAP> //class FunctorMD3Face : public FunctorMap<typename PFP::MAP>
//{ //{
// typedef typename PFP::MAP MAP; // typedef typename PFP::MAP MAP;
// typedef typename PFP::EMB EMB; // typedef typename PFP::VEC3 VEC3;
// //
// //
// protected: // protected:
// std::vector<gmtl::Vec3f>& m_vf1; // std::vector<VEC3>& m_vf1;
// //
// gmtl::Vec3f m_volCenter; // VEC3 m_volCenter;
// int m_lab; // int m_lab;
// float m_ke; // float m_ke;
// float m_kf; // float m_kf;
// float m_kv; // float m_kv;
// Marker m_mark; // DartMarkerStore m_mark;
// bool m_drawPhi1; // bool m_drawPhi1;
// //
// typename PFP::TVEC3 m_positions;
// //
// public: // public:
// FunctorMD3Face(MAP& map, std::vector<gmtl::Vec3f>& vf1, float ke, float kf, float kv, Marker m, bool df1): // FunctorMD3Face(MAP& map, typename PFP::TVEC3& positions, std::vector<VEC3>& vf1, float ke, float kf, float kv, Marker m, bool df1):
// FunctorMap<MAP>(map), m_vf1(vf1), m_lab(0), m_ke(ke), m_kf(kf), m_kv(kv), m_mark(m),m_drawPhi1(df1) // FunctorMap<MAP>(map), m_positions(positions), m_vf1(vf1), m_lab(0), m_ke(ke), m_kf(kf), m_kv(kv), m_mark(m),m_drawPhi1(df1)
// {} // {}
// //
// void setVolCenter(const gmtl::Vec3f& vc) { m_volCenter = vc;} // void setVolCenter(const VEC3& vc) { m_volCenter = vc;}
// //
// bool operator()(Dart d) // bool operator()(Dart d)
// { // {
// this->m_map.markDart(d,m_mark); // this->m_mark.markDart(d);
// //
// gmtl::Vec3f vPosPhi1[256]; // max 256 sides per face // VEC3 vPosPhi1[256]; // max 256 sides per face
// //
// std::vector<gmtl::Vec3f> vecPos; // std::vector<VEC3> vecPos;
// vecPos.reserve(16); // vecPos.reserve(16);
// gmtl::Vec3f centerFace(0.0f,0.0f,0.0f); // VEC3 centerFace(0.0f,0.0f,0.0f);
// //
// float k = 1.0f - m_kv; // float k = 1.0f - m_kv;
// //
// Dart dd = d; // Dart dd = d;
// do // do
// { // {
// const gmtl::Vec3f& P = this->m_map.getVertexEmb(dd)->getPosition(); // VEC3 P = m_positions[dd];//this->m_map.getEmbedding(VERTEX,dd)->getPosition();
// gmtl::Vec3f Q = m_volCenter*k + m_kv*P; // VEC3 Q = m_volCenter*k + m_kv*P;
// centerFace += Q; // centerFace += Q;
// vecPos.push_back(Q); // vecPos.push_back(Q);
// dd->setLabel(m_lab++); // dd = m_lab++;
// dd = this->m_map.phi1(dd); // dd = this->m_map.phi1(dd);
// }while (dd!=d); // }while (dd!=d);
// //
...@@ -323,13 +326,13 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -323,13 +326,13 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// //
// for (int i=0; i<nb; ++i) // for (int i=0; i<nb; ++i)
// { // {
// const gmtl::Vec3f& P = vecPos[i]; // VEC3 P = vecPos[i];
// gmtl::Vec3f Q = vecPos[i+1]*ke + vecPos[i]*k; // VEC3 Q = vecPos[i+1]*ke + vecPos[i]*k;
// glColor3f(1.0f,1.0f,0.0f); // glColor3f(1.0f,1.0f,0.0f);
// glVertex3fv(P.getData()); // glVertex3fv(P);
// glColor3f(1.0f,1.0f,1.0f); // glColor3f(1.0f,1.0f,1.0f);
// glVertex3fv(Q.getData()); // glVertex3fv(Q);
// gmtl::Vec3f f = P*0.5f + Q*0.5f; // VEC3 f = P*0.5f + Q*0.5f;
// m_vf1.push_back(f); // m_vf1.push_back(f);
// f = P*0.9f + Q*0.1f; // f = P*0.9f + Q*0.1f;
// vPosPhi1[i] = f; // vPosPhi1[i] = f;
...@@ -341,28 +344,29 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -341,28 +344,29 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// for (int i=0; i<nb; ++i) // for (int i=0; i<nb; ++i)
// { // {
// glColor3f(0.0f,1.0f,1.0f); // glColor3f(0.0f,1.0f,1.0f);
// int k=d->getLabel(); // int k=d;
// int j=(i+1)%nb; // int j=(i+1)%nb;
// gmtl::Vec3f fv3 = 2.0f*m_vf1[k] - vPosPhi1[i]; // VEC3 fv3 = 2.0f*m_vf1[k] - vPosPhi1[i];
// glVertex3fv(fv3.getData()); // glVertex3fv(fv3);
// glVertex3fv(vPosPhi1[j].getData()); // glVertex3fv(vPosPhi1[j]);
// d = this->m_map.phi1(d); // d = this->m_map.phi1(d);
// } // }
// } // }
// return false; // return false;
// } // }
//}; //};
//
//
//
//template <typename PFP> //template <typename PFP>
//void renderTopoMD3(typename PFP::MAP& the_map, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv, FunctorType& good) //void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv, FunctorType& good)
//{ //{
// typedef typename PFP::VEC3 VEC3;
// typedef typename PFP::REAL REAL;
// //
// std::vector<VEC3> vPosPhi23;
// //
// std::vector<gmtl::Vec3f> vPosPhi23; // vPosPhi23.reserve(map.getNbDarts());
//
// vPosPhi23.reserve(the_map.getNbDarts());
// //
// glLineWidth(1.0f); // glLineWidth(1.0f);
// glBegin(GL_LINES); // glBegin(GL_LINES);
...@@ -372,23 +376,24 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -372,23 +376,24 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// vecDarts.reserve(50); // vecDarts.reserve(50);
// FunctorStore fvol(vecDarts); // FunctorStore fvol(vecDarts);
// //
// Marker markerFace = the_map.getNewMarker(DART); // DartMarkerStore markerFace(map);
// FunctorMD3Face<PFP> fgl_cd(the_map,vPosPhi23,ke,kf,kv,markerFace,drawPhi1); //
// FunctorMD3Face<PFP> fgl_cd(map,positions,vPosPhi23,ke,kf,kv,markerFace,drawPhi1);
// //
// // Scan all darts of the map // // Scan all darts of the map
// for(Dart d = the_map.begin(); d != the_map.end(); the_map.next(d)) // for(Dart d = map.begin(); d != map.end(); map.next(d))
// { // {
// if ( good(d) && (!the_map.isMarkedDart(d,markerFace))) // foreach volume (not already marked) // if ( good(d) && (!markerFace.isMarked(d))) // foreach volume (not already marked)
// { // {
// gmtl::Vec3f centerVol= Geometry::volumeCentroid<PFP>(the_map,d) ; // compute center // VEC3 centerVol= Algo::Geometry::volumeCentroid<PFP>(map,d, positions) ; // compute center
// fgl_cd.setVolCenter(centerVol); //set center of volume in face drawing fonctor // fgl_cd.setVolCenter(centerVol); //set center of volume in face drawing fonctor
// //
// vecDarts.clear(); // vecDarts.clear();
// the_map.foreach_dart_of_oriented_volume(d,fvol); // get all darts of voluùe // map.foreach_dart_of_oriented_volume(d,fvol); // get all darts of voluùe
// //
// for (typename std::vector<Dart>::iterator it = vecDarts.begin(); it != vecDarts.end(); ++it) // for (typename std::vector<Dart>::iterator it = vecDarts.begin(); it != vecDarts.end(); ++it)
// { // {
// if (!the_map.isMarkedDart(*it,markerFace)) // for all face of the volume // if (!markerFace.isMarked(*it)) // for all face of the volume
// { // {
// fgl_cd(*it); // fgl_cd(*it);
// } // }
...@@ -396,8 +401,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -396,8 +401,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// } // }
// } // }
// //
// the_map.unmarkAll(markerFace); // markerFace.unmarkAll();
// the_map.releaseMarker(markerFace);
// //
// glEnd(); // glEnd();
// glLineWidth(2.0f); // glLineWidth(2.0f);
...@@ -406,24 +410,24 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -406,24 +410,24 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// // si on doit tracer phi2 & phi3 : unes seule passe // // si on doit tracer phi2 & phi3 : unes seule passe
// if ( drawPhi2 && drawPhi3) // if ( drawPhi2 && drawPhi3)
// { // {
// for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) // for(Dart d = map.begin(); d!= map.end(); map.next(d))
// { // {
// if (good(d)) // if (good(d))
// { // {
// int i=d->getLabel(); // int i=d;
// glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]); // glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]);
// //
// if (good(the_map.phi2(d))) // if (good(map.phi2(d)))
// { // {
// glColor3f(1.0,0.0,0.0); // glColor3f(1.0,0.0,0.0);
// int j=(the_map.phi2(d))->getLabel(); // int j=(map.phi2(d));
// glVertex3fv(vPosPhi23[i].getData()); // glVertex3fv(vPosPhi23[i].getData());
// glVertex3fv(vPosPhi23[j].getData()); // glVertex3fv(vPosPhi23[j].getData());
// } // }
// if (good(the_map.phi3(d))) // if (good(map.phi3(d)))
// { // {
// glColor3f(1.0,0.0,1.0); // glColor3f(1.0,0.0,1.0);
// int j=(the_map.phi3(d))->getLabel(); // int j=(map.phi3(d));
// glVertex3fv(vPosPhi23[i].getData()); // glVertex3fv(vPosPhi23[i].getData());
// glVertex3fv(vPosPhi23[j].getData()); // glVertex3fv(vPosPhi23[j].getData());
// } // }
...@@ -435,14 +439,14 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -435,14 +439,14 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// //
// if (drawPhi2) // if (drawPhi2)
// { // {
// for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) // for(Dart d = map.begin(); d!= map.end(); map.next(d))
// { // {
// if (good(d) && good(the_map.phi2(d))) // if (good(d) && good(map.phi2(d)))
// { // {
// glColor3f(1.0,0.0,0.0); // glColor3f(1.0,0.0,0.0);
// int i=d->getLabel(); // int i=d;
// glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]); // glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]);
// int j=(the_map.phi2(d))->getLabel(); // int j=(map.phi2(d));
// glVertex3fv(vPosPhi23[i].getData()); // glVertex3fv(vPosPhi23[i].getData());
// glVertex3fv(vPosPhi23[j].getData()); // glVertex3fv(vPosPhi23[j].getData());
// } // }
...@@ -451,14 +455,14 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -451,14 +455,14 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// //
// if (drawPhi3) // if (drawPhi3)
// { // {
// for(Dart d = the_map.begin(); d!= the_map.end(); the_map.next(d)) // for(Dart d = map.begin(); d!= map.end(); map.next(d))
// { // {
// if (good(d) && good(the_map.phi3(d))) // if (good(d) && good(map.phi3(d)))
// { // {
// glColor3f(1.0,0.0,1.0); // glColor3f(1.0,0.0,1.0);
// int i=d->getLabel(); // int i=d;
// glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]); // glTexCoord3f(vPosPhi23[i][0],vPosPhi23[i][1],vPosPhi23[i][2]);
// int j=(the_map.phi3(d))->getLabel(); // int j=(map.phi3(d));
// glVertex3fv(vPosPhi23[i].getData()); // glVertex3fv(vPosPhi23[i].getData());
// glVertex3fv(vPosPhi23[j].getData()); // glVertex3fv(vPosPhi23[j].getData());
// } // }
...@@ -469,6 +473,175 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -469,6 +473,175 @@ void renderTopoMD2(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
// //
//} //}
template <typename PFP>
void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
AutoAttributeHandler<Geom::Vec3f> fv1(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv11(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv2(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv2x(map, DART);
AutoAttributeHandler<Geom::Vec3f> vert(map, DART);
int m_nbDarts = 0;
// table of center of volume
std::vector<VEC3> vecCenters;
vecCenters.reserve(1000);
// table of nbfaces per volume
std::vector<unsigned int> vecNbFaces;
vecNbFaces.reserve(1000);
// table of face (one dart of each)
std::vector<Dart> vecDartFaces;
vecDartFaces.reserve(map.getNbDarts()/4);
DartMarker mark(map); // marker for darts
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
CellMarkerStore markVert(map, VERTEX); //marker for vertices
VEC3 center(0, 0, 0);
unsigned int nbv = 0;
unsigned int nbf = 0;
std::list<Dart> 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<Dart>::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);
nbf++;
Dart dNext = *face ;
do
{
if (!markVert.isMarked(dNext))
{
markVert.mark(dNext);
center += positions[dNext];
nbv++;
}
mark.mark(dNext); // Mark
m_nbDarts++;
Dart adj = map.phi2(dNext); // Get adjacent face
if (adj != dNext && !mark.isMarked(adj))
visitedFaces.push_back(adj); // Add it
dNext = map.phi1(dNext);
} while(dNext != *face);
}
}
center /= typename PFP::REAL(nbv);
vecCenters.push_back(center);
vecNbFaces.push_back(nbf);
}
glLineWidth(1.0f);
glBegin(GL_LINES);
glColor3f(1.0f,1.0f,1.0f);
std::vector<Dart>::iterator face = vecDartFaces.begin();
for (unsigned int iVol=0; iVol<vecNbFaces.size(); ++iVol)
{
for (unsigned int iFace = 0; iFace < vecNbFaces[iVol]; ++iFace)
{
Dart d = *face++;
std::vector<VEC3> vecPos;
vecPos.reserve(16);
// store the face & center
VEC3 center(0, 0, 0);
Dart dd = d;
do
{
const VEC3& P = positions[d];
vecPos.push_back(P);
//m_attIndex[d] = posDBI;
center += P;
d = map.phi1(d);
} while (d != dd);
center /= REAL(vecPos.size());
//shrink the face