// Copyright (c) 2006 GeometryFactory (France). All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL: https://github.com/CGAL/cgal/blob/v5.2/Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/internal/Common.h $ // $Id: Common.h 6f96731 2019-10-28T09:41:51+01:00 Mael Rouxel-Labbé // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Fernando Cacciola // #ifndef CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H #define CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace CGAL { namespace Surface_mesh_simplification { template inline bool handle_assigned(Handle h) { Handle null; return h != null; } template bool handle_exists(Iterator begin, Iterator end, Handle h) { if(handle_assigned(h)) { while(begin != end) if(begin++ == h) return true; } return false; } template struct No_constrained_edge_map { typedef typename boost::graph_traits::edge_descriptor key_type; typedef bool value_type; typedef value_type reference; typedef boost::readable_property_map_tag category; friend bool get(No_constrained_edge_map, key_type) { return false; } }; } // namespace Surface_mesh_simplification template inline std::string n_to_string(const N& n) { return boost::str(boost::format("%|5.19g|") % n); } template inline std::string xyz_to_string(const XYZ& xyz) { return boost::str(boost::format("(%|5.19g|,%|5.19g|,%|5.19g|)") % xyz.x() % xyz.y() % xyz.z()); } template inline std::string matrix_to_string(const Matrix& m) { return boost::str(boost::format("[%1%|%2%|%3%]") % xyz_to_string(m.r0()) % xyz_to_string(m.r1()) % xyz_to_string(m.r2())); } template inline std::string optional_to_string(const boost::optional& o) { if(o) return boost::str(boost::format("%1%") % *o); else return std::string("NONE"); } } // namespace CGAL #if defined(CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE) \ || defined(CGAL_SURFACE_SIMPLIFICATION_ENABLE_LT_TRACE) #define CGAL_SMS_ENABLE_TRACE #endif #ifdef CGAL_SMS_ENABLE_TRACE #include #include #include namespace internal { namespace { bool cgal_enable_sms_trace = true; } } #define CGAL_SMS_TRACE_IMPL(m) \ if(::internal::cgal_enable_sms_trace) { \ std::ostringstream ss; ss << m; std::string s = ss.str(); \ /*Surface_simplification_external_trace(s)*/ std::cerr << s << std::endl; \ } #define CGAL_SMS_DEBUG_CODE(code) code #else #define CGAL_SMS_DEBUG_CODE(code) #endif #ifdef CGAL_SURFACE_SIMPLIFICATION_ENABLE_LT_TRACE #define CGAL_SMS_LT_TRACE(l,m) if((l) <= CGAL_SURFACE_SIMPLIFICATION_ENABLE_LT_TRACE) CGAL_SMS_TRACE_IMPL(m) #else #define CGAL_SMS_LT_TRACE(l,m) #endif #ifdef CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE #define CGAL_SMS_TRACE_IF(c,l,m) if((c) && ((l) <= CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE)) CGAL_SMS_TRACE_IMPL(m) #define CGAL_SMS_TRACE(l,m) if((l) <= CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE) CGAL_SMS_TRACE_IMPL(m) #else #define CGAL_SMS_TRACE_IF(c,l,m) #define CGAL_SMS_TRACE(l,m) #endif #undef CGAL_SMS_ENABLE_TRACE #endif // CGAL_SURFACE_MESH_SIMPLIFICATION_DETAIL_COMMON_H