Cleaned cout/cerr ouput

This commit is contained in:
Mael Rouxel-Labbé 2017-01-20 12:40:15 +01:00
parent 9c2c6b9f50
commit c05a690449
9 changed files with 12 additions and 128 deletions

View File

@ -885,24 +885,22 @@ public:
{
std::pair<TM_edge_descriptor, bool> tmed = CGAL::edge(tmvd_s, tmvd_t, tm);
if(!tmed.second) {
std::cout << "was ignored because it is not a valid edge of the mesh (Warning!)" << std::endl;
std::cerr << "Warning: Ignored a constraint because it is not a valid edge of the mesh" << std::endl;
return false;
}
if(!is_border(tmed.first, tm)) { // ignore seams that are also a border edge
if(get(sem, tmed.first) == true) {
std::cout << "was ignored because it is already marked as a seam (Warning!)" << std::endl;
std::cerr << "Warning: Ignored a constraint because it is already marked as a seam" << std::endl;
return false;
}
std::cout << "was added to the seam mesh" << std::endl;
put(sem, tmed.first, true);
put(svm, tmvd_s, true);
put(svm, tmvd_t, true);
++number_of_seams;
} else {
std::cout << "was ignored because it is on the border of the mesh (Warning!)" << std::endl;
std::cerr << "Warning: Ignored a constraint because it is on the border of the mesh" << std::endl;
return false;
}
@ -960,7 +958,6 @@ public:
assert(s < tmvds.size() && t < tmvds.size());
TM_vertex_descriptor tmvd_s = tmvds[s], tmvd_t = tmvds[t];
std::cout << "Seam " << s << " " << t << " ";
if(!add_seam(tmvd_s, tmvd_t))
continue;

View File

@ -90,7 +90,6 @@ int main(int argc, char * argv[])
// Add the seams to the seam mesh
BOOST_FOREACH(SM_edge_descriptor e, seam_edges) {
std::cout << "Seam " << source(e, sm) << " " << target(e, sm) << " ";
mesh.add_seam(source(e, sm), target(e, sm));
}
}

View File

@ -118,7 +118,6 @@ int main(int argc, char * argv[])
// Add the seams to the seam mesh
BOOST_FOREACH(SM_edge_descriptor e, seam_edges_A) {
std::cout << "Seam " << source(e, sm_A) << " " << target(e, sm_A) << " ";
mesh_A.add_seam(source(e, sm_A), target(e, sm_A));
}
}
@ -188,7 +187,6 @@ int main(int argc, char * argv[])
// Add the seams to the seam mesh
BOOST_FOREACH(SM_edge_descriptor e, seam_edges_B) {
std::cout << "Seam " << source(e, sm_B) << " " << target(e, sm_B) << " ";
mesh_B.add_seam(source(e, sm_B), target(e, sm_B));
}
}

View File

