From 00df0e5d70aad75ba437c3a5bc11830b018f3730 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Mon, 28 Dec 2020 16:01:01 +0530 Subject: [PATCH 01/12] Defined a geometry for polyhedron --- include/boost/geometry/core/tags.hpp | 3 + .../boost/geometry/geometries/geometries.hpp | 1 + .../boost/geometry/geometries/polyhedron.hpp | 97 +++++++++++++++++++ .../geometries/register/polyhedron.hpp | 17 ++++ 4 files changed, 118 insertions(+) create mode 100644 include/boost/geometry/geometries/polyhedron.hpp create mode 100644 include/boost/geometry/geometries/register/polyhedron.hpp diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp index 6c33042f5c..659d27b8d2 100644 --- a/include/boost/geometry/core/tags.hpp +++ b/include/boost/geometry/core/tags.hpp @@ -105,6 +105,9 @@ struct box_tag : single_tag, areal_tag {}; /// Convenience segment (2-points) identifying tag struct segment_tag : single_tag, linear_tag {}; +/// OGC Polyhedral surface identifying tag +struct polyhedron_tag : single_tag, volumetric_tag {}; + /// OGC Multi point identifying tag struct multi_point_tag : multi_tag, pointlike_tag {}; diff --git a/include/boost/geometry/geometries/geometries.hpp b/include/boost/geometry/geometries/geometries.hpp index a116b20cb8..c9467d8343 100644 --- a/include/boost/geometry/geometries/geometries.hpp +++ b/include/boost/geometry/geometries/geometries.hpp @@ -29,5 +29,6 @@ #include #include #include +#include #endif // BOOST_GEOMETRY_GEOMETRIES_HPP diff --git a/include/boost/geometry/geometries/polyhedron.hpp b/include/boost/geometry/geometries/polyhedron.hpp new file mode 100644 index 0000000000..6cea529025 --- /dev/null +++ b/include/boost/geometry/geometries/polyhedron.hpp @@ -0,0 +1,97 @@ +#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYHEDRON_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POLYHEDRON_HPP + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST +#include +#endif + +namespace boost { namespace geometry +{ + +namespace model +{ + + +template +< + typename Point, + bool ClockWise = true, bool Closed = true, + template class PointList = std::vector, + template class RingList = std::vector, + template class PointAlloc = std::allocator, + template class RingAlloc = std::allocator +> +class polyhedron : public PointList, RingAlloc > > +{ + BOOST_CONCEPT_ASSERT( (concepts::Point) ); + +public : + + typedef Point point_type; + typedef ring ring_type; + typedef RingList > polyhedron_type; + //typedef RingList > base_type; + +#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST + + /// \constructor_default{polyhedron} + inline polyhedron() + : polyhedron_type() + {} + + /// \constructor_initialized_list{polyhedron} + inline polyhedron(std::initializer_list l) + : polyhedron_type(l.begin(), l.end()) + {} + +#endif + +}; + +} // namespace model + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct tag +< + model::polyhedron + < + Point, + ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + > +> +{ + typedef polyhedron_tag type; +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif \ No newline at end of file diff --git a/include/boost/geometry/geometries/register/polyhedron.hpp b/include/boost/geometry/geometries/register/polyhedron.hpp new file mode 100644 index 0000000000..c9e6cdde62 --- /dev/null +++ b/include/boost/geometry/geometries/register/polyhedron.hpp @@ -0,0 +1,17 @@ +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRON_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRON_HPP + + +#include +#include + +#define BOOST_GEOMETRY_REGISTER_POLYHEDRON(Polyhedron) \ +namespace boost { namespace geometry { namespace traits { \ + template<> struct tag { typedef polyhedron_tag type; }; \ +}}} + + +#define BOOST_GEOMETRY_REGISTER_POLYHEDRON_TEMPLATED(Polyhedron) \ +namespace boost { namespace geometry { namespace traits { \ + template struct tag< Polyhedron

> { typedef polyhedron_tag type; }; \ +}}} \ No newline at end of file From 617970d7fc776be140ca6ef4b6dd20301523fd1a Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 30 Dec 2020 12:51:37 +0530 Subject: [PATCH 02/12] Changed name from Polyhedron to PolyhedralSurface --- .../{polyhedron.hpp => PolyhedralSurface.hpp} | 30 +++++++++++-------- .../boost/geometry/geometries/geometries.hpp | 2 +- .../geometries/register/PolyhedralSurface.hpp | 17 +++++++++++ .../geometries/register/polyhedron.hpp | 17 ----------- 4 files changed, 36 insertions(+), 30 deletions(-) rename include/boost/geometry/geometries/{polyhedron.hpp => PolyhedralSurface.hpp} (67%) create mode 100644 include/boost/geometry/geometries/register/PolyhedralSurface.hpp delete mode 100644 include/boost/geometry/geometries/register/polyhedron.hpp diff --git a/include/boost/geometry/geometries/polyhedron.hpp b/include/boost/geometry/geometries/PolyhedralSurface.hpp similarity index 67% rename from include/boost/geometry/geometries/polyhedron.hpp rename to include/boost/geometry/geometries/PolyhedralSurface.hpp index 6cea529025..eee24099ba 100644 --- a/include/boost/geometry/geometries/polyhedron.hpp +++ b/include/boost/geometry/geometries/PolyhedralSurface.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYHEDRON_HPP -#define BOOST_GEOMETRY_GEOMETRIES_POLYHEDRON_HPP +#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYHEDRALSURFACE_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POLYHEDRALSURFACE_HPP #include #include @@ -32,27 +32,28 @@ template template class PointAlloc = std::allocator, template class RingAlloc = std::allocator > -class polyhedron : public PointList, RingAlloc > > +class PolyhedralSurface : public PointList, RingAlloc > > { BOOST_CONCEPT_ASSERT( (concepts::Point) ); public : - typedef Point point_type; - typedef ring ring_type; - typedef RingList > polyhedron_type; + //typedef Point point_type; + using point_type = Point; + using ring_type = ring; + using PolyhedralSurface_type = RingList >; //typedef RingList > base_type; #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_default{polyhedron} - inline polyhedron() - : polyhedron_type() + inline PolyhedralSurface() + : PolyhedralSurface_type() {} /// \constructor_initialized_list{polyhedron} - inline polyhedron(std::initializer_list l) - : polyhedron_type(l.begin(), l.end()) + inline PolyhedralSurface(std::initializer_list l) + : PolyhedralSurface_type(l.begin(), l.end()) {} #endif @@ -74,7 +75,7 @@ template template class PointAlloc, template class RingAlloc > -struct tag +/*struct tag < model::polyhedron < @@ -86,7 +87,12 @@ struct tag > { typedef polyhedron_tag type; -}; +};*/ +using tag < model::PolyhedralSurface < + Point, + ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc > > = PolyhedralSurface_tag; } // namespace traits diff --git a/include/boost/geometry/geometries/geometries.hpp b/include/boost/geometry/geometries/geometries.hpp index c9467d8343..1dfd98ea18 100644 --- a/include/boost/geometry/geometries/geometries.hpp +++ b/include/boost/geometry/geometries/geometries.hpp @@ -29,6 +29,6 @@ #include #include #include -#include +#include #endif // BOOST_GEOMETRY_GEOMETRIES_HPP diff --git a/include/boost/geometry/geometries/register/PolyhedralSurface.hpp b/include/boost/geometry/geometries/register/PolyhedralSurface.hpp new file mode 100644 index 0000000000..2e74f9386e --- /dev/null +++ b/include/boost/geometry/geometries/register/PolyhedralSurface.hpp @@ -0,0 +1,17 @@ +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP + + +#include +#include + +#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE(PolyhedralSurface) \ +namespace boost { namespace geometry { namespace traits { \ + template<> struct tag { typedef PolyhedralSurface_tag type; }; \ +}}} + + +#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE_TEMPLATED(PolyhedralSurface) \ +namespace boost { namespace geometry { namespace traits { \ + template struct tag< PolyhedralSurface

