From 6b80a81e3fea2756298625e9a9ee1123e6704940 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Fri, 21 Jun 2013 15:44:08 +0200 Subject: [PATCH] add checkXXXDegree functions (more efficient than XXXDegree == deg) --- include/Topology/gmap/gmap1.h | 7 +++++++ include/Topology/gmap/gmap1.hpp | 14 ++++++++++++++ include/Topology/gmap/gmap2.h | 21 +++++++++++++++++++++ include/Topology/gmap/gmap2.hpp | 6 ++++++ include/Topology/gmap/gmap3.h | 9 +++++++++ include/Topology/map/map1.h | 7 +++++++ include/Topology/map/map1.hpp | 15 +++++++++++++++ include/Topology/map/map2.h | 21 +++++++++++++++++++++ include/Topology/map/map2.hpp | 7 +++++++ include/Topology/map/map3.h | 9 +++++++++ 10 files changed, 116 insertions(+) diff --git a/include/Topology/gmap/gmap1.h b/include/Topology/gmap/gmap1.h index ad7be310..2d6cd2ef 100644 --- a/include/Topology/gmap/gmap1.h +++ b/include/Topology/gmap/gmap1.h @@ -180,6 +180,13 @@ public: */ unsigned int cycleDegree(Dart d); + //! Check the Length of a cycle (its number of oriented edges) + /*! @param d a dart of the cycle + * @param le the length to compare + * @return negative/null/positive if face degree is less/equal/greater than given degree + */ + int checkCycleDegree(Dart d, unsigned int le) ; + /** * check if the face of d is a triangle * @return a boolean indicating if the face is a triangle diff --git a/include/Topology/gmap/gmap1.hpp b/include/Topology/gmap/gmap1.hpp index 17bfb41f..76fc62a4 100644 --- a/include/Topology/gmap/gmap1.hpp +++ b/include/Topology/gmap/gmap1.hpp @@ -286,6 +286,20 @@ inline unsigned int GMap1::cycleDegree(Dart d) return count ; } +inline int GMap1::checkCycleDegree(Dart d, unsigned int degree) +{ + unsigned int count = 0 ; + Dart it = d ; + do + { + ++count ; + it = phi1(it) ; + } while ((count<=degree) && (it != d)) ; + + return count-degree; +} + + inline bool GMap1::isCycleTriangle(Dart d) { return (phi1(d) != d) && (phi1(phi1(phi1(d))) == d) ; diff --git a/include/Topology/gmap/gmap2.h b/include/Topology/gmap/gmap2.h index d33f278d..c447aa72 100644 --- a/include/Topology/gmap/gmap2.h +++ b/include/Topology/gmap/gmap2.h @@ -287,6 +287,13 @@ public: */ unsigned int vertexDegree(Dart d) ; + //! Check number of edges of the vertex 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 + */ + int checkVertexDegree(Dart d, unsigned int vd); + //! tell if the vertex of d is on the boundary of the map /*! @param d a dart */ @@ -326,6 +333,13 @@ public: */ unsigned int faceDegree(Dart d) ; + //! 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 + */ + int checkFaceDegree(Dart d, unsigned int le); + /** * tell if the face of d is on the boundary of the map */ @@ -348,6 +362,13 @@ public: */ unsigned int volumeDegree(Dart d); + //! Check number of faces of the volume of d with given parameter + /*! @param d a dart + * @param vd degree to compare with + * @return negative/null/positive if volume degree is less/equal/greater than given degree + */ + int checkVolumeDegree(Dart d, unsigned int volDeg); + // TODO a mettre en algo /** * check if the mesh is triangular or not diff --git a/include/Topology/gmap/gmap2.hpp b/include/Topology/gmap/gmap2.hpp index 747212f2..602e378d 100644 --- a/include/Topology/gmap/gmap2.hpp +++ b/include/Topology/gmap/gmap2.hpp @@ -187,6 +187,12 @@ inline unsigned int GMap2::faceDegree(Dart d) return GMap1::cycleDegree(d) ; } +inline int GMap2::checkFaceDegree(Dart d, unsigned int le) +{ + return GMap1::checkCycleDegree(d,le) ; +} + + inline bool GMap2::sameVolume(Dart d, Dart e) { return sameOrientedVolume(d, e) || sameOrientedVolume(beta2(d), e) ; diff --git a/include/Topology/gmap/gmap3.h b/include/Topology/gmap/gmap3.h index 1fa224cf..2283207b 100644 --- a/include/Topology/gmap/gmap3.h +++ b/include/Topology/gmap/gmap3.h @@ -214,6 +214,15 @@ public: */ unsigned int vertexDegree(Dart d) ; + + //! Check number of edges of the vertex 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 + */ + int checkVertexDegree(Dart d, unsigned int vd); + + //! Tell if the vertex of d is on the boundary /*! @param d a dart */ diff --git a/include/Topology/map/map1.h b/include/Topology/map/map1.h index 84ff1178..24fd801a 100644 --- a/include/Topology/map/map1.h +++ b/include/Topology/map/map1.h @@ -189,6 +189,13 @@ public: */ unsigned int cycleDegree(Dart d) ; + //! Check the Length of a cycle (its number of oriented edges) + /*! @param d a dart of the cycle + * @param degree the length to compare + * @return negative/null/positive if face degree is less/equal/greater than given degree + */ + int checkCycleDegree(Dart d, unsigned int degree) ; + /** * check if the cycle of d is a triangle * @return a boolean indicating if the cycle is a triangle diff --git a/include/Topology/map/map1.hpp b/include/Topology/map/map1.hpp index 6eafdb85..61ca6b27 100644 --- a/include/Topology/map/map1.hpp +++ b/include/Topology/map/map1.hpp @@ -231,6 +231,21 @@ inline unsigned int Map1::cycleDegree(Dart d) return count ; } + +inline int Map1::checkCycleDegree(Dart d, unsigned int degree) +{ + unsigned int count = 0 ; + Dart it = d ; + do + { + ++count ; + it = phi1(it) ; + } while ((count<=degree) && (it != d)) ; + + return count-degree; +} + + inline bool Map1::isCycleTriangle(Dart d) { return (phi1(d) != d) && (phi1(phi1(phi1(d))) == d) ; diff --git a/include/Topology/map/map2.h b/include/Topology/map/map2.h index 5ae744d3..166e9ac8 100644 --- a/include/Topology/map/map2.h +++ b/include/Topology/map/map2.h @@ -333,6 +333,13 @@ public: */ unsigned int vertexDegree(Dart d) ; + //! Check number of edges of the vertex 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 + */ + int checkVertexDegree(Dart d, unsigned int vd); + //! Tell if the vertex of d is on the boundary of the map /*! @param d a dart */ @@ -378,6 +385,13 @@ public: */ unsigned int faceDegree(Dart d) ; + //! 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 + */ + int checkFaceDegree(Dart d, unsigned int le); + /** * tell if the face of d is on the boundary of the map */ @@ -400,6 +414,13 @@ public: */ unsigned int volumeDegree(Dart d); + //! Check number of faces of the volume of d with given parameter + /*! @param d a dart + * @param vd degree to compare with + * @return negative/null/positive if volume degree is less/equal/greater than given degree + */ + int checkVolumeDegree(Dart d, unsigned int volDeg); + // TODO a mettre en algo /** * check if the mesh is triangular or not diff --git a/include/Topology/map/map2.hpp b/include/Topology/map/map2.hpp index 117dcd2e..18f5cbcb 100644 --- a/include/Topology/map/map2.hpp +++ b/include/Topology/map/map2.hpp @@ -184,6 +184,13 @@ inline unsigned int Map2::faceDegree(Dart d) return Map1::cycleDegree(d) ; } + +inline int Map2::checkFaceDegree(Dart d, unsigned int le) +{ + return Map1::checkCycleDegree(d,le) ; +} + + inline bool Map2::sameVolume(Dart d, Dart e) { return sameOrientedVolume(d, e) ; diff --git a/include/Topology/map/map3.h b/include/Topology/map/map3.h index 1f30269d..0c5cb516 100644 --- a/include/Topology/map/map3.h +++ b/include/Topology/map/map3.h @@ -301,6 +301,15 @@ public: */ unsigned int vertexDegree(Dart d) ; + + //! Check number of edges of the vertex 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 + */ + int checkVertexDegree(Dart d, unsigned int vd); + + //! Compute the number of edges of the vertex of d on the boundary /*! @param d a dart */ -- GitLab