Commit 9cb5f9c5 by Pierre Kraemer

### cell typing in map2 functions

parent cc4445d8
 ... ... @@ -59,10 +59,14 @@ int main() // easy way to find the central vertex of the grid Vertex v; // findCell(VERTEX,v,MAP,myMap, position[v] == VEC3(0,0,0) ); find_cell(myMap,v, [&](Vertex v) foreach_cell_until(myMap, [&] (Vertex it) { 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) ... ... @@ -73,14 +77,14 @@ int main() // WITH TRAVERSORS: // find incident faces to vertex Traversor2VF trvf(myMap,v.dart); Traversor2VF trvf(myMap, v.dart); for (Dart e = trvf.begin(); e != trvf.end(); e = trvf.next()) { std::cout << "Face of dart "< trvvaf(myMap,v.dart); Traversor2VVaF trvvaf(myMap, v.dart); for (Dart e = trvvaf.begin(); e != trvvaf.end(); e = trvvaf.next()) { std::cout << "vertex of dart "<(myMap,v,[&](Face f) // find faces incident to vertex v foreach_incident2(myMap, v, [&](Face f) { std::cout << "Face of dart "<(myMap,v,[&](Vertex x) // find vertices adjacent to vertex v thru a face foreach_adjacent2(myMap, v, [&](Vertex x) { std::cout << "vertex of dart "<
 ... ... @@ -28,9 +28,9 @@ public: 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; ... ... @@ -45,7 +45,7 @@ public: inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; } inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; } virtual inline void setMutuallyExclusiveSet(const QList& mex) = 0; virtual void setMutuallyExclusiveSet(const QList& mex) = 0; signals: void selectedCellsChanged(); ... ...
 ... ... @@ -151,10 +151,10 @@ protected: * @param tableIndices the indices table */ template void addTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices) ; void addTri(typename PFP::MAP& map, Face f, std::vector& tableIndices) ; template inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* position); inline void addEarTri(typename PFP::MAP& map, Face f, std::vector& tableIndices, const VertexAttribute* position); template 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: void recompute2Ears(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex); template 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: /** ... ...
 ... ... @@ -180,7 +180,7 @@ bool MapRender::computeEarIntersection(const VertexAttribute inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* pos) inline void MapRender::addEarTri(typename PFP::MAP& map, Face f, std::vector& tableIndices, const VertexAttribute* pos) { typedef typename PFP::VEC3 VEC3; ... ... @@ -190,24 +190,24 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& position = *pos ; // compute normal to polygon VEC3 normalPoly = Algo::Surface::Geometry::newellNormal(map, d, position); VEC3 normalPoly = Algo::Surface::Geometry::newellNormal(map, f, position); // first pass create polygon in chained list with angle computation VertexPoly* vpp = NULL; VertexPoly* prem = NULL; unsigned int nbv = 0; unsigned int nbe = 0; Dart a = d; Dart b = map.phi1(a); Dart c = map.phi1(b); Vertex a = f.dart; Vertex b = map.phi1(a); Vertex c = map.phi1(b); do { VEC3 P1 = position[map.template getEmbedding(a)]; VEC3 P2 = position[map.template getEmbedding(b)]; VEC3 P3 = position[map.template getEmbedding(c)]; VEC3 P1 = position[map.getEmbedding(a)]; VEC3 P2 = position[map.getEmbedding(b)]; VEC3 P3 = position[map.getEmbedding(c)]; float val = computeEarAngle(P1, P2, P3, normalPoly); VertexPoly* vp = new VertexPoly(map.template getEmbedding(b), val, (P3-P1).norm2(), vpp); VertexPoly* vp = new VertexPoly(map.getEmbedding(b), val, (P3-P1).norm2(), vpp); if (vp->value < 5.0f) nbe++; ... ... @@ -218,7 +218,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vectorear = ears.insert(vpp); vpp = vpp->next; ... ... @@ -237,9 +237,9 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vectorvalue <5.0f) if (vpp->value < 5.0f) computeEarIntersection(position, vpp, normalPoly); vpp->ear = ears.insert(vpp); vpp = vpp->next; ... ... @@ -248,7 +248,7 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector3) while (nbv > 3) { // take best (and valid!) ear VPMS::iterator be_it = ears.begin(); // best ear ... ... @@ -259,14 +259,14 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vectorprev->id); 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 ears.erase(be_it); // from map of ears ears.erase(be->next->ear); ears.erase(be->prev->ear); be = VertexPoly::erase(be); // and remove ear vertex from polygon recompute2Ears(position,be,normalPoly,ears,convex); recompute2Ears(position, be, normalPoly, ears, convex); convex = (*(ears.rbegin()))->value < 5.0f; } else // finish (no need to update ears) ... ... @@ -286,21 +286,21 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector inline void MapRender::addTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices) inline void MapRender::addTri(typename PFP::MAP& map, Face f, std::vector& tableIndices) { Dart a = d; Dart b = map.phi1(a); Dart c = map.phi1(b); Vertex a = f.dart; Vertex b = map.phi1(a); Vertex c = map.phi1(b); // loop to cut a polygon in triangle on the fly (works only with convex faces) do { tableIndices.push_back(map.template getEmbedding(d)); tableIndices.push_back(map.template getEmbedding(b)); tableIndices.push_back(map.template getEmbedding(c)); tableIndices.push_back(map.getEmbedding(a)); tableIndices.push_back(map.getEmbedding(b)); tableIndices.push_back(map.getEmbedding(c)); b = c; c = map.phi1(b); } while (c != d); } while (c.dart != a.dart); } template ... ... @@ -308,27 +308,22 @@ void MapRender::initTriangles(typename PFP::MAP& map, std::vector& table { tableIndices.reserve(4 * map.getNbDarts() / 3); // TraversorF trav(map, thread); if(position == NULL) { // for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) // foreachCellMT(VERTEX,d,typename PFP::MAP,map,thread) foreach_cell(map, [&] (Vertex v) foreach_cell(map, [&] (Face f) { addTri(map, v, tableIndices); },false,thread); addTri(map, f, tableIndices); }, false, thread); } else { // for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) foreach_cell(map, [&] (Vertex v) foreach_cell(map, [&] (Face f) { if(map.faceDegree(v) == 3) addTri(map, v, tableIndices); if(map.faceDegree(f) == 3) addTri(map, f, tableIndices); else addEarTri(map, v, tableIndices, position); },false,thread); addEarTri(map, f, tableIndices, position); }, false, thread); } } ... ...
 ... ... @@ -65,19 +65,6 @@ public: inline Cell next() ; inline void skip(Cell c); inline void apply(std::function)> f) { for (Cell c = begin(), e = end(); c.dart != e.dart; c = next()) if (f(c)) return; } inline void apply(std::function)> f) { for (Cell c = begin(), e = end(); c.dart != e.dart; c = next()) f(c); } } ; ... ... @@ -86,23 +73,22 @@ template inline void foreach_cell(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0) { TraversorCell trav(map, forceDartMarker, thread); trav.apply(f); for (Cell c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next()) f(c); } template inline void find_cell(const MAP& map, Cell c, std::function)> cond, bool forceDartMarker = false, unsigned int thread = 0) template inline void foreach_cell_until(const MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0) { TraversorCell trav(map, forceDartMarker, thread); c = trav.begin(); Cell e = trav.end(); while ((c.dart != e.dart) && (!cond(c))) c = trav.next(); for (Cell c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next()) if (!f(c)) break; } template class TraversorV : public TraversorCell { ... ...
 ... ... @@ -309,110 +309,110 @@ public: *************************************************************************/ //@{ //! Test if dart d and e belong to the same oriented vertex /*! @param d a dart * @param e a dart //! Test if vertices v1 and v2 represent the same oriented vertex /*! @param v1 a vertex * @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 /*! @param d a dart * @param e a dart //! Test if vertices v1 and v2 represent the same vertex /*! @param v1 a vertex * @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 /*! @param d a dart //! Compute the number of edges of the vertex v /*! @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 /*! @param d a dart //! 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 * @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 /*! @param d a dart //! Tell if the vertex v is on the boundary of the map /*! @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 */ Dart findBoundaryEdgeOfVertex(Dart d) const; Dart findBoundaryEdgeOfVertex(Vertex v) const; //! Test if dart d and e belong to the same edge /*! @param d a dart * @param e a dart //! Test if edges e1 and e2 represent the same edge /*! @param e1 an edge * @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 /*! @param d a dart * @param e a dart //! Test if faces f1 and f2 represent the same oriented face /*! @param f1 a face * @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 /*! @param d a dart * @param e a dart //! Test if faces f1 and f2 represent the same face /*! @param f1 a face * @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 /*! @param d a dart * @param vd degree to compare with * @return negative/null/positive if vertex degree is less/equal/greater than given degree //! 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(Dart d, unsigned int le) const; int checkFaceDegree(Face f, unsigned int fd) const; /** * tell if the face of d is on the boundary of the map * tell if the face f is incident to the boundary of the map */ bool isBoundaryFace(Dart d) const; bool isFaceIncidentToBoundary(Face f) const; /** * find the dart of edge that belong to the boundary * return NIL if the face is not on the boundary * find the dart of face f that belongs to 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 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 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 */ unsigned int volumeDegree(Dart d) const; unsigned int volumeDegree(Vol v) const; //! Check number of faces of the volume of d with given parameter /*! @param d a dart //! 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 * @return negative/null/positive if volume degree is less/equal/greater than given degree */ int checkVolumeDegree(Dart d, unsigned int volDeg)const; int checkVolumeDegree(Vol v, unsigned int vd) const; // TODO a mettre en algo /** ... ...
 ... ... @@ -537,7 +537,7 @@ void Map2::extractTrianglePair(Dart d) { Dart e = phi2(d) ; assert(!isBoundaryFace(d) && !isBoundaryFace(e)) ; assert(!isFaceIncidentToBoundary(d) && !isFaceIncidentToBoundary(e)) ; assert(faceDegree(d) == 3 && faceDegree(e) == 3) ; Dart d1 = phi2(this->phi1(d)) ; ... ... @@ -577,7 +577,7 @@ bool Map2::mergeVolumes(Dart d, Dart e, bool deleteFace) { assert(!this->template isBoundaryMarked<2>(d) && !this->template isBoundaryMarked<2>(e)) ; if (isBoundaryFace(d) || isBoundaryFace(e)) if (isFaceIncidentToBoundary(d) || isFaceIncidentToBoundary(e)) return false; // First traversal of both faces to check the face sizes ... ... @@ -653,157 +653,158 @@ void Map2::splitSurface(std::vector& vd, bool firstSideClosed, b *************************************************************************/ template bool Map2::sameOrientedVertex(Dart d, Dart e) const bool Map2::sameOrientedVertex(Vertex v1, Vertex v2) const { Dart it = d; // Foreach dart dNext in the vertex of d Dart it = v1.dart; // Foreach dart in vertex v1 do { if (it == e) // Test equality with e if (it == v2.dart) // Test equality with v2 return true; it = phi2(this->phi_1(it)); } while (it != d); } while (it != v1.dart); return false; // None is equal to e => vertices are distinct } template inline bool Map2::sameVertex(Dart d, Dart e) const inline bool Map2::sameVertex(Vertex v1, Vertex v2) const { return sameOrientedVertex(d, e) ; return sameOrientedVertex(v1, v2) ; } template unsigned int Map2::vertexDegree(Dart d) const unsigned int Map2::vertexDegree(Vertex v) const { unsigned int count = 0 ; Dart it = d ; Dart it = v.dart ; do { ++count ; it = phi2(this->phi_1(it)) ; } while (it != d) ; } while (it != v.dart) ; return count ; } template int Map2::checkVertexDegree(Dart d, unsigned int vd) const int Map2::checkVertexDegree(Vertex v, unsigned int vd) const { unsigned int count = 0 ; Dart it = d ; Dart it = v.dart ; do { ++count ; it = phi2(this->phi_1(it)) ; } while ((count <= vd) && (it != d)) ; } while ((count <= vd) && (it != v.dart)) ; return count - vd; } template bool Map2::isBoundaryVertex(Dart d) const bool Map2::isBoundaryVertex(Vertex v) const { Dart it = d ; Dart it = v.dart ; do { if (this->template isBoundaryMarked<2>(it)) return true ; it = phi2(this->phi_1(it)) ; } while (it != d) ; } while (it != v.dart) ; return false ; } template Dart Map2::findBoundaryEdgeOfVertex(Dart d) const Dart Map2::findBoundaryEdgeOfVertex(Vertex v) const { Dart it = d ; Dart it = v.dart ; do { if (this->template isBoundaryMarked<2>(it)) return it ; it = phi2(this->phi_1(it)) ; } while (it != d) ; } while (it != v.dart) ;