Commit 6a6f9b63 authored by untereiner's avatar untereiner

debut menage dans la maison 3-carte (emb+topo)

parent 61611d16
......@@ -25,9 +25,10 @@
#ifndef __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__
#include "Topology/map/map3.h"
#include "Topology/generic/embeddedMap3.h"
#include "Container/attributeContainer.h"
//#include "Topology/map/map3.h"
//#include "Topology/generic/embeddedMap3.h"
//#include "Container/attributeContainer.h"
#include "Topology/map/embeddedMap3.h"
namespace CGoGN
{
......@@ -40,7 +41,7 @@ namespace IHM
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3>
class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
template<typename T> friend class AttributeHandler_IHM ;
......
......@@ -350,71 +350,83 @@ bool EmbeddedMap3<MAP3>::check()
return false ;
CGoGNout << "Check: embedding begin" << CGoGNendl ;
DartMarker mv(*this);
for(Dart d = MAP3::begin(); d != MAP3::end(); MAP3::next(d))
{
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::isOrbitEmbedded(VERTEX))
{
if (MAP3::getEmbedding(FACE, d) != MAP3::getEmbedding(FACE, MAP3::phi1(d)))
if(!mv.isMarked(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 ;
mv.markOrbit(VERTEX, d);
unsigned int emb = MAP3::getEmbedding(VERTEX, d);
FunctorCheckEmbedding<MAP3> fce(*this, VERTEX, emb);
MAP3::foreach_dart_of_orbit(VERTEX, d, fce);
}
}
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 ;
}
}
// 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)))
// {
// 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 ;
return true ;
......
......@@ -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
/********************************************************/
......@@ -157,6 +176,7 @@ public:
}
};
// Multiple Functor: to apply several Functors in turn to a dart
/********************************************************/
......
......@@ -39,69 +39,55 @@ class EmbeddedMap3 : public Map3
public:
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,
bool delDegenerateVolumes = true);
virtual bool check();
//????????? fonction de 2-carte
virtual unsigned int closeHole(Dart d);
virtual void closeMap(DartMarker &marker);
virtual bool check();
} ;
} // namespace CGoGN
......
......@@ -305,18 +305,18 @@ public:
*/
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) ;
/**
* 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);
/**
* 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) ;
......@@ -373,20 +373,6 @@ public:
*/
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 @@
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)
{
//topological sewing
......@@ -63,7 +170,10 @@ void EmbeddedMap3::sewVolumes(Dart d, Dart e)
//embed the face orbit from the volume sewn
if (isOrbitEmbedded(FACE))
copyDartEmbedding(FACE, e, d) ;
{
unsigned int vEmb1 = getEmbedding(FACE, d);
embedOrbit(FACE, e, vEmb1) ;
}
}
void EmbeddedMap3::unsewVolumes(Dart d)
......@@ -126,155 +236,66 @@ bool EmbeddedMap3::mergeVolumes(Dart d)
return false;
}
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);
}
}
}
void EmbeddedMap3::cutEdge(Dart d)
bool EmbeddedMap3::check()
{
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) ;
}
bool topo = Map3::check() ;
if (!topo)
return false ;
if(isOrbitEmbedded(FACE))
std::cout << "Check: embedding begin" << std::endl ;
DartMarker mv(*this);
for(Dart d = begin(); d != end(); next(d))
{
Dart f = d;
do
if(isOrbitEmbedded(VERTEX))
{
Dart nd = phi1(f) ;
copyDartEmbedding(FACE, nd, f);
Dart f2 = phi2(nd);
if(f2!=nd)
if(!mv.isMarked(d))
{
Dart nd2 = phi2(f);
copyDartEmbedding(FACE, nd2, f2);
mv.markOrbit(VERTEX, d);
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);
} 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);
// if (phi2(phi_1(d)) != phi_1(d) && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi2(phi_1(d))))
// {
// std::cout << "Check: different embeddings on vertex" << std::endl ;
// return false ;
// }
//
// if(phi3(d) != d && getEmbedding(VERTEX, d) != getEmbedding(VERTEX, phi1(phi3(d))))
// {
// std::cout << "Check: different embeddings on vertex in the 2 oriented faces" << std::endl ;
// std::cout << "Dart #" << d << std::endl;
// std::cout << "Emb(d) = " << getEmbedding(VERTEX, d) << std::endl;
// std::cout << "Emb(phi32(d)) = " << getEmbedding(VERTEX, phi3(phi2(d))) << std::endl;
// return false ;
// }
f = alpha2(f);
} while(f != d);
}
}
int EmbeddedMap3::collapseEdge(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
unsigned int vEmb = EMBNULL ;
if(isOrbitEmbedded(VERTEX))
{
vEmb = getEmbedding(VERTEX, d) ;
embedOrbit(VERTEX,d,vEmb);
embedOrbit(VERTEX,phi2(d),vEmb);
// if (isOrbitEmbedded(EDGE))
// {
// if (getEmbedding(EDGE, d) != getEmbedding(EDGE, phi2(d)))
// {
// std::cout << "Check: different embeddings on edge" << std::endl ;
// return false ;
// }
// }
//
// if (isOrbitEmbedded(FACE))
// {
// if (getEmbedding(FACE, d) != getEmbedding(FACE, phi1(d)))
// {
// std::cout << "Check: different embeddings on face" << std::endl ;
// return false ;
// }
// }
}
int nbCol = Map3::collapseEdge(d,delDegenerateFaces,delDegenerateVolumes);
return nbCol;
}
void EmbeddedMap3::collapseFace(Dart d, bool delDegenerateFaces,
bool delDegenerateVolumes)
{
//unsigned int degree = faceDegree(d);
//Dart dsave;
// //si degree face = 3
// if(degree == 3)
// {
// dsave = phi3(phi2(phi1(d)));
// dsave = phi3(phi2(phi1(dsave)));
// //ATTENTION : il faut trouver un brin de l'orbite sommet de d non modifie par l'operation !!
// }
// else if(degree > 3)
// {
// dsave = phi1(phi2(phi1(d)));