> { typedef PolyhedralSurface_tag type; }; \ +}}} \ No newline at end of file diff --git a/include/boost/geometry/geometries/register/polyhedron.hpp b/include/boost/geometry/geometries/register/polyhedron.hpp deleted file mode 100644 index c9e6cdde62..0000000000 --- a/include/boost/geometry/geometries/register/polyhedron.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRON_HPP -#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRON_HPP - - -#include -#include - -#define BOOST_GEOMETRY_REGISTER_POLYHEDRON(Polyhedron) \ -namespace boost { namespace geometry { namespace traits { \ - template<> struct tag { typedef polyhedron_tag type; }; \ -}}} - - -#define BOOST_GEOMETRY_REGISTER_POLYHEDRON_TEMPLATED(Polyhedron) \ -namespace boost { namespace geometry { namespace traits { \ - template struct tag< Polyhedron

> { typedef polyhedron_tag type; }; \ -}}} \ No newline at end of file From 09917a03a1ac1e05b7944cea9027e3570516755d Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 30 Dec 2020 12:54:05 +0530 Subject: [PATCH 03/12] Added prefix for PolyhedralSurface --- include/boost/geometry/core/tags.hpp | 2 +- include/boost/geometry/io/wkt/detail/prefix.hpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp index 659d27b8d2..5e35bde264 100644 --- a/include/boost/geometry/core/tags.hpp +++ b/include/boost/geometry/core/tags.hpp @@ -106,7 +106,7 @@ struct box_tag : single_tag, areal_tag {}; struct segment_tag : single_tag, linear_tag {}; /// OGC Polyhedral surface identifying tag -struct polyhedron_tag : single_tag, volumetric_tag {}; +struct PolyhedralSurface_tag : single_tag, volumetric_tag {}; /// OGC Multi point identifying tag diff --git a/include/boost/geometry/io/wkt/detail/prefix.hpp b/include/boost/geometry/io/wkt/detail/prefix.hpp index b566e02aa6..7287dc9bbd 100644 --- a/include/boost/geometry/io/wkt/detail/prefix.hpp +++ b/include/boost/geometry/io/wkt/detail/prefix.hpp @@ -42,6 +42,11 @@ struct prefix_linestring static inline const char* apply() { return "LINESTRING"; } }; +struct prefix_polyhedron +{ + static inline const char* apply() { return "POLYHEDRON"; } +}; + struct prefix_multipoint { static inline const char* apply() { return "MULTIPOINT"; } From 2ee1f6619e55aa569f7234f47f7f679013e989ec Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 30 Dec 2020 13:00:38 +0530 Subject: [PATCH 04/12] Fixed failed checks --- include/boost/geometry/geometries/geometries.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/geometry/geometries/geometries.hpp b/include/boost/geometry/geometries/geometries.hpp index 1dfd98ea18..aa9d5f30c1 100644 --- a/include/boost/geometry/geometries/geometries.hpp +++ b/include/boost/geometry/geometries/geometries.hpp @@ -29,6 +29,6 @@ #include #include #include -#include +#include #endif // BOOST_GEOMETRY_GEOMETRIES_HPP From f3355d8be863e5128769ff1e0687b562743f4f44 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 30 Dec 2020 13:11:10 +0530 Subject: [PATCH 05/12] Fixed failed checks --- include/boost/geometry/geometries/PolyhedralSurface.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/geometries/PolyhedralSurface.hpp b/include/boost/geometry/geometries/PolyhedralSurface.hpp index eee24099ba..426b449269 100644 --- a/include/boost/geometry/geometries/PolyhedralSurface.hpp +++ b/include/boost/geometry/geometries/PolyhedralSurface.hpp @@ -75,7 +75,7 @@ template template class PointAlloc, template class RingAlloc > -/*struct tag +struct tag < model::polyhedron < @@ -87,12 +87,12 @@ template > { typedef polyhedron_tag type; -};*/ -using tag < model::PolyhedralSurface < +}; +/*using tag < model::PolyhedralSurface < Point, ClockWise, Closed, PointList, RingList, - PointAlloc, RingAlloc > > = PolyhedralSurface_tag; + PointAlloc, RingAlloc > > = PolyhedralSurface_tag;*/ } // namespace traits From 6db266c0aeb9bf58a61f16c6e7dcfb524d66fad0 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 30 Dec 2020 13:22:45 +0530 Subject: [PATCH 06/12] Fixed failed checks --- include/boost/geometry/geometries/PolyhedralSurface.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/geometries/PolyhedralSurface.hpp b/include/boost/geometry/geometries/PolyhedralSurface.hpp index 426b449269..39f1cb634e 100644 --- a/include/boost/geometry/geometries/PolyhedralSurface.hpp +++ b/include/boost/geometry/geometries/PolyhedralSurface.hpp @@ -77,7 +77,7 @@ template > struct tag < - model::polyhedron + model::PolyhedralSurface < Point, ClockWise, Closed, @@ -86,7 +86,7 @@ struct tag > > { - typedef polyhedron_tag type; + typedef PolyhedralSurface_tag type; }; /*using tag < model::PolyhedralSurface < Point, From 030d24081b715aee1eff88d795c9e5fabafe65f4 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Mon, 1 Feb 2021 14:24:03 +0530 Subject: [PATCH 07/12] Added polyhedral concept check --- example/01_point_example.cpp | 23 +++++ include/boost/geometry/core/point_type.hpp | 10 ++ include/boost/geometry/core/ring_type.hpp | 22 ++++- include/boost/geometry/core/tags.hpp | 2 +- .../geometry/geometries/PolyhedralSurface.hpp | 95 ++++++++++++------- .../concepts/PolyhedralSurface_concept.hpp | 43 +++++++++ .../geometry/geometries/concepts/check.hpp | 6 +- .../boost/geometry/io/wkt/detail/prefix.hpp | 4 +- include/boost/geometry/io/wkt/read.hpp | 34 ++++++- 9 files changed, 200 insertions(+), 39 deletions(-) create mode 100644 include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp diff --git a/example/01_point_example.cpp b/example/01_point_example.cpp index d1a70e74fb..108473cbd7 100644 --- a/example/01_point_example.cpp +++ b/example/01_point_example.cpp @@ -107,6 +107,29 @@ int main() // Some ways of getting point values + typedef model::point point_t; + typedef model::ring ring_t; + typedef model::PolyhedralSurface poly_t; + + poly_t polyhedron1; + poly_t polyhedron2 = {{{0,0,0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 0, 0}}, + {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, + {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; + + //append(polyhedron1[0], point_t{1, 0, 0}); + //append(polyhedron1[0], point_t{0, 0, 0}); + //append(polyhedron1[0], point_t{0, 1, 0}); + //append(polyhedron1[0], point_t{1, 1, 0}); + //append(polyhedron1[0], point_t{0, 0, 0}); + read_wkt("POLYHEDRALSURFACE Z(((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)), ((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)), ((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1)))", polyhedron1); + + typedef model::polygon poly; + poly polygon1; + read_wkt("POLYGON((0 0, 0 7, 4 2, 2 0, 0 0))", polygon1); + + typedef model::linestring lines; + lines line; + read_wkt("LINESTRING(0 0, 2 2, 3 1)", line); // 1: using the "get" function following the concepts behind std::cout << get<0>(p2) << "," << get<1>(p2) << std::endl; diff --git a/include/boost/geometry/core/point_type.hpp b/include/boost/geometry/core/point_type.hpp index 696e1e56ad..62eebb5fe8 100644 --- a/include/boost/geometry/core/point_type.hpp +++ b/include/boost/geometry/core/point_type.hpp @@ -92,6 +92,16 @@ struct point_type typedef typename boost::range_value::type type; }; +// Specialization for PolyhedralSurface: the point-type is the point-type of its rings +template +struct point_type +{ + typedef typename point_type + < + ring_tag, + typename ring_type::type + >::type type; +}; // Specialization for polygon: the point-type is the point-type of its rings template diff --git a/include/boost/geometry/core/ring_type.hpp b/include/boost/geometry/core/ring_type.hpp index 726b14ca5e..5134f61afd 100644 --- a/include/boost/geometry/core/ring_type.hpp +++ b/include/boost/geometry/core/ring_type.hpp @@ -23,7 +23,6 @@ #include #include - #include #include #include @@ -61,6 +60,13 @@ struct ring_mutable_type Geometry); }; +template +struct Poly_ring_type +{ + BOOST_GEOMETRY_STATIC_ASSERT_FALSE( + "Not implemented for this Geometry type.", + Geometry); +}; } // namespace traits @@ -87,6 +93,11 @@ struct ring_return_type typedef Ring& type; }; +template +struct ring_return_type +{ + typedef typename traits::Poly_ring_type::type type; +}; template struct ring_return_type @@ -145,6 +156,15 @@ struct ring_type typedef Ring type; }; +template +struct ring_type +{ + typedef typename std::remove_reference + < + typename ring_return_type::type + >::type type; +}; + template struct ring_type diff --git a/include/boost/geometry/core/tags.hpp b/include/boost/geometry/core/tags.hpp index 5e35bde264..d58b419e4d 100644 --- a/include/boost/geometry/core/tags.hpp +++ b/include/boost/geometry/core/tags.hpp @@ -106,7 +106,7 @@ struct box_tag : single_tag, areal_tag {}; struct segment_tag : single_tag, linear_tag {}; /// OGC Polyhedral surface identifying tag -struct PolyhedralSurface_tag : single_tag, volumetric_tag {}; +struct polyhedral_surface_tag : single_tag, volumetric_tag {}; /// OGC Multi point identifying tag diff --git a/include/boost/geometry/geometries/PolyhedralSurface.hpp b/include/boost/geometry/geometries/PolyhedralSurface.hpp index 39f1cb634e..e4aa232e04 100644 --- a/include/boost/geometry/geometries/PolyhedralSurface.hpp +++ b/include/boost/geometry/geometries/PolyhedralSurface.hpp @@ -25,35 +25,31 @@ namespace model template < - typename Point, - bool ClockWise = true, bool Closed = true, - template class PointList = std::vector, - template class RingList = std::vector, - template class PointAlloc = std::allocator, - template class RingAlloc = std::allocator + typename Ring, + template class Container = std::vector, + template class Allocator = std::allocator + > -class PolyhedralSurface : public PointList, RingAlloc > > +class PolyhedralSurface : public Container > { - BOOST_CONCEPT_ASSERT( (concepts::Point) ); + BOOST_CONCEPT_ASSERT( (concepts::Ring) ); public : - //typedef Point point_type; - using point_type = Point; - using ring_type = ring; - using PolyhedralSurface_type = RingList >; - //typedef RingList > base_type; + using point_type = model::point; + using ring_type = ring; + using ph = Container >; #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_default{polyhedron} inline PolyhedralSurface() - : PolyhedralSurface_type() + : ph() {} /// \constructor_initialized_list{polyhedron} inline PolyhedralSurface(std::initializer_list l) - : PolyhedralSurface_type(l.begin(), l.end()) + : ph(l.begin(), l.end()) {} #endif @@ -68,31 +64,66 @@ namespace traits template < - typename Point, - bool ClockWise, bool Closed, - template class PointList, - template class RingList, - template class PointAlloc, - template class RingAlloc + typename Ring, + template class Container, + template class Allocator > struct tag < model::PolyhedralSurface < - Point, - ClockWise, Closed, - PointList, RingList, - PointAlloc, RingAlloc + Ring, + Container, Allocator > > { - typedef PolyhedralSurface_tag type; + typedef polyhedral_surface_tag type; }; -/*using tag < model::PolyhedralSurface < - Point, - ClockWise, Closed, - PointList, RingList, - PointAlloc, RingAlloc > > = PolyhedralSurface_tag;*/ + +template +< + typename Ring, + template class Container, + template class Allocator +> +struct Poly_ring_type +< + model::PolyhedralSurface + < + Ring, + Container, Allocator + > +> +{ + typedef typename model::PolyhedralSurface + < + Ring, + Container, Allocator + >::ring_type& type; +}; + +/*template +< + typename Ring, + template class Container, + template class Allocator +> +struct ring_type +< + model::PolyhedralSurface + < + Ring, + Container, Allocator + > +> +{ + typedef typename model::PolyhedralSurface + < + Ring, + Container, Allocator + >::ring_type& type; + +};*/ } // namespace traits @@ -100,4 +131,4 @@ struct tag }} // namespace boost::geometry -#endif \ No newline at end of file +#endif diff --git a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp new file mode 100644 index 0000000000..afb1afeb35 --- /dev/null +++ b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp @@ -0,0 +1,43 @@ +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRALSURFACE_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRALSURFACE_HPP + +#include +#include +#include +#include +#include + +namespace boost { namespace geometry { namespace concepts +{ + + +template +class PolyhedralSurface +{ + +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + + typedef typename ring_type::type ring_type; + + + BOOST_CONCEPT_ASSERT( (concepts::Ring) ); + +public: + + BOOST_CONCEPT_USAGE(PolyhedralSurface) + { + + Geometry* polyhedralSurface = 0; + ring_type* ring = 0; + + } +#endif + +}; + +} // namepspace concepts + +} // namespace geometry + +} // namespace boost +#endif diff --git a/include/boost/geometry/geometries/concepts/check.hpp b/include/boost/geometry/geometries/concepts/check.hpp index 5b49f38843..a2884ce9a2 100644 --- a/include/boost/geometry/geometries/concepts/check.hpp +++ b/include/boost/geometry/geometries/concepts/check.hpp @@ -39,7 +39,7 @@ #include #include #include - +#include #include namespace boost { namespace geometry @@ -121,6 +121,10 @@ struct check : detail::concept_check::check > {}; +template +struct check + : detail::concept_check::check > +{}; template struct check diff --git a/include/boost/geometry/io/wkt/detail/prefix.hpp b/include/boost/geometry/io/wkt/detail/prefix.hpp index 7287dc9bbd..81e6d0e159 100644 --- a/include/boost/geometry/io/wkt/detail/prefix.hpp +++ b/include/boost/geometry/io/wkt/detail/prefix.hpp @@ -42,9 +42,9 @@ struct prefix_linestring static inline const char* apply() { return "LINESTRING"; } }; -struct prefix_polyhedron +struct prefix_polyhedral_surface { - static inline const char* apply() { return "POLYHEDRON"; } + static inline const char* apply() { return "POLYHEDRALSURFACE Z"; } }; struct prefix_multipoint diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 7d73adf731..66750450bd 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -453,6 +453,27 @@ struct polygon_parser } }; +template +struct polyhderal_surface_parser +{ + typedef typename ring_return_type::type ring_return_type; + typedef container_appender appender; + + static inline void apply(tokenizer::iterator& it, + tokenizer::iterator const& end, + std::string const& wkt, + PolyhedralSurface& ring) + { + handle_open_parenthesis(it, end, wkt); + int i = 0; + while(it != end && *it != ")"){ + //appender::apply(it, end, wkt, ring); + i++; + } + handle_close_parenthesis(it, end, wkt); + } +}; + inline bool one_of(tokenizer::iterator const& it, std::string const& value, @@ -563,7 +584,7 @@ struct geometry_parser { static inline void apply(std::string const& wkt, Geometry& geometry) { - geometry::clear(geometry); + //geometry::clear(geometry); tokenizer tokens(wkt, boost::char_separator(" ", ",()")); tokenizer::iterator it, end; @@ -844,6 +865,15 @@ struct read_wkt > {}; +template +struct read_wkt + : detail::wkt::geometry_parser + < + Geometry, + detail::wkt::polyhderal_surface_parser, + detail::wkt::prefix_polyhedral_surface + > +{}; template struct read_wkt @@ -903,7 +933,7 @@ struct read_wkt template inline void read_wkt(std::string const& wkt, Geometry& geometry) { - geometry::concepts::check(); + //geometry::concepts::check(); dispatch::read_wkt::type, Geometry>::apply(wkt, geometry); } From b551f6d96213ca57ca8a573c97ca6a7731080a13 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Mon, 1 Feb 2021 15:14:49 +0530 Subject: [PATCH 08/12] Added wkt read feature to polyhedral surfaces --- include/boost/geometry/algorithms/clear.hpp | 5 +++++ .../geometry/geometries/PolyhedralSurface.hpp | 21 ------------------- .../concepts/PolyhedralSurface_concept.hpp | 3 --- include/boost/geometry/io/wkt/read.hpp | 17 +++++++++------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/include/boost/geometry/algorithms/clear.hpp b/include/boost/geometry/algorithms/clear.hpp index 05c910f2e2..c396be5ed1 100644 --- a/include/boost/geometry/algorithms/clear.hpp +++ b/include/boost/geometry/algorithms/clear.hpp @@ -123,6 +123,11 @@ struct clear : detail::clear::collection_clear {}; +// Clear for Polyhedral surface +template +struct clear + : detail::clear::no_action +{}; // Polygon can (indirectly) use std for clear template diff --git a/include/boost/geometry/geometries/PolyhedralSurface.hpp b/include/boost/geometry/geometries/PolyhedralSurface.hpp index e4aa232e04..62afc41ede 100644 --- a/include/boost/geometry/geometries/PolyhedralSurface.hpp +++ b/include/boost/geometry/geometries/PolyhedralSurface.hpp @@ -102,28 +102,7 @@ struct Poly_ring_type >::ring_type& type; }; -/*template -< - typename Ring, - template class Container, - template class Allocator -> -struct ring_type -< - model::PolyhedralSurface - < - Ring, - Container, Allocator - > -> -{ - typedef typename model::PolyhedralSurface - < - Ring, - Container, Allocator - >::ring_type& type; -};*/ } // namespace traits diff --git a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp index afb1afeb35..81e014be93 100644 --- a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp +++ b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp @@ -27,9 +27,6 @@ class PolyhedralSurface BOOST_CONCEPT_USAGE(PolyhedralSurface) { - Geometry* polyhedralSurface = 0; - ring_type* ring = 0; - } #endif diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 66750450bd..1454f84b77 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -462,13 +462,18 @@ struct polyhderal_surface_parser static inline void apply(tokenizer::iterator& it, tokenizer::iterator const& end, std::string const& wkt, - PolyhedralSurface& ring) + PolyhedralSurface& Poly) { handle_open_parenthesis(it, end, wkt); - int i = 0; + typename ring_type::type ring; while(it != end && *it != ")"){ - //appender::apply(it, end, wkt, ring); - i++; + appender::apply(it, end, wkt, ring); + if(it!=end && *it == ",") + { + //skip after ring is parsed + ++it; + } + } handle_close_parenthesis(it, end, wkt); } @@ -584,7 +589,7 @@ struct geometry_parser { static inline void apply(std::string const& wkt, Geometry& geometry) { - //geometry::clear(geometry); + geometry::clear(geometry); tokenizer tokens(wkt, boost::char_separator(" ", ",()")); tokenizer::iterator it, end; @@ -933,7 +938,7 @@ struct read_wkt template inline void read_wkt(std::string const& wkt, Geometry& geometry) { - //geometry::concepts::check(); + geometry::concepts::check(); dispatch::read_wkt::type, Geometry>::apply(wkt, geometry); } From c1412c64027149d276b94d58e13b59b50e5ba4d1 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Tue, 23 Feb 2021 14:45:36 +0530 Subject: [PATCH 09/12] Added wkt write feature for polyhedral surfaces --- example/01_point_example.cpp | 8 +++- .../concepts/PolyhedralSurface_concept.hpp | 22 +++++++++++ .../geometry/geometries/concepts/check.hpp | 5 +++ .../boost/geometry/io/wkt/detail/prefix.hpp | 2 +- include/boost/geometry/io/wkt/read.hpp | 16 +++++++- include/boost/geometry/io/wkt/write.hpp | 38 +++++++++++++++++++ 6 files changed, 86 insertions(+), 5 deletions(-) diff --git a/example/01_point_example.cpp b/example/01_point_example.cpp index 108473cbd7..b21aeb50dc 100644 --- a/example/01_point_example.cpp +++ b/example/01_point_example.cpp @@ -115,18 +115,22 @@ int main() poly_t polyhedron2 = {{{0,0,0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; + + std::cout< poly; poly polygon1; read_wkt("POLYGON((0 0, 0 7, 4 2, 2 0, 0 0))", polygon1); - + std::cout< lines; lines line; read_wkt("LINESTRING(0 0, 2 2, 3 1)", line); diff --git a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp index 81e014be93..8ccea85c82 100644 --- a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp +++ b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp @@ -32,6 +32,28 @@ class PolyhedralSurface }; +//polyhedral surface(constant version) +template +class ConstPolyhedral +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + + typedef typename std::remove_const::type const_polyhedral_type; + + typedef typename ring_type::type ring_type; + + BOOST_CONCEPT_ASSERT( (concepts::ConstRing) ); + +public: + + BOOST_CONCEPT_USAGE(ConstPolyhedral) + { + + } + +#endif +}; + } // namepspace concepts } // namespace geometry diff --git a/include/boost/geometry/geometries/concepts/check.hpp b/include/boost/geometry/geometries/concepts/check.hpp index a2884ce9a2..d119dcebce 100644 --- a/include/boost/geometry/geometries/concepts/check.hpp +++ b/include/boost/geometry/geometries/concepts/check.hpp @@ -126,6 +126,11 @@ struct check : detail::concept_check::check > {}; +template +struct check + : detail::concept_check::check > +{}; + template struct check : detail::concept_check::check > diff --git a/include/boost/geometry/io/wkt/detail/prefix.hpp b/include/boost/geometry/io/wkt/detail/prefix.hpp index 81e6d0e159..56fdcd4a8e 100644 --- a/include/boost/geometry/io/wkt/detail/prefix.hpp +++ b/include/boost/geometry/io/wkt/detail/prefix.hpp @@ -44,7 +44,7 @@ struct prefix_linestring struct prefix_polyhedral_surface { - static inline const char* apply() { return "POLYHEDRALSURFACE Z"; } + static inline const char* apply() { return "POLYHEDRALSURFACE"; } }; struct prefix_multipoint diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 1454f84b77..26b47dd5a1 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -465,12 +465,23 @@ struct polyhderal_surface_parser PolyhedralSurface& Poly) { handle_open_parenthesis(it, end, wkt); - typename ring_type::type ring; while(it != end && *it != ")"){ + handle_open_parenthesis(it, end, wkt); + + typename ring_type::type ring; + appender::apply(it, end, wkt, ring); + traits::push_back + < + typename std::remove_reference + < + PolyhedralSurface + >::type + >::apply(Poly, ring); + handle_close_parenthesis(it, end, wkt); if(it!=end && *it == ",") { - //skip after ring is parsed + //skip "," after ring is parsed ++it; } @@ -549,6 +560,7 @@ inline bool initialize(tokenizer const& tokens, it = tokens.begin(); end = tokens.end(); + //std::cout<<*it<<" "< +struct wkt_polyhedral +{ + template + static inline void apply(std::basic_ostream& os, + Polyhedral_surface const& polyhedral, bool force_closure) + { + typedef typename std::remove_const::type const_polyhedral_type; + typedef typename ring_type::type ring; + + os << PrefixPolicy::apply(); + + os << "("; + for( typename boost::range_iterator::type + it = boost::begin(polyhedral); it != boost::end(polyhedral); ++it) + { + if(it != boost::begin(polyhedral)) + { + os << ","; + } + os << "("; + + wkt_sequence::apply(os, *it, force_closure); + os << ")"; + } + os << ")"; + } +}; + template struct wkt_multi { @@ -409,6 +438,15 @@ struct wkt > {}; +template +struct wkt + : detail::wkt::wkt_polyhedral + < + Polyhedral_surface, + detail::wkt::prefix_polyhedral_surface + > +{}; + template struct wkt : detail::wkt::wkt_multi From 90b4c79f265dc435355a43744d1d8301bcd6bd39 Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Tue, 23 Feb 2021 18:15:34 +0530 Subject: [PATCH 10/12] Added suggested changes --- example/01_point_example.cpp | 6 ++--- .../concepts/PolyhedralSurface_concept.hpp | 26 +++++-------------- .../geometry/geometries/concepts/check.hpp | 4 +-- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/example/01_point_example.cpp b/example/01_point_example.cpp index b21aeb50dc..61d2a5c704 100644 --- a/example/01_point_example.cpp +++ b/example/01_point_example.cpp @@ -116,7 +116,7 @@ int main() {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; - std::cout< poly; poly polygon1; read_wkt("POLYGON((0 0, 0 7, 4 2, 2 0, 0 0))", polygon1); - std::cout< lines; lines line; read_wkt("LINESTRING(0 0, 2 2, 3 1)", line); diff --git a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp index 8ccea85c82..63e063b7bd 100644 --- a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp +++ b/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp @@ -10,26 +10,19 @@ namespace boost { namespace geometry { namespace concepts { - template class PolyhedralSurface { - #ifndef DOXYGEN_NO_CONCEPT_MEMBERS - - typedef typename ring_type::type ring_type; - + using ring_type = typename ring_type::type; BOOST_CONCEPT_ASSERT( (concepts::Ring) ); - public: - + BOOST_CONCEPT_USAGE(PolyhedralSurface) { - } #endif - }; //polyhedral surface(constant version) @@ -37,10 +30,8 @@ template class ConstPolyhedral { #ifndef DOXYGEN_NO_CONCEPT_MEMBERS - - typedef typename std::remove_const::type const_polyhedral_type; - - typedef typename ring_type::type ring_type; + using const_polyhedral_type = typename std::remove_const::type; + using ring_type = typename ring_type::type; BOOST_CONCEPT_ASSERT( (concepts::ConstRing) ); @@ -48,15 +39,10 @@ class ConstPolyhedral BOOST_CONCEPT_USAGE(ConstPolyhedral) { - } #endif }; -} // namepspace concepts - -} // namespace geometry - -} // namespace boost -#endif +}}} // namespace boost::geometry::concepts +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRALSURFACE_HPP diff --git a/include/boost/geometry/geometries/concepts/check.hpp b/include/boost/geometry/geometries/concepts/check.hpp index d119dcebce..15d414550a 100644 --- a/include/boost/geometry/geometries/concepts/check.hpp +++ b/include/boost/geometry/geometries/concepts/check.hpp @@ -123,12 +123,12 @@ struct check template struct check - : detail::concept_check::check > + : detail::concept_check::check> {}; template struct check - : detail::concept_check::check > + : detail::concept_check::check> {}; template From d6b8e7ce91bd7ece08e2e7877c8c3b44e0e5d17f Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Wed, 24 Mar 2021 21:52:50 +0530 Subject: [PATCH 11/12] Added suggested changes --- example/01_point_example.cpp | 27 ------------ example/08_polyhedralsurface_example.cpp | 37 ++++++++++++++++ example/Jamfile | 1 + include/boost/geometry/algorithms/clear.hpp | 14 +++++- include/boost/geometry/core/point_type.hpp | 8 +--- include/boost/geometry/core/ring_type.hpp | 9 ++-- .../geometry/geometries/concepts/check.hpp | 4 +- ...ept.hpp => polyhedral_surface_concept.hpp} | 6 +-- .../boost/geometry/geometries/geometries.hpp | 2 +- ...dralSurface.hpp => polyhedral_surface.hpp} | 43 ++++++++----------- .../geometries/register/PolyhedralSurface.hpp | 17 -------- include/boost/geometry/io/wkt/read.hpp | 14 +++--- include/boost/geometry/io/wkt/write.hpp | 7 ++- 13 files changed, 88 insertions(+), 101 deletions(-) create mode 100644 example/08_polyhedralsurface_example.cpp rename include/boost/geometry/geometries/concepts/{PolyhedralSurface_concept.hpp => polyhedral_surface_concept.hpp} (90%) rename include/boost/geometry/geometries/{PolyhedralSurface.hpp => polyhedral_surface.hpp} (79%) delete mode 100644 include/boost/geometry/geometries/register/PolyhedralSurface.hpp diff --git a/example/01_point_example.cpp b/example/01_point_example.cpp index 61d2a5c704..d1a70e74fb 100644 --- a/example/01_point_example.cpp +++ b/example/01_point_example.cpp @@ -107,33 +107,6 @@ int main() // Some ways of getting point values - typedef model::point point_t; - typedef model::ring ring_t; - typedef model::PolyhedralSurface poly_t; - - poly_t polyhedron1; - poly_t polyhedron2 = {{{0,0,0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 0, 0}}, - {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, - {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; - - std::cout << wkt(polyhedron2) << std::endl; - - //append(polyhedron1[0], point_t{1, 0, 0}); - //append(polyhedron1[0], point_t{0, 0, 0}); - //append(polyhedron1[0], point_t{0, 1, 0}); - //append(polyhedron1[0], point_t{1, 1, 0}); - //append(polyhedron1[0], point_t{0, 0, 0}); - read_wkt("POLYHEDRALSURFACE(((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)),((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1)))", polyhedron1); - - std::cout << wkt(polyhedron1) << std::endl; - - typedef model::polygon poly; - poly polygon1; - read_wkt("POLYGON((0 0, 0 7, 4 2, 2 0, 0 0))", polygon1); - std::cout << wkt(polygon1) << std::endl; - typedef model::linestring lines; - lines line; - read_wkt("LINESTRING(0 0, 2 2, 3 1)", line); // 1: using the "get" function following the concepts behind std::cout << get<0>(p2) << "," << get<1>(p2) << std::endl; diff --git a/example/08_polyhedralsurface_example.cpp b/example/08_polyhedralsurface_example.cpp new file mode 100644 index 0000000000..56b44d0085 --- /dev/null +++ b/example/08_polyhedralsurface_example.cpp @@ -0,0 +1,37 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Polyhedral surface example + +#include +#include + +int main() +{ + using namespace boost::geometry; + + using point_t = model::point; + using ring_t = model::ring; + using polyhedral_t = model::polyhedral_surface; + + // intializing an empty polyhedral surface (deafault constructor) + polyhedral_t polyhedral2; + + // creating a polyhderal surface using standard initiallized list + polyhedral_t polyhedral1 = {{{0,0,0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 0, 0}}, + {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, + {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; + + // modifying a polyhedral surface + polyhedral1[0][1] = {1, 1, 1}; + + // read polyhedral surface wkt + read_wkt("POLYHEDRALSURFACE(((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)),((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1)))", polyhedral2); + + // write polyhedral surface wkt + std::cout << wkt(polyhedral1) << std::endl; + + std::cout << wkt(polyhedral2) << std::endl; + + // clear polyhedral surface + clear(polyhedral1); +} \ No newline at end of file diff --git a/example/Jamfile b/example/Jamfile index 17fae5000c..de9ced96d5 100644 --- a/example/Jamfile +++ b/example/Jamfile @@ -23,6 +23,7 @@ exe 06_a_transformation_example : 06_a_transformation_example.cpp ; exe 06_b_transformation_example : 06_b_transformation_example.cpp ; exe 07_a_graph_route_example : 07_a_graph_route_example.cpp ; exe 07_b_graph_route_example : 07_b_graph_route_example.cpp ; +exe 08_polyhedralsurface_example : 08_polyhedralsurface_example.cpp ; exe c01_custom_point_example : c01_custom_point_example.cpp ; exe c02_custom_box_example : c02_custom_box_example.cpp ; diff --git a/include/boost/geometry/algorithms/clear.hpp b/include/boost/geometry/algorithms/clear.hpp index c396be5ed1..656105e4c7 100644 --- a/include/boost/geometry/algorithms/clear.hpp +++ b/include/boost/geometry/algorithms/clear.hpp @@ -73,6 +73,18 @@ struct polygon_clear } }; +template +struct polyhedral_surface_clear +{ + static inline void apply(Polyhedral_surface& polyhedral_surface) + { + traits::clear + < + typename std::remove_reference::type + >::apply(polyhedral_surface); + } +}; + template struct no_action { @@ -126,7 +138,7 @@ struct clear // Clear for Polyhedral surface template struct clear - : detail::clear::no_action + : detail::clear::polyhedral_surface_clear {}; // Polygon can (indirectly) use std for clear diff --git a/include/boost/geometry/core/point_type.hpp b/include/boost/geometry/core/point_type.hpp index 62eebb5fe8..33cb2e1953 100644 --- a/include/boost/geometry/core/point_type.hpp +++ b/include/boost/geometry/core/point_type.hpp @@ -92,15 +92,11 @@ struct point_type typedef typename boost::range_value::type type; }; -// Specialization for PolyhedralSurface: the point-type is the point-type of its rings +// Specialization for PolyhedralSurface: the point-type is the point-type of its poly_ring_type template struct point_type { - typedef typename point_type - < - ring_tag, - typename ring_type::type - >::type type; + using type = typename point_type::type>::type; }; // Specialization for polygon: the point-type is the point-type of its rings diff --git a/include/boost/geometry/core/ring_type.hpp b/include/boost/geometry/core/ring_type.hpp index 5134f61afd..42bb3bb185 100644 --- a/include/boost/geometry/core/ring_type.hpp +++ b/include/boost/geometry/core/ring_type.hpp @@ -61,7 +61,7 @@ struct ring_mutable_type }; template -struct Poly_ring_type +struct poly_ring_type { BOOST_GEOMETRY_STATIC_ASSERT_FALSE( "Not implemented for this Geometry type.", @@ -96,7 +96,7 @@ struct ring_return_type template struct ring_return_type { - typedef typename traits::Poly_ring_type::type type; + using type = typename traits::poly_ring_type::type; }; template @@ -159,10 +159,7 @@ struct ring_type template struct ring_type { - typedef typename std::remove_reference - < - typename ring_return_type::type - >::type type; + using type = typename std::remove_reference::type>::type; }; diff --git a/include/boost/geometry/geometries/concepts/check.hpp b/include/boost/geometry/geometries/concepts/check.hpp index 15d414550a..d2d2bf404f 100644 --- a/include/boost/geometry/geometries/concepts/check.hpp +++ b/include/boost/geometry/geometries/concepts/check.hpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include namespace boost { namespace geometry @@ -128,7 +128,7 @@ struct check template struct check - : detail::concept_check::check> + : detail::concept_check::check> {}; template diff --git a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp b/include/boost/geometry/geometries/concepts/polyhedral_surface_concept.hpp similarity index 90% rename from include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp rename to include/boost/geometry/geometries/concepts/polyhedral_surface_concept.hpp index 63e063b7bd..ad86e2446e 100644 --- a/include/boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp +++ b/include/boost/geometry/geometries/concepts/polyhedral_surface_concept.hpp @@ -25,9 +25,9 @@ class PolyhedralSurface #endif }; -//polyhedral surface(constant version) +// polyhedral surface(constant version) template -class ConstPolyhedral +class ConstPolyhedralSurface { #ifndef DOXYGEN_NO_CONCEPT_MEMBERS using const_polyhedral_type = typename std::remove_const::type; @@ -37,7 +37,7 @@ class ConstPolyhedral public: - BOOST_CONCEPT_USAGE(ConstPolyhedral) + BOOST_CONCEPT_USAGE(ConstPolyhedralSurface) { } diff --git a/include/boost/geometry/geometries/geometries.hpp b/include/boost/geometry/geometries/geometries.hpp index aa9d5f30c1..076b11cef6 100644 --- a/include/boost/geometry/geometries/geometries.hpp +++ b/include/boost/geometry/geometries/geometries.hpp @@ -29,6 +29,6 @@ #include #include #include -#include +#include #endif // BOOST_GEOMETRY_GEOMETRIES_HPP diff --git a/include/boost/geometry/geometries/PolyhedralSurface.hpp b/include/boost/geometry/geometries/polyhedral_surface.hpp similarity index 79% rename from include/boost/geometry/geometries/PolyhedralSurface.hpp rename to include/boost/geometry/geometries/polyhedral_surface.hpp index 62afc41ede..785cb5a608 100644 --- a/include/boost/geometry/geometries/PolyhedralSurface.hpp +++ b/include/boost/geometry/geometries/polyhedral_surface.hpp @@ -3,14 +3,11 @@ #include #include - #include - #include #include #include #include - #include #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST #include @@ -18,11 +15,9 @@ namespace boost { namespace geometry { - namespace model { - - + template < typename Ring, @@ -30,7 +25,7 @@ template template class Allocator = std::allocator > -class PolyhedralSurface : public Container > +class polyhedral_surface : public Container > { BOOST_CONCEPT_ASSERT( (concepts::Ring) ); @@ -43,19 +38,18 @@ public : #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST /// \constructor_default{polyhedron} - inline PolyhedralSurface() - : ph() - {} + inline polyhedral_surface() + : ph() + {} /// \constructor_initialized_list{polyhedron} - inline PolyhedralSurface(std::initializer_list l) + inline polyhedral_surface(std::initializer_list l) : ph(l.begin(), l.end()) - {} + {} #endif - -}; +}; } // namespace model #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS @@ -70,14 +64,14 @@ template > struct tag < - model::PolyhedralSurface + model::polyhedral_surface < Ring, Container, Allocator > > { - typedef polyhedral_surface_tag type; + using type = polyhedral_surface_tag; }; template @@ -86,25 +80,22 @@ template template class Container, template class Allocator > -struct Poly_ring_type +struct poly_ring_type < - model::PolyhedralSurface + model::polyhedral_surface < Ring, Container, Allocator > > { - typedef typename model::PolyhedralSurface - < - Ring, - Container, Allocator - >::ring_type& type; + using type = typename model::polyhedral_surface + < + Ring, + Container, Allocator + >::ring_type&; }; - - - } // namespace traits #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS diff --git a/include/boost/geometry/geometries/register/PolyhedralSurface.hpp b/include/boost/geometry/geometries/register/PolyhedralSurface.hpp deleted file mode 100644 index 2e74f9386e..0000000000 --- a/include/boost/geometry/geometries/register/PolyhedralSurface.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP -#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP - - -#include -#include - -#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE(PolyhedralSurface) \ -namespace boost { namespace geometry { namespace traits { \ - template<> struct tag { typedef PolyhedralSurface_tag type; }; \ -}}} - - -#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE_TEMPLATED(PolyhedralSurface) \ -namespace boost { namespace geometry { namespace traits { \ - template struct tag< PolyhedralSurface

