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
00027 #ifndef MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00028 # define MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH
00029
00033
00034 # include <mln/util/edge.hh>
00035
00036
00037 namespace mln
00038 {
00039
00040
00041 template <typename G, typename F> class p_edges;
00042 template <typename G, typename F> class p_vertices;
00043
00044
00045
00046 namespace internal
00047 {
00048
00051 template <typename S, typename D, typename E>
00052 struct is_masked_impl_selector
00053 {
00055 bool is_masked(const mln_graph_element(S)& center,
00056 const mln_graph_element(S)& element) const;
00057 };
00058
00060 template <typename G1, typename F1, typename G2, typename F2, typename E>
00061 struct is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00062 {
00063 typedef p_vertices<G1,F1> S;
00064
00066 bool is_masked(const mln_graph_element(S)& center,
00067 const mln_graph_element(S)& element) const;
00068 };
00069
00071 template <typename G1, typename F1, typename G2, typename F2, typename E>
00072 struct is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00073 {
00074 typedef p_edges<G1,F1> S;
00075
00077 bool is_masked(const mln_graph_element(S)& center,
00078 const mln_graph_element(S)& element) const;
00079 };
00080
00081
00082 # ifndef MLN_INCLUDE_ONLY
00083
00084
00085 template <typename S, typename I, typename E>
00086 inline
00087 bool
00088 is_masked_impl_selector<S,I,E>::is_masked(const mln_graph_element(S)& center,
00089 const mln_graph_element(S)& element) const
00090 {
00091 (void) center;
00092 E& iter = internal::force_exact<E>(*this);
00093 return ! iter.target_()->mask()(element.id());
00094 }
00095
00096
00097 template <typename G1, typename F1, typename G2, typename F2, typename E>
00098 inline
00099 bool
00100 is_masked_impl_selector< p_vertices<G1,F1>, p_edges<G2,F2>, E >
00101 ::is_masked(const mln_graph_element(S)& center,
00102 const mln_graph_element(S)& element) const
00103 {
00104 E& iter = internal::force_exact<E>(*this);
00105
00106 util::edge<G1> e = center.edge_with(element);
00107 mln_postcondition(e.is_valid());
00108
00109 return ! iter.target_()->mask()(e.id());
00110 }
00111
00112
00119 template <typename G1, typename F1, typename G2, typename F2, typename E>
00120 inline
00121 bool
00122 is_masked_impl_selector< p_edges<G1,F1>, p_vertices<G2,F2>, E >
00123 ::is_masked(const mln_graph_element(S)& center,
00124 const mln_graph_element(S)& element) const
00125 {
00126 E& iter = internal::force_exact<E>(*this);
00127
00128 if (center.v1() == element.v2() || center.v2() == element.v2())
00129 return ! iter.target_()->mask()(element.v1());
00130
00131
00132 return ! iter.target_()->mask()(element.v2());
00133 }
00134
00135 # endif // ! MLN_INCLUDE_ONLY
00136
00137 }
00138
00139 }
00140
00141
00142 #endif // ! MLN_CORE_INTERNAL_IS_MASKED_IMPL_SELECTOR_HH