Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SbLine.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _SB_LINE_
24#define _SB_LINE_
25
26#include <Inventor/SbBase.h>
27#include <Inventor/SbVec.h>
28#include <Inventor/SbBox.h>
29
30
32//
33// Class: SbLine
34//
35// Represents a directed line in 3D space.
36//
38
39class SbLined;
40
57class SbLine {
58public:
62 SbLine() {}
63
70 SbLine(const SbVec3f &p0, const SbVec3f &p1);
71
75 void setValue(const SbVec3f &p0, const SbVec3f &p1);
76
84 void setPosDir( const SbVec3f &position, const SbVec3f &direction );
85
89 void setValue( const SbLined& line );
90
97 SbVec3f &ptOnThis,
98 SbVec3f &ptOnLine2 ) const;
99
103 SbVec3f getClosestPoint(const SbVec3f &point) const;
104
108 inline const SbVec3f &getPosition() const { return pos; }
109
113 inline const SbVec3f &getDirection() const { return dir; }
114
118 static void setIntersectEpsilon(const float epsilon);
119
120 private:
121
125 SbBool intersect(const SbBox3f &box, SbVec3f &enter, SbVec3f &exit) const;
126
130 SbBool intersect(const SbXfBox3f &xbox, SbVec3f &enter, SbVec3f &exit) const;
131
135 SbBool intersect(float angle, const SbBox3f &box) const;
136
140 SbBool intersect(float angle, const SbVec3f &point) const;
141
145 SbBool intersect(float angle, const SbVec3f &v0, const SbVec3f &v1, SbVec3f &pt) const;
146
150 SbBool intersect(
151 const SbVec3f &v0, const SbVec3f &v1, const SbVec3f &v2,
152 SbVec3f &pt, SbVec3f &barycentric, SbBool &front
153 ) const;
154
155private:
156 // Parametric description:
157 // l(t) = pos + t * dir
158 SbVec3f pos;
159 SbVec3f dir;
160};
161
162//======================================================================
163
182class SbLined {
183public:
188
195 SbLined(const SbVec3d &p0, const SbVec3d &p1);
196
200 void setValue(const SbVec3d &p0, const SbVec3d &p1);
201
209 void setPosDir( const SbVec3d &position, const SbVec3d &direction );
210
214 void setValue( const SbLine& line );
215
222 SbVec3d &ptOnThis,
223 SbVec3d &ptOnLine2 ) const;
224
228 SbVec3d getClosestPoint(const SbVec3d &point) const;
229
230
234 inline const SbVec3d &getPosition() const { return pos; }
235
239 inline const SbVec3d &getDirection() const { return dir; }
240
244 static void setIntersectEpsilon(const double epsilon);
245
246 private:
247 // Intersect the line with a box, point, line, and triangle.
248 SbBool intersect(const SbBox3d &box,
249 SbVec3d &enter, SbVec3d &exit) const;
250 SbBool intersect(double angle, const SbBox3d &box) const;
251 SbBool intersect(double angle, const SbVec3d &point) const;
252 SbBool intersect(double angle, const SbVec3d &v0,
253 const SbVec3d &v1, SbVec3d &pt) const;
254 SbBool intersect(const SbVec3d &v0,
255 const SbVec3d &v1,
256 const SbVec3d &v2,
257 SbVec3d &pt, SbVec3d &barycentric,
258 SbBool &front) const;
259
260 SbVec3d getClosestPoint_( const SbVec3d &point,
261 double &projlen ) const;
262
263 bool getClosestPoints_( const SbLined &line2,
264 SbVec3d &ptOnThis,
265 SbVec3d &ptOnLine2,
266 double &s,
267 double &t) const;
268
269private:
270 // Parametric description:
271 // l(t) = pos + t * dir
272 SbVec3d pos;
273 SbVec3d dir;
274};
275
276// Inline methods
277
278inline void SbLine::setValue( const SbLined& line )
279{
280 pos.setValue( line.getPosition() );
281 dir.setValue( line.getDirection() );
282}
283
284inline void SbLined::setValue( const SbLine& line )
285{
286 pos.setValue( line.getPosition() );
287 dir.setValue( line.getDirection() );
288}
289
290#endif /* _SB_LINE_ */
291
292
SbBool enter(uintptr_t key, void *value)
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box class.
Definition SbBox.h:972
3D box class.
Definition SbBox.h:649
Directed line in 3D.
Definition SbLine.h:57
static void setIntersectEpsilon(const float epsilon)
Setup epsilon to detect intersection of very small geometry.
SbBool getClosestPoints(const SbLine &line2, SbVec3f &ptOnThis, SbVec3f &ptOnLine2) const
Finds the two closest points between this line and line2, and loads them into ptOnThis and ptOnLi...
const SbVec3f & getDirection() const
Returns direction vector of line.
Definition SbLine.h:113
SbLine()
Default constructor.
Definition SbLine.h:62
void setPosDir(const SbVec3f &position, const SbVec3f &direction)
Sets line using a position and a direction vector.
const SbVec3f & getPosition() const
Returns position of line origin point.
Definition SbLine.h:108
SbVec3f getClosestPoint(const SbVec3f &point) const
Returns the closest point on the line to the given point.
void setValue(const SbVec3f &p0, const SbVec3f &p1)
Sets line to pass through points p0 and p1.
SbLine(const SbVec3f &p0, const SbVec3f &p1)
Constructor.
Directed line in 3D (double precision).
Definition SbLine.h:182
SbVec3d getClosestPoint(const SbVec3d &point) const
Returns the closest point on the line to the given point.
SbLined(const SbVec3d &p0, const SbVec3d &p1)
Constructor.
static void setIntersectEpsilon(const double epsilon)
Setup epsilon to detect intersection of very small geometry.
void setPosDir(const SbVec3d &position, const SbVec3d &direction)
Sets line using a position and a direction vector.
SbBool getClosestPoints(const SbLined &line2, SbVec3d &ptOnThis, SbVec3d &ptOnLine2) const
Finds the two closest points between this line and line2, and loads them into ptOnThis and ptOnLi...
void setValue(const SbVec3d &p0, const SbVec3d &p1)
Sets line to pass through points p0 and p1.
const SbVec3d & getDirection() const
Returns direction vector of line.
Definition SbLine.h:239
SbLined()
Default constructor.
Definition SbLine.h:187
const SbVec3d & getPosition() const
Returns position of line origin point.
Definition SbLine.h:234
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
SbVec3d & setValue(const double v[3])
Sets the vector components.
Definition SbVec.h:1292
3D vector class.
Definition SbVec.h:932
SbVec3f & setValue(const float v[3])
Sets the vector components.
Definition SbVec.h:1010
3D box with an associated transformation matrix.
Definition SbBox.h:1250
int SbBool
Boolean type.
Definition SbBase.h:87