Horus Doc || C++ Reference || Class Overview   Pixels   Images   Detector   Geometry   Registry || Doxygen's 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  * JV, 18Jun02: added updateSeg function
00020  */
00021 
00022 #ifndef VxSegmentList_h
00023 #define VxSegmentList_h
00024 
00025 #pragma warning( disable : 4786 )  
00026 
00027 #include <vector>
00028 #include "HxFeatureMap.h"
00029 #include "VxSegment.h"
00030 #include "HxIo.h"
00031 
00032 //using namespace std;
00033 
00034 class VxSegmentList
00035 {
00036 public:
00037     
00038     typedef std::vector<VxSegment>::const_iterator  const_iterator;
00039     typedef std::vector<VxSegment>::iterator            iterator;
00040 
00042                                 VxSegmentList();
00043 
00045                                 VxSegmentList(const HxString& filename);
00046 
00048                                 VxSegmentList(const VxSegmentList&);
00049 
00051                                 ~VxSegmentList();
00052 
00054     VxSegmentList&              operator=(const VxSegmentList& rhs);
00055 
00057     VxSegmentList*              clone() const;
00058 
00061     void                        push_back(const VxSegment& seg);
00062 
00065     void                        push_back(const VxSegmentList& sl);
00066 
00068     VxSegment                   get(int i) const;
00069 
00071     int                         size() const;
00072 
00075     const_iterator              begin_const() const;
00076 
00079     const_iterator              end_const() const;
00080 
00083     iterator                    begin();
00084 
00087     iterator                    end();
00088 
00093     STD_OSTREAM&                put(
00094                                     STD_OSTREAM& os = STD_COUT, 
00095                                     const std::vector<HxString>& fm = std::vector<HxString>()
00096                                     ) const;
00097 
00100     std::vector<HxString>       getIds() const;
00101 
00105     std::map<HxString,HxString> getTypes() const;
00106 
00109     void                        pushComment(const HxString &s) 
00110                                     {_data->_comment.push_back(s);}
00111 
00114     std::vector<HxString>       getComments() const 
00115                                     {return _data->_comment;}
00116 
00119     VxSegmentList               sort();
00120     
00125     int                         highestFrame();
00126 
00131     int                         lowestFrame();
00132 
00137     bool                        equal(VxSegmentList& sl);
00138 
00143     VxSegmentList               intersect(VxSegmentList& sl);
00144 
00145 /*  VxSegmentList               unite(VxSegmentList& sl); // TO DO */
00146 
00151     bool                        updateSeg(int pos, VxSegment& seg);
00152 
00153 private:
00154     void                        read(STD_ISTREAM& is);
00155 
00156     struct VxSegmentListRep{
00158         std::vector<VxSegment>  _segVec;
00159 
00160         std::vector<HxString>   _comment;
00161 
00162         int                     refCount;
00163         VxSegmentListRep()      { refCount = 1;}
00164     };
00165 
00166     VxSegmentListRep*           _data; /* Pointer to actual data. */
00167 
00168 };
00169 
00170 
00171 inline STD_OSTREAM& operator<<(STD_OSTREAM&  os,const VxSegmentList& sl)
00172 {
00173     return sl.put(os);
00174 }
00175 
00176 
00177 inline 
00178 VxSegmentList::VxSegmentList() {
00179     _data = new VxSegmentListRep();
00180 }
00181 
00182 inline 
00183 VxSegmentList::VxSegmentList(const VxSegmentList& his)
00184     : _data(his._data)
00185 {
00186     _data->refCount++;  
00187 }
00188 
00189 inline 
00190 VxSegmentList::~VxSegmentList() {
00191     _data->refCount--;
00192     if (_data->refCount == 0)   
00193         delete _data;
00194 }
00195 
00196 inline VxSegmentList& 
00197 VxSegmentList::operator=(const VxSegmentList& rhs)
00198 {
00199     if (--_data->refCount<= 0 && _data != rhs._data)
00200         delete _data;
00201     (_data=rhs._data)->refCount++;     
00202     return *this;   
00203 }
00204 
00205 inline VxSegmentList*
00206 VxSegmentList::clone() const {
00207     return new VxSegmentList(*this);
00208 }
00209 
00210 
00211 inline int
00212 VxSegmentList::size() const {
00213     return _data->_segVec.size();
00214 }
00215 
00216 
00217 inline void 
00218 VxSegmentList::push_back(const VxSegment& seg) {
00219     _data->_segVec.push_back(seg);
00220 }
00221 
00222 inline void 
00223 VxSegmentList::push_back(const VxSegmentList& sl) {
00224     for (VxSegmentList::const_iterator it=sl.begin_const(); it!=sl.end_const(); it++)
00225         push_back(*it);
00226 }
00227 
00228 inline VxSegment
00229 VxSegmentList::get(int i) const {
00230     return _data->_segVec[i];
00231 }
00232 
00233 
00234 inline VxSegmentList::const_iterator 
00235 VxSegmentList::begin_const() const {
00236     return _data->_segVec.begin();
00237 }
00238 
00239 inline VxSegmentList::const_iterator 
00240 VxSegmentList::end_const() const {
00241     return _data->_segVec.end();
00242 }
00243 
00244 
00245 inline VxSegmentList::iterator 
00246 VxSegmentList::begin() {
00247     return _data->_segVec.begin();
00248 }
00249 
00250 inline VxSegmentList::iterator 
00251 VxSegmentList::end() {
00252     return _data->_segVec.end();
00253 }
00254 
00255 
00256 #endif

Generated on Tue Feb 3 14:18:45 2004 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001