00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00027 # define MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00028
00032
00033 # include <mln/util/edge.hh>
00034
00035
00036 namespace mln
00037 {
00038
00039
00040 template <typename G, typename F> struct p_edges;
00041 template <typename G, typename F> struct p_vertices;
00042
00043
00044
00045 namespace internal
00046 {
00047
00050 template <typename S, typename D, typename E>
00051 struct is_masked_impl_selector
00052 {
00054 bool is_masked(const mln_graph_element(S)& center,
00055 const mln_graph_element(S)& element) const;
00056 };
00057
00059 template <typename G1, typename F1, typename G2, typename F2, typename E>
00060 struct is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00061 {
00062 typedef p_vertices<G1,F1> S;
00063
00065 bool is_masked(const mln_graph_element(S)& center,
00066 const mln_graph_element(S)& element) const;
00067 };
00068
00070 template <typename G1, typename F1, typename G2, typename F2, typename E>
00071 struct is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00072 {
00073 typedef p_edges<G1,F1> S;
00074
00076 bool is_masked(const mln_graph_element(S)& center,
00077 const mln_graph_element(S)& element) const;
00078 };
00079
00080
00081 # ifndef MLN_INCLUDE_ONLY
00082
00083
00084 template <typename S, typename I, typename E>
00085 inline
00086 bool
00087 is_masked_impl_selector<S,I,E>::is_masked(const mln_graph_element(S)& center,
00088 const mln_graph_element(S)& element) const
00089 {
00090 (void) center;
00091 E& iter = internal::force_exact<E>(*this);
00092 return ! iter.target_()->mask()(element.id());
00093 }
00094
00095
00096 template <typename G1, typename F1, typename G2, typename F2, typename E>
00097 inline
00098 bool
00099 is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00100 ::is_masked(const mln_graph_element(S)& center,
00101 const mln_graph_element(S)& element) const
00102 {
00103 E& iter = internal::force_exact<E>(*this);
00104
00105 util::edge<G1> e = center.edge_with(element);
00106 mln_postcondition(e.is_valid());
00107
00108 return ! iter.target_()->mask()(e.id());
00109 }
00110
00111
00118 template <typename G1, typename F1, typename G2, typename F2, typename E>
00119 inline
00120 bool
00121 is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00122 ::is_masked(const mln_graph_element(S)& center,
00123 const mln_graph_element(S)& element) const
00124 {
00125 E& iter = internal::force_exact<E>(*this);
00126
00127 if (center.v1() == element.v2() || center.v2() == element.v2())
00128 return ! iter.target_()->mask()(element.v1());
00129
00130
00131 return ! iter.target_()->mask()(element.v2());
00132 }
00133
00134 # endif // ! MLN_INCLUDE_ONLY
00135
00136 }
00137
00138 }
00139
00140
00141 #endif // ! MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH