OpendTect-6_4  6.4
cubicbeziercurve.h
Go to the documentation of this file.
1 #ifndef cubicbeziercurve_h
2 #define cubicbeziercurve_h
3 
4 /*+
5 ________________________________________________________________________
6 (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7 Author: K. Tingdahl
8 Date: 2005
9 Contents: Ranges
10 RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "geometrymod.h"
16 #include "parametriccurve.h"
17 #include "sets.h"
18 
19 namespace Geometry
20 {
21 
24 public:
25  CubicBezierCurve( const Coord3&, const Coord3&,
26  int firstparam=0, int step=1 );
27  CubicBezierCurve* clone() const;
28  IntervalND<float> boundingBox(bool) const;
29 
30  Coord3 computePosition( float ) const;
31  Coord3 computeTangent( float ) const;
32 
33  StepInterval<int> parameterRange() const;
34 
35  Coord3 getPosition( GeomPosID ) const;
36  bool setPosition( GeomPosID, const Coord3&);
37  bool unsetPosition( GeomPosID );
39  bool insertPosition( GeomPosID, const Coord3& );
40  bool removePosition( GeomPosID );
42  bool isDefined( GeomPosID ) const;
43 
44  Coord3 getBezierVertex( GeomPosID, bool before ) const;
45 
46  Coord3 getTangent( GeomPosID, bool computeifudf ) const;
47  bool setTangent( GeomPosID, const Coord3& );
48  bool unsetTangent( GeomPosID );
49  bool isTangentDefined( GeomPosID ) const;
50  float directionInfluence() const;
51  void setTangentInfluence(float);
52 
53  bool isCircular() const;
54  bool setCircular(bool yn);
55 
56 protected:
57  int getIndex( GeomPosID param ) const
58  { return mCast(int,(param-firstparam)/paramstep); }
59 
60  Coord3 computeTangent( GeomPosID ) const;
61 
63  int paramstep;
67 
68  bool iscircular;
69 };
70 
74 inline Coord3 cubicDeCasteljau( const Coord3* p, char i0, char di, float u )
75 {
76  p += i0;
77  if ( mIsZero(u,1e-3) ) return *p;
78  else if ( mIsEqual(u,1,1e-3) ) return p[3*di];
79 
80  const float one_minus_u = 1-u;
81  Coord3 interpolpos1 = p[di]*one_minus_u+p[di*2] * u;
82 
83  const Coord3 interpolpos0 = (*p*one_minus_u+p[di]*u) * one_minus_u +
84  interpolpos1 * u;
85 
86  interpolpos1 = interpolpos1 * one_minus_u +
87  (p[di*2]*one_minus_u+p[3*di]*u) * u;
88 
89  return interpolpos0*one_minus_u+interpolpos1*u;
90 }
91 
92 
93 inline Coord3 cubicDeCasteljauTangent( const Coord3* p, char i0, char di,
94  float u)
95 {
96  p += i0;
97  if ( mIsZero(u,1e-3) ) return p[di]-*p;
98  else if ( mIsEqual(u,1,1e-3) ) return p[3*di]-p[2*di];
99 
100  const float one_minus_u = 1-u;
101  Coord3 interpolpos1 = p[di]*one_minus_u+p[2*di] * u;
102 
103  const Coord3 interpolpos0 = (*p*one_minus_u+p[di]*u) * one_minus_u +
104  interpolpos1 * u;
105 
106  interpolpos1 = interpolpos1 * one_minus_u +
107  (p[2*di]*one_minus_u+p[3*di]*u) * u;
108 
109  return interpolpos1-interpolpos0;
110 }
111 
112 };
113 
114 #endif
#define mExpClass(module)
Definition: commondefs.h:160
A curve that is defined by regularly sampled positions.
Definition: parametriccurve.h:32
float directioninfluence
Definition: cubicbeziercurve.h:66
Coord3 cubicDeCasteljauTangent(const Coord3 *p, char i0, char di, float u)
Definition: cubicbeziercurve.h:93
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
#define mIsZero(x, eps)
Definition: commondefs.h:53
#define mCast(tp, v)
Definition: commondefs.h:124
Coord3 cubicDeCasteljau(const Coord3 *p, char i0, char di, float u)
Definition: cubicbeziercurve.h:74
int firstparam
Definition: cubicbeziercurve.h:62
#define mIsEqual(x, y, eps)
Definition: commondefs.h:54
od_int64 GeomPosID
Definition: geomelement.h:21
TypeSet< Coord3 > directions
Definition: cubicbeziercurve.h:65
int getIndex(GeomPosID param) const
Definition: cubicbeziercurve.h:57
Class to store ranges in N dimensions.
Definition: ranges.h:209
bool iscircular
Definition: cubicbeziercurve.h:68
Definition: cubicbeziercurve.h:22
A cartesian coordinate in 3D space.
Definition: coord.h:72
TypeSet< Coord3 > positions
Definition: cubicbeziercurve.h:64
int paramstep
Definition: cubicbeziercurve.h:63
Definition: arraytesselator.h:21

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