forked from swayfreeda/ImageBasedModellingEduV1.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexturing.h
executable file
·123 lines (102 loc) · 3.83 KB
/
texturing.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright (C) 2015, Nils Moehrle
* TU Darmstadt - Graphics, Capture and Massively Parallel Computing
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD 3-Clause license. See the LICENSE.txt file for details.
*/
#ifndef TEX_TEXTURING_HEADER
#define TEX_TEXTURING_HEADER
#include <vector>
#include "core/mesh.h"
#include "core/mesh_info.h"
#include "./3rdParty/mrf/graph.h"
#include "defines.h"
#include "settings.h"
#include "obj_model.h"
#include "uni_graph.h"
#include "texture_view.h"
#include "texture_patch.h"
#include "texture_atlas.h"
#include "sparse_table.h"
#include "seam_leveling.h"
typedef SparseTable<std::uint32_t, std::uint16_t, float> ST;
TEX_NAMESPACE_BEGIN
typedef std::vector<TextureView> TextureViews;
typedef std::vector<TexturePatch::Ptr> TexturePatches;
typedef std::vector<TextureAtlas::Ptr> TextureAtlases;
typedef ObjModel Model;
typedef UniGraph Graph;
typedef ST DataCosts;
typedef std::vector<std::vector<VertexProjectionInfo> > VertexProjectionInfos;
/**
* prepares the mesh for texturing
* -removes duplicated faces
* -ensures normals (face and vertex)
*/
void
prepare_mesh(core::VertexInfoList::Ptr vertex_infos, core::TriangleMesh::Ptr mesh);
/**
* Generates TextureViews from the in_scene.
*/
void
generate_texture_views(std::string in_scene, TextureViews * texture_views);
/**
* Builds up the meshes face adjacency graph using the vertex_infos
*/
void
build_adjacency_graph(core::TriangleMesh::ConstPtr mesh,
core::VertexInfoList::ConstPtr vertex_infos, UniGraph * graph);
/**
* Calculates the data costs for each face and texture view combination,
* if the face is visible within the texture view.
*/
void
calculate_data_costs(core::TriangleMesh::ConstPtr mesh,
TextureViews * texture_views, Settings const & settings, ST * data_costs);
/**
* Runs the view selection procedure and saves the labeling in the graph
*/
void
view_selection(ST const & data_costs, UniGraph * graph, Settings const & settings);
/**
* \decription Generates texture patches using the graph to determine adjacent faces with the same label.
* @param graph -- uniongraph with labels
* @param mesh -- triangle mesh
* @param vertex_infos -- vertex infos (vertex neighbours and facet neighbours)
* @param texture_views -- (texture views)
* @param vertex_projection_infos --
* @param texture_patches --
*/
void generate_texture_patches(UniGraph const & graph,
core::TriangleMesh::ConstPtr mesh,
core::VertexInfoList::ConstPtr vertex_infos,
TextureViews * texture_views,
VertexProjectionInfos * vertex_projection_infos,
TexturePatches * texture_patches);
/**
* Runs the seam leveling procedure proposed by Ivanov and Lempitsky
* [<A HREF="https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&sqi=2&ved=0CC8QFjAA&url=http%3A%2F%2Fwww.robots.ox.ac.uk%2F~vilem%2FSeamlessMosaicing.pdf&ei=_ZbvUvSZIaPa4ASi7IGAAg&usg=AFQjCNGd4x5HnMMR68Sn2V5dPgmqJWErCA&sig2=4j47bXgovw-uks9LBGl_sA">Seamless mosaicing of image-based texture maps</A>]
*/
void
global_seam_leveling(UniGraph const & graph, core::TriangleMesh::ConstPtr mesh,
core::VertexInfoList::ConstPtr vertex_infos,
VertexProjectionInfos const & vertex_projection_infos,
TexturePatches * texture_patches);
void
local_seam_leveling(UniGraph const & graph, core::TriangleMesh::ConstPtr mesh,
VertexProjectionInfos const & vertex_projection_infos,
TexturePatches * texture_patches);
void
generate_texture_atlases(TexturePatches * texture_patches,
TextureAtlases * texture_atlases);
/**
* Builds up an model for the mesh by constructing materials and
* texture atlases form the texture_patches
*/
void
build_model(core::TriangleMesh::ConstPtr mesh,
TextureAtlases const & texture_atlas, Model * model);
TEX_NAMESPACE_END
#endif /* TEX_TEXTURING_HEADER */