Fixed a function duplicated over different files

This commit is contained in:
Mael Rouxel-Labbé 2016-10-25 18:41:08 +02:00
parent 3644a91f82
commit fcdc127a08
2 changed files with 36 additions and 34 deletions

View File

@ -256,6 +256,23 @@ private:
uvmap, vimap, out); uvmap, vimap, out);
} }
/// Copy the data from two vectors to the UVmap.
template <typename VertexUVMap,
typename VertexIndexMap>
void assign_solution(const Vector& Xu,
const Vector& Xv,
const Vertex_set& vertices,
VertexUVMap uvmap,
const VertexIndexMap vimap)
{
BOOST_FOREACH(vertex_descriptor vd, vertices){
int index = get(vimap, vd);
NT u = Xu(index);
NT v = Xv(index);
put(uvmap, vd, Point_2(u, v));
}
}
// Private operations // Private operations
private: private:
/// Store the vertices and faces of the mesh in memory. /// Store the vertices and faces of the mesh in memory.
@ -1073,15 +1090,13 @@ private:
BOOST_FOREACH(vertex_descriptor vd, vertices){ BOOST_FOREACH(vertex_descriptor vd, vertices){
if(get(vpmap, vd)){ if(get(vpmap, vd)){
int index = get(vimap, vd); int index = get(vimap, vd);
std::cout << "at: " << index << " "
<< Xu[index] << " " << Xv[index] << std::endl;
CGAL_postcondition(std::abs(Xu[index] - Bu[index] ) < 1e-10); CGAL_postcondition(std::abs(Xu[index] - Bu[index] ) < 1e-10);
CGAL_postcondition(std::abs(Xv[index] - Bv[index] ) < 1e-10); CGAL_postcondition(std::abs(Xv[index] - Bv[index] ) < 1e-10);
} }
} }
) )
assign_solution<TriangleMesh>(Xu, Xv, vertices, uvmap, vimap); assign_solution(Xu, Xv, vertices, uvmap, vimap);
return status; return status;
} }

View File

@ -47,36 +47,6 @@
namespace CGAL { namespace CGAL {
/// Copy the data from two vectors to the UVmap.
template <typename TriangleMesh,
typename Vector,
typename Vertex_set,
typename VertexUVMap,
typename VertexIndexMap>
void assign_solution(const Vector& Xu,
const Vector& Xv,
const Vertex_set& vertices,
VertexUVMap uvmap,
VertexIndexMap vimap)
{
typedef Parameterizer_traits_3<TriangleMesh> Traits;
typedef typename Traits::NT NT;
typedef typename Traits::Point_2 Point_2;
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
BOOST_FOREACH(vertex_descriptor vd, vertices){
int index = get(vimap, vd);
NT u = Xu(index);
NT v = Xv(index);
// Point_2 p = get(uvmap, vd);
// std::cout << "old: " << p << " || new: " << u << " " << v << std::endl;
put(uvmap, vd, Point_2(u, v));
}
}
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
// Declaration // Declaration
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
@ -195,6 +165,23 @@ private:
out << std::endl; out << std::endl;
} }
/// Copy the data from two vectors to the UVmap.
template <typename VertexUVMap,
typename VertexIndexMap>
void assign_solution(const Vector& Xu,
const Vector& Xv,
const Vertex_set& vertices,
VertexUVMap uvmap,
const VertexIndexMap vimap)
{
BOOST_FOREACH(vertex_descriptor vd, vertices){
int index = get(vimap, vd);
NT u = Xu(index);
NT v = Xv(index);
put(uvmap, vd, Point_2(u, v));
}
}
// Private operations // Private operations
private: private:
/// Store the vertices and faces of the mesh in memory. /// Store the vertices and faces of the mesh in memory.
@ -737,7 +724,7 @@ private:
status = solve_mvc(A, Bu, Bv, Xu, Xv); status = solve_mvc(A, Bu, Bv, Xu, Xv);
// Assign the UV values // Assign the UV values
assign_solution<TriangleMesh>(Xu, Xv, vertices, uvmap, vimap); assign_solution(Xu, Xv, vertices, uvmap, vimap);
return Base::OK; return Base::OK;
} }