void triangulate_visitor::do_visit( mesh_model_t& model, shape_t& shape, mesh_model_t& new_model, shape_t& new_shape) { // copy attributes new_shape.attributes().point() = shape.attributes().point(); new_shape.attributes().constant() = shape.attributes().constant(); new_shape.attributes().vertex() = attribute_table_t::create_empty_with_same_attributes( shape.attributes().vertex()); new_shape.attributes().primitive() = attribute_table_t::create_empty_with_same_attributes( shape.attributes().primitive()); arrays::const_array_ref_t<math::point3f_t> points( shape.attributes().point().const_array( g_P_name)); arrays::const_array_ref_t<boost::uint32_t> verts_per_face( model.const_verts_per_face_array()); arrays::const_array_ref_t<boost::uint32_t> face_vert_indices( model.const_face_vert_indices_array()); boost::uint32_t face_start_index = 0; for( int i = 0, e = model.num_faces(); i < e; ++i) { boost::uint32_t num_verts = verts_per_face[i]; if( num_verts == 3) copy_face( model, shape, i, face_start_index, new_model, new_shape); else { if( num_verts == 4) { if( keep_quads_) copy_face( model, shape, i, face_start_index, new_model, new_shape); else triangulate_quad( model, shape, i, face_start_index, new_model, new_shape); } else { // TODO: triangulate polygon here throw core::not_implemented(); } } face_start_index += num_verts; } shape.swap( new_shape); throw core::not_implemented(); }