@ -263,7 +263,6 @@ private:
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(fc));
std::cout << vertices.size() << " vertices & " << faces.size() << " faces" << std::endl;
if (vertices.empty() || faces.empty())
return ERROR_EMPTY_MESH;
@ -304,7 +303,6 @@ private:
status = lscm_parameterizer.parameterize(mesh, bhd, uvmap, vimap, vpmap);
}
std::cout << "Computed initial parameterization" << std::endl;
return status;
}
@ -454,7 +452,6 @@ private:
return ERROR_NON_TRIANGULAR_MESH;
// Set w_ii in matrix
// std::cout << "setting wii at " << i << " : " << w_ii << std::endl;
A.set_coef(i, i, w_ii, true /*new*/);
return OK;
}
@ -482,7 +479,6 @@ private:
return status;
} else { // fixed vertices
int index = get(vimap, vd);
std::cout << index << " is fixed in A " << std::endl;
A.set_coef(index, index, 1, true /*new*/);
++count;
}
@ -506,9 +502,6 @@ private:
if(root_n > 2)
roots.push_back(r3);
// std::cout << "coeffs: " << a3 << " " << a2 << " " << a1 << " " << a0 << std::endl;
// std::cout << root_n << " roots: " << r1 << " " << r2 << " " << r3 << std::endl;
return roots.size();
}
@ -551,7 +544,6 @@ private:
for(std::size_t i=0; i<ak_roots.size(); i++)
{
roots.push_back(ak_roots[i].first.to_double());
std::cout << CGAL::to_double(ak_roots[i].first) << std::endl;
}
return roots.size();
@ -599,32 +591,24 @@ private:
Polynomial_2 pol1 = C1q * x + 2 * m_lambda * x * ( x*x + y*y - 1) - C2q;
Polynomial_2 pol2 = C1q * y + 2 * m_lambda * y * ( x*x + y*y - 1) - C3q;
std::cout << "init" << std::endl;
std::cout << "pol1: " << pol1 << std::endl << "pol2: " << pol2 << std::endl;
CGAL_precondition(is_square_free_2(pol1));
CGAL_precondition(is_square_free_2(pol2));
if(!is_coprime_2(pol1, pol2)) {
std::cout << "not coprime" << std::endl;
CGAL_assertion(false); // @todo handle that case
Polynomial_2 g, q1, q2;
make_coprime_2(pol1, pol2, g, q1, q2);
std::cout << "g: " << g << std::endl;
pol1 = q1;
pol2 = q2;
}
std::vector<std::pair<Algebraic_real_2, Multiplicity_type> > roots;
solve_2(pol1, pol2, std::back_inserter(roots));
std::cout << "solved with " << roots.size() << " roots." << std::endl;
for(std::size_t i=0; i<roots.size(); i++)
{
a_roots.push_back(roots[i].first.to_double().first);
b_roots.push_back(roots[i].first.to_double().second);
std::cout << CGAL::to_double(roots[i].first.to_double().first) << std::endl;
std::cout << CGAL::to_double(roots[i].first.to_double().second) << std::endl;
}
return a_roots.size();
@ -719,28 +703,11 @@ private:
NT p_diff_y = ppi.y() - ppj.y();
CGAL_precondition(p_diff_x != 0. || p_diff_y != 0.);
std::cout << "c: " << c << std::endl;
std::cout << "diff: " << diff_x << " " << diff_y << std::endl;
std::cout << "pdiff: " << p_diff_x << " " << p_diff_y << std::endl;
typedef typename boost::property_map<TriangleMesh,
boost::vertex_point_t>::const_type PPmap;
const PPmap ppmap = get(vertex_point, mesh);
std::cout << "Point_3: " << get(ppmap, source(hd, mesh)) << " || "
<< get(ppmap, target(hd, mesh)) << std::endl;
std::cout << "ADD1: " << c * ( p_diff_x*p_diff_x + p_diff_y*p_diff_y ) << std::endl;
std::cout << "ADD2: " << c * ( diff_x*p_diff_x + diff_y*p_diff_y ) << std::endl;
std::cout << "ADD3: " << c * ( diff_x*p_diff_y - diff_y*p_diff_x ) << std::endl;
C1 += c * ( p_diff_x*p_diff_x + p_diff_y*p_diff_y );
C2 += c * ( diff_x*p_diff_x + diff_y*p_diff_y );
C3 += c * ( diff_x*p_diff_y - diff_y*p_diff_x );
}
// std::cout << "C1: " << C1 << " , C2: " << C2 << " , C3: " << C3 << std::endl;
// Compute a and b
NT a = 0., b = 0.;
@ -791,8 +758,6 @@ private:
a = a_roots[ind];
b = b_roots[ind];
#endif
// std::cout << "ab: " << a << " " << b << std::endl;
}
// Update the map faces --> optimal Lt matrices
@ -959,10 +924,6 @@ private:
// cot_l * Lt_l * (xi - xj)_l
x += ct_l * ( a_l * diff_l_x + b_l * diff_l_y );
y += ct_l * ( -b_l * diff_l_x + a_l * diff_l_y );
std::cout << "akbk: " << a_k << " " << b_k << std::endl;
std::cout << "albl: " << a_l << " " << b_l << std::endl;
std::cout << "xy: " << x << " " << y << std::endl;
}
/// Compute the line i of right hand side vectors Bu and Bv
@ -1044,8 +1005,6 @@ private:
Bu.set(index, uv.x());
Bv.set(index, uv.y());
++count;
std::cout << index << " is fixed in B: ";
std::cout << uv.x() << " " << uv.y() << std::endl;
}
}
return status;
@ -1079,14 +1038,12 @@ private:
if (status != OK)
return status;
std::cout << "A, B: " << std::endl << A.eigen_object() << std::endl << Bu << std::endl << Bv << std::endl;
// Solve "A*Xu = Bu". On success, the solution is (1/Du) * Xu.
// Solve "A*Xv = Bv". On success, the solution is (1/Dv) * Xv.
NT Du, Dv;
if(!get_linear_algebra_traits().linear_solver(A, Bu, Xu, Du) ||
!get_linear_algebra_traits().linear_solver(A, Bv, Xv, Dv)) {
std::cout << "Could not solve linear system" << std::endl;
std::cerr << "Could not solve linear system" << std::endl;
status = ERROR_CANNOT_SOLVE_LINEAR_SYSTEM;
return status;
}
@ -1305,8 +1262,6 @@ public:
if(status != OK)
return status;
std::cout << "All data structures initialized" << std::endl;
// The matrix A is constant and can be initialized outside of the loop
int nbVertices = static_cast<int>(vertices.size());
Matrix A(nbVertices, nbVertices); // the constant matrix using in the linear system A*X = B
@ -1318,6 +1273,7 @@ public:
ltmap, uvmap);
NT energy_last;
std::cout << "Initial energy: " << energy_this << std::endl;
std::cout << m_iterations << " max iterations" << std::endl;
// main loop
for(unsigned int ite=1; ite<=m_iterations; ++ite)
@ -1354,7 +1310,7 @@ public:
if(!is_one_to_one_mapping(mesh, faces, uvmap)) {
// Use post processing to handle flipped elements
std::cout << "Parameterization is not valid; calling post processor" << std::endl;
std::cerr << "Parameterization is not valid; calling post processor" << std::endl;
status = post_process(mesh, vertices, faces, bhd, uvmap, vimap);
}

