diff --git a/src/OpenMesh/Apps/Subdivider/adaptive_subdivider.cc b/src/OpenMesh/Apps/Subdivider/adaptive_subdivider.cc index ee23b604..b3224431 100644 --- a/src/OpenMesh/Apps/Subdivider/adaptive_subdivider.cc +++ b/src/OpenMesh/Apps/Subdivider/adaptive_subdivider.cc @@ -275,8 +275,7 @@ int main(int argc, char **argv) // MyMesh::FaceFaceIter ff_it; - double quality(0.0), face_quality, temp_quality; - int valence; + double quality(0.0); // ---------------------------------------- subdivide std::cout << "\nSubdividing...\n"; @@ -306,7 +305,7 @@ int main(int argc, char **argv) for (f_it = mesh.faces_begin(); f_it != mesh.faces_end(); ++f_it) { - if (mesh.data(*f_it).state() < target1) { + if (mesh.data(*f_it).state() < int(target1) ) { ++i; fh = *f_it; timer2.start(); @@ -317,7 +316,7 @@ int main(int argc, char **argv) for (v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it) { - if (mesh.data(*v_it).state() < target2) { + if (mesh.data(*v_it).state() < int(target2) ) { vh = *v_it; timer2.cont(); subdivider.refine(vh); @@ -355,12 +354,12 @@ int main(int argc, char **argv) // check every face for (f_it = mesh.faces_begin(); f_it != mesh.faces_end(); ++f_it) { - face_quality = 0.0; - valence = 0; + double face_quality = 0.0; + int valence = 0; for (ff_it = mesh.ff_iter(*f_it); ff_it.is_valid(); ++ff_it) { - temp_quality = OpenMesh::dot( mesh.normal(*f_it), mesh.normal(*ff_it) ); + double temp_quality = OpenMesh::dot( mesh.normal(*f_it), mesh.normal(*ff_it) ); if (temp_quality >= 1.0) temp_quality = .99; diff --git a/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc b/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc index 8509ed58..d2c67e45 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc +++ b/src/OpenMesh/Apps/VDProgMesh/Analyzer/vdpmanalyzer.cc @@ -808,19 +808,18 @@ void compute_cone_of_normals(VHierarchyNodeHandle node_handle, VHierarchyNodeHandleContainer &leaf_nodes) { - float max_angle, angle; Vec3f n, ln; VertexHandle vh = vhierarchy_.node(node_handle).vertex_handle(); VHierarchyNodeHandleContainer::iterator n_it, n_end(leaf_nodes.end()); - n = mesh_.calc_vertex_normal(vh); - max_angle = 0.0f; + n = mesh_.calc_vertex_normal(vh); + float max_angle = 0.0f; n_it = leaf_nodes.begin(); while( n_it != n_end ) { ln = vhierarchy_.node(*n_it).normal(); - angle = acosf( dot(n,ln) ); + const float angle = acosf( dot(n,ln) ); max_angle = std::max(max_angle, angle ); ++n_it; @@ -844,7 +843,6 @@ compute_screen_space_error(VHierarchyNodeHandle node_handle, VHierarchyNodeHandl Mesh::VertexHandle vh; Vec3f residual, res; Vec3f lp, tri[3]; - float min_distance; float s, t; VHierarchyNodeHandleContainer::iterator n_it, n_end(leaf_nodes.end()); @@ -855,7 +853,7 @@ compute_screen_space_error(VHierarchyNodeHandle node_handle, VHierarchyNodeHandl // compute residual of a leaf-vertex from the current mesh_ vh = vhierarchy_.node(node_handle).vertex_handle(); residual = lp - mesh_.point(vh); - min_distance = residual.length(); + float min_distance = residual.length(); for (vf_it=mesh_.vf_iter(vh); vf_it.is_valid(); ++vf_it) { @@ -912,18 +910,16 @@ compute_mue_sigma(VHierarchyNodeHandle node_handle, float ratio = std::max(1.0f, max_inner/max_cross); float whole_degree = acosf(1.0f/ratio); float mue, max_mue; - float degree; - float res_length; Vec3f res; max_mue = 0.0f; for (r_it = residuals.begin(); r_it != r_end; ++r_it) { res = *r_it; - res_length = res.length(); + float res_length = res.length(); // TODO: take care when res.length() is too small - degree = acosf(dot(vn,res) / res_length); + float degree = acosf(dot(vn,res) / res_length); if (degree < 0.0f) degree = -degree; if (degree > float(M_PI_2)) degree = float(M_PI) - degree; diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc index 76c595ee..7dc8b22f 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.cc +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.cc @@ -115,7 +115,7 @@ PolyConnectivity::FaceHandle PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size) { VertexHandle vh; - size_t i, ii, n(_vhs_size), id; + size_t i, ii, n(_vhs_size); HalfedgeHandle inner_next, inner_prev, outer_next, outer_prev, boundary_next, boundary_prev, @@ -225,7 +225,7 @@ PolyConnectivity::add_face(const VertexHandle* _vertex_handles, size_t _vhs_size assert(inner_prev.is_valid()); assert(inner_next.is_valid()); - id = 0; + size_t id = 0; if (edgeData_[i].is_new) id |= 1; if (edgeData_[ii].is_new) id |= 2; diff --git a/src/OpenMesh/Examples/Tutorial10/fill_props.hh b/src/OpenMesh/Examples/Tutorial10/fill_props.hh index 461bba8a..75bed334 100644 --- a/src/OpenMesh/Examples/Tutorial10/fill_props.hh +++ b/src/OpenMesh/Examples/Tutorial10/fill_props.hh @@ -9,13 +9,12 @@ template bool fill_props( Mesh& _m, OpenMesh::VPropHandleT _ph, bool _check=false) { - float v; static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; for(typename Mesh::VertexIter it=_m.vertices_begin(); it != _m.vertices_end(); ++it) { - v = a[it->idx()%9]; + const float v = a[it->idx()%9]; if ( _check && !(_m.property( _ph, it ) == v) ) return false; else @@ -29,13 +28,11 @@ template bool fill_props( Mesh& _m, OpenMesh::EPropHandleT _ph, bool _check=false ) { - size_t n; - bool v; for( typename Mesh::EdgeIter it=_m.edges_begin(); it != _m.edges_end(); ++it) { - n = it->idx(); - v = ((n&(n-1))==0); // true for 0,1,2,4,8,.. + const size_t n = it->idx(); + const bool v = ((n&(n-1))==0); // true for 0,1,2,4,8,.. if (_check && _m.property( _ph, it ) != v) { @@ -58,11 +55,10 @@ template bool fill_props(Mesh& _m, OpenMesh::FPropHandleT _ph, bool _check=false) { - int n; for( typename Mesh::FaceIter it=_m.faces_begin(); it != _m.faces_end(); ++it) { - n = it->idx(); + const int n = it->idx(); _m.property( _ph, it ) = int2roman(++n); } return true; @@ -73,8 +69,6 @@ template bool fill_props( Mesh& _m, OpenMesh::HPropHandleT _ph, bool _check=false) { - int n; - T v; static float a[9] = { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f }; static float b[9] = { 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f }; static float c[9] = { 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 1.1f, 2.2f }; @@ -85,11 +79,11 @@ fill_props( Mesh& _m, OpenMesh::HPropHandleT _ph, bool _check=false) for( typename Mesh::HalfedgeIter it=_m.halfedges_begin(); it != _m.halfedges_end(); ++it) { - n = it->idx(); + const int n = it->idx(); // v = it->idx()+1; // ival // v = values[n%9]; // dval - v = ((n&(n-1))==0); // bval + T v = ((n&(n-1))==0); // bval v.vec4fval[0] = a[n%9]; v.vec4fval[1] = b[n%9]; v.vec4fval[2] = c[n%9]; @@ -107,10 +101,9 @@ template bool fill_props( Mesh& _m, OpenMesh::MPropHandleT _ph, bool _check=false) { - size_t idx; for( typename Mesh::FaceIter it=_m.faces_begin(); it != _m.faces_end(); ++it) { - idx = it->idx(); + const size_t idx = it->idx(); if ( _check && _m.property( _ph )[int2roman(idx+1)] != idx ) return false; else diff --git a/src/OpenMesh/Tools/Subdivider/Adaptive/Composite/RulesT.cc b/src/OpenMesh/Tools/Subdivider/Adaptive/Composite/RulesT.cc index c5afc22c..2cc005dc 100644 --- a/src/OpenMesh/Tools/Subdivider/Adaptive/Composite/RulesT.cc +++ b/src/OpenMesh/Tools/Subdivider/Adaptive/Composite/RulesT.cc @@ -107,7 +107,7 @@ Tvv3::raise(typename M::FaceHandle& _fh, state_t _target_state) typename M::Point face_position; const typename M::Point zero_point(0.0, 0.0, 0.0); std::vector vertex_vector; - int valence(0); + // raise all adjacent vertices to level x-1 for (fv_it = Base::mesh_.fv_iter(_fh); fv_it.is_valid(); ++fv_it) { @@ -137,6 +137,8 @@ Tvv3::raise(typename M::FaceHandle& _fh, state_t _target_state) Base::mesh_.split(_fh, vh); + int valence = 0; + // calculate display position for new vertex for (vv_it = Base::mesh_.vv_iter(vh); vv_it.is_valid(); ++vv_it) { @@ -1758,7 +1760,6 @@ EVc::init_coeffs(size_t _max_valence) if (coeffs_.size() < _max_valence+1) // less than? add additional valences { const double _2pi = 2.0*M_PI; - double c; if (coeffs_.empty()) coeffs_.push_back(0.0); // dummy for invalid valences 0,1,2 @@ -1766,7 +1767,7 @@ EVc::init_coeffs(size_t _max_valence) for(size_t v=coeffs_.size(); v <= _max_valence; ++v) { // ( 3/2 + cos ( 2 PI / valence ) )� / 2 - 1 - c = 1.5 + cos( _2pi / v ); + double c = 1.5 + cos( _2pi / v ); c = c * c * 0.5 - 1.0; coeffs_.push_back(c); }