PLaSK library
Loading...
Searching...
No Matches
boost_geometry.hpp
Go to the documentation of this file.
1
/*
2
* This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3
* Copyright (c) 2022 Lodz University of Technology
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, version 3.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*/
14
#ifndef PLASK__VECTOR__BOOST_GEOMETRY_H
15
#define PLASK__VECTOR__BOOST_GEOMETRY_H
16
21
#include "
2d.hpp
"
22
23
#include <boost/geometry.hpp>
24
25
// code is based on:
26
// https://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/examples/example_source_code__adapting_a_legacy_geometry_object_model.html#adaption_of_qpoint_source_code
27
namespace
boost
28
{
29
namespace
geometry
30
{
31
namespace
traits
32
{
33
// Adapt plask::Vec<2, double> to Boost.Geometry
34
35
template
<>
struct
tag<
plask
::Vec<2, double>>
36
{
typedef
point_tag
type
; };
37
38
template
<>
struct
coordinate_type<
plask
::Vec<2, double>>
39
{
typedef
double
type
; };
40
41
template
<>
struct
coordinate_system<
plask
::Vec<2, double>>
42
{
typedef
cs::cartesian
type
; };
43
44
template
<>
struct
dimension<
plask
::Vec<2, double>> : boost::mpl::int_<2> {};
45
46
template
<>
47
struct
access<
plask
::Vec<2, double>, 0>
48
{
49
static
double
get
(
plask::Vec<2, double>
const
& p)
50
{
51
return
p.c0;
52
}
53
54
static
void
set
(
plask::Vec<2, double>
& p,
double
const
& value)
55
{
56
p.c0 = value;
57
}
58
};
59
60
template
<>
61
struct
access<
plask
::Vec<2, double>, 1>
62
{
63
static
double
get
(
plask::Vec<2, double>
const
& p)
64
{
65
return
p.c1;
66
}
67
68
static
void
set
(
plask::Vec<2, double>
& p,
double
const
& value)
69
{
70
p.c1 = value;
71
}
72
};
73
}
74
}
75
}
// namespace boost::geometry::traits
76
77
#endif
// PLASK__VECTOR__BOOST_GEOMETRY_H
plask
vector
boost_geometry.hpp
Generated by
1.9.8