QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsraycastingutils_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsraycastingutils_p.h
3  --------------------------------------
4  Date : June 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSRAYCASTINGUTILS_P_H
17 #define QGSRAYCASTINGUTILS_P_H
18 
20 
21 //
22 // W A R N I N G
23 // -------------
24 //
25 // This file is not part of the QGIS API. It exists purely as an
26 // implementation detail. This header file may change from version to
27 // version without notice, or even be removed.
28 //
29 
30 #include <QVector3D>
31 
32 #define SIP_NO_FILE
33 
34 class QgsAABB;
35 
36 namespace Qt3DRender
37 {
38  class QCamera;
39 }
40 
41 
42 namespace QgsRayCastingUtils
43 {
44 
50  class Ray3D
51  {
52  public:
53  Ray3D();
54  explicit Ray3D( QVector3D origin, QVector3D direction = QVector3D( 0.0f, 0.0f, 1.0f ), float distance = 1.0f );
55 
56  QVector3D origin() const;
57  void setOrigin( QVector3D value );
58 
59  QVector3D direction() const;
60  void setDirection( QVector3D value );
61 
62  float distance() const;
63  void setDistance( float distance );
64 
65  bool contains( QVector3D point ) const;
66  bool contains( const Ray3D &ray ) const;
67 
68  QVector3D point( float t ) const;
69  float projectedDistance( QVector3D point ) const;
70 
71  QVector3D project( QVector3D vector ) const;
72 
73  float distance( QVector3D point ) const;
74 
75  Ray3D &transform( const QMatrix4x4 &matrix );
76  Ray3D transformed( const QMatrix4x4 &matrix ) const;
77 
78  // TODO c++20 - replace with = default
79  bool operator==( const Ray3D &other ) const;
80  bool operator!=( const Ray3D &other ) const;
81 
82  private:
83  QVector3D m_origin;
84  QVector3D m_direction;
85  float m_distance = 1.0f;
86  };
87 
94  bool rayBoxIntersection( const Ray3D &r, const QgsAABB &aabb );
95 
101  bool rayTriangleIntersection( const Ray3D &ray,
102  QVector3D a,
103  QVector3D b,
104  QVector3D c,
105  QVector3D &uvw,
106  float &t );
107 }
108 
110 
111 #endif // QGSRAYCASTINGUTILS_P_H
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
operator!=
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:430
Qt3DRender
Definition: qgs3dmapscene.h:28
QgsAABB
Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:33
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1