> { typedef PolyhedralSurface_tag type; }; \ -}}} \ No newline at end of file diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index 26b47dd5a1..7462b8afd3 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -456,8 +456,8 @@ struct polygon_parser template struct polyhderal_surface_parser { - typedef typename ring_return_type::type ring_return_type; - typedef container_appender appender; + using ring_return_type = typename ring_return_type::type; + using appender = container_appender; static inline void apply(tokenizer::iterator& it, tokenizer::iterator const& end, @@ -465,7 +465,8 @@ struct polyhderal_surface_parser PolyhedralSurface& Poly) { handle_open_parenthesis(it, end, wkt); - while(it != end && *it != ")"){ + while(it != end && *it != ")") + { handle_open_parenthesis(it, end, wkt); typename ring_type::type ring; @@ -473,11 +474,9 @@ struct polyhderal_surface_parser appender::apply(it, end, wkt, ring); traits::push_back < - typename std::remove_reference - < - PolyhedralSurface - >::type + typename std::remove_reference::type >::apply(Poly, ring); + handle_close_parenthesis(it, end, wkt); if(it!=end && *it == ",") { @@ -560,7 +559,6 @@ inline bool initialize(tokenizer const& tokens, it = tokens.begin(); end = tokens.end(); - //std::cout<<*it<<" "<& os, Polyhedral_surface const& polyhedral, bool force_closure) { - typedef typename std::remove_const::type const_polyhedral_type; - typedef typename ring_type::type ring; + using const_polyhedral_type = typename std::remove_const::type; + using ring = typename ring_type::type; os << PrefixPolicy::apply(); os << "("; - for( typename boost::range_iterator::type - it = boost::begin(polyhedral); it != boost::end(polyhedral); ++it) + for(auto it = boost::begin(polyhedral); it != boost::end(polyhedral); ++it) { if(it != boost::begin(polyhedral)) { From 408ca8f752471578c73c183328454293ceeea1ae Mon Sep 17 00:00:00 2001 From: Siddharth kumar Date: Sat, 3 Apr 2021 09:51:02 +0530 Subject: [PATCH 12/12] Fixed identation --- example/08_polyhedralsurface_example.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/example/08_polyhedralsurface_example.cpp b/example/08_polyhedralsurface_example.cpp index 56b44d0085..44cd61bd56 100644 --- a/example/08_polyhedralsurface_example.cpp +++ b/example/08_polyhedralsurface_example.cpp @@ -7,19 +7,18 @@ int main() { - using namespace boost::geometry; + using namespace boost::geometry; + using point_t = model::point; + using ring_t = model::ring; + using polyhedral_t = model::polyhedral_surface; - using point_t = model::point; - using ring_t = model::ring; - using polyhedral_t = model::polyhedral_surface; + // intializing an empty polyhedral surface (deafault constructor) + polyhedral_t polyhedral2; - // intializing an empty polyhedral surface (deafault constructor) - polyhedral_t polyhedral2; - - // creating a polyhderal surface using standard initiallized list + // creating a polyhderal surface using standard initiallized list polyhedral_t polyhedral1 = {{{0,0,0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}, {0, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}, {0, 0, 0}}, {{1, 1, 1}, {1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, {{1, 1, 1}, {1, 0, 1}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}, - {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}} }; + {{1, 1, 1}, {1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}}; // modifying a polyhedral surface polyhedral1[0][1] = {1, 1, 1}; @@ -34,4 +33,4 @@ int main() // clear polyhedral surface clear(polyhedral1); -} \ No newline at end of file +}