box.hh

00001 // Copyright (C) 2001, 2002  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_CORE_BOX_HH
00029 # define OLENA_CORE_BOX_HH
00030 
00031 namespace oln {
00032 
00033   // FIXME: despite its usefulness, this box class is not good
00034   // FIXME: since it is not generic.
00035 
00036   template <class PointType>
00037   class box 
00038   {
00039   public:
00040     typedef typename PointType::dpoint_type  dpoint_type;
00041     typedef PointType                   point_type;
00042 
00043     enum { d = point_type::dim };
00044     
00045     box();
00046 
00047     unsigned    
00048     dim() const;
00049     
00050     void        
00051     add(point_type p);
00052     
00053     void        
00054     add(const box<PointType>& p);
00055     
00056     bool        
00057     overlay(unsigned dim, const box<PointType>& p) const;
00058     
00059     void        
00060     make_consistent();
00061     
00062     point_type  
00063     mass_center();
00064     
00065     point_type  
00066     box_center();
00067     
00068     point_type  
00069     mass_center() const;
00070     
00071     point_type  
00072     box_center() const;
00073     
00074     point_type  
00075     top() const;
00076     
00077     unsigned    
00078     card() const;
00079     
00080     unsigned    
00081     inner_boxes_card() const;
00082     
00083     point_type  
00084     bottom() const;
00085     
00086     unsigned    
00087     width() const;
00088     
00089     unsigned    
00090     height() const;
00091     
00092     unsigned    
00093     integrale() const;
00094     
00095     float       
00096     inner_boxes_mean_dim(unsigned i) const;
00097     
00098     unsigned    
00099     volume() const;
00100     
00101     unsigned    
00102     area() const;
00103     
00104     float       
00105     density() const;
00106     
00107     float       
00108     square_ratio() const;
00109     
00110   private:
00111     bool        not_consistent_;
00112     point_type  top_;
00113     point_type  bottom_;
00114     point_type  mass_center_;
00115     point_type  box_center_;
00116     float       inner_boxes_mean_dim_[point_type::dim];
00117     unsigned    card_;
00118     unsigned    box_card_;
00119     dpoint_type dimension_;
00120     float       mass_[point_type::dim];
00121   };
00122 
00123 } // end of oln.
00124 
00125 # include <oln/core/box.hxx>
00126 
00127 #endif // OLENA_CORE_BOX_HH

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