segment.hh

00001 // Copyright (C) 2004  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00016 // MA 02111-1307, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
00027 
00028 #ifndef OLENA_SNAKES_SEGMENT_HH
00029 # define OLENA_SNAKES_SEGMENT_HH
00030 
00031 #include <oln/snakes/node.hh>
00032 
00033 #include <vector>
00034 #include <list>
00035 
00036 namespace oln {
00037 
00038   namespace snakes {
00039 
00044     template <class I>
00045     class segment
00046     {
00047     public:
00048       typedef typename std::vector<node<I> >::iterator iter_type;
00049       typedef typename std::vector<node<I> >::const_iterator const_iter_type;
00050       typedef typename I::point_type point_type;
00051 
00052     public:
00053       segment(std::list<point_type>& initial_contour);
00054 
00055     public:
00056       inline
00057       ntg::float_s
00058       energy(const I& gradient) const;
00062 
00063 
00064     public:
00065       std::list<point_type>
00066       contour(void) const;
00068 
00069     public:
00070       const_iter_type begin(void) const;
00071       iter_type begin(void);
00073       const_iter_type end(void) const;
00074       iter_type end(void);
00076 
00077     public:
00078       const node<I> prev_node(void) const;
00080       const node<I> next_node(void) const;
00082 
00083     private:
00084       std::vector<node<I> >     nodes;
00085       segment&                  prev_segment;
00086       segment&                  next_segment;
00087 
00088       const node<I> front(void) const;
00089       const node<I> back(void) const;
00090 
00091       friend
00092       std::ostream&
00093       ::operator<< <>(std::ostream&, const segment&);
00094     };
00095 
00096   } // end snakes
00097 
00098 } // end oln
00099 
00100 
00101 template <class I>
00102 std::ostream& operator<<(std::ostream& os, const oln::snakes::segment<I>& s)
00103 {
00104   os << "Segment:" << std::endl;
00105   for (typename oln::snakes::segment<I>::const_iter_type it = s.begin();
00106        it != s.end();
00107        ++it)
00108     os << *it << std::endl;
00109   return os;
00110 }
00111 
00112 #include <oln/snakes/segment.hxx>
00113 
00114 #endif // !OLENA_SNAKES_SEGMENT_HH

Generated on Thu Apr 15 20:13:14 2004 for Olena by doxygen 1.3.6-20040222