View File

@ -186,7 +186,6 @@ private:
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(fc));
std::cout << vertices.size() << " vertices & " << faces.size() << " faces" << std::endl;
}
/// Checks whether the polygon's border is simple.
@ -274,7 +273,6 @@ private:
typename CT::Vertex_handle vh = ct.insert(sp);
vh->info() = s;
// std::cout << "Added point: " << sp << '\n';
}
// Insert constraints (the border)
@ -283,7 +281,6 @@ private:
Point_2 sp = get(uvmap, s), tp = get(uvmap, t);
ct.insert_constraint(sp, tp);
// std::cout << "Constrained edge: " << sp << " " << tp << std::endl;
}
std::ofstream out("constrained_triangulation.cgal");
@ -450,7 +447,6 @@ private:
// if vh_i is fixed, there is nothing to do: A(i,i)=1 and A(i,j)=0 for j!=i
if(get(vpmap, vd_i))
{
// std::cout << i << " is fixed in A " << std::endl;
// @fixme unefficient: A(i,i) is written as many times as i has neighbors
A.set_coef(i, i, 1);
return;
@ -511,7 +507,6 @@ private:
// if vh_i is fixed, there is nothing to do: A(i,i)=1 and A(i,j)=0 for j!=i
if(get(vpmap, vd_i))
{
// std::cout << i << " is fixed in A " << std::endl;
// @fixme unefficient A(i,i) is written as many times as i has neighbors
A.set_coef(i, i, 1);
return;
@ -566,7 +561,6 @@ private:
// but not in 'ct'.
// Loop over the "outside" faces of ct
// std::cout << "add from ct" << std::endl;
typename CT::Finite_faces_iterator fit = ct.finite_faces_begin(),
fend = ct.finite_faces_end();
for(; fit!=fend; ++fit)
@ -578,7 +572,6 @@ private:
}
// Loop over the faces of 'mesh'
// std::cout << "add from mesh" << std::endl;
BOOST_FOREACH(face_descriptor fd, faces) {
fill_linear_system_matrix_mvc_from_mesh_face(mesh, fd, uvmap, vimap, vpmap, A);
}
@ -709,7 +702,7 @@ public:
// Not sure how to handle non-simple yet @fixme
if(!is_param_border_simple) {
std::cout << "Border is not simple!" << std::endl;
std::cerr << "Border is not simple!" << std::endl;
return ERROR_NON_CONVEX_BORDER;
}
@ -726,7 +719,7 @@ public:
// Run the MVC
parameterize_convex_hull_with_MVC(mesh, vertices, faces, ct, uvmap, vimap, vpmap);
std::cout << "End of post processing: Ok" << std::endl;
std::cout << "End of post processing" << std::endl;
return OK;
}

