 |
OpendTect
6.6
|
Go to the documentation of this file.
28 : closed_( closed ) {}
32 , closed_( closed ) {}
37 double distTo(
const T& pt,
int* segmentidxptr=0,
38 double* fractionptr=0)
const;
40 T closestPoint(
const T& pt)
const;
42 double arcLength(
int idx,
double frac=0.0)
const;
43 double arcLength(
const T& pt)
const;
44 double arcLength()
const;
46 T getPoint(
int idx,
double frac=0.0)
const;
47 T getPoint(
double arclen)
const;
51 int nextIdx(
int)
const;
56 template <
class T>
inline
59 if ( idx<0 || idx>=this->size() || !(*
this)[idx].isDefined() )
63 if ( idy>=this->size() || !(*
this)[idy].isDefined() )
65 while ( (--idy)>=0 && (*
this)[idy].isDefined() ) ;
69 if ( !closed_ && idy!=idx )
89 #define mUpdateMinDist( dist, idx, frac ) \
93 if ( segmentidxptr ) \
94 *segmentidxptr = idx; \
96 *fractionptr = frac; \
99 template <
class T>
inline
101 double* fractionptr )
const
105 for (
int idx=0; idx<this->size(); idx++ )
107 const int idy = nextIdx( idx );
111 const double a2 = pt.sqDistTo( (*
this)[idx] );
112 const double b2 = pt.sqDistTo( (*
this)[idy] );
113 const double c2 = (*this)[idx].sqDistTo( (*
this)[idy] );
115 if ( c2<=0.0 || b2>=a2+c2 )
120 else if ( a2 >= b2+c2 )
128 const double d = (a2+c2-b2) / (2*c);
129 const double h = (a2-d*d)>0 ?
Math::Sqrt(a2-d*d) : 0.0;
138 template <
class T>
inline
143 if (
mIsUdf( distTo(pt,&idx,&frac) ) )
146 const int idy = nextIdx( idx );
150 return (*
this)[idx]*(1.0-frac) + (*
this)[idy]*frac;
154 template <
class T>
inline
157 if ( index<0 || index>=this->size() || frac<0.0 || frac>1.0 )
162 for (
int idx=0; idx<=index; idx++ )
164 const int idy = nextIdx( idx );
168 const double len = (*this)[idx].distTo( (*
this)[idy] );
170 return arclen + len * frac;
179 template <
class T>
inline
184 if (
mIsUdf( distTo(pt,&idx,&frac) ) )
187 return arcLength( idx, frac );
191 template <
class T>
inline
194 return arcLength( this->size()-1, 1.0 );
198 template <
class T>
inline
201 if ( idx<0 || idx>=this->size() || frac<0.0 || frac>1.0 )
207 if ( frac==1.0 && !(*
this)[idx].isDefined() )
208 return getPoint( idx+1, 0.0 );
210 const int idy = nextIdx( idx );
214 return (*
this)[idx]*(1.0-frac) + (*
this)[idy]*frac;
218 template <
class T>
inline
224 for (
int idx=0; idx<this->size(); idx++ )
226 const int idy = nextIdx( idx );
230 const double len = (*this)[idx].distTo( (*
this)[idy] );
233 const double frac = arclen / len;
234 return (*
this)[idx]*(1.0-frac) + (*
this)[idy]*frac;
(Closed) sequence(s) of connected n-D coordinates. Undefined coordinates separate consecutive sequenc...
Definition: polylinend.h:25
double arcLength() const
Definition: polylinend.h:192
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
T closestPoint(const T &pt) const
Definition: polylinend.h:139
void setClosed(bool yn)
Definition: polylinend.h:34
#define mClass(module)
Definition: commondefs.h:181
PolyLineND(const TypeSet< T > &coords, bool closed=false)
Definition: polylinend.h:30
#define MAXDOUBLE
Definition: commondefs.h:120
#define mUpdateMinDist(dist, idx, frac)
Point-to-segment distance:
Definition: polylinend.h:89
bool closed_
Definition: polylinend.h:52
PolyLineND(bool closed=false)
Definition: polylinend.h:27
double distTo(const T &pt, int *segmentidxptr=0, double *fractionptr=0) const
Definition: polylinend.h:100
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
bool isClosed() const
Definition: polylinend.h:35
T getPoint(int idx, double frac=0.0) const
Definition: polylinend.h:199
int nextIdx(int) const
Definition: polylinend.h:57
Sets of (small) copyable elements.
Definition: commontypes.h:29
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021