From f3de4dfe013d566fca544e14fc2945f42cd8811c Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Mon, 18 Apr 2016 10:16:14 +0200 Subject: [PATCH] Clean up --- .../Polyhedron/Scene_surface_mesh_item.cpp | 15 +- .../demo/Polyhedron/Scene_surface_mesh_item.h | 11 +- .../include/CGAL/IO/File_header_OFF.h | 3 +- .../include/CGAL/IO/File_scanner_OFF.h | 108 ++++++------ Stream_support/include/CGAL/IO/Scanner_OFF.h | 2 - .../include/CGAL/Surface_mesh/Surface_mesh.h | 160 +----------------- 6 files changed, 70 insertions(+), 229 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 7f0cc9dc8b2..d4054b12059 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -1,12 +1,14 @@ #include "Scene_surface_mesh_item.h" #include -#include - #include #include -#include +#include +#include +#include + #include +#include #include #include @@ -17,13 +19,14 @@ #include typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::halfedge_descriptor Halfedge_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; struct Face_info { - Halfedge_descriptor e[3]; + halfedge_descriptor e[3]; bool is_external; }; typedef CGAL::Triangulation_2_filtered_projection_traits_3 P_traits; -typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; +typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb1; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS; diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h index a030c68856d..c9c36c0aab1 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.h @@ -13,12 +13,11 @@ #include #include -#include #include -#include -#include -#include -#include +#include + +#include + @@ -30,9 +29,7 @@ public: typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh SMesh; - typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef boost::graph_traits::face_descriptor face_descriptor; - typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; // Takes ownership of the argument. Scene_surface_mesh_item(SMesh*); diff --git a/Stream_support/include/CGAL/IO/File_header_OFF.h b/Stream_support/include/CGAL/IO/File_header_OFF.h index c4f7f5331fd..15a56771390 100644 --- a/Stream_support/include/CGAL/IO/File_header_OFF.h +++ b/Stream_support/include/CGAL/IO/File_header_OFF.h @@ -85,8 +85,7 @@ public: bool comments() const { return ! m_no_comments; } std::size_t index_offset() const { return m_offset; } - bool has_colors() const { return m_colors; } // COFF detected. - + bool has_colors() const { return m_colors; } // COFF detected. bool has_normals() const { return m_normals;} // NOFF format. bool is_homogeneous() const { return m_tag4; } // 4OFF detected. // nOFF detected. (will not be supported). diff --git a/Stream_support/include/CGAL/IO/File_scanner_OFF.h b/Stream_support/include/CGAL/IO/File_scanner_OFF.h index 880c6cc3bd4..c69000893d4 100644 --- a/Stream_support/include/CGAL/IO/File_scanner_OFF.h +++ b/Stream_support/include/CGAL/IO/File_scanner_OFF.h @@ -539,66 +539,66 @@ public: inline CGAL::Color get_color_from_line(std::istream &is) { - std::string color_info; - bool is_float = false; + std::string color_info; + bool is_float = false; - std::string col; - //get the line content - std::getline(is, col); - //split it into strings - std::istringstream iss(col); - //holds the rgb values - int rgb[3]; - int index =0; - //split the string into numbers - while(iss>>color_info){ - //stop if comment is read - if(color_info.at(0) == '#') - break; - //detect if the value is float - for(int c = 0; c(color_info.length()); c++) - { - if(color_info.at(c) == '.') - { - is_float = true; - break; - } - } - //if the value is of float type, convert it into an int - if(is_float) - rgb[index] = (int)(atof(color_info.c_str())*255); - //else stores the value - else - rgb[index] = atoi(color_info.c_str()); + std::string col; + //get the line content + std::getline(is, col); + //split it into strings + std::istringstream iss(col); + //holds the rgb values + int rgb[3]; + int index =0; + //split the string into numbers + while(iss>>color_info){ + //stop if comment is read + if(color_info.at(0) == '#') + break; + //detect if the value is float + for(int c = 0; c(color_info.length()); c++) + { + if(color_info.at(c) == '.') + { + is_float = true; + break; + } + } + //if the value is of float type, convert it into an int + if(is_float) + rgb[index] = (int)(atof(color_info.c_str())*255); + //else stores the value + else + rgb[index] = atoi(color_info.c_str()); - index++; - } - CGAL::Color color; - //if there were only one number, fetch the color in the color map - if(index<2) - color = getIndexedColor(rgb[0]); - //else create the coor with the 3 values; - else - color = CGAL::Color(rgb[0], rgb[1], rgb[2]); - return color; + index++; + } + CGAL::Color color; + //if there were only one number, fetch the color in the color map + if(index<2) + color = getIndexedColor(rgb[0]); + //else create the coor with the 3 values; + else + color = CGAL::Color(rgb[0], rgb[1], rgb[2]); + return color; } void scan_color( unsigned char& r, unsigned char& g, unsigned char& b) { - if ( binary()) { - float fr, fg, fb; - I_Binary_read_big_endian_float32( m_in, fr); - I_Binary_read_big_endian_float32( m_in, fg); - I_Binary_read_big_endian_float32( m_in, fb); - r = (unsigned char)(fr); - g = (unsigned char)(fg); - b = (unsigned char)(fb); + if ( binary()) { + float fr, fg, fb; + I_Binary_read_big_endian_float32( m_in, fr); + I_Binary_read_big_endian_float32( m_in, fg); + I_Binary_read_big_endian_float32( m_in, fb); + r = (unsigned char)(fr); + g = (unsigned char)(fg); + b = (unsigned char)(fb); - } else { - CGAL::Color color = get_color_from_line(m_in); - r = color.red(); - g = color.green(); - b = color.blue(); - } + } else { + CGAL::Color color = get_color_from_line(m_in); + r = color.red(); + g = color.green(); + b = color.blue(); + } } void skip_to_next_vertex( std::size_t current_vertex); diff --git a/Stream_support/include/CGAL/IO/Scanner_OFF.h b/Stream_support/include/CGAL/IO/Scanner_OFF.h index 3401d92f070..5f85cc96d63 100644 --- a/Stream_support/include/CGAL/IO/Scanner_OFF.h +++ b/Stream_support/include/CGAL/IO/Scanner_OFF.h @@ -117,8 +117,6 @@ private: file_scan_vertex( *m_scan, m_current.first); if ( m_scan->has_normals()) file_scan_normal( *m_scan, m_current.second); - if ( m_scan->has_colors()) - file_scan_color( *m_scan, Color); m_scan->skip_to_next_vertex( m_cnt); ++m_cnt; } else diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index fda6f91c6e1..1d724cc40ae 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -45,164 +45,8 @@ #include #include #include +#include -inline CGAL::Color getIndexColor(int id) -{ - switch(id) - { - case 0: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 1: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 2: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 3: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 4: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 5: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 6: return CGAL::Color(.7*255, .15*255, .1*255, .75*255); - case 7: return CGAL::Color(.2*255, .2*255, .8*255, .75*255); - case 8: return CGAL::Color(.9*255, .6*255, .02*255, .75*255 ); - case 9: return CGAL::Color(.1*255, .3*255, .8*255, .75*255 ); - case 10: return CGAL::Color(.1*255, .7*255, .2*255, .75*255 ); - case 11: return CGAL::Color(.8*255, .8*255, .4*255, .75*255 ); - case 12: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 13: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 14: return CGAL::Color( 0*255 ,.7*255, .7*255, .75*255 ); - case 15: return CGAL::Color(.9*255, 0*255, .2*255, .75*255 ); - case 16: return CGAL::Color(.2*255, .9*255, 0*255, .75*255 ); - case 17: return CGAL::Color( 0*255, .2*255, .9*255, .75*255 ); - case 18: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 19: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 20: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 21: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 22: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 23: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 24: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 25: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 26: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 27: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 28: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 29: return CGAL::Color(.7*255, .5*255, .2*255, .75*255 ); - case 30: return CGAL::Color(.7*255, .5*255, .2*255, .75*255 ); - case 31: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 32: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 33: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 34: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 35: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 36: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 37: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 38: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 39: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 40: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 41: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 42: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 43: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 44: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 45: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 46: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 47: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 48: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 49: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 50: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 51: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 52: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 53: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 54: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 55: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 56: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 57: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 58: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 59: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 60: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 61: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 62: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 63: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 64: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 65: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 66: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 67: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 68: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 69: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 70: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 71: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 72: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 73: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 74: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 75: return CGAL::Color(1.0*255, 1.0*255, 1.0*255, .75*255); - case 76: return CGAL::Color(.05*255, .3*255, .1*255, .75*255 ); - case 77: return CGAL::Color(.7*255, .01*255, .1*255, .75*255 ); - case 78: return CGAL::Color(.2*255, .05*255, .6*255, .75*255 ); - case 79: return CGAL::Color(.9*255, .9*255, .02*255, .75*255 ); - case 80: return CGAL::Color(.0*255, .2*255, .4*255, .75*255 ); - case 81: return CGAL::Color(.1*255, .4*255, .4*255, .75*255 ); - case 82: return CGAL::Color(.8*255, .8*255, .8*255, .75*255 ); - case 83: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 84: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 85: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 86: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 87: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 88: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 89: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 90: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 91: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 92: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 93: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 94: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 95: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 96: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 97: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 98: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 99: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 100: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 101: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 102: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 103: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 104: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 105: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 106: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 107: return CGAL::Color(.7*255, .5*255, .2*255, .75*255 ); - case 108: return CGAL::Color(.7*255, .5*255, .2*255, .75*255 ); - case 109: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 110: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 111: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 112: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 113: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 114: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 115: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 116: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 117: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 118: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 119: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 120: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 121: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 122: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 123: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 124: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 125: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 126: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 127: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 128: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 129: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 130: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 131: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 132: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 133: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 134: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - case 135: return CGAL::Color(.7*255, .7*255, 0*255, .75*255 ); - case 136: return CGAL::Color(.7*255, 0*255, .7*255, .75*255 ); - case 137: return CGAL::Color( 0*255, .7*255, .7*255, .75*255 ); - case 138: return CGAL::Color(.9*255, 0*255, 0*255, .75*255 ); - case 139: return CGAL::Color( 0*255, .9*255, 0*255, .75*255 ); - case 140: return CGAL::Color( 0*255, 0*255, .9*255, .75*255 ); - case 141: return CGAL::Color(.75*255, .75*255, .75*255, .75*255); - case 142: return CGAL::Color(.8*255, .4*255, 0*255, .75*255 ); - case 143: return CGAL::Color(.4*255, .8*255, 0*255, .75*255 ); - case 144: return CGAL::Color( 0*255, .4*255, .8*255, .75*255 ); - case 145: return CGAL::Color( 0*255, .8*255, .4*255, .75*255 ); - case 146: return CGAL::Color(.4*255, 0*255, .8*255, .75*255 ); - case 147: return CGAL::Color(.8*255, 0*255, .4*255, .75*255 ); - default : return CGAL::Color(120,120,120); - - - } -} namespace CGAL { @@ -2711,7 +2555,7 @@ private: //------------------------------------------------------- private data CGAL::Color color; //if there were only one number, fetch the color in the color map if(index<2) - color = getIndexColor(rgb[0]); + color = getIndexedColor(rgb[0]); //else create the coor with the 3 values; else color = CGAL::Color(rgb[0], rgb[1], rgb[2]);