#include "Mesh.h" #include using namespace SharpConstruct; using SharpConstruct::Optimized::Point3D; using SharpConstruct::Color; enum OptState{ DEFAULT, KEEP, DELETE, NEIGHBOR }; void Mesh::Optimize( float ) { std::vector< OptState > states( _vertex_locations.size(), DEFAULT ); //states[ _selected_vertex[ 0 ] ] = DELETE; for( unsigned i = 0; i < states.size(); ++i ) { std::set< unsigned > cons = _connected_polygon_vertices( i ); unsigned count = cons.size(); if( count <= 3 ) states[ i ] = KEEP; else { // If there are any DELETEs neighboring, mark as NEIGHBOR for( std::set< unsigned >::iterator it = cons.begin(); it != cons.end(); ++it ) { if( states[ *it ] == DELETE ) states[ i ] = NEIGHBOR; } // If it's not a NEIGHBOR, mark as DELETE if( states[ i ] == DEFAULT ) states[ i ] = DELETE; } } /*for( unsigned i = 0; i < states.size(); ++i ) { if( states[ i ] == NEIGHBOR ) { std::set< unsigned > cons( _connected_vertices( i ) ); unsigned count( 0 ); for( std::set< unsigned >::iterator it = cons.begin(); it != cons.end(); ++it ) { if( states[ *it ] == DELETE ) count++; } if( count >= 2 ) states[ i ] = DELETE; } }*/ for( unsigned i = 0; i < states.size(); ++i ) { if( states[ i ] == KEEP ) _vertex_colors[ i ] = Color( 0, 0, 1 ); if( states[ i ] == DELETE ) _vertex_colors[ i ] = Color( 1, 0, 0 ); if( states[ i ] == NEIGHBOR ) _vertex_colors[ i ] = Color( 0, 1, 0 ); } }