Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

VxSegmentList.h

00001 /*
00002  *  VxSegmentList
00003  *
00004  *  Copyright (c) 2000, TNO TPD, The Netherlands.
00005  *  All rights reserved. No part of this software may be handed to or used by persons 
00006  *  or organisation outside Kenniscentrum Watergraafsmeer (UvA-ISIS, TNO TPD) without 
00007  *  the written permission of TNO TPD.
00008  *
00009  *  Author(s):
00010  *      Jan Baan (baan@tpd.tno.nl)
00011  *
00012  */
00013 
00014 /* JV, 04Sep01: added sort function.
00015  * JV, 04Sep01: added highest and lowest frame function
00016  * JV, 04Sep01: added intersect function
00017  * JV, 04Sep01: added push_back for lists (merge)
00018  * JV, 04Sep01: converted std namespace functions to Horus approach
00019  */
00020 
00021 #ifndef VxSegmentList_h
00022 #define VxSegmentList_h
00023 
00024 #pragma warning( disable : 4786 )  
00025 
00026 #include <vector>
00027 #include "HxFeatureMap.h"
00028 #include "VxSegment.h"
00029 #include "HxIo.h"
00030 
00031 //using namespace std;
00032 
00033 class VxSegmentList
00034 {
00035 public:
00036     
00037     typedef std::vector<VxSegment>::const_iterator  const_iterator;
00038     typedef std::vector<VxSegment>::iterator            iterator;
00039 
00041                                 VxSegmentList();
00042 
00044                                 VxSegmentList(const HxString& filename);
00045 
00047                                 VxSegmentList(const VxSegmentList&);
00048 
00050                                 ~VxSegmentList();
00051 
00053     VxSegmentList&              operator=(const VxSegmentList& rhs);
00054 
00056     VxSegmentList*              clone() const;
00057 
00060     void                        push_back(const VxSegment& seg);
00061 
00064     void                        push_back(const VxSegmentList& sl);
00065 
00067     VxSegment                   get(int i) const;
00068 
00070     int                         size() const;
00071 
00074     const_iterator              begin_const() const;
00075 
00078     const_iterator              end_const() const;
00079 
00082     iterator                    begin();
00083 
00086     iterator                    end();
00087 
00092     STD_OSTREAM&                put(
00093                                     STD_OSTREAM& os = STD_COUT, 
00094                                     const std::vector<HxString>& fm = std::vector<HxString>()
00095                                     ) const;
00096 
00099     std::vector<HxString>       getIds() const;
00100 
00104     std::map<HxString,HxString> getTypes() const;
00105 
00108     void                        pushComment(const HxString &s) 
00109                                     {_data->_comment.push_back(s);}
00110 
00113     std::vector<HxString>       getComments() const 
00114                                     {return _data->_comment;}
00115 
00118     VxSegmentList               sort();
00119     
00124     int                         highestFrame();
00125 
00130     int                         lowestFrame();
00131 
00136     bool                        equal(VxSegmentList& sl);
00137 
00142     VxSegmentList               intersect(VxSegmentList& sl);
00143 
00144 /*  VxSegmentList               unite(VxSegmentList& sl); // TO DO */
00145 
00146 private:
00147     void                        read(STD_ISTREAM& is);
00148 
00149     struct VxSegmentListRep{
00151         std::vector<VxSegment>  _segVec;
00152 
00153         std::vector<HxString>   _comment;
00154 
00155         int                     refCount;
00156         VxSegmentListRep()      { refCount = 1;}
00157     };
00158 
00159     VxSegmentListRep*           _data; /* Pointer to actual data. */
00160 
00161 };
00162 
00163 
00164 inline STD_OSTREAM& operator<<(STD_OSTREAM&  os,const VxSegmentList& sl)
00165 {
00166     return sl.put(os);
00167 }
00168 
00169 
00170 inline 
00171 VxSegmentList::VxSegmentList() {
00172     _data = new VxSegmentListRep();
00173 }
00174 
00175 inline 
00176 VxSegmentList::VxSegmentList(const VxSegmentList& his)
00177     : _data(his._data)
00178 {
00179     _data->refCount++;  
00180 }
00181 
00182 inline 
00183 VxSegmentList::~VxSegmentList() {
00184     _data->refCount--;
00185     if (_data->refCount == 0)   
00186         delete _data;
00187 }
00188 
00189 inline VxSegmentList& 
00190 VxSegmentList::operator=(const VxSegmentList& rhs)
00191 {
00192     if (--_data->refCount<= 0 && _data != rhs._data)
00193         delete _data;
00194     (_data=rhs._data)->refCount++;     
00195     return *this;   
00196 }
00197 
00198 inline VxSegmentList*
00199 VxSegmentList::clone() const {
00200     return new VxSegmentList(*this);
00201 }
00202 
00203 
00204 inline int
00205 VxSegmentList::size() const {
00206     return _data->_segVec.size();
00207 }
00208 
00209 
00210 inline void 
00211 VxSegmentList::push_back(const VxSegment& seg) {
00212     _data->_segVec.push_back(seg);
00213 }
00214 
00215 inline void 
00216 VxSegmentList::push_back(const VxSegmentList& sl) {
00217     for (VxSegmentList::const_iterator it=sl.begin_const(); it!=sl.end_const(); it++)
00218         push_back(*it);
00219 }
00220 
00221 inline VxSegment
00222 VxSegmentList::get(int i) const {
00223     return _data->_segVec[i];
00224 }
00225 
00226 
00227 inline VxSegmentList::const_iterator 
00228 VxSegmentList::begin_const() const {
00229     return _data->_segVec.begin();
00230 }
00231 
00232 inline VxSegmentList::const_iterator 
00233 VxSegmentList::end_const() const {
00234     return _data->_segVec.end();
00235 }
00236 
00237 
00238 inline VxSegmentList::iterator 
00239 VxSegmentList::begin() {
00240     return _data->_segVec.begin();
00241 }
00242 
00243 inline VxSegmentList::iterator 
00244 VxSegmentList::end() {
00245     return _data->_segVec.end();
00246 }
00247 
00248 
00249 #endif

Generated on Tue Jan 8 13:59:19 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001