OpendTect-6_4  6.4
posinfo2d.h
Go to the documentation of this file.
1 #ifndef posinfo2d_h
2 #define posinfo2d_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Bert
9  Date: Jul 2010 (org 2005 / 2008)
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "basicmod.h"
16 #include "typeset.h"
17 #include "coord.h"
18 #include "bufstring.h"
19 #include "od_iosfwd.h"
20 
21 
22 namespace PosInfo
23 {
24 
30 {
31 public:
32 
33  Line2DPos( int n=0 ) : nr_(n) {}
34  bool operator ==( const Line2DPos& p ) const { return nr_ == p.nr_; }
35  bool operator !=( const Line2DPos& p ) const { return nr_ != p.nr_; }
36  bool operator >( const Line2DPos& p ) const { return nr_ > p.nr_; }
37  bool operator <( const Line2DPos& p ) const { return nr_ < p.nr_; }
38  bool operator >=( const Line2DPos& p ) const { return nr_>=p.nr_; }
39  bool operator <=( const Line2DPos& p ) const { return nr_<=p.nr_; }
40 
41  int nr_;
43 
44 };
45 
46 
52 {
53 public:
54  Line2DPos3D( int n=0, float z=mUdf(float) )
55  : Line2DPos(n), z_(z) {}
56 
57  float z_;
58 };
59 
60 
66 {
67 public:
68  Line2DData(const char* lnm=0);
69 
70  Line2DData(const Line2DData& l2d)
71  : zrg_(l2d.zRange())
72  , lnm_(l2d.lineName())
73  , posns_(l2d.positions()){}
74 
75  const StepInterval<float>& zRange() const { return zrg_; }
76  const OD::String& lineName() const { return lnm_; }
77  void setZRange( const StepInterval<float>& zrg )
78  { zrg_ = zrg; }
79  void setLineName( const char* lnm ) { lnm_ = lnm; }
80  int size() const { return posns_.size();}
81  const TypeSet<Line2DPos>& positions() const { return posns_; }
82  bool isEmpty() const { return posns_.isEmpty(); }
83 
84  void add(const Line2DPos&);
85  void remove(int trcnr);
86  void setEmpty() { posns_.erase(); }
87  void limitTo(Interval<int> trcrg);
88 
89  int indexOf(int trcnr) const;
90  int nearestIdx( const Coord& crd ) const
91  { return gtIndex(crd); }
92  int nearestIdx(const Coord&,
93  const Interval<int>& trcnrrg) const;
94 
95  bool getPos(const Coord& crd,Line2DPos& l2p,
96  float* dist=0) const;
97  bool getPos(const Coord& crd,Line2DPos& l2p,
98  float threshold_distance) const;
99  bool getPos(int trcnr,Line2DPos&) const;
100 
101  void dump(od_ostream&,bool pretty=true) const;
102  bool read(od_istream&,bool asc);
103  bool write(od_ostream&,bool asc,bool newlns=false) const;
104 
105  const TypeSet<int>& getBendPoints() const;
106  void getBendPositions(TypeSet<Line2DPos>&) const;
107  void setBendPoints(const TypeSet<int>&);
108 
109  StepInterval<Pos::TraceID> trcNrRange() const;
110  Coord getNormal(int trcnr) const;
111  void compDistBetwTrcsStats(float& max,float& median) const;
112  float distBetween(int startnr,int stopnr) const;
113 
114  bool coincidesWith(const Line2DData&) const;
119 protected:
120 
125 
126  int gtIndex(int,bool&) const;
127  int gtIndex(const Coord&,double* sqdist=0) const;
128  int getSegmentIndexClosestToPoint(const Coord&) const;
129 
130  friend class Line2DDataIterator;
131 
132 };
133 
134 
138 {
139 public:
140 
142  : ld_(ld), idx_(-1) {}
143 
144  inline bool next()
145  {
146  idx_++;
147  return idx_ < ld_.posns_.size();
148  }
149 
150  inline void reset() { idx_ = -1; }
151  inline const Line2DPos& line2DPos() const { return ld_.posns_[idx_]; }
152  inline int trcNr() const
153  { return idx_>=0 ? ld_.posns_[idx_].nr_ : mUdf(int); }
154  inline void setTrcNr( int trcnr )
155  { idx_ = ld_.indexOf( trcnr ); }
156 
157  const Line2DData& ld_;
158  int idx_;
159 
160 };
161 
162 
163 } // namespace PosInfo
164 
165 #endif
#define mExpClass(module)
Definition: commondefs.h:160
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:26
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
const Line2DData & ld_
Definition: posinfo2d.h:157
int nr_
Definition: posinfo2d.h:41
const TypeSet< Line2DPos > & positions() const
Definition: posinfo2d.h:81
const StepInterval< float > & zRange() const
Definition: posinfo2d.h:75
void setEmpty()
Definition: posinfo2d.h:86
int nearestIdx(const Coord &crd) const
Definition: posinfo2d.h:90
int size() const
Definition: posinfo2d.h:80
void setLineName(const char *lnm)
Definition: posinfo2d.h:79
Line2DPos with a z value.
Definition: posinfo2d.h:51
TypeSet< Line2DPos > posns_
Definition: posinfo2d.h:123
Position info for a 2D line.
Definition: posinfo2d.h:65
A cartesian coordinate in 2D space.
Definition: coord.h:25
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
void reset()
Definition: posinfo2d.h:150
BufferString lnm_
Definition: posinfo2d.h:122
OD class for stream read.
Definition: od_istream.h:24
Line2DDataIterator(const Line2DData &ld)
Definition: posinfo2d.h:141
Set of (small) copyable elements.
Definition: commontypes.h:30
bool isEmpty() const
Definition: posinfo2d.h:82
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
One position on a 2D line.
Definition: posinfo2d.h:29
int idx_
Definition: posinfo2d.h:158
Line2DData(const Line2DData &l2d)
Definition: posinfo2d.h:70
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:62
void setTrcNr(int trcnr)
Definition: posinfo2d.h:154
bool next()
Definition: posinfo2d.h:144
StepInterval< float > zrg_
Definition: posinfo2d.h:121
Iterates through Line2DData.
Definition: posinfo2d.h:137
Position info, often segmented.
Definition: posinfo.h:40
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
float z_
Definition: posinfo2d.h:57
TypeSet< int > bendpoints_
Definition: posinfo2d.h:124
int trcNr() const
Definition: posinfo2d.h:152
Coord coord_
Definition: posinfo2d.h:42
void setZRange(const StepInterval< float > &zrg)
Definition: posinfo2d.h:77
Line2DPos3D(int n=0, float z=Values::Undef< float >::val())
Definition: posinfo2d.h:54
const Line2DPos & line2DPos() const
Definition: posinfo2d.h:151
Line2DPos(int n=0)
Definition: posinfo2d.h:33
const OD::String & lineName() const
Definition: posinfo2d.h:76

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019