From 9791072ab476809f5ef5b099cd21a9fa040f0637 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 4 Oct 2011 17:59:15 +0200 Subject: [PATCH] 3-carte : rendu topo GL1 ok, closeHole corrige, ajout splitFace --- include/Algo/Render/GL1/topo_render.h | 4 +- include/Algo/Render/GL1/topo_render.hpp | 117 ++++++++++++++---------- include/Topology/gmap/gmap3.h | 8 ++ src/Topology/gmap/gmap2.cpp | 5 +- src/Topology/gmap/gmap3.cpp | 16 ++++ 5 files changed, 96 insertions(+), 54 deletions(-) diff --git a/include/Algo/Render/GL1/topo_render.h b/include/Algo/Render/GL1/topo_render.h index 796255d1..562667e1 100644 --- a/include/Algo/Render/GL1/topo_render.h +++ b/include/Algo/Render/GL1/topo_render.h @@ -94,7 +94,7 @@ void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool * @param kf exploding coefficient for face (1.0 normal draw) */ template -void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta1, bool drawBeta2, float ke, float kf); +void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float ke, float kf); /** * Render darts of g-map @@ -108,7 +108,7 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions * @param kv exploding coefficient for volumes (1.0 normal draw) */ template -void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta1, bool drawBeta2, bool drawBeta3, float ke, float kf, float kv); +void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv); } // namespace GL1 diff --git a/include/Algo/Render/GL1/topo_render.hpp b/include/Algo/Render/GL1/topo_render.hpp index ef3dfe2f..f460e566 100644 --- a/include/Algo/Render/GL1/topo_render.hpp +++ b/include/Algo/Render/GL1/topo_render.hpp @@ -661,7 +661,7 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions if (!mf.isMarked(d)) { std::vector vecPos; - vecPos.reserve(16); + vecPos.reserve(32); // store the face & center VEC3 center(0); @@ -705,16 +705,12 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions glVertex3fv(Q_mid.data()); vert[d] = P; - VEC3 f = P*0.5f + P_mid*0.5f; - posBeta2[d] = f; + posBeta2[d] = P*0.5f + P_mid*0.5f; - f = Q*0.5f + Q_mid*0.5f; - posBeta2[map.beta0(d)] = f; + posBeta2[map.beta0(d)] = Q*0.5f + Q_mid*0.5f; - f = P*0.9f + P_mid*0.1f; - posBeta1[d] = f; - f = Q*0.9f + Q_mid*0.1f; - posBeta1[map.beta0(d)] = f; + posBeta1[d] = P*0.9f + P_mid*0.1f; + posBeta1[map.beta0(d)] = Q*0.9f + Q_mid*0.1f; d = map.phi1(d); } mf.markOrbit(FACE, d); @@ -754,35 +750,37 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions } template -void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta1, bool drawBeta2, bool drawBeta3, float ke, float kf, float kv) +void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv) { typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; - AutoAttributeHandler fv1(map, DART); - AutoAttributeHandler fv11(map, DART); - AutoAttributeHandler fv2(map, DART); - AutoAttributeHandler fv2x(map, DART); + AutoAttributeHandler posBeta1(map, DART); + AutoAttributeHandler posBeta2(map, DART); //beta 3 link is represented at the same location as beta2 AutoAttributeHandler vert(map, DART); - int m_nbDarts = 0; - - // table of center of volume - std::vector vecCenters; - vecCenters.reserve(1000); - // table of nbfaces per volume - std::vector vecNbFaces; - vecNbFaces.reserve(1000); // table of face (one dart of each) std::vector vecDartFaces; - vecDartFaces.reserve(map.getNbDarts()/4); + vecDartFaces.reserve(map.getNbDarts()/6); //6 = nb of darts for tri mesh + + // table of degree of faces + std::vector vecNbFaces; + vecNbFaces.reserve(vecDartFaces.size()); + + // table of center of volume (to explode volumes) + std::vector vecVolCenters; + vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh DartMarker mark(map); // marker for darts + CellMarker mVol(map, VOLUME); for (Dart d = map.begin(); d != map.end(); map.next(d)) { + if(!mVol.isMarked(d)) + { + mVol.mark(d); CellMarkerStore markVert(map, VERTEX); //marker for vertices - VEC3 center(0, 0, 0); - unsigned int nbv = 0; + VEC3 center(0); + unsigned int nbVertices = 0; unsigned int nbf = 0; std::list visitedFaces; // Faces that are traversed visitedFaces.push_back(d); // Start with the face of d @@ -798,24 +796,28 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions Dart dNext = *face ; do { + mark.mark(dNext); // Mark +// mark.mark(map.beta0(dNext)); + if (!markVert.isMarked(dNext)) { markVert.mark(dNext); center += positions[dNext]; - nbv++; + nbVertices++; } - mark.mark(dNext); // Mark - m_nbDarts++; - Dart adj = map.phi2(dNext); // Get adjacent face + + Dart adj = map.phi2(dNext); // add adjacent face if not done already if (adj != dNext && !mark.isMarked(adj)) - visitedFaces.push_back(adj); // Add it + visitedFaces.push_back(adj); + dNext = map.phi1(dNext); } while(dNext != *face); } } - center /= typename PFP::REAL(nbv); - vecCenters.push_back(center); + center /= typename PFP::REAL(nbVertices); + vecVolCenters.push_back(center); vecNbFaces.push_back(nbf); + } } glLineWidth(1.0f); @@ -823,8 +825,10 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions glColor3f(1.0f,1.0f,1.0f); std::vector::iterator face = vecDartFaces.begin(); + //for each volume for (unsigned int iVol=0; iVol