Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

model::polyhedral_surface
PrevUpHomeNext

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

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


    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)); 3

    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); 4

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

    return 0;
}

1

Initializing an empty polyhedral surface (default constructor)

2

Creating a polyhedral surface (cube) using standard initialized list

3

Creating a polyhedral surface (triangular pyramid) using append and resize. See figure below.

4

Initialize polyhedral surface (cube) with wkt

5

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)))

triangular_pyramid


PrevUpHomeNext