int main() { int n = 0,j = 0,k = 0,temp = 0; //no od inputs int a[1000] = {0,}; //storage int i,ii = 0; //itrator int iter; int min; scanf("%d",&n); int count = 0; //counter while(n--){ scanf("%d",&a[i]); if(a[i] == 0){ continue; //overwrite if zero } i++; } iter = get_elem(a); for(i=0;i<=iter;i++){ /* get minimun elem and store it a[i] */ for(j= 1;j<iter;j++){ if(a[0]>a[j]){ temp = a[0]; a[0] = a[j]; a[j] = temp; } } min = a[0]; /*cut the stick */ for(k=0;k<iter;k++){ a[k] = a[k]-min; count++; } /*printf it here*/ printf("%d\n",count); fill_hole(a,iter); iter = get_elem(a); count = 0; i=0; } return 0; }
void generate_texture_patches(UniGraph const & graph, mve::TriangleMesh::ConstPtr mesh, mve::MeshInfo const & mesh_info, std::vector<TextureView> * texture_views, Settings const & settings, std::vector<std::vector<VertexProjectionInfo> > * vertex_projection_infos, std::vector<TexturePatch::Ptr> * texture_patches) { util::WallTimer timer; mve::TriangleMesh::FaceList const & mesh_faces = mesh->get_faces(); mve::TriangleMesh::VertexList const & vertices = mesh->get_vertices(); vertex_projection_infos->resize(vertices.size()); std::size_t num_patches = 0; std::cout << "\tRunning... " << std::flush; #pragma omp parallel for schedule(dynamic) for (std::size_t i = 0; i < texture_views->size(); ++i) { std::vector<std::vector<std::size_t> > subgraphs; int const label = i + 1; graph.get_subgraphs(label, &subgraphs); TextureView * texture_view = &texture_views->at(i); texture_view->load_image(); std::list<TexturePatchCandidate> candidates; for (std::size_t j = 0; j < subgraphs.size(); ++j) { candidates.push_back(generate_candidate(label, *texture_view, subgraphs[j], mesh)); } texture_view->release_image(); /* Merge candidates which contain the same image content. */ std::list<TexturePatchCandidate>::iterator it, sit; for (it = candidates.begin(); it != candidates.end(); ++it) { for (sit = candidates.begin(); sit != candidates.end();) { Rect<int> bounding_box = sit->bounding_box; if (it != sit && bounding_box.is_inside(&it->bounding_box)) { TexturePatch::Faces & faces = it->texture_patch->get_faces(); TexturePatch::Faces & ofaces = sit->texture_patch->get_faces(); faces.insert(faces.end(), ofaces.begin(), ofaces.end()); TexturePatch::Texcoords & texcoords = it->texture_patch->get_texcoords(); TexturePatch::Texcoords & otexcoords = sit->texture_patch->get_texcoords(); math::Vec2f offset; offset[0] = sit->bounding_box.min_x - it->bounding_box.min_x; offset[1] = sit->bounding_box.min_y - it->bounding_box.min_y; for (std::size_t i = 0; i < otexcoords.size(); ++i) { texcoords.push_back(otexcoords[i] + offset); } sit = candidates.erase(sit); } else { ++sit; } } } it = candidates.begin(); for (; it != candidates.end(); ++it) { std::size_t texture_patch_id; #pragma omp critical { texture_patches->push_back(it->texture_patch); texture_patch_id = num_patches++; } std::vector<std::size_t> const & faces = it->texture_patch->get_faces(); std::vector<math::Vec2f> const & texcoords = it->texture_patch->get_texcoords(); for (std::size_t i = 0; i < faces.size(); ++i) { std::size_t const face_id = faces[i]; std::size_t const face_pos = face_id * 3; for (std::size_t j = 0; j < 3; ++j) { std::size_t const vertex_id = mesh_faces[face_pos + j]; math::Vec2f const projection = texcoords[i * 3 + j]; VertexProjectionInfo info = {texture_patch_id, projection, {face_id}}; #pragma omp critical vertex_projection_infos->at(vertex_id).push_back(info); } } } } merge_vertex_projection_infos(vertex_projection_infos); { std::vector<std::size_t> unseen_faces; std::vector<std::vector<std::size_t> > subgraphs; graph.get_subgraphs(0, &subgraphs); #pragma omp parallel for schedule(dynamic) for (std::size_t i = 0; i < subgraphs.size(); ++i) { std::vector<std::size_t> const & subgraph = subgraphs[i]; bool success = false; if (settings.hole_filling) { success = fill_hole(subgraph, graph, mesh, mesh_info, vertex_projection_infos, texture_patches); } if (success) { num_patches += 1; } else { if (settings.keep_unseen_faces) { #pragma omp critical unseen_faces.insert(unseen_faces.end(), subgraph.begin(), subgraph.end()); } } } if (!unseen_faces.empty()) { mve::ByteImage::Ptr image = mve::ByteImage::create(3, 3, 3); std::vector<math::Vec2f> texcoords; for (std::size_t i = 0; i < unseen_faces.size(); ++i) { math::Vec2f projections[] = {{2.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 2.0f}}; texcoords.insert(texcoords.end(), &projections[0], &projections[3]); } TexturePatch::Ptr texture_patch = TexturePatch::create(0, unseen_faces, texcoords, image); texture_patches->push_back(texture_patch); std::size_t texture_patch_id = texture_patches->size() - 1; for (std::size_t i = 0; i < unseen_faces.size(); ++i) { std::size_t const face_id = unseen_faces[i]; std::size_t const face_pos = face_id * 3; for (std::size_t j = 0; j < 3; ++j) { std::size_t const vertex_id = mesh_faces[face_pos + j]; math::Vec2f const projection = texcoords[i * 3 + j]; VertexProjectionInfo info = {texture_patch_id, projection, {face_id}}; #pragma omp critical vertex_projection_infos->at(vertex_id).push_back(info); } } } } merge_vertex_projection_infos(vertex_projection_infos); std::cout << "done. (Took " << timer.get_elapsed_sec() << "s)" << std::endl; std::cout << "\t" << num_patches << " texture patches." << std::endl; }