Developer documentation | Axl-2.5.1

axlPlaneParametric.cpp
Go to the documentation of this file.
1 /* axlPlaneParametric.cpp ---
2  *
3  * Author: Valentin Michelet
4  * Copyright (C) 2008-2013 - Valentin Michelet, Inria.
5  * Created: Tue Jul 23 16:58:59 2013 (+0100)
6  */
7 
8 /* Commentary:
9  *
10  */
11 
12 /* Change log:
13  *
14  */
15 
16 #include "axlPlaneParametric.h"
17 #include "axlPlane.h"
18 #include "axlPoint.h"
19 
20 #include <dtkCoreSupport/dtkGlobal.h>
21 
22 // /////////////////////////////////////////////////////////////////
23 // axlPlaneParametricPrivate
24 // /////////////////////////////////////////////////////////////////
25 
26 class axlPlaneParametricPrivate {
27 public:
28  axlPlane* plane;
29  axlPoint* i;
30  axlPoint* j;
31 };
32 
33 // /////////////////////////////////////////////////////////////////
34 // axlPlaneParametric implementation
35 // /////////////////////////////////////////////////////////////////
36 
39  d(new axlPlaneParametricPrivate) {
40 
41  DTK_UNUSED(parent);
42 
43  this->setObjectName(this->identifier());
44 
45  d->plane = new axlPlane;
46  d->i = new axlPoint;
47  d->j = new axlPoint;
48 }
49 
52  d(new axlPlaneParametricPrivate) {
53 
54  this->setObjectName(this->identifier());
55 
56  d->plane = new axlPlane(plane);
57  d->i = new axlPoint(i);
58  d->i->normalize();
59  d->j = new axlPoint(axlPoint::crossProduct(plane->normal(), i));
60  d->j->normalize();
61 }
62 
65  d(new axlPlaneParametricPrivate) {
66 
67  this->setObjectName(this->identifier());
68 
69  d->plane = new axlPlane(plane);
70  d->i = new axlPoint(i);
71  d->i->normalize();
72  d->j = new axlPoint(axlPoint::crossProduct(plane.normal(), i));
73  d->j->normalize();
74 }
75 
78  d(new axlPlaneParametricPrivate) {
79 
80  this->setObjectName(this->identifier());
81  this->setParent(other.parent());
82 
83  d->plane = new axlPlane(other.d->plane);
84  d->i = new axlPoint(other.d->i);
85  d->i->normalize();
86  d->j = new axlPoint(other.d->j);
87  d->j->normalize();
88 }
89 
91  delete d->plane;
92  d->plane = NULL;
93  delete d->i;
94  d->i = NULL;
95  delete d->j;
96  d->j = NULL;
97 
98  delete d;
99  d = NULL;
100 }
101 
102 QString axlPlaneParametric::description(void) const {
103  QString result = "axlPlaneParametric";
104  result.append("\nPlane : " + d->plane->description()
105  + "\nu : " + d->i->description()
106  + "\nv : " + d->j->description());
107  return result;
108 }
109 
110 QString axlPlaneParametric::identifier(void) const {
111  return "axlPlaneParametric";
112 }
113 
115  *(d->plane) = plane;
116  *(d->j) = axlPoint::crossProduct(*(plane.normal()), *(d->i));
117  d->j->normalize();
118 }
119 
121  *(d->i) = *i;
122  d->i->normalize();
123  *(d->j) = axlPoint::crossProduct(*(d->plane->normal()), *i);
124  d->j->normalize();
125 }
126 
128  *(d->j) = *j;
129 }
130 
132  *(d->plane) = *(other.d->plane);
133  *(d->i) = *(other.d->i);
134  *(d->j) = *(other.d->j);
135 
136  return *this;
137 }
138 
140  d->i->coordinates()[0] = i[0];
141  d->i->coordinates()[1] = i[1];
142  d->i->coordinates()[2] = i[2];
143 }
144 
146  d->j->coordinates()[0] = j[0];
147  d->j->coordinates()[1] = j[1];
148  d->j->coordinates()[2] = j[2];
149 }
150 
152  return d->plane;
153 }
154 
156  return d->i;
157 }
158 
160  return d->j;
161 }
162 
163 
164 axlPoint axlPlaneParametric::eval(double u, double v) {
165  return *(d->plane->point()) + *(d->i)*u + *(d->j)*v;
166 }
167 
168 void axlPlaneParametric::eval(axlPoint* point, double u, double v) {
169  axlPoint p = *(d->plane->point()) + *(d->i)*u + *(d->j)*v;
170  point->setCoordinates(p.x(), p.y(), p.z());
171 }
172 
173 void axlPlaneParametric::eval(double& x, double& y, double& z, double u, double v) {
174  axlPoint p = *(d->plane->point()) + *(d->i)*u + *(d->j)*v;
175  x = p.x();
176  y = p.y();
177  z = p.z();
178 }
179 
180 void axlPlaneParametric::normal(axlPoint *normal, double, double) {
181  *(normal) = *(d->plane->normal());
182 }
183 
184 void axlPlaneParametric::parameterOf(const axlPoint& point, double& u, double& v) {
185  axlPoint* o = d->plane->point();
186 
187  axlPoint op = point - *o;
188  u = axlPoint::dotProduct(op, d->i);
189  v = axlPoint::dotProduct(op, d->j);
190 }
191 
192 
193 // /////////////////////
194 // Slots
195 // /////////////////////
197  *(d->plane) = *plane;
198 }
199 
201  *(d->i) = *i;
202 }
203 
205  *(d->j) = *j;
206 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
axlPlane * getPlane(void) const
void setPlane(const axlPlane &plane)
virtual void normal(axlPoint *normal, double, double)
Class axlPlane defines 3D planes.
Definition: axlPlane.h:34
virtual QString identifier(void) const
axlPlaneParametric & operator=(const axlPlaneParametric &other)
axlPoint * getJ(void) const
virtual void parameterOf(const axlPoint &point, double &u, double &v)
void setI(axlPoint *i)
void setJ(axlPoint *j)
axlPoint normal
Definition: axlPlane.h:37
static double dotProduct(const axlPoint &lhs, const axlPoint &rhs)
Definition: axlPoint.cpp:508
double y
Definition: axlPoint.h:37
virtual QString description(void) const
virtual ~axlPlaneParametric(void)
double z
Definition: axlPoint.h:38
axlPlaneParametric(axlAbstractSurfaceParametric *parent=0)
void onJChanged(axlPoint *j)
axlPoint * getI(void) const
static axlPoint crossProduct(const axlPoint &lhs, const axlPoint &rhs)
Returns the cross product between lhs (coords) and rhs (coords).
Definition: axlPoint.cpp:485
double x
Definition: axlPoint.h:37
void setCoordinates(double x, double y, double z)
Change coordinates of this point.
Definition: axlPoint.cpp:370
void onPlaneChanged(axlPlane *plane)
void onIChanged(axlPoint *i)
virtual axlPoint eval(double u, double v)