View File

@ -130,13 +130,6 @@ private:
return ERROR_WRONG_PARAMETER;
}
std::cout << "cones and ids" << std::endl;
typename ConeMap::const_iterator cit = cmap.begin(), cend = cmap.end();
for(; cit!=cend; ++cit) {
// std::cout << target(halfedge(cit->first,mesh), mesh.mesh())
// << " n°: " << get(vimap, cit->first) << std::endl;
}
return OK;
}
@ -159,8 +152,6 @@ private:
/// Adds a positional constraint on a vertex x_ind, so that x_ind * w = rhs.
void addConstraint(Matrix& A, Vector& B, int& id_r, int id_c, double w, Point_2 rhs) const
{
std::cout << "Constraining " << id_c << " to " << rhs << std::endl;
A.set_coef(2*id_r, 2*id_c, w, true /*new_coef*/);
A.set_coef(2*id_r + 1, 2*id_c + 1, w, true /*new_coef*/);
@ -178,8 +169,6 @@ private:
const Eigen::Matrix2d& T,
Matrix& A, Vector& B) const
{
std::cout << "transconstraints: " << s << " " << t << std::endl;
// Matlab lines are commented for comparison.
// Matlab fills together 2*x-1 and 2*x, but C++ fills 2*x and 2*x+1,
// as everything (including loops!) starts at 0 and not 1.
@ -218,8 +207,6 @@ private:
NT ang, int& current_line_id_in_A,
Matrix& A, Vector& B) const
{
std::cout << "constraining segment of length " << seam_segment.size() << std::endl;
// check that if there is a common vertex, it is at the beginning
const bool is_reversed = (seam_segment.back().first == seam_segment.back().second);
@ -227,8 +214,6 @@ private:
ang *= -1;
}
std::cout << "with angle " << ang << std::endl;
// the rotation matrix according to the angle 'ang'
Eigen::Matrix2d R;
R(0,0) = std::cos(2 * CGAL_PI / ang); R(0,1) = - std::sin(2 * CGAL_PI / ang);
@ -237,8 +222,6 @@ private:
const int s0 = is_reversed ? seam_segment.back().first : seam_segment.front().first;
const int t0 = is_reversed ? seam_segment.back().second : seam_segment.front().second;
std::cout << "s0/t0: " << s0 << " " << t0 << std::endl;
typename std::vector<std::pair<int, int> >::const_iterator it = seam_segment.begin(),
end = seam_segment.end();
@ -251,7 +234,6 @@ private:
for(; it!=end; ++it) {
const int s = it->first;
const int t = it->second;
std::cout << "v1/v2: " << s << " " << t << std::endl;
CGAL_assertion(s != t);
// sending s to t (and _not_ t to s !)
@ -286,8 +268,6 @@ private:
internal::find_start_cone(cmap, vimap, start_cone, start_cone_index);
CGAL_postcondition(start_cone != vertex_descriptor() && start_cone_index != -1);
// std::cout << "initial cone is " << start_cone << std::endl;
// parameterize the initial cone
addConstraint(A, B, current_line_id_in_A, start_cone_index,
1. /*entry in A*/, tcoords[0]);
@ -317,7 +297,6 @@ private:
const vertex_descriptor hd2_source = source(hd2, mesh);
const int hd1s_index = get(vimap, hd1_source);
const int hd2s_index = get(vimap, hd2_source);
std::cout << hd1s_index << " " << hd2s_index << std::endl;
// If orbifold type IV and it is second cone in flattening, add constraint
if(orb_type == Parallelogram && cmap.find(hd1_source) != cmap.end()
@ -354,7 +333,6 @@ private:
break;
}
std::cout << "-------------------------" << std::endl;
seam_segment.clear();
++segment_index;
}
@ -364,7 +342,6 @@ private:
CGAL_postcondition(mesh.has_on_seam(bhd) && is_border(bhd, mesh));
}
std::cout << current_line_id_in_A << " vs " << number_of_linear_constraints(mesh) << std::endl;
CGAL_postcondition(current_line_id_in_A == number_of_linear_constraints(mesh));
}
@ -385,8 +362,6 @@ private:
const Point_3& pj, int j,
const Point_3& pk, int k, Matrix& L) const
{
// std::cout << "compute mvc coef at: " << i << " " << j << " " << k << std::endl;
// For MVC, the entry of L(i,j) is - [ tan(gamma_ij/2) + tan(delta_ij)/2 ] / |ij|
// where gamma_ij and delta_ij are the angles at i around the edge ij
@ -504,7 +479,6 @@ private:
VertexUVMap uvmap,
const VertexIndexMap vimap) const
{
std::cout << "size of X: " << X.size() << std::endl;
CGAL_assertion(X.size() == static_cast<int>(2 * num_vertices(mesh)));
BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)) {
@ -528,8 +502,6 @@ private:
std::size_t n = L.column_dimension();
std::size_t big_n = n + A.row_dimension();
std::cout << "n: " << n << " and big_n: " << big_n << std::endl;
// Fill the large system M.Xf = Bf:
// ( L A' ) ( Xf ) = ( B )
// ( A 0 ) ( Xf ) = ( 0 )
@ -543,30 +515,22 @@ private:
Bf[n+i] = B[i];
}
std::cout << "filled Bf" << std::endl;
// matrix M
for(int k=0; k<L.eigen_object().outerSize(); ++k) {
for(typename Eigen::SparseMatrix<double>::InnerIterator
it(L.eigen_object(), k); it; ++it) {
M.set_coef(it.row(), it.col(), it.value(), true /*new_coef*/);
// std::cout << it.row() << " " << it.col() << " " << it.value() << '\n';
}
}
std::cout << "filled topleft of M" << std::endl;
for(int k=0; k<A.eigen_object().outerSize(); ++k) {
for(typename Eigen::SparseMatrix<double>::InnerIterator
it(A.eigen_object(), k); it; ++it) {
M.set_coef(it.col(), it.row() + n, it.value(), true /*new_coef*/); // A
M.set_coef(it.row() + n, it.col(), it.value(), true /*new_coef*/); // A'
// std::cout << it.row() << " " << it.col() << " " << it.value() << '\n';
}
}
std::cout << "Filled M and Bf" << std::endl;
#ifdef CGAL_SMP_OUTPUT_ORBIFOLD_MATRICES
std::ofstream outM("matrices/M.txt");
outM.precision(20);
@ -605,14 +569,12 @@ private:
CGAL::Timer task_timer;
task_timer.start();
std::cout << "Solving..." << std::endl;
SparseLinearAlgebraTraits_d solver;
if(!solver.linear_solver(M, Bf, Xf, D)) {
std::cout << "Could not solve linear system" << std::endl;
std::cerr << "Could not solve linear system" << std::endl;
return ERROR_CANNOT_SOLVE_LINEAR_SYSTEM;
}
CGAL_assertion(D == 1.0);
std::cout << "Solved the linear system in " << task_timer.time() << " seconds" << std::endl;
Vector X(n);
for(std::size_t i=0; i<n; ++i) {
@ -659,7 +621,6 @@ public:
VertexUVMap uvmap,
VertexIndexMap vimap) const
{
std::cout << "Flattening" << std::endl;
Error_code status;
status = check_cones(cmap);
@ -679,7 +640,6 @@ public:
AddRotationalConstraint(mesh, cmap, vimap, A, B);
#ifdef CGAL_SMP_OUTPUT_ORBIFOLD_MATRICES
std::cout << "A and B are filled" << std::endl;
std::ofstream outA("matrices/A.txt"), outB("matrices/B.txt");
for(int k=0; k<A.eigen_object().outerSize(); ++k) {
@ -714,13 +674,6 @@ public:
// compute the flattening by solving the boundary conditions
// while satisfying the convex combination property with L
std::cout << "Solving the system ";
#ifdef CGAL_SMP_USE_SPARSESUITE_SOLVERS
std::cout << "with a sparse linear solver from Sparsesuite." << std::endl;
#else
std::cout << "with a sparse linear solver from Eigen." << std::endl;
#endif
status = computeFlattening(mesh, A, B, L, uvmap, vimap);
if(status != OK)
return status;

View File

@ -210,7 +210,6 @@ bool check_input_validity(const SeamMesh& mesh,
end = cones.end();
for(; it!=end; ++it) {
if(it->second == First_unique_cone) {
std::cout << "Check cones: first at " << it->first << std::endl;
if(found_first_unique_cone) {
std::cerr << "Error: More than one 'First_unique_cone'" << std::endl;
return false;
@ -218,7 +217,6 @@ bool check_input_validity(const SeamMesh& mesh,
found_first_unique_cone = true;
}
else if(it->second == Second_unique_cone) {
std::cout << "Check cones: second at " << it->first << std::endl;
if(found_second_unique_cone) {
std::cerr << "Error: More than one 'Second_unique_cone'" << std::endl;
return false;
@ -340,7 +338,7 @@ Error_code read_cones(const TriangleMesh& pm, const char* filename,
cones.push_back(cone_index);
}
std::cout << "Cones: ";
std::cout << "Input cones: ";
for(std::size_t i=0; i<cones.size(); ++i)
std::cout << cones[i] << " ";
std::cout << std::endl;
@ -407,8 +405,6 @@ void locate_cones(const SeamMesh& mesh,
// the cones in the underlying mesh
std::size_t cvdss = cone_tm_vds.size();
std::cout << cvdss << " cones to locate" << std::endl;
for(std::size_t i=0; i<cvdss; ++i) {
TM_vertex_descriptor smvd = cone_tm_vds[i];
BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)) {
@ -420,9 +416,7 @@ void locate_cones(const SeamMesh& mesh,
ct = Second_unique_cone;
else
ct = Duplicated_cone;
std::cout << smvd << " and "
<< vd << " (" << target(halfedge(vd, mesh), mesh.mesh()) << ")"
<< " ct: " << ct << std::endl;
cones.insert(std::make_pair(vd, ct));
}
}
@ -507,8 +501,6 @@ void locate_unordered_cones(const SeamMesh& mesh,
ct = Duplicated_cone;
}
std::cout << "new cone with type: " << ct << std::endl;
cones.insert(std::make_pair(vertex_on_seam, ct));
}
}

View File

@ -41,7 +41,7 @@ class Dijkstra_end_exception : public std::exception
{
const char* what() const throw ()
{
return "Reached the target vertex";
return "Dijkstra: reached the target vertex";
}
};

View File

@ -292,10 +292,6 @@ bool is_one_to_one_mapping(const TriangleMesh& mesh,
std::ptrdiff_t cutoff = 2000;
CGAL::box_self_intersection_d(boxes_ptr.begin(), boxes_ptr.end(),
intersect_facets, cutoff);
// std::cout << boxes.size() << " boxes" << std::endl;
// std::cout << counter << " intersections" << std::endl;
return (counter == 0);
}