OpendTect  6.3
posinfo2d.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: Jul 2010 (org 2005 / 2008)
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "basicmod.h"
14 #include "typeset.h"
15 #include "coord.h"
16 #include "bufstring.h"
17 #include "od_iosfwd.h"
18 
19 
20 namespace PosInfo
21 {
22 
28 {
29 public:
30 
31  Line2DPos( int n=0 ) : nr_(n) {}
32  bool operator ==( const Line2DPos& p ) const { return nr_ == p.nr_; }
33  bool operator !=( const Line2DPos& p ) const { return nr_ != p.nr_; }
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 
39  int nr_;
41 
42 };
43 
44 
50 {
51 public:
52  Line2DPos3D( int n=0, float z=mUdf(float) )
53  : Line2DPos(n), z_(z) {}
54 
55  float z_;
56 };
57 
58 
64 {
65 public:
66  Line2DData(const char* lnm=0);
67 
68  Line2DData(const Line2DData& l2d)
69  : zrg_(l2d.zRange())
70  , lnm_(l2d.lineName())
71  , posns_(l2d.positions()){}
72 
73  const StepInterval<float>& zRange() const { return zrg_; }
74  const OD::String& lineName() const { return lnm_; }
75  void setZRange( const StepInterval<float>& zrg )
76  { zrg_ = zrg; }
77  void setLineName( const char* lnm ) { lnm_ = lnm; }
78  int size() const { return posns_.size();}
79  const TypeSet<Line2DPos>& positions() const { return posns_; }
80  bool isEmpty() const { return posns_.isEmpty(); }
81 
82  void add(const Line2DPos&);
83  void remove(int trcnr);
84  void setEmpty() { posns_.erase(); }
85  void setPositions( const TypeSet<Line2DPos>& posns )
86  { posns_ = posns; }
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  StepInterval<Pos::TraceID> trcNrRange() const;
106  Coord getNormal(int trcnr) const;
107  void compDistBetwTrcsStats(float& max, float& median) const;
108  float distBetween(int startnr,int stopnr) const;
109 
110  bool coincidesWith(const Line2DData&) const;
115 protected:
116 
120 
121  int gtIndex(int,bool&) const;
122  int gtIndex(const Coord&,double* sqdist=0) const;
123 
124  friend class Line2DDataIterator;
125 
126 };
127 
128 
132 {
133 public:
134 
136  : ld_(ld), idx_(-1) {}
137 
138  inline bool next()
139  {
140  idx_++;
141  return idx_ < ld_.posns_.size();
142  }
143 
144  inline void reset() { idx_ = -1; }
145  inline const Line2DPos& line2DPos() const { return ld_.posns_[idx_]; }
146  inline int trcNr() const { return ld_.posns_[idx_].nr_; }
147  inline void setTrcNr( int trcnr )
148  { idx_ = ld_.indexOf( trcnr ); }
149 
150  const Line2DData& ld_;
151  int idx_;
152 
153 };
154 
155 
156 } // namespace PosInfo
#define mExpClass(module)
Definition: commondefs.h:157
bool operator>(const NamedObject &obj1, const NamedObject &obj2)
Definition: namedobj.h:75
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
const Line2DData & ld_
Definition: posinfo2d.h:150
int nr_
Definition: posinfo2d.h:39
const TypeSet< Line2DPos > & positions() const
Definition: posinfo2d.h:79
const StepInterval< float > & zRange() const
Definition: posinfo2d.h:73
void setEmpty()
Definition: posinfo2d.h:84
int nearestIdx(const Coord &crd) const
Definition: posinfo2d.h:90
int size() const
Definition: posinfo2d.h:78
void setLineName(const char *lnm)
Definition: posinfo2d.h:77
Line2DPos with a z value.
Definition: posinfo2d.h:49
TypeSet< Line2DPos > posns_
Definition: posinfo2d.h:119
Position info for a 2D line.
Definition: posinfo2d.h:63
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:173
void reset()
Definition: posinfo2d.h:144
BufferString lnm_
Definition: posinfo2d.h:118
OD class for stream read.
Definition: od_istream.h:23
Line2DDataIterator(const Line2DData &ld)
Definition: posinfo2d.h:135
Set of (small) copyable elements.
Definition: commontypes.h:26
bool isEmpty() const
Definition: posinfo2d.h:80
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
One position on a 2D line.
Definition: posinfo2d.h:27
int idx_
Definition: posinfo2d.h:151
Line2DData(const Line2DData &l2d)
Definition: posinfo2d.h:68
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
void setTrcNr(int trcnr)
Definition: posinfo2d.h:147
bool next()
Definition: posinfo2d.h:138
StepInterval< float > zrg_
Definition: posinfo2d.h:117
Iterates through Line2DData.
Definition: posinfo2d.h:131
void setPositions(const TypeSet< Line2DPos > &posns)
Definition: posinfo2d.h:85
Position info, often segmented.
Definition: posinfo.h:38
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
float z_
Definition: posinfo2d.h:55
int trcNr() const
Definition: posinfo2d.h:146
Coord coord_
Definition: posinfo2d.h:40
void setZRange(const StepInterval< float > &zrg)
Definition: posinfo2d.h:75
Line2DPos3D(int n=0, float z=Values::Undef< float >::val())
Definition: posinfo2d.h:52
2D point or vector class.
Definition: commontypes.h:58
const Line2DPos & line2DPos() const
Definition: posinfo2d.h:145
Line2DPos(int n=0)
Definition: posinfo2d.h:31
const OD::String & lineName() const
Definition: posinfo2d.h:74

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