Commit fa461dc7 authored by thomas's avatar thomas
Browse files

Merge branch 'feature-trimap' of git@icube-forge.unistra.fr:untereiner/cgogn.git into develop

parents adf3778e 29f7de99
......@@ -190,6 +190,9 @@ void MyQT::cb_Open()
// }
// SelectorDartNoBoundary<MAP> nb(myMap);
myMap.check();
m_topo_render->updateData(myMap, position, 0.8f, 0.8f, 0.8f);
m_explode_render->updateData<PFP>(myMap, position, color);
......
......@@ -646,8 +646,6 @@ Dart swapGen3To2(typename PFP::MAP& map, Dart d)
Dart stop = map.phi1(map.phi2(map.phi_1(d)));
if(map.deleteEdge(d) == NIL)
{
std::cout << "boundary" << std::endl;
std::vector<Dart> edges;
Dart dbegin = map.findBoundaryFaceOfEdge(d);
Traversor3EW<typename PFP::MAP> t(map, d);
......@@ -663,11 +661,23 @@ Dart swapGen3To2(typename PFP::MAP& map, Dart d)
map.template copyDartEmbedding<VERTEX>(d, map.phi1(e)) ;
map.template copyDartEmbedding<VERTEX>(e, map.phi1(d)) ;
if (map.template isOrbitEmbedded<FACE>())
{
map.template copyDartEmbedding<FACE>(map.phi1(d), d) ;
map.template copyDartEmbedding<FACE>(map.phi1(e), e) ;
}
d = map.phi3(dbegin);
e = map.phi2(d);
map.flipEdge(d);
map.template copyDartEmbedding<VERTEX>(d, map.phi1(e)) ;
map.template copyDartEmbedding<VERTEX>(e, map.phi1(d)) ;
if (map.template isOrbitEmbedded<FACE>())
{
map.template copyDartEmbedding<FACE>(map.phi_1(d), d) ;
map.template copyDartEmbedding<FACE>(map.phi_1(e), e) ;
}
}
std::vector<Dart> edges;
......@@ -716,8 +726,6 @@ std::vector<Dart> swapGen3To2Optimized(typename PFP::MAP& map, Dart d)
Dart stop = map.phi1(map.phi2(map.phi_1(d)));
if(map.deleteEdge(d) == NIL)
{
std::cout << "boundary" << std::endl;
std::vector<Dart> edges;
Dart dbegin = map.findBoundaryFaceOfEdge(d);
Traversor3EW<typename PFP::MAP> t(map, d);
......@@ -733,11 +741,23 @@ std::vector<Dart> swapGen3To2Optimized(typename PFP::MAP& map, Dart d)
map.template copyDartEmbedding<VERTEX>(d, map.phi1(e)) ;
map.template copyDartEmbedding<VERTEX>(e, map.phi1(d)) ;
if (map.template isOrbitEmbedded<FACE>())
{
map.template copyDartEmbedding<FACE>(map.phi1(d), d) ;
map.template copyDartEmbedding<FACE>(map.phi1(e), e) ;
}
d = map.phi3(dbegin);
e = map.phi2(d);
map.flipEdge(d);
map.template copyDartEmbedding<VERTEX>(d, map.phi1(e)) ;
map.template copyDartEmbedding<VERTEX>(e, map.phi1(d)) ;
if (map.template isOrbitEmbedded<FACE>())
{
map.template copyDartEmbedding<FACE>(map.phi_1(d), d) ;
map.template copyDartEmbedding<FACE>(map.phi_1(e), e) ;
}
}
std::vector<Dart> edges;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __MAP2_TRIANGULAR_H__
#define __MAP2_TRIANGULAR_H__
#include "Topology/generic/mapCommon.h"
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
namespace CGoGN
{
namespace Simplex
{
template <typename MAP_IMPL>
class Map2 : public MapCommon<MAP_IMPL>
{
protected:
init();
public:
typedef MAP_IMPL IMPL;
typedef MapCommon<MAP_IMPL> ParentMap;
Map2();
static const unsigned int DIMENSION = 2;
virtual std::string mapTypeName() const;
virtual unsigned int dimension() const;
virtual void clear(bool removeAttrib);
virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
Dart phi1(Dart d) const;
Dart phi_1(Dart d) const;
Dart phi2(Dart d) const;
template <int N>
Dart phi(Dart d) const;
Dart alpha0(Dart d) const;
Dart alpha1(Dart d) const;
Dart alpha_1(Dart d) const;
protected:
//! Link dart d with dart e by an involution
/*! @param d,e the darts to link
* - Before: d->d and e->e
* - After: d->e and e->d
*/
void phi2sew(Dart d, Dart e);
//! Unlink the current dart by an involution
/*! @param d the dart to unlink
* - Before: d->e and e->d
* - After: d->d and e->e
*/
void phi2unsew(Dart d);
public:
/*! @name Generator and Deletor
* To generate or delete faces in a 1-map
*************************************************************************/
//@{
//! Create an new face made of 3 linked darts.
/*! @return return a dart of the face
*/
Dart newFace() ;
//! Delete an oriented face erasing its 3 darts
/*! @param d a dart of the face
*/
void deleteFace(Dart d) ;
//@}
/*! @name Topological Operators
* Topological operations on 1-maps
*************************************************************************/
//@{
//! Split a vertex v between d and e inserting an edge after d and e
/*! \pre Darts d & e MUST belong to the same vertex
* @param d first dart in vertex v
* @param e second dart in vertex v
*/
void splitVertex(Dart d, Dart e);
//TODO deleteVertex can create a Hole or must generate a new triangulation
//! Delete the vertex of d (works only for internal vertices)
/*! Does not create a hole -> all the faces
* around the vertex are merged into one face
* @param d a dart of the vertex to delete
* @return a dart of the resulting face (NIL if the deletion has not been executed)
*/
Dart deleteVertex(Dart d);
//! Collapse an edge of a cycle
/*! \warning Dart d no longer exists after the call
* @param d the edge
*/
void collapseEdge(Dart d);
/**
* Flip the edge of d (rotation in phi1 order)
* WARNING : Works only for non-border edges
* @param d a dart of the edge to flip
* @return true if the flip has been executed, false otherwise
*/
bool flipEdge(Dart d);
/**
* Flip the edge of d (rotation in phi_1 order)
* WARNING : Works only for non-border edges
* @param d a dart of the edge to flip
* @return true if the flipBack has been executed, false otherwise
*/
bool flipBackEdge(Dart d);
//! Sew two oriented faces along oriented edges
/*! \pre Edges of darts d & e MUST be boundary edges
* @param d a dart of the first face
* @param e a dart of the second face
* @param withBoundary: if false, faces must have phi2 fixed points (only for construction: import/primitives)
*/
void sewFaces(Dart d, Dart e, bool withBoundary = true);
//! Unsew two oriented faces
/*! \pre Edge of dart d MUST NOT be a boundary edge
* @param d a dart of a face
*/
virtual void unsewFaces(Dart d, bool withBoundary = true);
/**
* Extract a pair of sewed triangles and sew their adjacent faces
* d is a dart of the common edge of the pair of triangles
*/
void extractTrianglePair(Dart d) ;
/**
* Insert a pair of sewed triangles in a vertex by exploding the edges of v1 and v2
* v1 and v2 belong to the same vertex
* d is a dart of the common edge of the pair of triangles
*/
void insertTrianglePair(Dart d, Dart v1, Dart v2) ;
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
//@{
//! Test if vertices v1 and v2 represent the same oriented vertex
/*! @param v1 a vertex
* @param v2 a vertex
*/
bool sameOrientedVertex(Vertex v1, Vertex v2) const;
//! Test if vertices v1 and v2 represent the same vertex
/*! @param v1 a vertex
* @param v2 a vertex
*/
bool sameVertex(Vertex v1, Vertex v2) const;
//! Compute the number of edges of the vertex v
/*! @param v a vertex
*/
unsigned int vertexDegree(Vertex v) const;
//! Check number of edges of the vertex v with given parameter
/*! @param v a vertex
* @param vd degree to compare with
* @return negative/null/positive if vertex degree is less/equal/greater than given degree
*/
int checkVertexDegree(Vertex v, unsigned int vd) const;
//! Tell if the vertex v is on the boundary of the map
/*! @param v a vertex
*/
bool isBoundaryVertex(Vertex v) const;
/**
* find the dart of vertex v that belongs to the boundary
* return NIL if the vertex is not on the boundary
*/
Dart findBoundaryEdgeOfVertex(Vertex v) const;
//! Test if edges e1 and e2 represent the same edge
/*! @param e1 an edge
* @param e2 an edge
*/
bool sameEdge(Edge e1, Edge e2) const;
/**
* tell if the edge e is on the boundary of the map
*/
bool isBoundaryEdge(Edge e) const;
//! Test if faces f1 and f2 represent the same oriented face
/*! @param f1 a face
* @param f2 a face
*/
bool sameOrientedFace(Face f1, Face f2) const;
//! Test if faces f1 and f2 represent the same face
/*! @param f1 a face
* @param f2 a face
*/
bool sameFace(Face f1, Face f2) const;
/**
* compute the number of edges of the face f
*/
unsigned int faceDegree(Face f) const;
//! Check number of edges of the face f with given parameter
/*! @param f a face
* @param fd degree to compare with
* @return negative/null/positive if face degree is less/equal/greater than given degree
*/
int checkFaceDegree(Face f, unsigned int fd) const;
/**
* tell if the face f is incident to the boundary of the map
*/
bool isFaceIncidentToBoundary(Face f) const;
/**
* find the dart of face f that belongs to the boundary
* return NIL if the face is not incident to the boundary
*/
Dart findBoundaryEdgeOfFace(Face f) const;
//! Test if volumes v1 and v2 represent the same oriented volume
/*! @param d a dart
* @param e a dart
*/
bool sameOrientedVolume(Vol v1, Vol v2) const;
//! Test if volumes v1 and v2 represent the same volume
/*! @param d a dart
* @param e a dart
*/
bool sameVolume(Vol v1, Vol v2) const;
//! Compute the number of faces in the volume v
/*! @param d a dart
*/
unsigned int volumeDegree(Vol v) const;
//! Check number of faces of the volume v with given parameter
/*! @param v a volume
* @param vd degree to compare with
* @return negative/null/positive if volume degree is less/equal/greater than given degree
*/
int checkVolumeDegree(Vol v, unsigned int vd) const;
/*! @name Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
//@{
//! Apply a functor on every dart of a vertex
/*! @param d a dart of the vertex
* @param f the functor to apply
*/
void foreach_dart_of_vertex(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of an edge
/*! @param d a dart of the edge
* @param f the functor to apply
*/
void foreach_dart_of_edge(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of an face
/*! @param d a dart of the volume
* @param f the functor to apply
*/
void foreach_dart_of_face(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of an face
/*! @param d a dart of the volume
* @param f the functor to apply
*/
void foreach_dart_of_volume(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of a connected component
/*! @param d a dart of the connected component
* @param f the functor to apply
*/
void foreach_dart_of_cc(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of a vertex of map1 representing the face of d
/*! @param d a dart of the vertex
* @param f the functor to apply
*/
void foreach_dart_of_vertex1(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//! Apply a functor on every dart of an edge of map1 representing the face of d
/*! @param d a dart of the edge
* @param f the functor to apply
*/
void foreach_dart_of_edge1(Dart d, std::function<void (Dart)>& f, unsigned int thread = 0) const;
//@}
};
} // namespace Simplex
} // namespace CGoGN
#include "Topology/map/map2t.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace CGoGN
{
namespace Simplex
{
template <typename MAP_IMPL>
inline void Map2<MAP_IMPL>::init()
{
MAP_IMPL::addInvolution() ;
}
template <typename MAP_IMPL>
inline Map2<MAP_IMPL>::Map2() : MapCommon<MAP_IMPL>()
{
init() ;
}
template <typename MAP_IMPL>
inline std::string Map2<MAP_IMPL>::mapTypeName() const
{
return "Map2" ;
}
template <typename MAP_IMPL>
inline unsigned int Map2<MAP_IMPL>::dimension() const
{
return 2 ;
}
template <typename MAP_IMPL>
inline void Map2<MAP_IMPL>::clear(bool removeAttrib)
{
ParentMap::clear(removeAttrib) ;
if (removeAttrib)
init() ;
}
template <typename MAP_IMPL>
inline unsigned int Map2<MAP_IMPL>::getNbInvolutions() const
{
return 1;
}
template <typename MAP_IMPL>
inline unsigned int Map2<MAP_IMPL>::getNbPermutations() const
{
return 1;
}
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::phi1(Dart d) const
{
return MAP_IMPL::template getPermutation<0>(d);
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::phi_1(Dart d) const
{
return MAP_IMPL::template getPermutationInv<0>(d);
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::phi2(Dart d) const
{
return MAP_IMPL::template getInvolution<0>(d);
}
template <typename MAP_IMPL>
template <int N>
inline Dart Map2<MAP_IMPL>::phi(Dart d) const
{
assert( (N > 0) || !"negative parameters not allowed in template multi-phi");
if (N < 10)
{
switch(N)
{
case 1 : return phi1(d) ;
case 2 : return phi2(d) ;
default : assert(!"Wrong multi-phi relation value") ; return d ;
}
}
switch(N%10)
{
case 1 : return phi1(phi<N/10>(d)) ;
case 2 : return phi2(phi<N/10>(d)) ;
default : assert(!"Wrong multi-phi relation value") ; return d ;
}
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::alpha0(Dart d) const
{
return phi2(d) ;
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::alpha1(Dart d) const
{
return phi2(phi_1(d)) ;
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::alpha_1(Dart d) const
{
return phi1(phi2(d)) ;
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::phi2_1(Dart d) const
{
return phi2(phi_1(d)) ;
}
template <typename MAP_IMPL>
inline Dart Map2<MAP_IMPL>::phi12(Dart d) const
{
return phi1(phi2(d)) ;
}
template <typename MAP_IMPL>
inline void Map2<MAP_IMPL>::phi2sew(Dart d, Dart e)
{
MAP_IMPL::template involutionSew<0>(d,e);
}
template <typename MAP_IMPL>
inline void Map2<MAP_IMPL>::phi2unsew(Dart d)
{
MAP_IMPL::template involutionUnsew<0>(d);
}
/*! @name Generator and Deletor
* To generate or delete faces in a 2-map
*************************************************************************/
template <typename MAP_IMPL>
Dart Map2<MAP_IMPL>::newFace()
{
Dart d = this->newDart() ; // Create the first edge
this->newDart() ; // Create the first edge
this->newDart() ; // Create the first edge
return d;
}
template <typename MAP_IMPL>
void Map2<MAP_IMPL>::deleteFace(Dart d)
{
assert(!this->template isBoundaryMarked<2>(d)) ;
Dart it = d ;
do
{
if(!isBoundaryEdge(it))
unsewFaces(it) ;
it = this->phi1(it) ;
} while(it != d) ;
Dart dd = phi2(d) ;
ParentMap::deleteCycle(d) ;
ParentMap::deleteCycle(dd) ;
}
/*! @name Topological Operators
* Topological operations on 2-maps
*************************************************************************/
template <typename MAP_IMPL>
void Map2<MAP_IMPL>::splitVertex(Dart d, Dart e)