-
Notifications
You must be signed in to change notification settings - Fork 15
/
CuboidalRegion.hpp
63 lines (53 loc) · 1.88 KB
/
CuboidalRegion.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef CUBOIDAL_REGION_HPP
#define CUBOIDAL_REGION_HPP
#include <boost/bind.hpp>
#include "Region.hpp"
#include "Box.hpp"
template<typename Ttraits_>
class CuboidalRegion
: public BasicRegionImpl<Ttraits_, Box<typename Ttraits_::world_type::traits_type::length_type> >
{
public:
typedef BasicRegionImpl<Ttraits_, Box<typename Ttraits_::world_type::traits_type::length_type> > base_type;
typedef typename base_type::traits_type traits_type;
typedef typename base_type::identifier_type identifier_type;
typedef typename base_type::shape_type shape_type;
typedef typename base_type::rng_type rng_type;
typedef typename base_type::position_type position_type;
typedef typename base_type::length_type length_type;
identifier_type const& id() const
{
return base_type::id_;
}
virtual position_type random_position(rng_type& rng) const
{
return ::random_position(base_type::shape(),
boost::bind(&rng_type::uniform, rng, -1., 1.));
}
virtual position_type random_vector(length_type const& r, rng_type& rng) const
{
return normalize(
create_vector<position_type>(
rng.uniform(-1., 1.),
rng.uniform(-1., 1.),
rng.uniform(-1., 1.)), r);
}
virtual position_type bd_displacement(length_type const& r, rng_type& rng) const
{
return create_vector<position_type>(
rng.normal(0., r),
rng.normal(0., r),
rng.normal(0., r));
}
virtual void accept(ImmutativeStructureVisitor<traits_type> const& visitor) const
{
visitor(*this);
}
virtual void accept(MutativeStructureVisitor<traits_type> const& visitor)
{
visitor(*this);
}
CuboidalRegion(identifier_type const& id, shape_type const& shape)
: base_type(id, shape) {}
};
#endif /* CUBOIDAL_REGION_HPP */