Commit c97d7f8d authored by Thomas's avatar Thomas

Merge branch 'master' of cgogn.u-strasbg.fr:~untereiner/CGoGN

parents edfc3ed4 6a6f9b63
...@@ -25,9 +25,10 @@ ...@@ -25,9 +25,10 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP3__ #ifndef __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__ #define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/map3.h" //#include "Topology/map/map3.h"
#include "Topology/generic/embeddedMap3.h" //#include "Topology/generic/embeddedMap3.h"
#include "Container/attributeContainer.h" //#include "Container/attributeContainer.h"
#include "Topology/map/embeddedMap3.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -40,7 +41,7 @@ namespace IHM ...@@ -40,7 +41,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ; template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3> class ImplicitHierarchicalMap3 : public EmbeddedMap3
{ {
template<typename T> friend class AttributeHandler_IHM ; template<typename T> friend class AttributeHandler_IHM ;
......
...@@ -350,71 +350,83 @@ bool EmbeddedMap3<MAP3>::check() ...@@ -350,71 +350,83 @@ bool EmbeddedMap3<MAP3>::check()
return false ; return false ;
CGoGNout << "Check: embedding begin" << CGoGNendl ; CGoGNout << "Check: embedding begin" << CGoGNendl ;
DartMarker mv(*this);
for(Dart d = MAP3::begin(); d != MAP3::end(); MAP3::next(d)) for(Dart d = MAP3::begin(); d != MAP3::end(); MAP3::next(d))
{ {
if (MAP3::isOrbitEmbedded(VERTEX)) if(MAP3::isOrbitEmbedded(VERTEX))
{
if (MAP3::phi2(MAP3::phi_1(d)) != MAP3::phi_1(d) && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d))))
{
CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ;
return false ;
}
if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi1(MAP3::phi3(d))))
{
CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
CGoGNout << "Dart #" << d << CGoGNendl;
CGoGNout << "Emb(d) = " << MAP3::getEmbedding(VERTEX, d) << CGoGNendl;
CGoGNout << "Emb(phi32(d)) = " << MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))) << CGoGNendl;
return false ;
}
}
if (MAP3::isOrbitEmbedded(EDGE))
{
if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi2(d)))
{
CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
return false ;
}
if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi3(d)))
{
CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
return false ;
}
}
if (MAP3::isOrbitEmbedded(FACE))
{ {
if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi1(d))) if(!mv.isMarked(d))
{ {
CGoGNout << "Check: different embeddings on face" << CGoGNendl ; mv.markOrbit(VERTEX, d);
return false ; unsigned int emb = MAP3::getEmbedding(VERTEX, d);
} FunctorCheckEmbedding<MAP3> fce(*this, VERTEX, emb);
MAP3::foreach_dart_of_orbit(VERTEX, d, fce);
if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi3(d)))
{
CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
return false ;
} }
} }
if (MAP3::isOrbitEmbedded(VOLUME)) // if (MAP3::isOrbitEmbedded(VERTEX))
{ // {
if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi1(d))) // if (MAP3::phi2(MAP3::phi_1(d)) != MAP3::phi_1(d) && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d))))
{ // {
CGoGNout << "Check: different embeddings in volume" << CGoGNendl ; // CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ;
return false ; // return false ;
} // }
//
if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi2(d))) // if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi1(MAP3::phi3(d))))
{ // {
CGoGNout << "Check: different embeddings in volume" << CGoGNendl ; // CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
return false ; // CGoGNout << "Dart #" << d << CGoGNendl;
} // CGoGNout << "Emb(d) = " << MAP3::getEmbedding(VERTEX, d) << CGoGNendl;
} // CGoGNout << "Emb(phi32(d)) = " << MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))) << CGoGNendl;
// return false ;
// }
//
// }
//
// if (MAP3::isOrbitEmbedded(EDGE))
// {
// if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi2(d)))
// {
// CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
// return false ;
// }
//
// if (MAP3::getEmbedding(EDGE, d) != MAP3::getEmbedding(EDGE, MAP3::phi3(d)))
// {
// CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
// return false ;
// }
// }
//
// if (MAP3::isOrbitEmbedded(FACE))
// {
// if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi1(d)))
// {
// CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
// return false ;
// }
//
// if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi3(d)))
// {
// CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
// return false ;
// }
// }
//
// if (MAP3::isOrbitEmbedded(VOLUME))
// {
// if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi1(d)))
// {
// CGoGNout << "Check: different embeddings in volume" << CGoGNendl ;
// return false ;
// }
//
// if (MAP3::getEmbedding(VOLUME, d) != MAP3::getEmbedding(VOLUME, MAP3::phi2(d)))
// {
// CGoGNout << "Check: different embeddings in volume" << CGoGNendl ;
// return false ;
// }
// }
} }
CGoGNout << "Check: embedding ok" << CGoGNendl ; CGoGNout << "Check: embedding ok" << CGoGNendl ;
return true ; return true ;
......
...@@ -113,6 +113,25 @@ public: ...@@ -113,6 +113,25 @@ public:
} }
}; };
// Functor Check Embedding : to check the embeddings of the given map
template <typename MAP>
class FunctorCheckEmbedding : public FunctorMap<MAP>
{
protected:
unsigned int orbit;
unsigned int emb;
public:
FunctorCheckEmbedding(MAP& map, unsigned int orb, unsigned int e) : FunctorMap<MAP>(map), orbit(orb), emb(e)
{}
bool operator()(Dart d)
{
return (this->m_map.getEmbedding(orbit, d) != emb);
}
};
// Search Functor: look for a given dart when applied // Search Functor: look for a given dart when applied
/********************************************************/ /********************************************************/
...@@ -157,6 +176,7 @@ public: ...@@ -157,6 +176,7 @@ public:
} }
}; };
// Multiple Functor: to apply several Functors in turn to a dart // Multiple Functor: to apply several Functors in turn to a dart
/********************************************************/ /********************************************************/
......
...@@ -39,69 +39,55 @@ class EmbeddedMap3 : public Map3 ...@@ -39,69 +39,55 @@ class EmbeddedMap3 : public Map3
public: public:
typedef Map3 TOPO_MAP; typedef Map3 TOPO_MAP;
//!
/*! /*!
* *
*/ */
virtual void sewVolumes(Dart d, Dart e); virtual bool deleteVertex(Dart d);
/*! No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
* @param d a dart
*/
virtual void cutEdge(Dart d);
/*! The attributes attached to the edge of d are kept on the resulting edge
* @param d a dart of the edge to cut
*/
virtual void uncutEdge(Dart d);
//!
/*! /*!
* *
*/ */
virtual void unsewVolumes(Dart d); virtual void splitFace(Dart d, Dart e);
//!
/*! /*!
* *
*/ */
virtual bool mergeVolumes(Dart d); virtual Dart cutSpike(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); virtual void sewVolumes(Dart d, Dart e);
//! Cut the edge of d /*!
/*! @param d a dart of the edge to cut *
*/ */
virtual void cutEdge(Dart d); virtual void unsewVolumes(Dart d);
//!
/*! /*!
* *
*/ */
virtual Dart cutSpike(Dart d); virtual 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);
//!
/*! /*!
* *
*/ */
virtual void collapseFace(Dart d, bool delDegenerateFaces = true, virtual bool check();
bool delDegenerateVolumes = true);
//????????? fonction de 2-carte
virtual unsigned int closeHole(Dart d); virtual unsigned int closeHole(Dart d);
virtual void closeMap(DartMarker &marker);
virtual bool check();
} ; } ;
} // namespace CGoGN } // namespace CGoGN
......
...@@ -305,18 +305,18 @@ public: ...@@ -305,18 +305,18 @@ public:
*/ */
bool sameVertex(Dart d, Dart e) ; bool sameVertex(Dart d, Dart e) ;
/** //! Compute the number of edges of the vertex of d
* compute the number of edges of the vertex of d /*! @param d a dart
*/ */
unsigned int vertexDegree(Dart d) ; unsigned int vertexDegree(Dart d) ;
/** //! Compute the number of faces in the volume of d
* compute the number of faces in the volume of d /*! @param d a dart
*/ */
unsigned int volumeDegree(Dart d); unsigned int volumeDegree(Dart d);
/** //! Tell if the vertex of d is on the boundary of the map
* tell if the vertex of d is on the boundary of the map /*! @param d a dart
*/ */
bool isBoundaryVertex(Dart d) ; bool isBoundaryVertex(Dart d) ;
...@@ -373,20 +373,6 @@ public: ...@@ -373,20 +373,6 @@ public:
*/ */
bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread=0); bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread=0);
//!
/*! TODO Ajout a valider
* restreint aux complexes simpliciaux
* Apply a functor on the all darts in the set of the star from orbit
*/
bool foreach_dart_of_star(Dart d, unsigned int orbit, FunctorType& f, 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);
//@} //@}
}; };
......
This diff is collapsed.
...@@ -30,6 +30,113 @@ ...@@ -30,6 +30,113 @@
namespace CGoGN namespace CGoGN
{ {
bool EmbeddedMap3::deleteVertex(Dart d)
{
return Map3::deleteVertex(d);
}
void EmbeddedMap3::cutEdge(Dart d)
{
Map3::cutEdge(d);
if(isOrbitEmbedded(EDGE))
{
Dart nd = phi1(d) ;
embedNewCell(EDGE, nd) ;
copyCell(EDGE, nd, d) ;
unsigned int vEmb = getEmbedding(EDGE, d);
embedOrbit(EDGE, d, vEmb) ;
}
if(isOrbitEmbedded(FACE))
{
Dart f = d;
do
{
Dart nd = phi1(f) ;
copyDartEmbedding(FACE, nd, f);
Dart f2 = phi2(nd);
if(f2!=nd)
{
Dart nd2 = phi2(f);
copyDartEmbedding(FACE, nd2, f2);
}
f = alpha2(f);
} while(f != d);
}
if(isOrbitEmbedded(VOLUME))
{
Dart f = d;
do
{
Dart nd = phi1(f) ;
copyDartEmbedding(VOLUME, nd, f);
Dart nd2 = phi2(f);
if(f!=nd2)
copyDartEmbedding(VOLUME, nd2, f);
f = alpha2(f);
} while(f != d);
}
}
void EmbeddedMap3::uncutEdge(Dart d)
{
Map3::uncutEdge(d);
}
void EmbeddedMap3::splitFace(Dart d, Dart e)
{
Map3::splitFace(d,e);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, phi2(phi_1(d)), d);
copyDartEmbedding(VERTEX, phi2(phi_1(e)), e);
if(phi3(d) != d)
{
Dart d3 = phi3(d);
Dart e3 = phi3(e);
copyDartEmbedding(VERTEX, phi1(d3), phi1(phi2(phi1(d3))));
copyDartEmbedding(VERTEX, phi1(e3), phi1(phi2(phi1(e3))));
}
}
if(isOrbitEmbedded(FACE))
{
embedNewCell(FACE, phi2(phi_1(d)));
copyCell(FACE, phi2(phi_1(d)), d);
}
if(isOrbitEmbedded(VOLUME))
{
copyDartEmbedding(VOLUME, phi_1(d), d);
copyDartEmbedding(VOLUME, phi2(phi_1(d)), d);
if(phi3(d) != d)
{
Dart d3 = phi3(d);
copyDartEmbedding(VOLUME, phi1(d3), d3);
copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3);
}
}
}
Dart EmbeddedMap3::cutSpike(Dart d)
{
Dart e = Map3::cutSpike(d);
return e;
}
void EmbeddedMap3::sewVolumes(Dart d, Dart e) void EmbeddedMap3::sewVolumes(Dart d, Dart e)
{ {
//topological sewing //topological sewing
...@@ -63,7 +170,10 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e) ...@@ -63,7 +170,10 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e)
//embed the face orbit from the volume sewn //embed the face orbit from the volume sewn
if (isOrbitEmbedded(FACE)) if (isOrbitEmbedded(FACE))
copyDartEmbedding(FACE, e, d) ; {
unsigned int vEmb1 = getEmbedding(FACE, d);
embedOrbit(FACE, e, vEmb1) ;
}
} }
void EmbeddedMap3::unsewVolumes(Dart d) void EmbeddedMap3::unsewVolumes(Dart d)
...@@ -126,155 +236,66 @@ bool EmbeddedMap3::mergeVolumes(Dart d) ...@@ -126,155 +236,66 @@ bool EmbeddedMap3::mergeVolumes(Dart d)
return false; return false;
} }
void EmbeddedMap3::splitFace(Dart d, Dart e) bool EmbeddedMap3::check()
{
Map3::splitFace(d,e);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, phi2(phi_1(d)), d);
copyDartEmbedding(VERTEX, phi2(phi_1(e)), e);
if(phi3(d) != d)
{
Dart d3 = phi3(d);
Dart e3 = phi3(e);
copyDartEmbedding(VERTEX, phi1(d3), phi1(phi2(phi1(d3))));
copyDartEmbedding(VERTEX, phi1(e3), phi1(phi2(phi1(e3))));
}
}
if(isOrbitEmbedded(FACE))
{
embedNewCell(FACE, phi2(phi_1(d)));
copyCell(FACE, phi2(phi_1(d)), d);
}
if(isOrbitEmbedded(VOLUME))
{
copyDartEmbedding(VOLUME, phi_1(d), d);
copyDartEmbedding(VOLUME, phi2(phi_1(d)), d);
if(phi3(d) != d)
{
Dart d3 = phi3(d);
copyDartEmbedding(VOLUME, phi1(d3), d3);
copyDartEmbedding(VOLUME, phi2(phi1(d3)), d3);
}
}
}
void EmbeddedMap3::cutEdge(Dart d)
{ {
Map3::cutEdge(d); bool topo = Map3::check() ;
if (!topo)
if(isOrbitEmbedded(EDGE)) return false ;
{
Dart nd = phi1(d) ;
embedNewCell(EDGE, nd) ;
copyCell(EDGE, nd, d) ;
unsigned int vEmb = getEmbedding(EDGE, d);
embedOrbit(EDGE, d, vEmb) ;
}
if(isOrbitEmbedded(FACE)) std::cout << "Check: embedding begin" << std::endl ;
DartMarker mv(*this);
for(Dart d = begin(); d != end(); next(d))
{ {
Dart f = d; if(isOrbitEmbedded(VERTEX))
do
{ {
Dart nd = phi1(f) ; if(!mv.isMarked(d))
copyDartEmbedding(FACE, nd, f);
Dart f2 = phi2(nd);
if(f2!=nd)
{ {
Dart nd2 = phi2(f); mv.markOrbit(VERTEX, d);
copyDartEmbedding(FACE, nd2, f2); unsigned int emb = getEmbedding(VERTEX, d);
FunctorCheckEmbedding<Map3> fce(*this, VERTEX, emb);
if(foreach_dart_of_orbit(VERTEX, d, fce))
{
std::cout << "Embedding Check : different embeddings on vertex" << std::endl;
}
} }
}
f = alpha2(f); // if (phi2(phi_1(d)) != phi_1(d) && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi2(phi_1(d))))
} while(f != d); // {
} // std::cout << "Check: different embeddings on vertex" << std::endl ;
// return false ;
if(isOrbitEmbedded(VOLUME)) // }
{ //
Dart f = d; // if(phi3(d) != d && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi1(phi3(d))))