KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bbox_3d.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Mario Luzeiro <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
25
26#ifndef _BBOX_3D_H_
27#define _BBOX_3D_H_
28
29#include <plugins/3dapi/xv3d_types.h> // SFVEC2F
30#include <glm/mat4x4.hpp>
31
32struct RAY;
33
34
38struct BBOX_3D
39{
40public:
44 BBOX_3D();
45
51 explicit BBOX_3D( const SFVEC3F& aPbInit );
52
59 BBOX_3D( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
60
61 ~BBOX_3D();
62
63
70 void Set( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
71
72 void Set( const BBOX_3D& aBBox );
73
78 void Set( const SFVEC3F& aPoint );
79
85 void Union( const SFVEC3F& aPoint );
86
92 void Union( const BBOX_3D& aBBox );
93
99 void Scale( float aScale );
100
104 void ScaleNextUp();
105
109 void ScaleNextDown();
110
116 bool Intersects( const BBOX_3D& aBBox ) const;
117
123 bool Inside( const SFVEC3F& aPoint ) const;
124
131 bool Inside( const BBOX_3D& aBBox ) const;
132
138 void ApplyTransformation( glm::mat4 aTransformMatrix );
139
145 float Volume() const;
146
152 bool IsInitialized() const;
153
157 void Reset();
158
164 SFVEC3F GetCenter() const;
165
171 float GetCenter( unsigned int aAxis ) const;
172
176 SFVEC3F Offset( const SFVEC3F& p ) const;
177
181 const SFVEC3F GetExtent() const;
182
188 const SFVEC3F& Min() const { return m_min; }
189
195 const SFVEC3F& Max() const { return m_max; }
196
197
201 unsigned int MaxDimension() const;
202
206 float GetMaxDimension() const;
207
211 float SurfaceArea() const;
212
218 bool Intersect( const RAY& aRay, float* t ) const;
219
220 bool Intersect( const RAY& aRay ) const;
221
230 bool Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) const;
231
232private:
235};
236
237#endif // _BBOX_3D_H_
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
Definition bbox_3d.cpp:190
BBOX_3D()
Create with default values a bounding box (not initialized)
Definition bbox_3d.cpp:33
const SFVEC3F GetExtent() const
Definition bbox_3d.cpp:141
bool Intersect(const RAY &aRay, float *t) const
void Union(const SFVEC3F &aPoint)
Recalculate the bounding box adding a point.
Definition bbox_3d.cpp:98
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition bbox_3d.h:233
SFVEC3F GetCenter() const
Return the center point of the bounding box.
Definition bbox_3d.cpp:128
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition bbox_3d.h:188
SFVEC3F Offset(const SFVEC3F &p) const
Definition bbox_3d.cpp:257
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition bbox_3d.h:234
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition bbox_3d.h:195
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
Definition bbox_3d.cpp:64
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition bbox_3d.cpp:91
void ApplyTransformation(glm::mat4 aTransformMatrix)
Apply a transformation matrix to the box points.
Definition bbox_3d.cpp:302
unsigned int MaxDimension() const
Definition bbox_3d.cpp:147
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
Definition bbox_3d.cpp:214
float SurfaceArea() const
Definition bbox_3d.cpp:170
float Volume() const
Calculate the volume of a bounding box.
Definition bbox_3d.cpp:247
float GetMaxDimension() const
Definition bbox_3d.cpp:163
void ScaleNextDown()
Scale a bounding box to the next float representation making it smaller.
Definition bbox_3d.cpp:202
~BBOX_3D()
Definition bbox_3d.cpp:52
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition bbox_3d.cpp:84
bool Inside(const SFVEC3F &aPoint) const
Check if a point is inside this bounding box.
Definition bbox_3d.cpp:227
void Scale(float aScale)
Scales a bounding box by its center.
Definition bbox_3d.cpp:178
Definition ray.h:59
glm::vec3 SFVEC3F
Definition xv3d_types.h:40