diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/constraints_map.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/constraints_map.h new file mode 100644 index 00000000000..0005d5fbc50 --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/constraints_map.h @@ -0,0 +1,40 @@ +#ifndef CGAL_POLYGON_MESH_PROCESSING_CONSTRAINTS_MAP_H +#define CGAL_POLYGON_MESH_PROCESSING_CONSTRAINTS_MAP_H + +#include + +namespace CGAL { +namespace Polygon_mesh_processing { +namespace internal { + + template + struct Constrained_vertices_map + { + typedef Descriptor key_type; + typedef bool value_type; + typedef value_type& reference; + typedef boost::read_write_property_map_tag category; + + // to change this to boost::shared_ptr + std::shared_ptr> const_things; + + public: + Constrained_vertices_map() : const_things(new std::set) {} + + friend bool get(const Constrained_vertices_map& map, const key_type& d) + { + typename std::set::iterator it = map.const_things->find(d); + return it != map.const_things->end() ? true : false; + } + + friend void put(Constrained_vertices_map& map, const key_type& d) + { + map.const_things->insert(d); + } + }; + +} +} +} + +#endif //CGAL_POLYGON_MESH_PROCESSING_CONSTRAINTS_MAP_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h index 6688e1105d0..2713d910890 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/curvature_flow_impl.h @@ -18,8 +18,8 @@ // // Author(s) : Konstantinos Katrioplas (konst.katrioplas@gmail.com) -#ifndef CURVATURE_FLOW_IMPL_H -#define CURVATURE_FLOW_IMPL_H +#ifndef CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_EXPLICIT_IMPL_H +#define CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_EXPLICIT_IMPL_H #include #include @@ -37,13 +37,9 @@ namespace CGAL { - namespace Polygon_mesh_processing { - namespace internal { - - template > class Cotangent_weight : CotangentValue @@ -317,4 +313,4 @@ private: -#endif // CURVATURE_FLOW_IMPL_H +#endif // CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_EXPLICIT_IMPL_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h index b828a28c064..c42990c91a9 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/mesh_smoothing_impl.h @@ -18,8 +18,8 @@ // // Author(s) : Konstantinos Katrioplas (konst.katrioplas@gmail.com) -#ifndef CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_IMPL_H -#define CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_IMPL_H +#ifndef CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_IMPL_H +#define CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_IMPL_H #include #include @@ -44,32 +44,6 @@ namespace CGAL { namespace Polygon_mesh_processing { namespace internal { -template -struct Constrained_vertices_map -{ - typedef Descriptor key_type; - typedef bool value_type; - typedef value_type& reference; - typedef boost::read_write_property_map_tag category; - - // to change this to boost::shared_ptr - std::shared_ptr> const_things; - -public: - Constrained_vertices_map() : const_things(new std::set) {} - - friend bool get(const Constrained_vertices_map& map, const key_type& d) - { - typename std::set::iterator it = map.const_things->find(d); - return it != map.const_things->end() ? true : false; - } - - friend void put(Constrained_vertices_map& map, const key_type& d) - { - map.const_things->insert(d); - } -}; - template class Compatible_remesher { @@ -106,8 +80,6 @@ public: { check_vertex_range(face_range); - //check_constraints(); - BOOST_FOREACH(face_descriptor f, face_range) input_triangles_.push_back(triangle(f)); @@ -681,11 +653,11 @@ private: template void check_vertex_range(const FaceRange& face_range) { - BOOST_FOREACH(face_descriptor f, face_range) - { - BOOST_FOREACH(vertex_descriptor v, vertices_around_face(halfedge(f, mesh_), mesh_)) - vrange_.insert(v); - } + BOOST_FOREACH(face_descriptor f, face_range) + { + BOOST_FOREACH(vertex_descriptor v, vertices_around_face(halfedge(f, mesh_), mesh_)) + vrange_.insert(v); + } } private: @@ -710,4 +682,4 @@ private: -#endif // CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_IMPL_H +#endif // CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_IMPL_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/modified_curvature_flow_impl.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/modified_curvature_flow_impl.h index 7b5dc4f1e5e..71518d561d1 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/modified_curvature_flow_impl.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Smoothing/modified_curvature_flow_impl.h @@ -18,8 +18,8 @@ // // Author(s) : Konstantinos Katrioplas (konst.katrioplas@gmail.com) -#ifndef SMOOTHING_H -#define SMOOTHING_H +#ifndef CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_IMPL_H +#define CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_IMPL_H #include #include @@ -118,35 +118,6 @@ struct Incident_area }; -template -struct Constrained_vertices_map -{ - typedef Descriptor key_type; - typedef bool value_type; - typedef value_type& reference; - typedef boost::read_write_property_map_tag category; - - // to change this to boost::shared_ptr - std::shared_ptr> const_things; - -public: - Constrained_vertices_map() : const_things(new std::set) {} - - friend bool get(const Constrained_vertices_map& map, const key_type& d) - { - typename std::set::iterator it = map.const_things->find(d); - return it != map.const_things->end() ? true : false; - } - - friend void put(Constrained_vertices_map& map, const key_type& d) - { - map.const_things->insert(d); - } -}; - - - - template(vertices(mesh).size())) {} -/* - void init_smoothing() + + + template + void init_smoothing(const FaceRange& face_range) { - //check_vertex_range(face_range); - - //check_constraints(); - + check_face_range(face_range); } -*/ + void setup_system(Eigen_matrix& A, Eigen_matrix& L, Eigen_matrix& D, Eigen_vector& bx, Eigen_vector& by, Eigen_vector& bz, @@ -271,7 +241,8 @@ public: tripletList.reserve(8 * nb_vert_); // todo: calculate exactly how many non zero entries there will be. - for(face_descriptor f : faces(mesh_)) + //for(face_descriptor f : faces(mesh_)) + for(face_descriptor f : frange_) { for(halfedge_descriptor hi : halfedges_around_face(halfedge(f, mesh_), mesh_)) { @@ -323,7 +294,7 @@ private: { //D.resize(nb_vert_, nb_vert_); - for(face_descriptor f : faces(mesh_)) + for(face_descriptor f : frange_) { double area = face_area(f, mesh_); for(vertex_descriptor v : vertices_around_face(halfedge(f, mesh_), mesh_)) @@ -546,18 +517,15 @@ private: } */ - - // to use template - void check_vertex_range(const FaceRange& face_range) + void check_face_range(const FaceRange& face_range) { + frange_.resize(faces(mesh_).size()); BOOST_FOREACH(face_descriptor f, face_range) - { - BOOST_FOREACH(vertex_descriptor v, vertices_around_face(halfedge(f, mesh_), mesh_)) - vrange.insert(v); - } + frange_.insert(f); } + private: // data members @@ -565,7 +533,7 @@ private: PolygonMesh& mesh_; VertexPointMap& vpmap_; std::size_t nb_vert_; - std::set vrange; + std::set frange_; IndexMap vimap_ = get(boost::vertex_index, mesh_); VertexConstraintMap vcmap_; Edge_cotangent_weight weight_calculator_; @@ -584,4 +552,4 @@ private: } // CGAL -#endif // SMOOTHING_H +#endif // CGAL_POLYGON_MESH_PROCESSING_CURVATURE_FLOW_IMPL_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/mesh_smoothing.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/mesh_smoothing.h index 749c36f32ca..4d5e843b89c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/mesh_smoothing.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/mesh_smoothing.h @@ -18,13 +18,14 @@ // // Author(s) : Konstantinos Katrioplas (konst.katrioplas@gmail.com) -#ifndef CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_H -#define CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_H +#ifndef CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_H +#define CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_H #include #include #include #include +#include #include #ifdef CGAL_PMP_SMOOTHING_VERBOSE @@ -339,4 +340,4 @@ void aspect_ratio_evaluation(PolygonMesh& pmesh, const char* filename) } // namespace Polygon_mesh_processing } // namespace CGAL -#endif // CGAL_POLYGON_MESH_PROCESSING_SMOOTHING_H +#endif // CGAL_POLYGON_MESH_PROCESSING_MESH_SMOOTHING_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_smoothing.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_smoothing.h index 05317b160c6..3f7b94a2666 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_smoothing.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/shape_smoothing.h @@ -18,11 +18,15 @@ // // Author(s) : Konstantinos Katrioplas (konst.katrioplas@gmail.com) +#ifndef CGAL_POLYGON_MESH_PROCESSING_SHAPE_SMOOTHING_H +#define CGAL_POLYGON_MESH_PROCESSING_sHAPE_SMOOTHING_H + #include #include #include #include #include +#include namespace CGAL { namespace Polygon_mesh_processing { @@ -242,7 +246,7 @@ void smooth_modified_curvature_flow(const FaceRange& faces, PolygonMesh& pmesh, } else { - // implicit + // implicit scheme typedef typename Eigen::VectorXd Eigen_vector; typedef typename Eigen::SparseMatrix Eigen_matrix; @@ -374,3 +378,5 @@ void solve_mcf_system(const FaceRange& faces, PolygonMesh& mesh, const double& t } //Polygon_mesh_processing } //CGAL + +#endif // CGAL_POLYGON_MESH_PROCESSING_SHAPE_SMOOTHING_H diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp index 3f0f5415a8e..7ba33f7fe6a 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp @@ -63,7 +63,11 @@ void test_implicit_constrained(const char* filename) if(z > 19) selected_vertices.insert(v); } + + #ifdef CGAL_PMP_SMOOTHING_VERBOSE std::cout<<"number of selected vertices= "<value(); - smooth_curvature_flow(pmesh, parameters::number_of_iterations(nb_iter)); + smooth_curvature_flow_explicit(faces(pmesh), pmesh, parameters::number_of_iterations(nb_iter)); poly_item->invalidateOpenGLBuffers(); poly_item->itemChanged();