From 8280eccd6aeeab9f49d92f4dac59f2a3d9774528 Mon Sep 17 00:00:00 2001 From: Samuel Hornus Date: Wed, 11 May 2011 15:01:38 +0000 Subject: [PATCH] mark functions in Triangulation_face.h as required by the Concept. Add precondition that Face be of dim strictly smaller than ambient_dim; fix bug due to this precondition, in Triangulation.h --- Triangulation/TODO | 1 + .../Triangulation_ref/TriangulationFace.tex | 4 ++- Triangulation/include/CGAL/Triangulation.h | 13 +++++++++- .../include/CGAL/Triangulation_face.h | 25 ++++++++++--------- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Triangulation/TODO b/Triangulation/TODO index 2a28283975c..f25743cd40f 100644 --- a/Triangulation/TODO +++ b/Triangulation/TODO @@ -26,6 +26,7 @@ Regular_complex Regular_triangulation *) code not done : ------------------ +/IN_SIMPLEX/IN_FULL_CELL /is_finite/! is_infinite/ flag stuff, really documented ? : is_boundary_facet diff --git a/Triangulation/doc_tex/Triangulation_ref/TriangulationFace.tex b/Triangulation/doc_tex/Triangulation_ref/TriangulationFace.tex index 0ecbd5889b7..60bad8f3621 100644 --- a/Triangulation/doc_tex/Triangulation_ref/TriangulationFace.tex +++ b/Triangulation/doc_tex/Triangulation_ref/TriangulationFace.tex @@ -60,7 +60,9 @@ of the face in the cell \ccVar.\ccc{full_cell()}. \ccPrecond $0\leq i\leq$\ccVar \ccc{Full_cell_handle}.} \ccMethod{void set_index(int i, int j);}{Sets the index of the \ccc{i}-th -vertex of the face. \ccPrecond $0\leq j\leq$\ccVar.\ccc{full_cell()->ambient_dimension()}.} +vertex of the face. +\ccPrecond $0\leq i<$\ccVar.\ccc{full_cell()->ambient_dimension()}. +\ccPrecond $0\leq j\leq$\ccVar.\ccc{full_cell()->ambient_dimension()}.} \ccSeeAlso diff --git a/Triangulation/include/CGAL/Triangulation.h b/Triangulation/include/CGAL/Triangulation.h index 2309aa24f53..5865214c7ad 100644 --- a/Triangulation/include/CGAL/Triangulation.h +++ b/Triangulation/include/CGAL/Triangulation.h @@ -909,7 +909,7 @@ Triangulation face.set_full_cell(s); int num(0); int verts(0); - for(int i = 0; i <= cur_dim; ++i) + for(int i = 0; i < cur_dim; ++i) { if( orientations_[i] == COPLANAR ) { @@ -919,6 +919,17 @@ Triangulation else face.set_index(verts++, i); } + //-- We could put if{}else{} below in the loop above, but then we would + // need to test if (verts < cur_dim) many times... we do it only once + // here: + if( orientations_[cur_dim] == COPLANAR ) + { + ++num; + facet = Facet(s, cur_dim); + } + else if( verts < cur_dim ) + face.set_index(verts, cur_dim); + //--// if( 0 == num ) { loc_type = IN_SIMPLEX; diff --git a/Triangulation/include/CGAL/Triangulation_face.h b/Triangulation/include/CGAL/Triangulation_face.h index ec3ee7c127b..6f7059c13de 100644 --- a/Triangulation/include/CGAL/Triangulation_face.h +++ b/Triangulation/include/CGAL/Triangulation_face.h @@ -28,8 +28,8 @@ class Triangulation_face { typedef typename internal::Dimen_plus_one::type Dimen_plus; public: - typedef typename TDS::Full_cell_handle Full_cell_handle; - typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Full_cell_handle Full_cell_handle; /* Concept */ + typedef typename TDS::Vertex_handle Vertex_handle; /* Concept */ typedef internal::S_or_D_array Indices; protected: @@ -37,42 +37,42 @@ protected: Indices indices_; public: - explicit Triangulation_face(Full_cell_handle s) + explicit Triangulation_face(Full_cell_handle s) /* Concept */ : full_cell_(s), indices_(s->ambient_dimension()+1) { CGAL_assertion( Full_cell_handle() != s ); clear(); } - explicit Triangulation_face(const int ambient_dim) + explicit Triangulation_face(const int ambient_dim) /* Concept */ : full_cell_(), indices_(ambient_dim+1) { clear(); } - Triangulation_face(const Triangulation_face & f) + Triangulation_face(const Triangulation_face & f) /* Concept */ : full_cell_(f.full_cell_), indices_(f.indices_) {} - int feature_dimension() const + int feature_dimension() const /* Concept */ { int i(0); while( -1 != indices_[i] ) ++i; return (i-1); } - Full_cell_handle full_cell() const + Full_cell_handle full_cell() const /* Concept */ { return full_cell_; } - int index(const int i) const + int index(const int i) const /* Concept */ { CGAL_precondition( (0 <= i) && (i <= feature_dimension()) ); return indices_[i]; } - Vertex_handle vertex(const int i) const + Vertex_handle vertex(const int i) const /* Concept */ { int j = index(i); if( j == -1 ) @@ -82,21 +82,22 @@ public: // - - - - - - - - - - - - - - - - - - UPDATE FUNCTIONS - void clear() + void clear() /* Concept */ { const int d = indices_.size(); for(int i = 0; i < d; ++i ) indices_[i] = -1; } - void set_full_cell(Full_cell_handle s) + void set_full_cell(Full_cell_handle s) /* Concept */ { CGAL_precondition( Full_cell_handle() != s ); full_cell_ = s; } - void set_index(const int i, const int idx) + void set_index(const int i, const int idx) /* Concept */ { + CGAL_precondition( (0 <= i) && ((size_t)i+1 < indices_.size()) ); CGAL_precondition( (0 <= idx) && ((size_t)idx < indices_.size()) ); indices_[i] = idx; }