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

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