Commit 68b357cf authored by Thomas's avatar Thomas
Browse files

amelioration topoRenderGMD2

parent 4beeb689
...@@ -61,7 +61,7 @@ void SimpleGMap2::cb_redraw() ...@@ -61,7 +61,7 @@ void SimpleGMap2::cb_redraw()
{ {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(1.0f); glLineWidth(1.0f);
Algo::Render::GL1::renderTopoGMD2<PFP>(myMap, position, true, true, 0.9f, 0.9f); Algo::Render::GL1::renderTopoGMD2<PFP>(myMap, position, false, true, 0.9f, 0.9f);
} }
......
...@@ -649,123 +649,64 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions ...@@ -649,123 +649,64 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions
AutoAttributeHandler<Geom::Vec3f> fv1(map, DART); AutoAttributeHandler<Geom::Vec3f> fv1(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv11(map, DART); AutoAttributeHandler<Geom::Vec3f> fv11(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv2(map, DART); AutoAttributeHandler<Geom::Vec3f> fv2(map, DART);
AutoAttributeHandler<Geom::Vec3f> fv2x(map, DART);
AutoAttributeHandler<Geom::Vec3f> vert(map, DART); AutoAttributeHandler<Geom::Vec3f> vert(map, DART);
int m_nbDarts = 0; glLineWidth(2.0f);
glColor3f(0.9f,0.9f,0.9f);
// 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); glBegin(GL_LINES);
glColor3f(1.0f,1.0f,1.0f);
std::vector<Dart>::iterator face = vecDartFaces.begin(); DartMarker mf(map);
for (unsigned int iVol=0; iVol<vecNbFaces.size(); ++iVol) for(Dart d = map.begin(); d!= map.end(); map.next(d))
{ {
for (unsigned int iFace = 0; iFace < vecNbFaces[iVol]; ++iFace) if (!mf.isMarked(d))
{ {
Dart d = *face++;
std::vector<VEC3> vecPos; std::vector<VEC3> vecPos;
vecPos.reserve(16); vecPos.reserve(16);
std::vector<VEC3> vecF1;
vecF1.reserve(16);
// store the face & center // store the face & center
VEC3 center(0, 0, 0); VEC3 center(0.0f,0.0f,0.0f);
Dart dd = d; Dart dd = d;
do do
{ {
const VEC3& P = positions[d]; const VEC3& P = positions[d];
vecPos.push_back(P); vecPos.push_back(positions[d]);
//m_attIndex[d] = posDBI;
center += P; center += P;
d = map.phi1(d); d = map.phi1(d);
} while (d != dd); }while (d!=dd);
center /= REAL(vecPos.size()); center /= REAL(vecPos.size());
//shrink the face //shrink the face
unsigned int nb = vecPos.size(); unsigned int nb = vecPos.size();
float okf = 1.0f - kf; float k = 1.0f - kf;
for (unsigned int i = 0; i < nb; ++i) for (unsigned int i=0; i<nb; ++i)
{ {
vecPos[i] = center*okf + vecPos[i]*kf; vecPos[i] = center*k + vecPos[i]*kf;
} }
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
// compute position of points to use for drawing topo k = 1.0f - ke;
float oke = 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]*oke; VEC3 P = vecPos[i]*ke + vecPos[i+1]*k;
VEC3 Q = vecPos[i+1]*ke + vecPos[i]*oke; VEC3 Q = vecPos[i+1]*ke + vecPos[i]*k;
vert[d] = P;
glVertex3fv(P.data()); glVertex3fv(P.data());
glVertex3fv(Q.data()); glVertex3fv(Q.data());
vert[d] = P;
fv1[d] = P*0.1f + Q*0.9f; VEC3 f = P*0.5f + Q*0.5f;
fv11[d] = P*0.9f + Q*0.1f; fv2[d] = f;
f = P*0.1f + Q*0.9f;
fv2[d] = P*0.52f + Q*0.48f; fv1[d] = f;
fv2x[d] = P*0.48f + Q*0.52f; f = P*0.9f + Q*0.1f;
fv11[d] = f;
d = map.phi1(d); d = map.phi1(d);
} }
mf.markOrbit(FACE, d);
} }
} }
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
Dart e = map.beta2(d); Dart e = map.beta2(d);
...@@ -779,7 +720,6 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions ...@@ -779,7 +720,6 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions
e = map.beta1(d); e = map.beta1(d);
if ((d<e) && drawBeta1) if ((d<e) && drawBeta1)
{ {
e = map.beta1(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());
...@@ -796,7 +736,6 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions ...@@ -796,7 +736,6 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions
glVertex3fv(vert[d].data()); glVertex3fv(vert[d].data());
} }
glEnd(); glEnd();
} }
template <typename PFP> template <typename PFP>
......
Supports Markdown
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