compute.hh 3.78 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
// 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_PRIMITIVE_LINK_COMPUTE_HH
# define SCRIBO_PRIMITIVE_LINK_COMPUTE_HH

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


# include <scribo/core/macros.hh>
# 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
58
	  bool is_potential_link_(unsigned current_object,
59
60
	                         const P& start_point, const P& p) const

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

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

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

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

Guillaume Lazzara's avatar
Guillaume Lazzara committed
73
	  void compute_next_site_(P& p)
74

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

Guillaume Lazzara's avatar
Guillaume Lazzara committed
77
	  void start_processing_object_(unsigned current_object)
78
79
80
81

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

Guillaume Lazzara's avatar
Guillaume Lazzara committed
84
85
86
87
88
      /// \overload
      /// The default anchor is set to 0, the mass center.
      template <typename F>
      object_links<scribo_support(F)>
      compute(Link_Functor<F>& functor);
89
90
91
92
93
94

# ifndef MLN_INCLUDE_ONLY


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

	F& functor = exact(functor_);

	for_all_ncomponents(current_object, functor.objects().nlabels())
	{
	  functor.start_processing_object(current_object); //<-- start_processing_object
Guillaume Lazzara's avatar
Guillaume Lazzara committed
104
	  primitive::internal::find_link(functor, current_object, anchor);
105
106
107
108
109
110
111
	}

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


Guillaume Lazzara's avatar
Guillaume Lazzara committed
112
113
114
115
116
117
118
119
      template <typename F>
      object_links<scribo_support(F)>
      compute(Link_Functor<F>& functor)
      {
	return compute(functor, anchor::MassCenter);
      }


120
121
122
123
124
125
126
127
128
# 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