Commit 4e1f6ec2 authored by Thomas's avatar Thomas

mise a jour pour les g-cartes

parent 4f0b45f5
...@@ -109,8 +109,8 @@ int main(int argc, char **argv) ...@@ -109,8 +109,8 @@ int main(int argc, char **argv)
PFP::TVEC3 normal ; PFP::TVEC3 normal ;
AttributeHandler<Geom::Vec3f> color ; AttributeHandler<Geom::Vec3f> color ;
Dart d2 = myMap.newOrientedFace(3); Dart d2 = myMap.newFace(3);
Dart d3 = myMap.newOrientedFace(4); Dart d3 = myMap.newFace(4);
myMap.sewFaces(d2,d3); myMap.sewFaces(d2,d3);
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
...@@ -203,7 +203,7 @@ int main(int argc, char **argv) ...@@ -203,7 +203,7 @@ int main(int argc, char **argv)
PFP::TVEC3 position2 ; PFP::TVEC3 position2 ;
AttributeHandler<Geom::Vec3f> color2 ; AttributeHandler<Geom::Vec3f> color2 ;
Dart dx = myMap2.newOrientedFace(4); Dart dx = myMap2.newFace(4);
position2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "position"); position2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "position");
color2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "couleur"); color2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "couleur");
......
...@@ -323,6 +323,13 @@ public: ...@@ -323,6 +323,13 @@ public:
* @param fonct functor obj ref * @param fonct functor obj ref
*/ */
bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread=0); bool foreach_dart_of_cc(Dart d, FunctorType& fonct, unsigned int thread=0);
//!
/*! TODO Ajout a valider
* restreint aux complexes simpliciaux
* Apply a functor on the all darts in the set of the link from orbit
*/
bool foreach_dart_of_link(Dart d, unsigned int orbit, FunctorType& f, unsigned int thread=0);
//@} //@}
}; };
......
...@@ -115,6 +115,33 @@ public: ...@@ -115,6 +115,33 @@ public:
bool mergeVolumes(Dart d); bool mergeVolumes(Dart d);
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
* faces are build (faces with less than 3 edges). If it occurs the faces
* are deleted and the adjacencies are updated (see deleteIfDegenerated).
* \warning This may produce two distinct vertices if the edge
* was the only link between two border faces
* @param d a dart in the deleted edge
* @param delDegenerateFaces a boolean (default to true)
*/
virtual int collapseEdge(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);
//!
/*!
*
* @param
* @param
* @param
*/
virtual void collapseFace(Dart d, bool delDegenerateFaces = true, bool delDegenerateVolumes = true);
//!
/*!
*
*/
virtual Dart cutSpike(Dart d);
/*! @name Cell Functors /*! @name Cell Functors
* Apply functors to all darts of a cell * Apply functors to all darts of a cell
*************************************************************************/ *************************************************************************/
......
...@@ -93,6 +93,24 @@ inline Dart GMap3::beta(const Dart d) ...@@ -93,6 +93,24 @@ inline Dart GMap3::beta(const Dart d)
} }
} }
inline Dart GMap3::alpha2(Dart d)
{
Dart e = phi2(d);
Dart f = phi3(e);
if (f != e)
return f;
f = d;
e = phi3(f);
while (e != f)
{
f = phi2(e);
e = phi3(f);
}
return f;
}
inline Dart GMap3::phi3(Dart d) inline Dart GMap3::phi3(Dart d)
{ {
Dart e = beta3(d) ; Dart e = beta3(d) ;
...@@ -157,4 +175,6 @@ inline void GMap3::phi3unsew(Dart d) ...@@ -157,4 +175,6 @@ inline void GMap3::phi3unsew(Dart d)
} // end namespace CGoGN } // end namespace CGoGN
...@@ -597,4 +597,33 @@ bool GMap2::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread) ...@@ -597,4 +597,33 @@ bool GMap2::foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread)
return found; return found;
} }
bool GMap2::foreach_dart_of_link(Dart d, unsigned int orbit, FunctorType& f, unsigned int thread)
{
if(orbit == VERTEX)
{
Dart dNext = d;
do
{
if(GMap2::foreach_dart_of_edge(phi1(dNext),f,thread))
return true;
dNext = alpha1(dNext);
} while (dNext != d);
return false;
}
else if(orbit == FACE)
{
if(GMap2::foreach_dart_of_vertex(phi_1(d),f,thread))
return true;
if(GMap2::foreach_dart_of_vertex(phi_1(phi2(d)),f,thread))
return true;
return false;
}
return false;
}
} // namespace CGoGN } // namespace CGoGN
...@@ -110,7 +110,185 @@ bool GMap3::mergeVolumes(Dart d) ...@@ -110,7 +110,185 @@ bool GMap3::mergeVolumes(Dart d)
return false ; return false ;
} }
int GMap3::collapseEdge(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
Dart e = d;
int i = 0;
//stocke un brin par volume autour de l'arete
std::list<Dart> tmp;
do
{
tmp.push_back(e);
e = alpha2(e);
i++;
} while (e != d);
for (std::list<Dart>::iterator it = tmp.begin(); it != tmp.end(); ++it)
{
Dart e = phi2(*it);
cutSpike(e);
Dart t1=e,t2=e;
//si les faces opposées ont un tetraedre cousu
if(phi3(phi2(phi1(e))) != phi2(phi1(e))) {
t1 = phi3(phi2(phi1(e)));
unsewVolumes(t1);
}
if(phi3(phi2(phi_1(e))) != phi2(phi_1(e))) {
t2 = phi3(phi2(phi_1(e)));
unsewVolumes(t2);
}
if(t1 != e && t2 != e) {
sewVolumes(t1,t2);
}
//unsewVolumes(e);
//unsewVolumes(*it);
deleteOrientedVolume(*it);
}
return i;
}
//TODO
void GMap3::collapseFace(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
Dart e = d;
std::list<Dart> tmp;
//save a dart from the edge for all neighbors
do
{
//if(phi3(phi2(e)) != phi2(e))
// tmp.push_back(phi3(phi2(e)));
tmp.push_back(phi3(phi2(e)));
e = phi1(e);
}while(e != d);
//del the last one (n-1 edge collapse)
tmp.pop_back();
//CGoGNout << "#voisin=" << tmp.size() << CGoGNendl;
//collapse all the edges in the list
for(std::list<Dart>::iterator it = tmp.begin() ; it != tmp.end() ; ++it)
{
Dart d = *it;
//CGoGNout << "collapseEdge" << CGoGNendl;
//collapseEdge(*it, delDegenerateFaces, delDegenerateVolumes);
//stocke un brin par volume autour de l'arete
Dart e = d;
//stocke un brin par volume autour de l'arete
std::list<Dart> tmpedge;
do
{
tmpedge.push_back(e);
e = alpha2(e);
} while (e != d);
for (std::list<Dart>::iterator it = tmpedge.begin(); it != tmpedge.end(); ++it)
{
Dart e = phi2(*it);
cutSpike(e);
Dart t1=e,t2=e;
//si les faces opposées ont un tetraedre cousu
if(phi3(phi2(phi1(e))) != phi2(phi1(e))) {
t1 = phi3(phi2(phi1(e)));
unsewVolumes(t1);
}
if(phi3(phi2(phi_1(e))) != phi2(phi_1(e))) {
t2 = phi3(phi2(phi_1(e)));
unsewVolumes(t2);
}
if(t1 != e && t2 != e) {
sewVolumes(t1,t2);
}
//deleteOrientedVolume(*it);
}
}
// for(std::list<Dart>::iterator it = tmp.begin() ; it != tmp.end() ; ++it)
// {
// deleteOrientedVolume(*it);
// }
}
Dart GMap3::cutSpike(Dart d)
{
Dart e=d;
int nb=0;
Dart dNew;
int tet=0;
//CGoGNout << "cut" << CGoGNendl;
//count the valence of the vertex
do {
nb++;
e=phi1(phi2(e));
} while (e!=d);
if(nb<3)
{
CGoGNout << "Warning : cannot cut 2 volumes without creating a degenerated face " << CGoGNendl;
return d;
}
else
{
//triangulate around the vertex
do {
if(phi1(phi1(phi1(e)))!=e)
{
splitFace(phi_1(e),phi1(e));
//CGoGNout << "split" << CGoGNendl;
}
else
tet++;
e=phi1(phi2(e));
} while (e!=d);
// CGoGNout << "#tet= " << tet << CGoGNendl;
// CGoGNout << "#nb= " << nb << CGoGNendl;
//si toute ces faces ne sont pas triangulaires (on insere une face)
if(tet != nb) {
//CGoGNout << "new face" << CGoGNendl;
dNew=newFace(nb);
Dart d3 = newFace(nb);
sewVolumes(dNew,d3);
//sew a face following the triangles
Dart dTurn=dNew;
do {
Dart d1 = phi1(e);
Dart dSym = phi2(d1);
phi2unsew(d1);
phi2sew(dTurn,d1);
phi2sew(phi3(dTurn),dSym);
dTurn = phi1(dTurn);
e=phi1(phi2(e));
}while(e!=d);
}
else
dNew = d;
}
return dNew;
}
bool GMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread) bool GMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
......
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