Commit 9791072a authored by Thomas's avatar Thomas

3-carte : rendu topo GL1 ok, closeHole corrige, ajout splitFace

parent 5a707d34
......@@ -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 <typename PFP>
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 <typename PFP>
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
......
......@@ -661,7 +661,7 @@ void renderTopoGMD2(typename PFP::MAP& map, const typename PFP::TVEC3& positions
if (!mf.isMarked(d))
{
std::vector<VEC3> 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 <typename PFP>
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<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> posBeta1(map, DART);
AutoAttributeHandler<Geom::Vec3f> posBeta2(map, DART); //beta 3 link is represented at the same location as beta2
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);
vecDartFaces.reserve(map.getNbDarts()/6); //6 = nb of darts for tri mesh
// table of degree of faces
std::vector<unsigned int> vecNbFaces;
vecNbFaces.reserve(vecDartFaces.size());
// table of center of volume (to explode volumes)
std::vector<VEC3> 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<Dart> 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<Dart>::iterator face = vecDartFaces.begin();
//for each volume
for (unsigned int iVol=0; iVol<vecNbFaces.size(); ++iVol)
{
//for each face
for (unsigned int iFace = 0; iFace < vecNbFaces[iVol]; ++iFace)
{
Dart d = *face++;
......@@ -833,16 +837,15 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
vecPos.reserve(16);
// store the face & center
VEC3 center(0, 0, 0);
VEC3 center(0);
Dart dd = d;
do
{
const VEC3& P = positions[d];
const VEC3& P = positions[dd];
vecPos.push_back(P);
//m_attIndex[d] = posDBI;
center += P;
d = map.phi1(d);
} while (d != dd);
dd = map.phi1(dd);
} while (dd != d);
center /= REAL(vecPos.size());
//shrink the face
......@@ -851,7 +854,7 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
float okv = 1.0f - kv;
for (unsigned int i = 0; i < nb; ++i)
{
vecPos[i] = vecCenters[iVol]*okv + vecPos[i]*kv;
vecPos[i] = vecVolCenters[iVol]*okv + vecPos[i]*kv;
vecPos[i] = center*okf + vecPos[i]*kf;
}
vecPos.push_back(vecPos.front()); // copy the first for easy computation on next loop
......@@ -863,16 +866,30 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
VEC3 P = vecPos[i]*ke + vecPos[i+1]*oke;
VEC3 Q = vecPos[i+1]*ke + vecPos[i]*oke;
VEC3 P_mid = P+(Q-P)*kd*0.5f;
VEC3 Q_mid = Q+(P-Q)*kd*0.5f;
vert[d] = P;
glVertex3fv(P.data());
glVertex3fv(P_mid.data());
if(drawBeta0)
{
glColor3f(0.0f,0.0f,1.0f);
glVertex3fv(P_mid.data());
glVertex3fv(Q_mid.data());
glColor3f(1.0f,1.0f,1.0f);
}
glVertex3fv(Q.data());
glVertex3fv(Q_mid.data());
fv1[d] = P*0.1f + Q*0.9f;
fv11[d] = P*0.9f + Q*0.1f;
posBeta1[d] = P*0.9f + P_mid*0.1f;
posBeta1[map.beta0(d)] = Q*0.9f + Q_mid*0.1f;
fv2[d] = P*0.52f + Q*0.48f;
fv2x[d] = P*0.48f + Q*0.52f;
posBeta2[d] = P*0.5f + P_mid*0.5f;
posBeta2[map.beta0(d)] = Q*0.5f + Q_mid*0.5f;
d = map.phi1(d);
}
......@@ -881,22 +898,23 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
}
//draw beta1, beta2, beta3 if required
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
Dart e = map.beta2(d);
if ((d<e) && drawBeta2)
{
glColor3f(1.0,0.0,0.0);
glVertex3fv(fv2[d].data());
glVertex3fv(fv2[e].data());
glVertex3fv(posBeta2[d].data());
glVertex3fv(posBeta2[e].data());
}
e = map.beta3(d);
if ((d<e) && drawBeta3)
{
glColor3f(1.0,1.0,0.0);
glVertex3fv(fv2[d].data());
glVertex3fv(fv2[e].data());
glVertex3fv(posBeta2[d].data());
glVertex3fv(posBeta2[e].data());
}
e = map.beta1(d);
......@@ -904,15 +922,16 @@ void renderTopoGMD3(typename PFP::MAP& map, const typename PFP::TVEC3& positions
{
e = map.beta1(d);
glColor3f(0.0f,1.0f,1.0f);
glVertex3fv(fv1[d].data());
glVertex3fv(fv11[e].data());
glVertex3fv(posBeta1[d].data());
glVertex3fv(posBeta1[e].data());
}
}
glEnd(); // LINES
//draw points of the map
glPointSize(5.0f);
glColor3f(0.0f,0.0f,0.0f);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_POINTS);
for(Dart d = map.begin(); d!= map.end(); map.next(d))
{
......
......@@ -114,6 +114,14 @@ public:
*/
bool mergeVolumes(Dart d);
//! Split a face inserting an edge between two vertices
/*! \pre Dart d and e should belong to the same face and be distinct
* @param d dart of first vertex
* @param e dart of second vertex
* @return the dart of the new edge lying in the vertex of d after the cut
*/
virtual void splitFace(Dart d, Dart e);
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
......
......@@ -333,10 +333,9 @@ bool GMap2::mergeVolumes(Dart d, Dart e)
return true ;
}
// TODO check this function
unsigned int GMap2::closeHole(Dart d)
{
assert(phi2(d) == d); // Nothing to close
assert(beta2(d) == d); // Nothing to close
Dart first = GMap1::newEdge(); // First edge of the face that will fill the hole
unsigned int countEdges = 1;
......@@ -355,7 +354,7 @@ unsigned int GMap2::closeHole(Dart d)
if (dPhi1 != d)
{
Dart next = newDart(); // Add a new edge there and link it to the face
Dart next = GMap1::newEdge(); // Add a new edge there and link it to the face
++countEdges;
phi1sew(first, next); // the edge is linked to the face
phi2sew(dNext, next); // the face is linked to the hole
......
......@@ -110,6 +110,22 @@ bool GMap3::mergeVolumes(Dart d)
return false ;
}
void GMap3::splitFace(Dart d, Dart e)
{
GMap2::splitFace(d,e);
if (phi3(d) != d)
{
Dart dd = phi1(phi3(d));
Dart ee = phi1(phi3(e));
GMap2::splitFace(dd,ee);
phi3sew(phi_1(d), phi_1(ee));
phi3sew(phi_1(e), phi_1(dd));
}
}
int GMap3::collapseEdge(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
......
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