component_info.hh 3.37 KB
Newer Older
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena.  If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction.  Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License.  This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.

#ifndef SCRIBO_CORE_COMPONENT_INFO_HH
# define SCRIBO_CORE_COMPONENT_INFO_HH

/// \file
///
/// \brief Component information data structure.


# include <mln/core/alias/box2d.hh>
# include <mln/core/alias/point2d.hh>
# include <mln/util/object_id.hh>

# include <scribo/core/tag/component.hh>
# include <scribo/core/tag/line.hh>

namespace scribo
{

  typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t;

  class component_info
  {
    typedef mln::util::object_id<scribo::ComponentId, unsigned> component_id_t;
    typedef mln::util::object_id<scribo::LineId, unsigned> line_id_t;

  public:
    component_info();
    component_info(const component_id_t& id,
		   const mln::box2d& bbox,
		   const mln::point2d& mass_center,
		   unsigned card);

    component_id_t id() const;
    const mln::box2d& bbox() const;
    const mln::point2d& mass_center() const;
    unsigned card() const;
    component::Tag tag() const;
    void update_tag(component::Tag tag);

    line_id_t line_id() const;

  private:
    component_id_t id_;
    mln::box2d bbox_;
    mln::point2d mass_center_;
    unsigned card_;
    component::Tag tag_;

    line_id_t line_id_;
  };


# ifndef MLN_INCLUDE_ONLY


  component_info::component_info()
  {

  }


  component_info::component_info(const component_id_t& id,
				 const mln::box2d& bbox,
				 const mln::point2d& mass_center,
				 unsigned card)
    : id_(id), bbox_(bbox), mass_center_(mass_center), card_(card),
      tag_(component::None), line_id_(0)
  {

  }


  component_info::component_id_t
  component_info::id() const
  {
    return id_;
  }


  const mln::box2d&
  component_info::bbox() const
  {
    return bbox_;
  }


  const mln::point2d&
  component_info::mass_center() const
  {
    return mass_center_;
  }

  unsigned
  component_info::card() const
  {
    return card_;
  }


  component::Tag
  component_info::tag() const
  {
    return tag_;
  }


  void
  component_info::update_tag(component::Tag tag)
  {
    tag_ = tag;
  }

  component_info::line_id_t
  component_info::line_id() const
  {
    return line_id_;
  }


# endif // ! MLN_INCLUDE_ONLY


} // end of namespace scribo


#endif // ! SCRIBO_CORE_COMPONENT_INFO_HH