Developer documentation | Axl-2.5.1

axlAbstractCurveParametric.cpp
Go to the documentation of this file.
1 /* axlAbstractCurveParametric.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Meriadeg Perrinel, Inria.
5  * Created: Tue Nov 9 17:03:56 2010 (+0100)
6  * Version: $Id$
7  * Last-Updated: Mon Nov 22 14:27:36 2010 (+0100)
8  * By: Meriadeg Perrinel
9  * Update #: 18
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 
23 //#include <axlCore/axlAbstractVisitorParametric.h>
24 
25 #include "axlPoint.h"
26 #include "axlMesh.h"
27 
28 #include <dtkCoreSupport/dtkGlobal.h>
29 
30 class axlAbstractCurveParametricPrivate
31 {
32 public:
33  int samples;
34  //axlAbstractVisitorParametric *visitor;
35 };
36 
37 axlAbstractCurveParametric::axlAbstractCurveParametric(void) : axlAbstractCurve(), d(new axlAbstractCurveParametricPrivate)
38 {
39  //d->visitor = NULL;
40 
41 }
42 
44 {
45  delete d;
46 
47  d = NULL;
48 }
49 
51 {
52  DTK_DEFAULT_IMPLEMENTATION;
53  return 0;
54 }
55 
57 {
58  DTK_DEFAULT_IMPLEMENTATION;
59  return 1;
60 }
61 
63 {
64 // if(d->visitor){
65 // return d->visitor->eval(u);
66 // }
67 
68  return axlPoint();
69 }
70 
71 
72 //axlAbstractVisitorParametric *axlAbstractCurveParametric::getVisitor(void){
73 // return d->visitor;
74 //}
75 
76 //void axlAbstractCurveParametric::setVisitor(axlAbstractVisitorParametric *visitor){
77 // d->visitor = visitor;
78 //}
79 
80 
81 axlMesh axlAbstractCurveParametric::eval(double u, int derivs, bool from_right)
82 {
83  Q_UNUSED(u);
84  Q_UNUSED(derivs);
85  Q_UNUSED(from_right);
86 
87  return axlMesh();
88 }
89 
91 {
92  DTK_DEFAULT_IMPLEMENTATION;
93  DTK_UNUSED(point);
94  DTK_UNUSED(u);
95 }
96 
97 
99 
100  unsigned N=200;
101 
102  double du = (this->endParam()-this->startParam())/N;
103  double um = this->startParam();
104 
105  axlPoint* P = new axlPoint;
106  this->eval(P, um);
107 
108  double dm = axlPoint::distance(point,*P);
109  double dd = dm;
110 
111  for (double u = um+du; u <= this->endParam(); u += du) {
112  this->eval(P,u);
113  if ((dd = axlPoint::distance(point,*P)) < dm) {
114  dm = dd;
115  um = u;
116  }
117  }
118 
119  delete P;
120 
121  return um;
122 }
123 
124 
126 {
127  DTK_DEFAULT_IMPLEMENTATION;
128 
129  return 0;
130 }
131 
133 {
134  DTK_DEFAULT_IMPLEMENTATION;
135 
136  return 0;
137 }
138 
140 {
141  Q_UNUSED(numSamples);
142 }
143 
145 {
146  return d->samples;
147 }
148 
150  DTK_UNUSED(direct);
151 }
152 
154 {
155  d->samples = samples;
156 }
virtual double length(double tolerance)
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
virtual void onDirectChanged(bool direct)
double parameterOf(const axlPoint &p)
virtual void setNumSamples(int numSamples)
static double distance(const axlPoint &lhs, const axlPoint &rhs)
Returns the distance between lhs point and rhs point.
Definition: axlPoint.cpp:459
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41