![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
correctBoost , Chapter 1. Geometry , Algorithms
|
Тип |
Концепция |
Имя |
Описание |
---|---|---|---|
Геометрия и амп; | Любой тип, выполняющий концепцию геометрии | Геометрия | Модель указанного понятия, которая при необходимости будет исправлена |
Или
#include <boost/geometry.hpp>
Или
#include <boost/geometry/algorithms/correct.hpp>
Правильная функция не определяется OGC.
Геометрия |
статус |
---|---|
![]() | |
Сегмент | ![]() |
![]() | |
Струна | ![]() |
Кольцо | ![]() |
![]() | |
![]() | |
![]() | |
Мультиполигон | ![]() |
Вариант | ![]() |
Дело |
поведение |
---|---|
Кольцо | |
Исправлен многополигон | |
Коробка корректируется относительно минимальных и максимальных углов | |
линейный
Показывает, как исправить многоугольник относительно его ориентации и закрытия
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/polygon.hpp> #include <boost/geometry/geometries/adapted/boost_tuple.hpp> BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) #include <boost/assign.hpp> int main() { using boost::assign::tuple_list_of; typedef boost::geometry::model::polygon < boost::tuple<int, int> > clockwise_closed_polygon; clockwise_closed_polygon cwcp; // Fill it counterclockwise (so wrongly), forgetting the closing point boost::geometry::exterior_ring(cwcp) = tuple_list_of(0, 0)(10, 10)(0, 9); // Add a counterclockwise closed inner ring (this is correct) boost::geometry::interior_rings(cwcp).push_back(tuple_list_of(1, 2)(4, 6)(2, 8)(1, 2)); // Its area should be negative (because of wrong orientation) // and wrong (because of omitted closing point) double area_before = boost::geometry::area(cwcp); // Correct it! boost::geometry::correct(cwcp); // Check its new area double area_after = boost::geometry::area(cwcp); // And output it std::cout << boost::geometry::dsv(cwcp) << std::endl; std::cout << area_before << " -> " << area_after << std::endl; return 0; }
Результат:
(((0, 0), (0, 9), (10, 10), (0, 0)), ((1, 2), (4, 6), (2, 8), (1, 2))) -7 -> 38
Статья correct раздела Chapter 1. Geometry Algorithms может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.
:: Главная :: Algorithms ::
реклама |