| Home | Libraries | People | FAQ | More

#### model::polyhedral_surface

A Polyhedral Surface is a contiguous collection of polygons in 3-dimensional space, which share common boundary segments. The concepts and the constructors don't check if the boundary segments are common but is_valid() does.

###### Model of

PolyhedralSurface Concept

###### Synopsis

    template<typename Polygon, template< typename, typename > class Container, template< typename > class Allocator>
    class model::polyhedral_surface
          : public std::vector< Polygon, std::allocator< Polygon > >
    {
      // ...
    };

###### Template parameter(s)

Parameter | Default | Description
--- | --- | ---
typename Polygon |  | polygon type
template< typename, typename > class Container | std::vector | container type for polygons, default std::vector
template< typename > class Allocator | std::allocator | container-allocator-type, for the polygons

###### Constructor(s)

Function | Description | Parameters
--- | --- | ---
    polyhedral_surface()
| Default constructor, creating an empty polyhedron. |
    polyhedral_surface(std::initializer_list< Polygon > l)
| \constructor_initialized_list{polyhedron} | std::initializer_list< Polygon >: l:

###### Header

Either

`#include <boost/geometry/geometries/geometries.hpp>`

Or

`#include <boost/geometry/geometries/polyhedral_surface.hpp>`

###### Examples

Declaration and use of the Boost.Geometry model::polyhedral_surface, modelling the PolyhedralSurface Concept

    #include <iostream>
    #include <boost/geometry.hpp>
    #include <boost/geometry/geometries/geometries.hpp>

    namespace bg = boost::geometry;

    int main()
    {
        using point_t = bg::model::point<double, 3, bg::cs::cartesian>;
        using polygon_t = bg::model::polygon<point_t>;
        using polyhedral_t = bg::model::polyhedral_surface<polygon_t>;

        polyhedral_t polyhedral0;

        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}}}};

        polyhedral0.resize(4);
        bg::append(polyhedral0[0].outer(), point_t(0.0, 0.0, 0.0));
        bg::append(polyhedral0[0].outer(), point_t(5.0, 0.0, 0.0));
        bg::append(polyhedral0[0].outer(), point_t(0.0, 5.0, 0.0));
        bg::append(polyhedral0[1].outer(), point_t(0.0, 0.0, 0.0));
        bg::append(polyhedral0[1].outer(), point_t(0.0, 5.0, 0.0));
        bg::append(polyhedral0[1].outer(), point_t(0.0, 0.0, 5.0));
        bg::append(polyhedral0[2].outer(), point_t(0.0, 0.0, 0.0));
        bg::append(polyhedral0[2].outer(), point_t(5.0, 0.0, 0.0));
        bg::append(polyhedral0[2].outer(), point_t(0.0, 0.0, 5.0));
        bg::append(polyhedral0[3].outer(), point_t(5.0, 0.0, 0.0));
        bg::append(polyhedral0[3].outer(), point_t(0.0, 5.0, 0.0));
        bg::append(polyhedral0[3].outer(), point_t(0.0, 0.0, 5.0));

        polyhedral_t polyhedral2;
        bg::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);

        std::cout << bg::wkt(polyhedral0) << std::endl;
        std::cout << bg::wkt(polyhedral1) << std::endl;
        std::cout << bg::wkt(polyhedral2) << std::endl;

        return 0;
    }

| Initializing an empty polyhedral surface (default constructor)
| Creating a polyhedral surface (cube) using standard initialized list
| Creating a polyhedral surface (triangular pyramid) using append and resize. See figure below.
| Initialize polyhedral surface (cube) with wkt
| Write polyhedral surface wkt

Output:

    POLYHEDRALSURFACE(((0 0 0,5 0 0,0 5 0,0 0 0)),((0 0 0,0 5 0,0 0 5,0 0 0)),((0 0 0,5 0 0,0 0 5,0 0 0)),((5 0 0,0 5 0,0 0 5,5 0 0)))
    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)))
    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)))