Skip to content
  • Giovanni Palma's avatar
    Index: ChangeLog · f4a29507
    Giovanni Palma authored
    from  Giovanni Palma  <giovanni@lrde.epita.fr>
    
    	* NEWS: Describe color and attributes improvement.
    
    Index: integre/ChangeLog
    from  Giovanni Palma  <giovanni@lrde.epita.fr>
    
    	* ntg/vect/vec.hh: Add sup() function to vec traits.
    
    Index: metalic/ChangeLog
    from  Giovanni Palma  <giovanni@lrde.epita.fr>
    
    	* mlc/type.hh: Add some useful macros.
    
    Index: olena/ChangeLog
    from  Giovanni Palma  <giovanni@lrde.epita.fr>
    
    	* oln/morpho/attributes.hh: Add new attributes. Correct the olders.
    
    	* oln/morpho/attribute_union_find.hh: Change lambda type from ref
    	to pointer.
    	* oln/morpho/attribute_closing_opening.hh: Fix some argument
    	types. Add new declarations.
    
    Index: NEWS
    --- NEWS Fri, 08 Aug 2003 16:27:13 +0200 david (oln/0_NEWS 1.16 640)
    +++ NEWS Mon, 09 Feb 2004 18:44:40 +0100 palma_g (oln/0_NEWS 1.16 640)
    @@ -1,3 +1,13 @@
    +Olena 0.10	Not yet
    +
    +	* Attribute opening/closing enhancement
    +	  - Make the algothim more generic.
    +	  - Add a lot of attributes.
    +
    +	* Change the color conversion system
    +	  - CIE RGB is the main color system.
    +	  - Conversion between 2 color systems should pass by the RGB one.
    +
     Olena 0.9	August 8, 2003
    
             * New static hierarchy paradigm
    Index: metalic/mlc/type.hh
    --- metalic/mlc/type.hh Fri, 07 Nov 2003 17:19:10 +0100 burrus_n
    (oln/c/21_type.hh 1.27 640)
    +++ metalic/mlc/type.hh Mon, 09 Feb 2004 18:14:34 +0100 palma_g
    (oln/c/21_type.hh 1.27 640)
    @@ -237,6 +237,13 @@
     # define mlc_exact_type(T) typename mlc::exact< T >::ret
     # define mlc_exact_type_(T) mlc::exact< T >::ret
    
    +// Return the exact virtual type of two given types (inheritance
    determination).
    +
    +# define mlc_exact_vt_type(T, Exact)		typename mlc::exact_vt<T, Exact>::ret
    +# define mlc_2_exact_vt_type(self, T, Exact)	typename mlc::exact_vt<self<T,
    Exact>, Exact>::ret
    +# define mlc_exact_vt_type_(T, Exact)		mlc::exact_vt<T, Exact>::ret
    +# define mlc_2_exact_vt_type_(self, T, Exact)	mlc::exact_vt<self<T, Exact>,
    Exact>::ret
    +
     namespace mlc
     {
    
    @@ -299,4 +306,10 @@
    
     # define mlc_init_static_hierarchy(Exact)
    
    +/*---------.
    +| dispatch |
    +`---------*/
    +
    +# define mlc_dispatch(Fun)			return exact().Fun##_impl
    +
     #endif // ! METALIC_TYPE_HH
    Index: olena/oln/morpho/attribute_closing_opening.hh
    --- olena/oln/morpho/attribute_closing_opening.hh Fri, 06 Feb 2004 16:02:37
    +0100 palma_g (oln/q/49_attribute_ 1.11 640)
    +++ olena/oln/morpho/attribute_closing_opening.hh Fri, 06 Feb 2004 17:44:37
    +0100 palma_g (oln/q/49_attribute_ 1.11 640)
    @@ -41,7 +41,7 @@
     	oln_concrete_type(I)
     	  attr_closing_(const abstract::non_vectorial_image<I>& input,
     			const abstract::neighborhood<N>& Ng,
    -			const attr_lambda_type(A) lambda)
    +			const attr_lambda_type(A) &lambda)
     	{
     	  typedef tarjan::tarjan_set<oln_concrete_type(I), A > tarjan_set_type;
     	  tarjan_set_type area_closing(input.exact(), attr_env_type(A)());
    @@ -53,7 +53,7 @@
     	oln_concrete_type(I)
     	  attr_opening_(const abstract::non_vectorial_image<I>& input,
     			const abstract::neighborhood<N>& Ng,
    -			const attr_lambda_type(A) lambda)
    +			const attr_lambda_type(A) &lambda)
     	{
     	  typedef tarjan::tarjan_set<oln_concrete_type(I), A > tarjan_set_type;
     	  tarjan_set_type area_opening(input.exact(), attr_env_type(A)());
    @@ -68,7 +68,7 @@
           oln_concrete_type(I) \
     	T##_opening(const abstract::non_vectorial_image<I>& input, \
     		       const abstract::neighborhood<N>& Ng, \
    -		       const attr_lambda_type(T##_type<unsigned>) lambda) \
    +		       const attr_lambda_type(T##_type<unsigned>) &lambda) \
           { \
     	return internal::attr_opening_<I, N, T##_type<unsigned> >(input, Ng, lambda);
    \
           }
    @@ -78,7 +78,7 @@
           oln_concrete_type(I) \
     	T##_closing(const abstract::non_vectorial_image<I>& input, \
     		       const abstract::neighborhood<N>& Ng, \
    -		       const attr_lambda_type(T##_type<unsigned>) lambda) \
    +		       const attr_lambda_type(T##_type<unsigned>) &lambda) \
           { \
     	return internal::attr_closing_<I, N, T##_type<unsigned> >(input, Ng, lambda);
    \
           }
    @@ -90,7 +90,7 @@
           oln_concrete_type(I) \
     	T##_opening(const abstract::non_vectorial_image<I>& input, \
     		       const abstract::neighborhood<N>& Ng, \
    -		       const attr_lambda_type(T##_type<I>) lambda) \
    +		       const attr_lambda_type(T##_type<I>) &lambda) \
           { \
     	return internal::attr_opening_<I, N, T##_type<I> >(input, Ng, lambda); \
           }
    @@ -100,7 +100,7 @@
           oln_concrete_type(I) \
     	T##_closing(const abstract::non_vectorial_image<I>& input, \
     		       const abstract::neighborhood<N>& Ng, \
    -		       const attr_lambda_type(T##_type<I>) lambda) \
    +		       const attr_lambda_type(T##_type<I>) &lambda) \
           { \
     	return internal::attr_closing_<I, N, T##_type<I> >(input, Ng, lambda); \
           }
    @@ -159,6 +159,9 @@
     	xxx_closing_im_decl(dist)
     	xxx_closing_im_decl(square)
     	xxx_opening_im_decl(square)
    +	xxx_closing_im_decl(rectangle)
    +	xxx_opening_im_decl(rectangle)
    +
         }
       }
     }
    Index: olena/oln/morpho/attribute_union_find.hh
    --- olena/oln/morpho/attribute_union_find.hh Fri, 06 Feb 2004 16:02:37 +0100
    palma_g (oln/q/50_attribute_ 1.9 640)
    +++ olena/oln/morpho/attribute_union_find.hh Fri, 06 Feb 2004 17:55:37 +0100
    palma_g (oln/q/50_attribute_ 1.9 640)
    @@ -150,7 +150,7 @@
     	{
     	  precondition((parent_[x] == ACTIVE()) || (parent_[x] == INACTIVE()));
     	  precondition((parent_[y] == ACTIVE()) || (parent_[y] == INACTIVE()));
    -	  return ( (input_[x] == input_[y]) || (aux_data_[x] < lambda_));
    +	  return ( (input_[x] == input_[y]) || (aux_data_[x] < *lambda_));
     	}
    
     	void
    @@ -165,7 +165,7 @@
     	      }
     	    else
     	      {
    -		aux_data_[p] = lambda_;
    +		aux_data_[p] = *lambda_;
     	      }
     	}
    
    @@ -177,7 +177,7 @@
     		     const abstract::neighborhood<N>& Ng,
     		     const bool closing)
     	{
    -	  lambda_ = lambda;
    +	  lambda_ = &lambda;
    
     	  std::vector<point_type>	I(input_.npoints());
    
    @@ -232,7 +232,7 @@
     	const image_type & input_;
     	typename mute<T, point_type>::ret parent_;
     	typename mute<T, ATTRIBUTE>::ret aux_data_;
    -	lambda_type lambda_;
    +	const lambda_type *lambda_;
     	const env_type	env_;
           };
         }
    Index: integre/ntg/vect/vec.hh
    --- integre/ntg/vect/vec.hh Thu, 27 Nov 2003 11:26:27 +0100 burrus_n
    (oln/t/18_vec.hh 1.7.1.1 640)
    +++ integre/ntg/vect/vec.hh Mon, 09 Feb 2004 18:32:07 +0100 palma_g
    (oln/t/18_vec.hh 1.7.1.1 640)
    @@ -105,6 +105,23 @@
           typedef self				 base_type;
           typedef T					 storage_type[N];
           typedef typename typetraits<T>::cumul_type cumul_type[N];
    +
    +      static const self &sup()
    +      {
    +	static self tmp = mkSup();
    +
    +	return tmp;
    +      };
    +
    +    protected:
    +      static self mkSup()
    +      {
    +	self tmp;
    +
    +	for (unsigned i = 0; i < N; ++i)
    +	  tmp[i] = ntg_sup_val(T);
    +	return tmp;
    +      };
         };
    
       } // end of internal.
    Index: olena/oln/morpho/attributes.hh
    --- olena/oln/morpho/attributes.hh Fri, 06 Feb 2004 16:02:37 +0100 palma_g
    (oln/j/45_attributes 1.1 644)
    +++ olena/oln/morpho/attributes.hh Mon, 09 Feb 2004 18:37:42 +0100 palma_g
    (oln/j/45_attributes 1.1 644)
    @@ -27,12 +27,15 @@
    
     #ifndef ATTRIBUTES_HH
     # define ATTRIBUTES_HH
    +# include <mlc/type.hh>
    +# include <vector>
    +
     // some usefull macros
    
     // those macros should be moved into mlc
    -# define oln_exact_vt_type(T, Exact)	typename mlc::exact_vt<T, Exact>::ret
    -# define oln_2_exact_vt_type(self, T, Exact)	typename mlc::exact_vt<self<T,
    Exact>, Exact>::ret
    -# define dispatch(Fun)			return exact().Fun##_impl
    +// # define mlc_exact_vt_type(T, Exact)	typename mlc::exact_vt<T, Exact>::ret
    +// # define oln_2_exact_vt_type(self, T, Exact)	typename mlc::exact_vt<self<T,
    Exact>, Exact>::ret
    +// # define dispatch(Fun)			return exact().Fun##_impl
    
     // attribute dedicated macros
     # define attr_lambda_type(T)	typename attr_traits<T>::lambda_type
    @@ -40,38 +43,23 @@
     # define attr_value_type(T)	typename attr_traits<T>::value_type
    
     # define attr_type_decl(slef_type) \
    -      typedef oln_exact_vt_type(self_type, Exact)	exact_type; \
    +      typedef mlc_exact_vt_type(self_type, Exact)	exact_type; \
           typedef attr_value_type(exact_type)		value_type; \
           typedef attr_env_type(exact_type)			env_type; \
           typedef attr_lambda_type(exact_type)		lambda_type
    
    -
    -
    -// misc
    -namespace my {
    -
    -  int diffabs(int v1, int v2)
    +namespace oln {
    +  namespace morpho {
    +    namespace tarjan {
    +      namespace tools {
    +	// should be moved elsewhere
    +	template <class T>
    +	T diffabs(const T &v1, const T &v2)
       {
         return v1 > v2 ? v1 - v2 : v2 - v1;
       }
    
    -  template <class T>
    -  T max(T v1, T v2)
    -  {
    -    return v1 > v2 ? v1 : v2;
       }
    -
    -  template <class T>
    -  T min(T v1, T v2)
    -  {
    -    return v1 < v2 ? v1 : v2;
    -  }
    -
    -} // end of namespace my
    -
    -namespace oln {
    -  namespace morpho {
    -    namespace tarjan {
           // environment herarchy
           // not used yet
           template <class Exact>
    @@ -104,22 +92,28 @@
    
     	void operator+=(const exact_type& rhs)
     	{
    -	  dispatch(pe)(rhs);
    +	  mlc_dispatch(pe)(rhs);
     	};
    
    -	void operator=(lambda_type lambda)
    +	bool operator>=(const lambda_type &lambda) const
     	{
    -	  dispatch(equal)(lambda);
    +	  mlc_dispatch(ge)(lambda);
     	};
    
     	bool operator<(const lambda_type& lambda) const
     	{
    -	  dispatch(less)(lambda);
    +	  mlc_dispatch(less)(lambda);
     	};
    
     	bool operator!=(const lambda_type& lambda) const
     	{
    -	  dispatch(ne)(lambda);
    +	  mlc_dispatch(ne)(lambda);
    +	};
    +
    +	// impl
    +	bool ge_impl(const lambda_type &lambda) const
    +	{
    +	  return !(*this < lambda);
     	};
    
           protected:
    @@ -131,9 +125,9 @@
     	|   area    |
     	*-----------*/
    
    -      template <class T, class Exact = mlc::final>
    +      template <class T = unsigned, class Exact = mlc::final>
           class area_type:
    -	public attribute<oln_2_exact_vt_type(area_type, T, Exact)>
    +	public attribute<mlc_2_exact_vt_type(area_type, T, Exact)>
           {
           public:
     	typedef area_type<T, Exact>			self_type;
    @@ -160,11 +154,6 @@
     	    value_ += rhs.value_;
     	  };
    
    -	void equal_impl(lambda_type lambda)
    -	  {
    -	    value_ = lambda;
    -	  };
    -
     	bool less_impl(const lambda_type& lambda) const
     	  {
     	    return value_ < lambda;
    @@ -186,9 +175,9 @@
     	|  volume   |
     	*-----------*/
    
    -      template <class T, class Exact = mlc::final>
    +      template <class T = unsigned, class Exact = mlc::final>
           class volume_type:
    -	public attribute<oln_2_exact_vt_type(volume_type, T, Exact)>
    +	public attribute<mlc_2_exact_vt_type(volume_type, T, Exact)>
           {
           public:
     	typedef volume_type<T, Exact>			self_type;
    @@ -216,17 +205,17 @@
     	// interface part
     	const value_type &getValue() const
     	  {
    -	    dispatch(getValue)();
    +	    mlc_dispatch(getValue)();
     	  };
    
     	const value_type &getReflevel() const
     	  {
    -	    dispatch(getReflevel)();
    +	    mlc_dispatch(getReflevel)();
     	  };
    
     	const value_type &getArea() const
     	  {
    -	    dispatch(getArea)();
    +	    mlc_dispatch(getArea)();
     	  };
    
     	// impl part
    @@ -245,14 +234,9 @@
     	    return area_;
     	  };
    
    -	void equal_impl(lambda_type lambda)
    -	  {
    -	    value_ = lambda;
    -	  };
    -
     	void pe_impl(const volume_type& rhs)
     	  {
    -	    value_ += rhs.getValue() + area_ * my::diffabs(reflevel_,
    rhs.getReflevel());
    +	    value_ += rhs.getValue() + area_ * tools::diffabs(reflevel_,
    rhs.getReflevel());
     	    area_ += rhs.getArea();
     	  };
    
    @@ -276,9 +260,9 @@
     	|  height   |
     	*-----------*/
    
    -      template <class T, class Exact = mlc::final>
    +      template <class T = unsigned, class Exact = mlc::final>
           class height_type:
    -	public attribute<oln_2_exact_vt_type(height_type, T, Exact)>
    +	public attribute<mlc_2_exact_vt_type(height_type, T, Exact)>
           {
           public:
     	typedef height_type<T, Exact>			self_type;
    @@ -297,13 +281,13 @@
     		      const oln_point_type(I)& p,
     		      const env_type&):
     	  reflevel_(input[p]),
    -	  value_(0)
    +	  value_(ntg_zero_val(value_type))
     	  {
     	  };
    
     	const value_type &getReflevel() const
     	  {
    -	    dispatch(getReflevel)();
    +	    mlc_dispatch(getReflevel)();
     	  };
    
     	// impl part
    @@ -312,14 +296,9 @@
     	    return reflevel_;
     	  };
    
    -	void equal_impl(lambda_type lambda)
    -	  {
    -	    value_ = lambda;
    -	  };
    -
     	void pe_impl(const height_type& rhs)
     	  {
    -	    value_ = my::diffabs(reflevel_, rhs.getReflevel());
    +	    value_ = tools::diffabs(reflevel_, rhs.getReflevel());
     	  };
    
     	bool less_impl(const lambda_type& lambda) const
    @@ -342,9 +321,9 @@
           | maxvalue  |
           *-----------*/
    
    -    template <class T, class Exact = mlc::final>
    +    template <class T = unsigned, class Exact = mlc::final>
         class maxvalue_type:
    -      public attribute<oln_2_exact_vt_type(maxvalue_type, T, Exact)>
    +      public attribute<mlc_2_exact_vt_type(maxvalue_type, T, Exact)>
         {
         public:
           typedef maxvalue_type<T, Exact>			self_type;
    @@ -368,7 +347,7 @@
    
           const value_type &getValue() const
     	{
    -	  dispatch(getValue)();
    +	  mlc_dispatch(getValue)();
     	};
    
           const value_type &getValue_impl() const
    @@ -378,7 +357,7 @@
    
           void pe_impl(const maxvalue_type& rhs)
     	{
    -	  value_ = my::max(value_, rhs.getValue());
    +	  value_ = ntg::max(value_, rhs.getValue());
     	};
    
           bool less_impl(const lambda_type& lambda) const
    @@ -400,9 +379,9 @@
           | minvalue  |
           *-----------*/
    
    -    template <class T, class Exact = mlc::final>
    +    template <class T = unsigned, class Exact = mlc::final>
         class minvalue_type:
    -      public attribute<oln_2_exact_vt_type(minvalue_type, T, Exact)>
    +      public attribute<mlc_2_exact_vt_type(minvalue_type, T, Exact)>
         {
         public:
           typedef minvalue_type<T, Exact>			self_type;
    @@ -426,7 +405,7 @@
    
           const value_type &getValue() const
     	{
    -	  dispatch(getValue)();
    +	  mlc_dispatch(getValue)();
     	};
    
           const value_type &getValue_impl() const
    @@ -436,7 +415,7 @@
    
           void pe_impl(const minvalue_type& rhs)
     	{
    -	  value_ = my::min(value_, rhs.getValue());
    +	  value_ = ntg::min(value_, rhs.getValue());
     	};
    
           bool less_impl(const lambda_type& lambda) const
    @@ -460,7 +439,7 @@
    
           template <class I, class Exact = mlc::final>
           class disk_type:
    -	public attribute<oln_2_exact_vt_type(disk_type, I, Exact)>
    +	public attribute<mlc_2_exact_vt_type(disk_type, I, Exact)>
           {
           public:
     	typedef disk_type<I, Exact>			self_type;
    @@ -487,7 +466,7 @@
    
     	const pts_type &getPts() const
     	  {
    -	    dispatch(getPts)();
    +	    mlc_dispatch(getPts)();
     	  };
    
     	// impl
    @@ -500,7 +479,7 @@
     	void pe_impl(const disk_type& rhs)
     	{
     	  std::copy(rhs.getPts().begin(), rhs.getPts().end(),
    std::back_inserter(pts_));
    -	  value_ = 0;
    +	  value_ = ntg_zero_val(value_type);
     	  for (cst_iter_type p1 = pts_.begin(); p1 != pts_.end(); ++p1)
     	    for (cst_iter_type p2 = pts_.begin(); p2 != pts_.end(); ++p2)
     	      {
    @@ -537,7 +516,7 @@
    
           template <class I, class Exact = mlc::final>
           class dist_type:
    -	public attribute<oln_2_exact_vt_type(dist_type, I, Exact)>
    +	public attribute<mlc_2_exact_vt_type(dist_type, I, Exact)>
           {
           public:
     	typedef dist_type<I, Exact>			self_type;
    @@ -546,9 +525,6 @@
     	typedef oln_point_type(im_type)			point_type;
     	typedef oln_dpoint_type(im_type)		dpoint_type;
    
    -// 	typedef float value_type;
    -// 	typedef value_type lambda_type;
    -
     	dist_type()
     	{
     	};
    @@ -556,7 +532,7 @@
     	dist_type(const im_type&,
     		  const point_type& p,
     		  const env_type &) :
    -	  value_(0),
    +	  value_(ntg_zero_val(value_type)),
     	  center_(p)
     	{
     	};
    @@ -567,7 +543,7 @@
    
     	const point_type &getCenter() const
     	  {
    -	    dispatch(getCenter)();
    +	    mlc_dispatch(getCenter)();
     	  };
    
     	// impl
    @@ -580,7 +556,7 @@
     	{
     	  dpoint_type	p = center_ - rhs.getCenter();
    
    -	  value_ = 0;
    +	  value_ = ntg_zero_val(value_type);
     	  for (int i = 0; i < point_traits<point_type>::dim; ++i)
     	    value_ += p.nth(i) * p.nth(i);
     	  value_ = sqrt(value_);
    @@ -610,7 +586,7 @@
    
           template <class I, class Exact = mlc::final>
           class square_type:
    -	public attribute<oln_2_exact_vt_type(square_type, I, Exact)>
    +	public attribute<mlc_2_exact_vt_type(square_type, I, Exact)>
           {
           public:
     	typedef square_type<I, Exact>			self_type;
    @@ -619,139 +595,177 @@
     	typedef oln_point_type(im_type)			point_type;
     	typedef oln_dpoint_type(im_type)		dpoint_type;
    
    -// 	typedef unsigned value_type;
    -// 	typedef value_type lambda_type;
    +	enum {dim = point_traits<point_type>::dim};
    
     	square_type()
     	{
     	}
    
    -	square_type(const lambda_type &lambda) : value_(lambda)
    +	square_type(const lambda_type &lambda):
    +	  mins_(dim),
    +	  maxs_(dim),
    +	  value_(lambda)
    +	  {
    +	    for (int i = 0; i < point_traits<point_type>::dim; ++i)
     	  {
    +		maxs_[i] = lambda;
    +		mins_[i] = ntg_zero_val(coord);
    +	      }
     	  };
    
     	square_type(const im_type&,
     		    const point_type& p,
     		    const env_type &) :
    -	  value_(0)
    +	  mins_(dim), maxs_(dim), value_(ntg_zero_val(value_type))
     	{
    -	  min_row_ = max_row_ = p.row();
    -	  min_col_ = max_col_ = p.col();
    +	  for (int i = 0; i < dim; ++i)
    +	    mins_[i] = maxs_[i] = p.nth(i);
     	}
    
    -	int getMinRow() const
    +	int getMin(int i) const
     	  {
    -	    dispatch(getMinRow)();
    +	    mlc_dispatch(getMin)(i);
     	  };
    
    -	int getMaxRow() const
    +	int getMax(int i) const
     	  {
    -	    dispatch(getMaxRow)();
    +	    mlc_dispatch(getMax)(i);
     	  };
    
    -	int getMaxCol() const
    +	// impl
    +	int getMin_impl(int i) const
     	  {
    -	    dispatch(getMaxCol)();
    +	    precondition(i < dim);
    +	    return mins_[i];
     	  };
    
    -	int getMinCol() const
    +	int getMax_impl(int i) const
     	  {
    -	    dispatch(getMinCol)();
    +	    precondition(i < dim);
    +	    return maxs_[i];
     	  };
    
    -	// impl
    -	int getMinRow_impl() const
    +	void pe_impl(const square_type &rhs)
    +	{
    +	  for (int i = 0; i < dim; ++i)
    +	    {
    +	      mins_[i] = ntg::min(mins_[i], rhs.getMin(i));
    +	      maxs_[i] = ntg::max(maxs_[i], rhs.getMax(i));
    +	    }
    +	  value_ = maxs_[0] - mins_[0];
    +	  for (int i = 1; i < dim; ++i)
    +	    if (value_ < value_type(maxs_[i] - mins_[i]))
    +	      value_ = maxs_[i] - mins_[i];
    +	}
    +
    +	bool less_impl(const lambda_type &lambda) const
    +	{
    +	  return value_ < lambda;
    +	}
    +
    +	bool ne_impl(const lambda_type &lambda) const
     	  {
    -	    return min_row_;
    +	    return value_ != lambda;
     	  };
    
    -	int getMaxRow_impl() const
    +      protected:
    +	std::vector<coord>	mins_;
    +	std::vector<coord>	maxs_;
    +	value_type		value_;
    +      };
    +
    +
    +
    +      /*-----------*
    +	| rectangle |
    +	*-----------*/
    +      template <class I, class Exact = mlc::final>
    +      class rectangle_type:
    +	public attribute<mlc_2_exact_vt_type(rectangle_type, I, Exact)>
     	  {
    -	    return max_row_;
    +      public:
    +	typedef rectangle_type<I, Exact>		self_type;
    +	attr_type_decl(self_type);
    +	typedef abstract::image<mlc_exact_type(I)>	im_type;
    +	typedef oln_point_type(im_type)			point_type;
    +	typedef oln_dpoint_type(im_type)		dpoint_type;
    +	enum {dim = point_traits<point_type>::dim };
    +
    +	rectangle_type(const lambda_type &lambda): maxs_(dim), mins_(dim)
    +	  {
    +	    for (int i = 0; i < dim; ++i)
    +	      {
    +		mins_[i] = ntg_zero_val(value_type);
    +		maxs_[i] = lambda[i];
    +	      }
     	  };
    
    -	int getMaxCol_impl() const
    +	rectangle_type()
    +	{
    +	}
    +
    +	rectangle_type(const im_type&, const point_type &p, const env_type &):
    maxs_(dim), mins_(dim)
    +	{
    +	  for (int i = 0; i < dim; ++i)
    +	    mins_[i] = maxs_[i] = p.nth(i);
    +	}
    +
    +	value_type getMin(int i) const
     	  {
    -	    return max_col_;
    +	    mlc_dispatch(getMin)(i);
     	  };
    
    -	int getMinCol_impl() const
    +	value_type getMax(int i) const
     	  {
    -	    return min_col_;
    +	    mlc_dispatch(getMax)(i);
     	  };
    
    -	void pe_impl(const square_type& rhs)
    +	// impl
    +	value_type getMin_impl(int i) const
    +	  {
    +	    precondition(i < point_traits<point_type>::dim);
    +	    return mins_[i];
    +	  };
    +
    +	value_type getMax_impl(int i) const
    +	  {
    +	    precondition(i < point_traits<point_type>::dim);
    +	    return maxs_[i];
    +	  };
    +
    +	void pe_impl(const rectangle_type &rhs)
    +	{
    +	  for (int i = 0; i < dim; ++i)
     	{
    -	  min_row_ = my::min(min_row_, rhs.getMinRow());
    -	  min_col_ = my::min(min_col_, rhs.getMinCol());
    -	  max_row_ = my::max(max_row_, rhs.getMaxRow());
    -	  max_col_ = my::max(max_col_, rhs.getMaxCol());
    -	  value_ = my::max(max_row_ - min_row_, max_col_ - min_col_);
    +	      mins_[i] = ntg::min(mins_[i], rhs.getMin(i));
    +	      maxs_[i] = ntg::max(maxs_[i], rhs.getMax(i));
    +	    }
     	}
    
     	bool less_impl(const lambda_type& lambda) const
     	{
    -	  return value_ < lambda;
    +	  for (int i = 0; i < dim; ++i)
    +	    if ((maxs_[i] - mins_[i]) >= lambda[i])
    +	      return false;
    +	  return true;
     	}
    
     	bool ne_impl(const lambda_type &lambda) const
     	  {
    -	    return value_ != lambda;
    +	    for (int i = 0; i < dim; ++i)
    +	      if ((maxs_[i] - mins_[i]) == lambda[i])
    +		return false;
    +	    return true;
     	  };
    
           protected:
    -	value_type	value_;
    -	int		min_row_;
    -	int		max_row_;
    -	int		min_col_;
    -	int		max_col_;
    +	std::vector<value_type>	maxs_;
    +	std::vector<value_type>	mins_;
           };
    
    -
    -
    -//       /*-----------*
    -// 	| rectangle |
    -// 	*-----------*/
    -//       template <class I, class Exact = mlc::final>
    -//       struct rectangle_type
    -//       {
    -// 	typedef unsigned value_type;
    -// 	typedef std::pair<value_type,value_type> lambda_type;
    -
    -// 	value_type drow, dcol;
    -// 	int min_row, max_row, min_col, max_col;
    -
    -// 	rectangle_type()
    -// 	{
    -// 	}
    -
    -// 	template <class T>
    -// 	rectangle_type(const image2d<T>&, const point2d& p) :
    -// 	  drow(0),
    -// 	  dcol(0)
    -// 	{
    -// 	  min_row = max_row = p.row();
    -// 	  min_col = max_col = p.col();
    -// 	}
    -
    -// 	void operator+=(const rectangle_type& rhs)
    -// 	{
    -// 	  min_row = my::min(min_row, rhs.min_row);
    -// 	  min_col = my::min(min_col, rhs.min_col);
    -// 	  max_row = my::max(max_row, rhs.max_row);
    -// 	  max_col = my::max(max_col, rhs.max_col);
    -// 	  drow = max_row - min_row;
    -// 	  dcol = max_col - min_col;
    -// 	}
    -
    -// 	bool operator>=(const lambda_type& lambda) const
    -// 	{
    -// 	  return drow >= lambda.first || dcol >= lambda.second;
    -// 	}
    -//       };
    -
    -
    -// traits specialisations
    +      /*-------------------------
    +	| traits specialisations |
    +	\------------------------*/
    
           // volume traits
    @@ -826,16 +840,18 @@
     	typedef NullEnv		env_type;
           };
    
    -//       // rectangle traits
    -//       tempalte <class Exact>
    -// 	typedef unsigned value_type;
    -// 	typedef std::pair<value_type,value_type> lambda_type;
    -
    +      // rectangle traits
    +      template <class I, class Exact>
    +      struct attr_traits<rectangle_type<I, Exact> >
    +      {
    +	typedef unsigned					value_type;
    +	typedef ntg::vec<I::dim, value_type, mlc::final>	lambda_type;
    +	typedef NullEnv						env_type;
    +      };
         }
       }
     }
    
    -
     /*-----------*
       |  diamond  |
       *-----------*/
    
        prcs2git-id: 10.62
    f4a29507
To find the state of this project's repository at the time of any of these versions, check out the tags.