compute.hh 3.96 KB
Newer Older
Guillaume Lazzara's avatar
Guillaume Lazzara committed
1
2
// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
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
//
// 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_PRIMITIVE_LINK_COMPUTE_HH
# define SCRIBO_PRIMITIVE_LINK_COMPUTE_HH

/// \file
///
/// Compute links between objects according a given functor.


# include <scribo/core/macros.hh>
36
# include <scribo/core/component_set.hh>
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# include <scribo/core/object_links.hh>
# include <scribo/core/concept/link_functor.hh>
# include <scribo/primitive/link/internal/find_link.hh>

namespace scribo
{

  namespace primitive
  {

    namespace link
    {

      /*! \brief Compute links between objects according a given functor.

	  \param[in,out] functor Linking policy.

	  \return Object links.


	  Functors must implement the following interface :


Guillaume Lazzara's avatar
Guillaume Lazzara committed
60
	  bool is_potential_link_(unsigned current_object,
61
62
	                         const P& start_point, const P& p) const

Guillaume Lazzara's avatar
Guillaume Lazzara committed
63
	  bool valid_link_(unsigned current_object,
64
65
	                  const P& start_point, const P& p)

Guillaume Lazzara's avatar
Guillaume Lazzara committed
66
	  bool verify_link_criterion_(unsigned current_object,
67
68
	                             const P& start_point, const P& p)

Guillaume Lazzara's avatar
Guillaume Lazzara committed
69
70
	  void validate_link_(unsigned current_object,
	                     const P& start_point, const P& p, unsigned anchor)
71

Guillaume Lazzara's avatar
Guillaume Lazzara committed
72
73
	  void invalidate_link_(unsigned current_object,
	                       const P& start_point, const P& p, unsigned anchor)
74

Guillaume Lazzara's avatar
Guillaume Lazzara committed
75
	  void compute_next_site_(P& p)
76

Guillaume Lazzara's avatar
Guillaume Lazzara committed
77
	  const mln_site(L)& start_point_(unsigned current_object, unsigned anchor)
78

Guillaume Lazzara's avatar
Guillaume Lazzara committed
79
	  void start_processing_object_(unsigned current_object)
80
81
82
83

      */
      template <typename F>
      object_links<scribo_support(F)>
Guillaume Lazzara's avatar
Guillaume Lazzara committed
84
      compute(Link_Functor<F>& functor, anchor::Type anchor);
85

Guillaume Lazzara's avatar
Guillaume Lazzara committed
86
      /// \overload
Guillaume Lazzara's avatar
Guillaume Lazzara committed
87
      /// The default anchor is set to anchor::MassCenter.
Guillaume Lazzara's avatar
Guillaume Lazzara committed
88
89
90
      template <typename F>
      object_links<scribo_support(F)>
      compute(Link_Functor<F>& functor);
91
92
93
94
95
96

# ifndef MLN_INCLUDE_ONLY


      template <typename F>
      object_links<scribo_support(F)>
Guillaume Lazzara's avatar
Guillaume Lazzara committed
97
      compute(Link_Functor<F>& functor_, anchor::Type anchor)
98
99
100
101
      {
	trace::entering("scribo::primitive::link::compute");

	F& functor = exact(functor_);
102
103
104
105
106
107
108
109
110
	const typename F::component_set_t&
	  comp_set = functor.components();

	for_all_ncomponents(current_object, comp_set.nelements())
	  if (comp_set(current_object).tag() != component::Ignored)
	  {
	    functor.start_processing_object(current_object); //<-- start_processing_object
	    primitive::internal::find_link(functor, current_object, anchor);
	  }
111
112
113
114
115
116

	trace::exiting("scribo::primitive::link::compute");
	return functor.links();
      }


Guillaume Lazzara's avatar
Guillaume Lazzara committed
117
118
119
120
121
122
123
124
      template <typename F>
      object_links<scribo_support(F)>
      compute(Link_Functor<F>& functor)
      {
	return compute(functor, anchor::MassCenter);
      }


125
126
127
128
129
130
131
132
133
# endif // ! MLN_INCLUDE_ONLY

    } // end of namespace scribo::primitive::link

  } // end of namespace scribo::primitive

} // end of namespace scribo

#endif // ! SCRIBO_PRIMITIVE_LINK_COMPUTE_HH