Commit 5e70a78b authored by untereiner's avatar untereiner
Browse files

Map3 no_boundary : la suite

parent 766d3300
...@@ -30,10 +30,8 @@ ...@@ -30,10 +30,8 @@
namespace CGoGN namespace CGoGN
{ {
/** /*! Class of 3-dimensional maps with managed embeddings
* Class of 3-dimensional maps */
* with managed embeddings
*/
class EmbeddedMap3 : public Map3 class EmbeddedMap3 : public Map3
{ {
public: public:
...@@ -81,13 +79,15 @@ public: ...@@ -81,13 +79,15 @@ public:
*/ */
virtual void splitVolume(std::vector<Dart>& vd); virtual void splitVolume(std::vector<Dart>& vd);
/**
* No attribute is attached to the new volume
*/
virtual unsigned int closeHole(Dart d, bool forboundary = true);
/*! /*!
* *
*/ */
virtual bool check(); virtual bool check();
//????????? fonction de 2-carte
virtual unsigned int closeHole(Dart d);
} ; } ;
} // namespace CGoGN } // namespace CGoGN
......
...@@ -377,13 +377,13 @@ public: ...@@ -377,13 +377,13 @@ public:
*/ */
bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a edge //! Apply a functor on every dart of an edge
/*! @param d a dart of the edge /*! @param d a dart of the edge
* @param f the functor to apply * @param f the functor to apply
*/ */
bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a volume //! Apply a functor on every dart of an oriented volume
/*! @param d a dart of the volume /*! @param d a dart of the volume
* @param f the functor to apply * @param f the functor to apply
*/ */
...@@ -393,7 +393,6 @@ public: ...@@ -393,7 +393,6 @@ public:
/*! @param d a dart of the volume /*! @param d a dart of the volume
* @param f the functor to apply * @param f the functor to apply
*/ */
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a connected component //! Apply a functor on every dart of a connected component
......
...@@ -135,6 +135,11 @@ inline bool Map2::sameEdge(Dart d, Dart e) ...@@ -135,6 +135,11 @@ inline bool Map2::sameEdge(Dart d, Dart e)
return d == e || phi2(d) == e ; return d == e || phi2(d) == e ;
} }
inline bool Map2::isBoundaryEdge(Dart d)
{
return isBoundaryMarked(d) || isBoundaryMarked(phi2(d));
}
inline bool Map2::sameOrientedFace(Dart d, Dart e) inline bool Map2::sameOrientedFace(Dart d, Dart e)
{ {
return Map1::sameCycle(d, e) ; return Map1::sameCycle(d, e) ;
......
...@@ -123,7 +123,6 @@ public: ...@@ -123,7 +123,6 @@ public:
*************************************************************************/ *************************************************************************/
//@{ //@{
//TODO deleteVertex : works only for boundary vertices
//! Delete the vertex of d //! Delete the vertex of d
/*! All the faces around the vertex are merged into one face /*! All the faces around the vertex are merged into one face
* @param d a dart of the vertex to delete * @param d a dart of the vertex to delete
...@@ -171,7 +170,6 @@ public: ...@@ -171,7 +170,6 @@ public:
/*! @param vd a vector of darts /*! @param vd a vector of darts
*/ */
virtual void splitVolume(std::vector<Dart>& vd); virtual void splitVolume(std::vector<Dart>& vd);
//@} //@}
/*! @name Topological Queries /*! @name Topological Queries
...@@ -179,12 +177,6 @@ public: ...@@ -179,12 +177,6 @@ public:
*************************************************************************/ *************************************************************************/
//@{ //@{
//! Test if dart d and e belong to the same oriented vertex
/*! @param d a dart
* @param e a dart
*/
bool sameOrientedVertex(Dart d, Dart e) ;
//! Test if dart d and e belong to the same vertex //! Test if dart d and e belong to the same vertex
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -223,6 +215,12 @@ public: ...@@ -223,6 +215,12 @@ public:
*/ */
bool isBoundaryEdge(Dart d) ; bool isBoundaryEdge(Dart d) ;
/**
* find the dart of edge that belong to the boundary
* return NIL if the edge is not on the boundary
*/
Dart findBoundaryFaceOfEdge(Dart d);
//! Test if dart d and e belong to the same oriented face //! Test if dart d and e belong to the same oriented face
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
...@@ -248,12 +246,6 @@ public: ...@@ -248,12 +246,6 @@ public:
*************************************************************************/ *************************************************************************/
//@{ //@{
//! Apply a functor on each dart of a vertex
/*! @param d a dart of the vertex
* @param fonct the functor
*/
bool foreach_dart_of_oriented_vertex(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on each dart of a vertex //! Apply a functor on each dart of a vertex
/*! @param d a dart of the vertex /*! @param d a dart of the vertex
* @param fonct the functor * @param fonct the functor
...@@ -266,24 +258,12 @@ public: ...@@ -266,24 +258,12 @@ public:
*/ */
bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0);
bool foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on each dart of an oriented face //! Apply a functor on each dart of an oriented face
/*! @param d a dart of the oriented face /*! @param d a dart of the oriented face
* @param fonct the functor * @param fonct the functor
*/ */
bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0);
// TODO change to oriented volume to handle higher dimension ?
//! Apply a functor on each dart of an volume
/*! @param d a dart of the volume
* @param fonct the functor
*/
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0)
{
return foreach_dart_of_oriented_volume(d,f);
}
//! Apply a functor on each dart of a cc //! Apply a functor on each dart of a cc
/*! @param d a dart of the cc /*! @param d a dart of the cc
* @param fonct the functor * @param fonct the functor
...@@ -291,6 +271,26 @@ public: ...@@ -291,6 +271,26 @@ 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);
//@} //@}
/*! @name Close map after import or creation
* These functions must be used with care, generally only by import algorithms
*************************************************************************/
//@{
//! Close a topological hole (a sequence of connected fixed point of phi3). DO NOT USE, only for import/creation algorithm
/*! \pre dart d MUST be fixed point of phi3 relation
* Add a volume to the map that closes the hole.
* @param d a dart of the hole (with phi3(d)==d)
* @param forboundary tag the created face as boundary (default is true)
* @return the degree of the created volume
*/
virtual unsigned int closeHole(Dart d, bool forboundary = true);
//! Close the map removing topological holes: DO NOT USE, only for import/creation algorithm
/*! Add volumes to the map that close every existing hole.
* These faces are marked as boundary.
*/
void closeMap();
//@}
}; };
} // namespace CGoGN } // namespace CGoGN
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
namespace CGoGN namespace CGoGN
{ {
/// INLINE FUNCTIONS
inline void Map3::init() inline void Map3::init()
{ {
m_phi3 = addRelation("phi3") ; m_phi3 = addRelation("phi3") ;
...@@ -98,17 +96,11 @@ inline Dart Map3::phi(Dart d) ...@@ -98,17 +96,11 @@ inline Dart Map3::phi(Dart d)
} }
} }
/*
* N'a pas de sens dans une 3-carte, n'est pas une permutation
*/
inline Dart Map3::alpha0(Dart d) inline Dart Map3::alpha0(Dart d)
{ {
return phi3(d) ; return phi3(d) ;
} }
/*
* idem
*/
inline Dart Map3::alpha1(Dart d) inline Dart Map3::alpha1(Dart d)
{ {
return phi_1(phi3(d)) ; return phi_1(phi3(d)) ;
...@@ -119,46 +111,11 @@ inline Dart Map3::alpha2(Dart d) ...@@ -119,46 +111,11 @@ inline Dart Map3::alpha2(Dart d)
return phi3(phi2(d)); return phi3(phi2(d));
} }
//inline Dart Map3::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 Map3::alpha_2(Dart d) inline Dart Map3::alpha_2(Dart d)
{ {
return phi2(phi3(d)); return phi2(phi3(d));
} }
//inline Dart Map3::alpha_2(Dart d)
//{
// Dart e = phi3(d);
//
// if (e != d)
// return phi2(e);
//
// e = d;
// Dart f = phi2(d);
// while (phi3(f) != f)
// {
// e = phi3(f);
// f = phi2(e);
// }
// return e;
//}
inline void Map3::phi3sew(Dart d, Dart e) inline void Map3::phi3sew(Dart d, Dart e)
{ {
assert((*m_phi3)[d.index] == d) ; assert((*m_phi3)[d.index] == d) ;
...@@ -174,51 +131,32 @@ inline void Map3::phi3unsew(Dart d) ...@@ -174,51 +131,32 @@ inline void Map3::phi3unsew(Dart d)
(*m_phi3)[e.index] = e ; (*m_phi3)[e.index] = e ;
} }
inline bool Map3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread) /*! @name Topological Queries
{ * Return or set various topological information
return foreach_dart_of_oriented_vertex(d, f, thread); *************************************************************************/
}
//template<typename TMAP>
//bool Map3::foreach_dart_of_parent_cell(int dim, Dart d, FunctorType& f)
//{
// switch(dim)
// {
// case 0: return this->TMAP::foreach_dart_of_vertex(d,f);
// case 1: return this->TMAP::foreach_dart_of_edge(d,f);
// case 2: return this->TMAP::foreach_dart_of_face(d,f);
// case -1: return this->TMAP::foreach_dart_of_cc(d,f);
// }
// return false;
//}
//
//template<typename TMAP>
//bool Map3::markOrbitOf(int dim, Dart d, Marker m)
//{
// FunctorMark<Map3> fmark(*this, m);
// switch(dim)
// {
// case 0: return this->TMAP::foreach_dart_of_vertex(d,fmark);
// case 1: return this->TMAP::foreach_dart_of_edge(d,fmark);
// case 2: return this->TMAP::foreach_dart_of_face(d,fmark);
// case -1: return this->TMAP::foreach_dart_of_cc(d,fmark);
// }
// return false;
//}
//
//template<typename TMAP>
//bool Map3::unmarkOrbitOf(int dim, Dart d, Marker m)
//{
// FunctorUnmark<Map3> fumark(*this, m);
// switch(dim)
// {
// case 0: return this->TMAP::foreach_dart_of_vertex(d,fumark);
// case 1: return this->TMAP::foreach_dart_of_edge(d,fumark);
// case 2: return this->TMAP::foreach_dart_of_face(d,fumark);
// case -1: return this->TMAP::foreach_dart_of_cc(d,fumark);
// }
// return false;
//}
} // namespace CGoGN inline bool Map3::sameEdge(Dart d, Dart e)
{
return sameOrientedEdge(d, e) || sameOrientedEdge(phi2(d), e) ;
}
inline bool Map3::sameFace(Dart d, Dart e)
{
return Map2::sameOrientedFace(d, e) || Map2::sameOrientedFace(phi3(d), e) ;
}
inline bool Map3::isBoundaryFace(Dart d)
{
return isBoundaryMarked(d) || isBoundaryMarked(phi3(d));
}
/*! @name Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
inline bool Map3::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
{
return Map2::foreach_dart_of_oriented_face(d, f, thread) || Map2::foreach_dart_of_oriented_face(phi3(d), f, thread);
}
} // namespace CGoGN
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <vector>
#include <algorithm>
#include "Topology/map/embeddedMap3.h" #include "Topology/map/embeddedMap3.h"
namespace CGoGN namespace CGoGN
...@@ -310,26 +307,4 @@ bool EmbeddedMap3::check() ...@@ -310,26 +307,4 @@ bool EmbeddedMap3::check()
return true ; return true ;
} }
unsigned int EmbeddedMap3::closeHole(Dart d)
{
unsigned int nbE = Map3::closeHole(d);
Dart dd = phi2(d);
Dart f = dd;
do
{
if(isOrbitEmbedded(VERTEX))
copyDartEmbedding(VERTEX,f, phi1(phi2(f)));
if(isOrbitEmbedded(EDGE))
copyDartEmbedding(EDGE, f, phi2(f));
if(isOrbitEmbedded(VOLUME))
copyDartEmbedding(VOLUME, f, phi2(f));
f = phi1(f);
}
while(dd != f);
return nbE;
}
} // namespace CGoGN } // namespace CGoGN
...@@ -352,17 +352,13 @@ void Map2::unsewFaces(Dart d) ...@@ -352,17 +352,13 @@ void Map2::unsewFaces(Dart d)
Dart e = newBoundaryCycle(2); Dart e = newBoundaryCycle(2);
Dart ee = phi1(e) ; Dart ee = phi1(e) ;
if (isBoundaryVertex(d)) Dart f = findBoundaryEdgeOfVertex(d);
{ if(f != NIL)
Dart f = findBoundaryEdgeOfVertex(d);
phi1sew(e, phi_1(f)); phi1sew(e, phi_1(f));
}
if (isBoundaryVertex(dd)) f = findBoundaryEdgeOfVertex(dd);
{ if(f != NIL)
Dart f = findBoundaryEdgeOfVertex(dd);
phi1sew(ee, phi_1(f)); phi1sew(ee, phi_1(f));
}
phi2unsew(d); phi2unsew(d);
...@@ -575,12 +571,6 @@ Dart Map2::findBoundaryEdgeOfVertex(Dart d) ...@@ -575,12 +571,6 @@ Dart Map2::findBoundaryEdgeOfVertex(Dart d)
return NIL ; return NIL ;
} }
bool Map2::isBoundaryEdge(Dart d)
{
Dart e = phi2(d);
return isBoundaryMarked(e) || isBoundaryMarked(d);
}
bool Map2::isBoundaryFace(Dart d) bool Map2::isBoundaryFace(Dart d)
{ {
Dart it = d ; Dart it = d ;
...@@ -745,31 +735,31 @@ bool Map2::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int ...@@ -745,31 +735,31 @@ bool Map2::foreach_dart_of_oriented_volume(Dart d, FunctorType& f, unsigned int
DartMarkerStore mark(*this, thread); // Lock a marker DartMarkerStore mark(*this, thread); // Lock a marker
bool found = false; // Last functor return value bool found = false; // Last functor return value
std::list<Dart> visitedFaces; // Faces that are traversed std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(1024) ;
visitedFaces.push_back(d); // Start with the face of d visitedFaces.push_back(d); // Start with the face of d
std::list<Dart>::iterator face;
// For every face added to the list // For every face added to the list
for (face = visitedFaces.begin(); !found && face != visitedFaces.end(); ++face) for (std::vector<Dart>::iterator it = visitedFaces.begin(); !found && it != visitedFaces.end(); ++it)
{ {
if (!isBoundaryMarked(*face) && !mark.isMarked(*face)) // Face has not been visited yet if (!isBoundaryMarked(*it) && !mark.isMarked(*it)) // Face has not been visited yet
{ {
// Apply functor to the darts of the face // Apply functor to the darts of the face
found = foreach_dart_of_oriented_face(*face, f); found = foreach_dart_of_oriented_face(*it, f);
// If functor returns false then mark visited darts (current face) // If functor returns false then mark visited darts (current face)
// and add non visited adjacent faces to the list of face // and add non visited adjacent faces to the list of face
if (!found) if (!found)
{ {
Dart it = *face ; Dart e = *it ;
do do
{ {
mark.mark(it); // Mark mark.mark(e); // Mark
Dart adj = phi2(it); // Get adjacent face Dart adj = phi2(e); // Get adjacent face
if (!isBoundaryMarked(adj) && !mark.isMarked(adj)) if (!isBoundaryMarked(adj) && !mark.isMarked(adj))
visitedFaces.push_back(adj); // Add it visitedFaces.push_back(adj); // Add it
it = phi1(it); e = phi1(e);
} while(it != *face); } while(e != *it);
} }
} }
} }
...@@ -808,16 +798,8 @@ unsigned int Map2::closeHole(Dart d, bool forboundary) ...@@ -808,16 +798,8 @@ unsigned int Map2::closeHole(Dart d, bool forboundary)
} }
} while (dPhi1 != d); } while (dPhi1 != d);
if (countEdges < 3) if(forboundary)
{ boundaryMarkOrbit(FACE, phi2(d));
countEdges = 0 ;
collapseDegeneratedFace(first); // if the closing face is 2-sided, collapse it
}
else
{
if(forboundary)
boundaryMarkOrbit(FACE, phi2(d));
}
return countEdges ; return countEdges ;
} }
......
...@@ -238,12 +238,40 @@ void Map3::sewVolumes(Dart d, Dart e, bool withBoundary) ...@@ -238,12 +238,40 @@ void Map3::sewVolumes(Dart d, Dart e, bool withBoundary)
void Map3::unsewVolumes(Dart d) void Map3::unsewVolumes(Dart d)
{ {
Dart fitD = d; assert(!isBoundaryFace(d)) ;
unsigned int nbE = faceDegree(d) ;
Dart d3 = phi3(d);
Dart b1 = newBoundaryCycle(nbE) ;
Dart b2 = newBoundaryCycle(nbE) ;
Dart fit1 = d ;
Dart fit2 = d3 ;
Dart fitB1 = b1 ;
Dart fitB2 = b2 ;
do do
{ {
phi3unsew(fitD); Dart f = findBoundaryFaceOfEdge(fit1) ;
fitD = phi1(fitD); if(f != NIL)
} while(fitD != d); {
Dart f2 = phi2(f) ;
phi2unsew(f) ;
phi2sew(fitB1, f) ;
phi2sew(fitB2, f2) ;
}
else
phi2sew(fitB1, fitB2) ;
phi3unsew(