Commit 1ee70274 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of cgogn:~kraemer/CGoGN into develop

parents c66ab714 19872ac9
...@@ -59,10 +59,14 @@ int main() ...@@ -59,10 +59,14 @@ int main()
// easy way to find the central vertex of the grid // easy way to find the central vertex of the grid
Vertex v; Vertex v;
// findCell(VERTEX,v,MAP,myMap, position[v] == VEC3(0,0,0) ); foreach_cell_until<VERTEX>(myMap, [&] (Vertex it)
find_cell<VERTEX>(myMap,v, [&](Vertex v)
{ {
return position[v] == VEC3(0,0,0); if (position[it] == VEC3(0,0,0))
{
v = it;
return true;
}
return false;
}); });
// must test of find ok (if not v.dart is NIL) // must test of find ok (if not v.dart is NIL)
...@@ -73,14 +77,14 @@ int main() ...@@ -73,14 +77,14 @@ int main()
// WITH TRAVERSORS: // WITH TRAVERSORS:
// find incident faces to vertex // find incident faces to vertex
Traversor2VF<MAP> trvf(myMap,v.dart); Traversor2VF<MAP> trvf(myMap, v.dart);
for (Dart e = trvf.begin(); e != trvf.end(); e = trvf.next()) for (Dart e = trvf.begin(); e != trvf.end(); e = trvf.next())
{ {
std::cout << "Face of dart "<<e<< " incident to vertex of dart " << v.dart<< std::endl; std::cout << "Face of dart "<<e<< " incident to vertex of dart " << v.dart<< std::endl;
} }
// find adjacent vertices thru a face // find adjacent vertices thru a face
Traversor2VVaF<MAP> trvvaf(myMap,v.dart); Traversor2VVaF<MAP> trvvaf(myMap, v.dart);
for (Dart e = trvvaf.begin(); e != trvvaf.end(); e = trvvaf.next()) for (Dart e = trvvaf.begin(); e != trvvaf.end(); e = trvvaf.next())
{ {
std::cout << "vertex of dart "<<e<< " adjacent to vertex of dart " << v.dart<< " by a face" << std::endl; std::cout << "vertex of dart "<<e<< " adjacent to vertex of dart " << v.dart<< " by a face" << std::endl;
...@@ -88,16 +92,16 @@ int main() ...@@ -88,16 +92,16 @@ int main()
// WITH FOREACH FUNCTION (C++11 lambda expression) // WITH FOREACH FUNCTION (C++11 lambda expression)
// find incident faces to vertex // find faces incident to vertex v
foreach_incident2<FACE>(myMap,v,[&](Face f) foreach_incident2<FACE>(myMap, v, [&](Face f)
{ {
std::cout << "Face of dart "<<f<< " incident to vertex of dart " << v.dart<< std::endl; std::cout << "Face of dart " << f << " incident to vertex of dart " << v.dart << std::endl;
}); });
// find adjacent vertices thru a face // find vertices adjacent to vertex v thru a face
foreach_adjacent2<FACE>(myMap,v,[&](Vertex x) foreach_adjacent2<FACE>(myMap, v, [&](Vertex x)
{ {
std::cout << "vertex of dart "<<x<< " adjacent to vertex of dart " << v.dart<< " by a face" << std::endl; std::cout << "vertex of dart " << x << " adjacent to vertex of dart " << v.dart << " by a face" << std::endl;
}); });
return 0; return 0;
......
...@@ -28,9 +28,9 @@ public: ...@@ -28,9 +28,9 @@ public:
inline const QString& getName() { return m_name; } inline const QString& getName() { return m_name; }
virtual inline unsigned int getOrbit() const = 0; virtual unsigned int getOrbit() const = 0;
virtual inline unsigned int getNbSelectedCells() const = 0; virtual unsigned int getNbSelectedCells() const = 0;
virtual void rebuild() = 0; virtual void rebuild() = 0;
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; } inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; }
inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; } inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; }
virtual inline void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex) = 0; virtual void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex) = 0;
signals: signals:
void selectedCellsChanged(); void selectedCellsChanged();
......
...@@ -151,10 +151,10 @@ protected: ...@@ -151,10 +151,10 @@ protected:
* @param tableIndices the indices table * @param tableIndices the indices table
*/ */
template <typename PFP> template <typename PFP>
void addTri(typename PFP::MAP& map, Dart d, std::vector<GLuint>& tableIndices) ; void addTri(typename PFP::MAP& map, Face f, std::vector<GLuint>& tableIndices) ;
template<typename PFP> template<typename PFP>
inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLuint>& tableIndices, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>* position); inline void addEarTri(typename PFP::MAP& map, Face f, std::vector<GLuint>& tableIndices, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>* position);
template<typename PFP> template<typename PFP>
float computeEarAngle(const typename PFP::VEC3& P1, const typename PFP::VEC3& P2, const typename PFP::VEC3& P3, const typename PFP::VEC3& normalPoly); float computeEarAngle(const typename PFP::VEC3& P1, const typename PFP::VEC3& P2, const typename PFP::VEC3& P3, const typename PFP::VEC3& normalPoly);
...@@ -166,7 +166,7 @@ protected: ...@@ -166,7 +166,7 @@ protected:
void recompute2Ears(const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex); void recompute2Ears(const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex);
template<typename VEC3> template<typename VEC3>
bool inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc); bool inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc);
public: public:
/** /**
......
...@@ -180,7 +180,7 @@ bool MapRender::computeEarIntersection(const VertexAttribute<typename PFP::VEC3, ...@@ -180,7 +180,7 @@ bool MapRender::computeEarIntersection(const VertexAttribute<typename PFP::VEC3,
} }
template<typename PFP> template<typename PFP>
inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLuint>& tableIndices, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>* pos) inline void MapRender::addEarTri(typename PFP::MAP& map, Face f, std::vector<GLuint>& tableIndices, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>* pos)
{ {
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
...@@ -190,24 +190,24 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -190,24 +190,24 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
const VertexAttribute<VEC3, typename PFP::MAP::IMPL>& position = *pos ; const VertexAttribute<VEC3, typename PFP::MAP::IMPL>& position = *pos ;
// compute normal to polygon // compute normal to polygon
VEC3 normalPoly = Algo::Surface::Geometry::newellNormal<PFP>(map, d, position); VEC3 normalPoly = Algo::Surface::Geometry::newellNormal<PFP>(map, f, position);
// first pass create polygon in chained list with angle computation // first pass create polygon in chained list with angle computation
VertexPoly* vpp = NULL; VertexPoly* vpp = NULL;
VertexPoly* prem = NULL; VertexPoly* prem = NULL;
unsigned int nbv = 0; unsigned int nbv = 0;
unsigned int nbe = 0; unsigned int nbe = 0;
Dart a = d; Vertex a = f.dart;
Dart b = map.phi1(a); Vertex b = map.phi1(a);
Dart c = map.phi1(b); Vertex c = map.phi1(b);
do do
{ {
VEC3 P1 = position[map.template getEmbedding<VERTEX>(a)]; VEC3 P1 = position[map.getEmbedding(a)];
VEC3 P2 = position[map.template getEmbedding<VERTEX>(b)]; VEC3 P2 = position[map.getEmbedding(b)];
VEC3 P3 = position[map.template getEmbedding<VERTEX>(c)]; VEC3 P3 = position[map.getEmbedding(c)];
float val = computeEarAngle<PFP>(P1, P2, P3, normalPoly); float val = computeEarAngle<PFP>(P1, P2, P3, normalPoly);
VertexPoly* vp = new VertexPoly(map.template getEmbedding<VERTEX>(b), val, (P3-P1).norm2(), vpp); VertexPoly* vp = new VertexPoly(map.getEmbedding(b), val, (P3-P1).norm2(), vpp);
if (vp->value < 5.0f) if (vp->value < 5.0f)
nbe++; nbe++;
...@@ -218,7 +218,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -218,7 +218,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
b = c; b = c;
c = map.phi1(c); c = map.phi1(c);
nbv++; nbv++;
}while (a != d); } while (a.dart != f.dart);
VertexPoly::close(prem, vpp); VertexPoly::close(prem, vpp);
...@@ -227,7 +227,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -227,7 +227,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
{ {
// second pass with no test of intersections with polygons // second pass with no test of intersections with polygons
vpp = prem; vpp = prem;
for (unsigned int i=0; i< nbv; ++i) for (unsigned int i = 0; i < nbv; ++i)
{ {
vpp->ear = ears.insert(vpp); vpp->ear = ears.insert(vpp);
vpp = vpp->next; vpp = vpp->next;
...@@ -237,9 +237,9 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -237,9 +237,9 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
{ {
// second pass test intersections with polygons // second pass test intersections with polygons
vpp = prem; vpp = prem;
for (unsigned int i=0; i< nbv; ++i) for (unsigned int i = 0; i < nbv; ++i)
{ {
if (vpp->value <5.0f) if (vpp->value < 5.0f)
computeEarIntersection<PFP>(position, vpp, normalPoly); computeEarIntersection<PFP>(position, vpp, normalPoly);
vpp->ear = ears.insert(vpp); vpp->ear = ears.insert(vpp);
vpp = vpp->next; vpp = vpp->next;
...@@ -248,7 +248,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -248,7 +248,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
// NOW WE HAVE THE POLYGON AND EARS // NOW WE HAVE THE POLYGON AND EARS
// LET'S REMOVE THEM // LET'S REMOVE THEM
while (nbv>3) while (nbv > 3)
{ {
// take best (and valid!) ear // take best (and valid!) ear
VPMS::iterator be_it = ears.begin(); // best ear VPMS::iterator be_it = ears.begin(); // best ear
...@@ -259,14 +259,14 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -259,14 +259,14 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
tableIndices.push_back(be->prev->id); tableIndices.push_back(be->prev->id);
nbv--; nbv--;
if (nbv>3) // do not recompute if only one triangle left if (nbv > 3) // do not recompute if only one triangle left
{ {
//remove ears and two sided ears //remove ears and two sided ears
ears.erase(be_it); // from map of ears ears.erase(be_it); // from map of ears
ears.erase(be->next->ear); ears.erase(be->next->ear);
ears.erase(be->prev->ear); ears.erase(be->prev->ear);
be = VertexPoly::erase(be); // and remove ear vertex from polygon be = VertexPoly::erase(be); // and remove ear vertex from polygon
recompute2Ears<PFP>(position,be,normalPoly,ears,convex); recompute2Ears<PFP>(position, be, normalPoly, ears, convex);
convex = (*(ears.rbegin()))->value < 5.0f; convex = (*(ears.rbegin()))->value < 5.0f;
} }
else // finish (no need to update ears) else // finish (no need to update ears)
...@@ -286,21 +286,21 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu ...@@ -286,21 +286,21 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector<GLu
} }
template<typename PFP> template<typename PFP>
inline void MapRender::addTri(typename PFP::MAP& map, Dart d, std::vector<GLuint>& tableIndices) inline void MapRender::addTri(typename PFP::MAP& map, Face f, std::vector<GLuint>& tableIndices)
{ {
Dart a = d; Vertex a = f.dart;
Dart b = map.phi1(a); Vertex b = map.phi1(a);
Dart c = map.phi1(b); Vertex c = map.phi1(b);
// loop to cut a polygon in triangle on the fly (works only with convex faces) // loop to cut a polygon in triangle on the fly (works only with convex faces)
do do
{ {
tableIndices.push_back(map.template getEmbedding<VERTEX>(d)); tableIndices.push_back(map.getEmbedding(a));
tableIndices.push_back(map.template getEmbedding<VERTEX>(b)); tableIndices.push_back(map.getEmbedding(b));
tableIndices.push_back(map.template getEmbedding<VERTEX>(c)); tableIndices.push_back(map.getEmbedding(c));
b = c; b = c;
c = map.phi1(b); c = map.phi1(b);
} while (c != d); } while (c.dart != a.dart);
} }
template<typename PFP> template<typename PFP>
...@@ -308,27 +308,22 @@ void MapRender::initTriangles(typename PFP::MAP& map, std::vector<GLuint>& table ...@@ -308,27 +308,22 @@ void MapRender::initTriangles(typename PFP::MAP& map, std::vector<GLuint>& table
{ {
tableIndices.reserve(4 * map.getNbDarts() / 3); tableIndices.reserve(4 * map.getNbDarts() / 3);
// TraversorF<typename PFP::MAP> trav(map, thread);
if(position == NULL) if(position == NULL)
{ {
// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) foreach_cell<FACE>(map, [&] (Face f)
// foreachCellMT(VERTEX,d,typename PFP::MAP,map,thread)
foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
addTri<PFP>(map, v, tableIndices); addTri<PFP>(map, f, tableIndices);
},false,thread); }, false, thread);
} }
else else
{ {
// for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) foreach_cell<FACE>(map, [&] (Face f)
foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
if(map.faceDegree(v) == 3) if(map.faceDegree(f) == 3)
addTri<PFP>(map, v, tableIndices); addTri<PFP>(map, f, tableIndices);
else else
addEarTri<PFP>(map, v, tableIndices, position); addEarTri<PFP>(map, f, tableIndices, position);
},false,thread); }, false, thread);
} }
} }
......
...@@ -65,19 +65,6 @@ public: ...@@ -65,19 +65,6 @@ public:
inline Cell<ORBIT> next() ; inline Cell<ORBIT> next() ;
inline void skip(Cell<ORBIT> c); inline void skip(Cell<ORBIT> c);
inline void apply(std::function<bool (Cell<ORBIT>)> f)
{
for (Cell<ORBIT> c = begin(), e = end(); c.dart != e.dart; c = next())
if (f(c))
return;
}
inline void apply(std::function<void (Cell<ORBIT>)> f)
{
for (Cell<ORBIT> c = begin(), e = end(); c.dart != e.dart; c = next())
f(c);
}
} ; } ;
...@@ -86,23 +73,22 @@ template <unsigned int ORBIT, typename MAP, typename FUNC> ...@@ -86,23 +73,22 @@ template <unsigned int ORBIT, typename MAP, typename FUNC>
inline void foreach_cell(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0) inline void foreach_cell(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0)
{ {
TraversorCell<MAP, ORBIT> trav(map, forceDartMarker, thread); TraversorCell<MAP, ORBIT> trav(map, forceDartMarker, thread);
trav.apply(f); for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
f(c);
} }
template <unsigned int ORBIT, typename MAP > template <unsigned int ORBIT, typename MAP, typename FUNC>
inline void find_cell(const MAP& map, Cell<ORBIT> c, std::function<bool (Cell<ORBIT>)> cond, bool forceDartMarker = false, unsigned int thread = 0) inline void foreach_cell_until(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0)
{ {
TraversorCell<MAP, ORBIT> trav(map, forceDartMarker, thread); TraversorCell<MAP, ORBIT> trav(map, forceDartMarker, thread);
c = trav.begin(); for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
Cell<ORBIT> e = trav.end(); if (!f(c))
while ((c.dart != e.dart) && (!cond(c))) break;
c = trav.next();
} }
template <typename MAP> template <typename MAP>
class TraversorV : public TraversorCell<MAP, VERTEX> class TraversorV : public TraversorCell<MAP, VERTEX>
{ {
......
...@@ -309,110 +309,110 @@ public: ...@@ -309,110 +309,110 @@ public:
*************************************************************************/ *************************************************************************/
//@{ //@{
//! Test if dart d and e belong to the same oriented vertex //! Test if vertices v1 and v2 represent the same oriented vertex
/*! @param d a dart /*! @param v1 a vertex
* @param e a dart * @param v2 a vertex
*/ */
bool sameOrientedVertex(Dart d, Dart e) const; bool sameOrientedVertex(Vertex v1, Vertex v2) const;
//! Test if dart d and e belong to the same vertex //! Test if vertices v1 and v2 represent the same vertex
/*! @param d a dart /*! @param v1 a vertex
* @param e a dart * @param v2 a vertex
*/ */
bool sameVertex(Dart d, Dart e) const; bool sameVertex(Vertex v1, Vertex v2) const;
//! Compute the number of edges of the vertex of d //! Compute the number of edges of the vertex v
/*! @param d a dart /*! @param v a vertex
*/ */
unsigned int vertexDegree(Dart d) const; unsigned int vertexDegree(Vertex v) const;
//! Check number of edges of the vertex of d with given parameter //! Check number of edges of the vertex v with given parameter
/*! @param d a dart /*! @param v a vertex
* @param vd degree to compare with * @param vd degree to compare with
* @return negative/null/positive if vertex degree is less/equal/greater than given degree * @return negative/null/positive if vertex degree is less/equal/greater than given degree
*/ */
int checkVertexDegree(Dart d, unsigned int vd) const; int checkVertexDegree(Vertex v, unsigned int vd) const;
//! Tell if the vertex of d is on the boundary of the map //! Tell if the vertex v is on the boundary of the map
/*! @param d a dart /*! @param v a vertex
*/ */
bool isBoundaryVertex(Dart d) const; bool isBoundaryVertex(Vertex v) const;
/** /**
* find the dart of vertex that belong to the boundary * find the dart of vertex v that belongs to the boundary
* return NIL if the vertex is not on the boundary * return NIL if the vertex is not on the boundary
*/ */
Dart findBoundaryEdgeOfVertex(Dart d) const; Dart findBoundaryEdgeOfVertex(Vertex v) const;
//! Test if dart d and e belong to the same edge //! Test if edges e1 and e2 represent the same edge
/*! @param d a dart /*! @param e1 an edge
* @param e a dart * @param e2 an edge
*/ */
bool sameEdge(Dart d, Dart e) const; bool sameEdge(Edge e1, Edge e2) const;
/** /**
* tell if the edge of d is on the boundary of the map * tell if the edge e is on the boundary of the map
*/ */
bool isBoundaryEdge(Dart d) const; bool isBoundaryEdge(Edge e) const;
//! Test if dart d and e belong to the same oriented face //! Test if faces f1 and f2 represent the same oriented face
/*! @param d a dart /*! @param f1 a face
* @param e a dart * @param f2 a face
*/ */
bool sameOrientedFace(Dart d, Dart e) const; bool sameOrientedFace(Face f1, Face f2) const;
//! Test if dart d and e belong to the same face //! Test if faces f1 and f2 represent the same face
/*! @param d a dart /*! @param f1 a face
* @param e a dart * @param f2 a face
*/ */
bool sameFace(Dart d, Dart e) const; bool sameFace(Face f1, Face f2) const;
/** /**
* compute the number of edges of the face of d * compute the number of edges of the face f
*/ */
unsigned int faceDegree(Dart d) const; unsigned int faceDegree(Face f) const;
//! Check number of edges of the face of d with given parameter //! Check number of edges of the face f with given parameter
/*! @param d a dart /*! @param f a face
* @param vd degree to compare with * @param fd degree to compare with
* @return negative/null/positive if vertex degree is less/equal/greater than given degree * @return negative/null/positive if face degree is less/equal/greater than given degree
*/ */
int checkFaceDegree(Dart d, unsigned int le) const; int checkFaceDegree(Face f, unsigned int fd) const;
/** /**
* tell if the face of d is adjacent to the boundary of the map * tell if the face f is incident to the boundary of the map
*/ */
bool isBoundaryAdjacentFace(Dart d) const; bool isFaceIncidentToBoundary(Face f) const;
/** /**
* find the dart of edge that belong to the boundary * find the dart of face f that belongs to the boundary
* return NIL if the face is not on the boundary * return NIL if the face is not incident to the boundary
*/ */
Dart findBoundaryEdgeOfFace(Dart d) const; Dart findBoundaryEdgeOfFace(Face f) const;
//! Test if dart d and e belong to the same oriented volume //! Test if volumes v1 and v2 represent the same oriented volume
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
*/ */
bool sameOrientedVolume(Dart d, Dart e) const; bool sameOrientedVolume(Vol v1, Vol v2) const;
//! Test if dart d and e belong to the same volume //! Test if volumes v1 and v2 represent the same volume
/*! @param d a dart /*! @param d a dart
* @param e a dart * @param e a dart
*/ */
bool sameVolume(Dart d, Dart e) const; bool sameVolume(Vol v1, Vol v2) const;
//! Compute the number of faces in the volume of d //! Compute the number of faces in the volume v
/*! @param d a dart /*! @param d a dart