Skip to content
Closed
27 changes: 27 additions & 0 deletions example/01_point_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@ int main()


// Some ways of getting point values
typedef model::point<double, 3, cs::cartesian> point_t;
typedef model::ring<point_t> ring_t;
typedef model::PolyhedralSurface<ring_t> 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<point_2d> 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<point_2d> 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;
Expand Down
5 changes: 5 additions & 0 deletions include/boost/geometry/algorithms/clear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ struct clear<Geometry, ring_tag>
: detail::clear::collection_clear<Geometry>
{};

// Clear for Polyhedral surface
template <typename Geometry>
struct clear<Geometry, polyhedral_surface_tag>
: detail::clear::no_action<Geometry>
{};

// Polygon can (indirectly) use std for clear
template <typename Polygon>
Expand Down
10 changes: 10 additions & 0 deletions include/boost/geometry/core/point_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ struct point_type<ring_tag, Ring>
typedef typename boost::range_value<Ring>::type type;
};

// Specialization for PolyhedralSurface: the point-type is the point-type of its rings
template <typename PolyhedralSurface>
struct point_type<polyhedral_surface_tag, PolyhedralSurface>
{
typedef typename point_type
<
ring_tag,
typename ring_type<polyhedral_surface_tag, PolyhedralSurface>::type
>::type type;
};

// Specialization for polygon: the point-type is the point-type of its rings
template <typename Polygon>
Expand Down
22 changes: 21 additions & 1 deletion include/boost/geometry/core/ring_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <type_traits>

#include <boost/range/value_type.hpp>

#include <boost/geometry/core/static_assert.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
Expand Down Expand Up @@ -61,6 +60,13 @@ struct ring_mutable_type
Geometry);
};

template <typename Geometry>
struct Poly_ring_type
{
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
"Not implemented for this Geometry type.",
Geometry);
};

} // namespace traits

Expand All @@ -87,6 +93,11 @@ struct ring_return_type<ring_tag, Ring>
typedef Ring& type;
};

template <typename PolyhedralSurface>
struct ring_return_type<polyhedral_surface_tag, PolyhedralSurface>
{
typedef typename traits::Poly_ring_type<PolyhedralSurface>::type type;
};

template <typename Polygon>
struct ring_return_type<polygon_tag, Polygon>
Expand Down Expand Up @@ -145,6 +156,15 @@ struct ring_type<ring_tag, Ring>
typedef Ring type;
};

template <typename PolyhedralSurface>
struct ring_type<polyhedral_surface_tag, PolyhedralSurface>
{
typedef typename std::remove_reference
<
typename ring_return_type<polyhedral_surface_tag, PolyhedralSurface>::type
>::type type;
};


template <typename Polygon>
struct ring_type<polygon_tag, Polygon>
Expand Down
3 changes: 3 additions & 0 deletions include/boost/geometry/core/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 polyhedral_surface_tag : single_tag, volumetric_tag {};


/// OGC Multi point identifying tag
struct multi_point_tag : multi_tag, pointlike_tag {};
Expand Down
113 changes: 113 additions & 0 deletions include/boost/geometry/geometries/PolyhedralSurface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYHEDRALSURFACE_HPP
#define BOOST_GEOMETRY_GEOMETRIES_POLYHEDRALSURFACE_HPP

#include <memory>
#include <vector>

#include <boost/concept/assert.hpp>

#include <boost/geometry/geometries/concepts/point_concept.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>

#include <boost/config.hpp>
#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
#include <initializer_list>
#endif

