polyhedral_surface_concept.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Boost.Geometry
  2. // Copyright (c) 2025 Siddharth Kumar, Roorkee, India.
  3. // Copyright (c) 2025 Oracle and/or its affiliates.
  4. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRAL_SURFACE_CONCEPT_HPP
  9. #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRAL_SURFACE_CONCEPT_HPP
  10. #include <type_traits>
  11. #include <boost/concept_check.hpp>
  12. #include <boost/range/concepts.hpp>
  13. #include <boost/geometry/core/access.hpp>
  14. #include <boost/geometry/core/cs.hpp>
  15. #include <boost/geometry/core/ring_type.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
  18. namespace boost { namespace geometry { namespace concepts
  19. {
  20. template <typename Geometry>
  21. class PolyhedralSurface
  22. {
  23. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  24. using polygon_type = typename boost::range_value<Geometry>::type;
  25. BOOST_CONCEPT_ASSERT( (concepts::Polygon<polygon_type>) );
  26. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  27. BOOST_STATIC_ASSERT( (geometry::dimension<Geometry>::value == 3) );
  28. BOOST_STATIC_ASSERT( (std::is_same<typename geometry::cs_tag_t<Geometry>,
  29. geometry::cartesian_tag>::value) );
  30. public:
  31. BOOST_CONCEPT_USAGE(PolyhedralSurface)
  32. {
  33. Geometry* ps = 0;
  34. traits::clear<Geometry>::apply(*ps);
  35. traits::resize<Geometry>::apply(*ps, 0);
  36. // The concept should support the second version of push_back, using &&
  37. polygon_type* poly = 0;
  38. traits::push_back<Geometry>::apply(*ps, std::move(*poly));
  39. }
  40. #endif
  41. };
  42. // polyhedral surface(constant version)
  43. template <typename Geometry>
  44. class ConstPolyhedralSurface
  45. {
  46. #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
  47. using polygon_type = typename boost::range_value<Geometry>::type;
  48. BOOST_CONCEPT_ASSERT( (concepts::ConstPolygon<polygon_type>) );
  49. BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
  50. BOOST_STATIC_ASSERT( (geometry::dimension<Geometry>::value == 3) );
  51. BOOST_STATIC_ASSERT( (std::is_same<typename geometry::cs_tag_t<Geometry>,
  52. geometry::cartesian_tag>::value) );
  53. public:
  54. BOOST_CONCEPT_USAGE(ConstPolyhedralSurface)
  55. {}
  56. #endif
  57. };
  58. template <typename Geometry>
  59. struct concept_type<Geometry, polyhedral_surface_tag>
  60. {
  61. using type = PolyhedralSurface<Geometry>;
  62. };
  63. template <typename Geometry>
  64. struct concept_type<Geometry const, polyhedral_surface_tag>
  65. {
  66. using type = ConstPolyhedralSurface<Geometry>;
  67. };
  68. }}} // namespace boost::geometry::concepts
  69. #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRAL_SURFACE_CONCEPT_HPP