From cd704b9cda6f3d60f4926f1176171e6957f6f8af Mon Sep 17 00:00:00 2001 From: Peter Hachenberger Date: Tue, 7 Mar 2006 19:48:46 +0000 Subject: [PATCH] changes according to Ralf Osbild: The optional messages (verbose) were improved in both files: OFF_to_nef_3.h vertex_cycle_to_nef_3.h Correction in OFF_to_nef_3.h: old: V.reserve(NOI); new: V_f.reserve(NOI); Changes in vertex_cycle_to_nef_3.h The meaning of the parameter 'normal' is now less mandatory. Because of this, the structure of the funtion body slightly changed. --- .../CGAL/Nef_3/vertex_cycle_to_nef_3.h | 63 +++++++------------ Nef_3/include/CGAL/OFF_to_nef_3.h | 20 ++---- 2 files changed, 30 insertions(+), 53 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h b/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h index e65871aa718..1b8581eecc4 100644 --- a/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h +++ b/Nef_3/include/CGAL/Nef_3/vertex_cycle_to_nef_3.h @@ -100,7 +100,7 @@ bool projected_vertex_cycle_to_nef_3 (typename Nef_3::SNC_structure &snc, if ( v_it == v_last ) break; // while-end if ( *v_pred_it == *v_it ) continue ; // no self-loops ctp.insert_constraint (*v_pred_it, *v_it); - if ( ctp.number_of_vertices() != nov ) break; // error + if ( ctp.number_of_vertices() != nov ) break; // constraints intersect } if ( v_it == v_last && *v_pred_it != *v_first) // no self-loops { ctp.insert_constraint (*v_pred_it, *v_first); @@ -109,14 +109,6 @@ bool projected_vertex_cycle_to_nef_3 (typename Nef_3::SNC_structure &snc, // assertion if ( ctp.number_of_vertices() != nov ) { ostr << " -> Vertex cycle is not simple; edges intersect."; - /* old - if (verb) - { std::cerr << "\n" << __FILE__ << ", line " << __LINE__ - << ": assertion violation: vertex cycle is not simple!" - << " (edges intersect)" - << std::endl; - } - */ return false; } CGAL_assertion (ctp.is_valid()); @@ -229,18 +221,6 @@ bool projected_vertex_cycle_to_nef_3 (typename Nef_3::SNC_structure &snc, } while (t_vh != t_vh_0) ; // do-while ends -#ifdef CGAL_NEF_VERTEX_CYCLE_INFO - { // test information - int count = 0; - for (typename CTP::Subconstraint_iterator scit = ctp.subconstraints_begin(); - scit != ctp.subconstraints_end(); ++scit) ++count; - std::cout << "The number of resulting constrained edges is " - << count << "\n" - << "number of vertices= " << ctp.number_of_vertices() << "\n" - << "number of faces= " << ctp.number_of_faces() << "\n"; - } -#endif - return true; } @@ -286,13 +266,13 @@ typedef CGAL::Constrained_triangulation_plus_2 YZ_tri_plus; std::ostringstream ostr; if ( normal == NULL_VECTOR ) - { // assertion violation - // This case can occur if vertex cycle is not simple! - is_nef = false; - ostr << " -> normal == NULL_VECTOR."; + { // report it + ostr << " -> function parameter 'normal' is NULL_VECTOR" + << " (this can be a symptom of an error)."; } - else - { // direction of projection? + + if ( normal != NULL_VECTOR ) + { // projection depending on normal vector direc='z'; if ( CGAL::abs(normal.x()) > CGAL::abs(normal.y()) ) { if ( CGAL::abs(normal.x()) > CGAL::abs(normal.z()) ) direc='x'; @@ -303,6 +283,7 @@ typedef CGAL::Constrained_triangulation_plus_2 YZ_tri_plus; // project and triangulate vertices, // convert result to Nef polyhedron + ostr << " Direction of projection is '" << direc << "'."; if ( direc == 'x' ) { is_nef = projected_vertex_cycle_to_nef_3 ( snc, v_first, v_last, ostr); @@ -316,29 +297,33 @@ typedef CGAL::Constrained_triangulation_plus_2 YZ_tri_plus; is_nef = projected_vertex_cycle_to_nef_3 ( snc, v_first, v_last, ostr); } + } - // if input data is corrupted, try again - if ( !is_nef && direc != 'x' && normal.x() != 0 ) - { is_nef = projected_vertex_cycle_to_nef_3 ( + if ( !is_nef ) + { // if conversion is unsuccessful so far, try another projection + if ( !is_nef && direc != 'x' ) + { ostr << " Now, direction of projection is 'x'."; + is_nef = projected_vertex_cycle_to_nef_3 ( snc, v_first, v_last, ostr); } - if ( !is_nef && direc != 'y' && normal.y() != 0 ) - { is_nef = projected_vertex_cycle_to_nef_3 ( + if ( !is_nef && direc != 'y' ) + { ostr << " Now, direction of projection is 'y'."; + is_nef = projected_vertex_cycle_to_nef_3 ( snc, v_first, v_last, ostr); } - if ( !is_nef && direc != 'z' && normal.z() != 0 ) - { is_nef = projected_vertex_cycle_to_nef_3 ( + if ( !is_nef && direc != 'z' ) + { ostr << " Now, direction of projection is 'z'."; + is_nef = projected_vertex_cycle_to_nef_3 ( snc, v_first, v_last, ostr); } } - // convertion impossible? + // no successful conversion? if ( !is_nef && verb ) - { // TO DO + Fehlermeldungsstring - std::cerr << "\n" << __FILE__ << ", line " << __LINE__ - << ": error history:" + { std::cerr << "\nConversion from vertex cycle to Nef_polyhedron_3" + << " was not successful. Error history:" << ostr.str().c_str() - << " -> Empty Nef_polyhedron_3 constructed." << std::endl; + << " Finally, empty Nef_polyhedron_3 was constructed." << std::endl; } return is_nef; diff --git a/Nef_3/include/CGAL/OFF_to_nef_3.h b/Nef_3/include/CGAL/OFF_to_nef_3.h index a865f01e6bf..9f46306f4ff 100644 --- a/Nef_3/include/CGAL/OFF_to_nef_3.h +++ b/Nef_3/include/CGAL/OFF_to_nef_3.h @@ -19,7 +19,6 @@ #include // --- begin preliminary number type converter ----------------- -// --- (to be excluded some day?) ------------------------------ #ifndef NUMBER_TYPE_CONVERTER_NEF_3_H #define NUMBER_TYPE_CONVERTER_NEF_3_H @@ -164,7 +163,7 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) Scan_point_set V_f_scan; V_f_scan.reserve(NOI); Point_set V_f; - V.reserve(NOI); + V_f.reserve(NOI); Scan_index_it ind_it = f_it->begin(); for (jdx=0; ind_it != f_it->end(); ++ind_it, ++jdx) @@ -177,6 +176,7 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) NOI = jdx; bool is_nef = false; + CGAL_assertion_msg( V_f.size() >= 1 || !verb, "empty vertex cycle"); if ( V_f.size() >= 1 ) { // compute Newell vector Scan_vector normal; @@ -189,20 +189,12 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) is_nef = true; } } - else - { if (verb) - { std::cerr << "\n" << __FILE__ << ", line " << __LINE__ - << ": error: -> Empty vertex cycle." - << std::endl; - } - } if ( !is_nef ) { ++discarded_facets; if (verb) - { std::cerr << "(Within context:)" - << " Discard input facet " << (idx+1) - << " (numbered from 1)." + { std::cerr << "Hence, discard input facet " << (idx+1) + << " (enumerated beginning with 1)." << " Check semantics!\n" << std::endl; } } @@ -210,7 +202,7 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) #ifdef CGAL_NEF_OFF_TO_NEF_TIMER t_convert.stop(); - std::cout << "time conversion: " << t_convert.time()<< std::endl; + std::cout << "time (conversion): " << t_convert.time()<< std::endl; #endif // union of queue entries @@ -230,7 +222,7 @@ OFF_to_nef_3 (std::istream &i_st, Nef_3 &nef_union, bool verb=false) #ifdef CGAL_NEF_OFF_TO_NEF_TIMER t_union.stop(); - std::cout << "time union: " << t_union.time() << "\n" << std::endl; + std::cout << "time (union): " << t_union.time() << "\n" << std::endl; #endif // return values