diff --git a/Surface_mesh_topology/doc/Surface_mesh_topology/CGAL/Path_on_surface.h b/Surface_mesh_topology/doc/Surface_mesh_topology/CGAL/Path_on_surface.h index 39ca841f152..547877d145d 100644 --- a/Surface_mesh_topology/doc/Surface_mesh_topology/CGAL/Path_on_surface.h +++ b/Surface_mesh_topology/doc/Surface_mesh_topology/CGAL/Path_on_surface.h @@ -39,7 +39,7 @@ namespace Surface_mesh_topology { /// clears this path. void clear(); - /// returns `true` iff `hd` can be added at the end of this path. If `flip` is true, `hd`'d direction is reversed before checking + /// returns `true` iff `hd` can be added at the end of this path. If `flip` is true, `hd`'s direction is reversed before checking bool can_be_pushed(halfedge_descriptor hd, bool flip=false) const; /// adds `hd` at the end of this path. If `flip` is true, the reverse of `hd` is considered. diff --git a/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h b/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h index 467d9f735a9..5154bbf9695 100644 --- a/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h +++ b/Surface_mesh_topology/include/CGAL/Curves_on_surface_topology.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { namespace Surface_mesh_topology { @@ -110,7 +111,7 @@ public: Path_on_surface compute_edgewidth(const WeightFunctor& wf) const { if (m_shortest_noncontractible_cycle==nullptr) - { m_shortest_noncontractible_cycle = new Shortest_noncontractible_cycle(m_original_map); } + { update_shortest_noncontractible_cycle_pointer(); } return m_shortest_noncontractible_cycle->compute_edgewidth(NULL, wf); } @@ -118,7 +119,7 @@ public: Path_on_surface compute_edgewidth() const { if (m_shortest_noncontractible_cycle==nullptr) - { m_shortest_noncontractible_cycle = new Shortest_noncontractible_cycle(m_original_map); } + { update_shortest_noncontractible_cycle_pointer(); } return m_shortest_noncontractible_cycle->compute_edgewidth(); } @@ -127,7 +128,7 @@ public: Path_on_surface compute_shortest_noncontractible_cycle_with_basepoint(DartHandle dh, const WeightFunctor& wf) const { if (m_shortest_noncontractible_cycle==nullptr) - { m_shortest_noncontractible_cycle = new Shortest_noncontractible_cycle(m_original_map); } + { update_shortest_noncontractible_cycle_pointer(); } return m_shortest_noncontractible_cycle->compute_cycle(dh, NULL, wf); } @@ -136,7 +137,7 @@ public: Path_on_surface compute_shortest_noncontractible_cycle_with_basepoint(DartHandle dh) const { if (m_shortest_noncontractible_cycle==nullptr) - { m_shortest_noncontractible_cycle = new Shortest_noncontractible_cycle(m_original_map); } + { update_shortest_noncontractible_cycle_pointer(); } return m_shortest_noncontractible_cycle->compute_cycle(dh); } @@ -144,27 +145,27 @@ public: Path_on_surface compute_facewidth() const { if (m_facewidth==nullptr) - { m_facewidth = new Facewidth(m_original_map); } + { update_facewidth_pointer(); } return m_facewidth->compute_facewidth(); } - void update_shortest_noncontractible_cycle_pointer() + void update_shortest_noncontractible_cycle_pointer() const { - m_shortest_noncontractible_cycle = new Shortest_noncontractible_cycle(m_original_map); + m_shortest_noncontractible_cycle = std::make_unique(m_original_map); } - void update_facewidth_pointer() + void update_facewidth_pointer() const { - m_facewidth = new Facewidth(m_original_map); + m_facewidth = std::make_unique(m_original_map); } protected: Mesh& m_original_map; mutable Gmap m_radial_map; mutable internal::Minimal_quadrangulation* m_minimal_quadrangulation; - mutable Shortest_noncontractible_cycle* m_shortest_noncontractible_cycle; - mutable Facewidth* m_facewidth; + mutable std::unique_ptr m_shortest_noncontractible_cycle; + mutable std::unique_ptr m_facewidth; typename Gmap_wrapper::Origin_to_copy_map m_origin_to_copy; typename Gmap_wrapper::Copy_to_origin_map m_copy_to_origin; }; diff --git a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Shortest_noncontractible_cycle.h b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Shortest_noncontractible_cycle.h index db05c73ab2e..464d176dbbc 100644 --- a/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Shortest_noncontractible_cycle.h +++ b/Surface_mesh_topology/include/CGAL/Surface_mesh_topology/internal/Shortest_noncontractible_cycle.h @@ -69,6 +69,7 @@ public: ~Shortest_noncontractible_cycle() { + // std::cerr << "Destructor...\n"; // For testing unique_ptr m_gmap.free_mark(m_is_hole); }