This commit is contained in:
Maxime Gimeno 2016-04-18 10:16:14 +02:00
parent 827adf63b8
commit f3de4dfe01
6 changed files with 70 additions and 229 deletions

View File

@ -1,12 +1,14 @@
#include "Scene_surface_mesh_item.h"
#include <queue>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <boost/graph/properties.hpp>
#include <boost/graph/graph_traits.hpp>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <boost/container/flat_map.hpp>
#include <CGAL/boost/graph/properties_Surface_mesh.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>
@ -17,13 +19,14 @@
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::halfedge_descriptor Halfedge_descriptor;
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::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<Scene_surface_mesh_item::Kernel> P_traits;
typedef CGAL::Triangulation_vertex_base_with_info_2<Halfedge_descriptor,P_traits> Vb;
typedef CGAL::Triangulation_vertex_base_with_info_2<halfedge_descriptor,P_traits> Vb;
typedef CGAL::Triangulation_face_base_with_info_2<Face_info, P_traits > Fb1;
typedef CGAL::Constrained_triangulation_face_base_2<P_traits, Fb1> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;

View File

@ -13,12 +13,11 @@
#include <boost/scoped_ptr.hpp>
#include <boost/array.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <boost/container/flat_map.hpp>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
@ -30,9 +29,7 @@ public:
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> SMesh;
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<SMesh>::halfedge_descriptor halfedge_descriptor;
// Takes ownership of the argument.
Scene_surface_mesh_item(SMesh*);

View File

@ -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).

View File

@ -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<static_cast<int>(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<static_cast<int>(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);

View File

@ -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

View File

@ -45,164 +45,8 @@
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/Euler_operations.h>
#include <CGAL/IO/File_scanner_OFF.h>
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]);