namespace boost { namespace geometry
{

namespace model
{


template
<
typename Ring,
template<typename, typename> class Container = std::vector,
template<typename> class Allocator = std::allocator

>
class PolyhedralSurface : public Container<Ring, Allocator<Ring> >
{
BOOST_CONCEPT_ASSERT( (concepts::Ring<Ring>) );

public :

using point_type = model::point<double, 3, boost::geometry::cs::cartesian>;
using ring_type = ring<point_type, true, true>;
using ph = Container<ring_type, Allocator<ring_type> >;

#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awulkiew do we still need these defines in new code?
I don't think so.


/// \constructor_default{polyhedron}
inline PolyhedralSurface()
: ph()
{}

/// \constructor_initialized_list{polyhedron}
inline PolyhedralSurface(std::initializer_list<ring_type> l)
: ph(l.begin(), l.end())
{}

#endif

};

} // namespace model

#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{

template
<
typename Ring,
template<typename, typename> class Container,
template<typename> class Allocator
>
struct tag
<
model::PolyhedralSurface
<
Ring,
Container, Allocator
>
>
{
typedef polyhedral_surface_tag type;
};

template
<
typename Ring,
template<typename, typename> class Container,
template<typename> class Allocator
>
struct Poly_ring_type
<
model::PolyhedralSurface
<
Ring,
Container, Allocator
>
>
{
typedef typename model::PolyhedralSurface
<
Ring,
Container, Allocator
>::ring_type& type;
};




} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS

}} // namespace boost::geometry

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRALSURFACE_HPP
#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYHEDRALSURFACE_HPP

#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/geometries/concepts/ring_concept.hpp>

namespace boost { namespace geometry { namespace concepts
{


template <typename Geometry>
class PolyhedralSurface
{

#ifndef DOXYGEN_NO_CONCEPT_MEMBERS

typedef typename ring_type<Geometry>::type ring_type;


BOOST_CONCEPT_ASSERT( (concepts::Ring<ring_type>) );

public:

BOOST_CONCEPT_USAGE(PolyhedralSurface)
{

}
#endif

};

//polyhedral surface(constant version)
template <typename Geometry>
class ConstPolyhedral
{
#ifndef DOXYGEN_NO_CONCEPT_MEMBERS

typedef typename std::remove_const<Geometry>::type const_polyhedral_type;

typedef typename ring_type<const_polyhedral_type>::type ring_type;

BOOST_CONCEPT_ASSERT( (concepts::ConstRing<ring_type>) );

public:

BOOST_CONCEPT_USAGE(ConstPolyhedral)
{

}

#endif
};

} // namepspace concepts

} // namespace geometry

} // namespace boost
#endif
11 changes: 10 additions & 1 deletion include/boost/geometry/geometries/concepts/check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <boost/geometry/geometries/concepts/polygon_concept.hpp>
#include <boost/geometry/geometries/concepts/ring_concept.hpp>
#include <boost/geometry/geometries/concepts/segment_concept.hpp>

#include <boost/geometry/geometries/concepts/PolyhedralSurface_concept.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>

namespace boost { namespace geometry
Expand Down Expand Up @@ -121,6 +121,15 @@ struct check<Geometry, polygon_tag, false>
: detail::concept_check::check<concepts::Polygon<Geometry> >
{};

template <typename Geometry>
struct check<Geometry, polyhedral_surface_tag, false>
: detail::concept_check::check<concepts::PolyhedralSurface<Geometry> >
{};

template <typename Geometry>
struct check<Geometry, polyhedral_surface_tag, true>
: detail::concept_check::check<concepts::ConstPolyhedral<Geometry> >
{};

template <typename Geometry>
struct check<Geometry, box_tag, true>
Expand Down
1 change: 1 addition & 0 deletions include/boost/geometry/geometries/geometries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/geometries/PolyhedralSurface.hpp>

#endif // BOOST_GEOMETRY_GEOMETRIES_HPP
17 changes: 17 additions & 0 deletions include/boost/geometry/geometries/register/PolyhedralSurface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP
#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POLYHEDRALSURFACE_HPP


#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>

#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE(PolyhedralSurface) \
namespace boost { namespace geometry { namespace traits { \
template<> struct tag<PolyhedralSurface> { typedef PolyhedralSurface_tag type; }; \
}}}


#define BOOST_GEOMETRY_REGISTER_POLYHEDRALSURFACE_TEMPLATED(PolyhedralSurface) \
namespace boost { namespace geometry { namespace traits { \
template<typename P> struct tag< PolyhedralSurface<P> > { typedef PolyhedralSurface_tag type; }; \
}}}
5 changes: 5 additions & 0 deletions include/boost/geometry/io/wkt/detail/prefix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ struct prefix_linestring
static inline const char* apply() { return "LINESTRING"; }
};

struct prefix_polyhedral_surface
{
static inline const char* apply() { return "POLYHEDRALSURFACE"; }
};

struct prefix_multipoint
{
static inline const char* apply() { return "MULTIPOINT"; }
Expand Down
Loading