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 (C) 1992-2021 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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef _BBOX_3D_H_
31#define _BBOX_3D_H_
32
33#include <plugins/3dapi/xv3d_types.h> // SFVEC2F
34#include <glm/mat4x4.hpp>
35
36struct RAY;
37
38
42struct BBOX_3D
43{
44public:
48 BBOX_3D();
49
55 explicit BBOX_3D( const SFVEC3F& aPbInit );
56
63 BBOX_3D( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
64
65 ~BBOX_3D();
66
67
74 void Set( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
75
76 void Set( const BBOX_3D& aBBox );
77
82 void Set( const SFVEC3F& aPoint );
83
89 void Union( const SFVEC3F& aPoint );
90
96 void Union( const BBOX_3D& aBBox );
97
103 void Scale( float aScale );
104
108 void ScaleNextUp();
109
113 void ScaleNextDown();
114
120 bool Intersects( const BBOX_3D& aBBox ) const;
121
127 bool Inside( const SFVEC3F& aPoint ) const;
128
135 bool Inside( const BBOX_3D& aBBox ) const;
136
142 void ApplyTransformation( glm::mat4 aTransformMatrix );
143
149 float Volume() const;
150
156 bool IsInitialized() const;
157
161 void Reset();
162
168 SFVEC3F GetCenter() const;
169
175 float GetCenter( unsigned int aAxis ) const;
176
180 SFVEC3F Offset( const SFVEC3F& p ) const;
181
185 const SFVEC3F GetExtent() const;
186
192 const SFVEC3F& Min() const { return m_min; }
193
199 const SFVEC3F& Max() const { return m_max; }
200
201
205 unsigned int MaxDimension() const;
206
210 float GetMaxDimension() const;
211
215 float SurfaceArea() const;
216
222 bool Intersect( const RAY& aRay, float* t ) const;
223
224 bool Intersect( const RAY& aRay ) const;
225
234 bool Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) const;
235
236private:
239};
240
241#endif // _BBOX_3D_H_
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:43
void ScaleNextUp()
Scale a bounding box to the next float representation making it larger.
Definition: bbox_3d.cpp:194
BBOX_3D()
Create with default values a bounding box (not initialized)
Definition: bbox_3d.cpp:37
const SFVEC3F GetExtent() const
Definition: bbox_3d.cpp:145
bool Intersect(const RAY &aRay, float *t) const
Definition: bbox_3d_ray.cpp:46
void Union(const SFVEC3F &aPoint)
Recalculate the bounding box adding a point.
Definition: bbox_3d.cpp:102
SFVEC3F m_min
(12) point of the lower position of the bounding box
Definition: bbox_3d.h:237
SFVEC3F GetCenter() const
Return the center point of the bounding box.
Definition: bbox_3d.cpp:132
const SFVEC3F & Min() const
Return the minimum vertex pointer.
Definition: bbox_3d.h:192
SFVEC3F Offset(const SFVEC3F &p) const
Definition: bbox_3d.cpp:261
SFVEC3F m_max
(12) point of the higher position of the bounding box
Definition: bbox_3d.h:238
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:199
void Set(const SFVEC3F &aPbMin, const SFVEC3F &aPbMax)
Set bounding box with new parameters.
Definition: bbox_3d.cpp:68
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95
void ApplyTransformation(glm::mat4 aTransformMatrix)
Apply a transformation matrix to the box points.
Definition: bbox_3d.cpp:306
unsigned int MaxDimension() const
Definition: bbox_3d.cpp:151
bool Intersects(const BBOX_3D &aBBox) const
Test if a bounding box intersects this box.
Definition: bbox_3d.cpp:218
float SurfaceArea() const
Definition: bbox_3d.cpp:174
float Volume() const
Calculate the volume of a bounding box.
Definition: bbox_3d.cpp:251
float GetMaxDimension() const
Definition: bbox_3d.cpp:167
void ScaleNextDown()
Scale a bounding box to the next float representation making it smaller.
Definition: bbox_3d.cpp:206
~BBOX_3D()
Definition: bbox_3d.cpp:56
bool IsInitialized() const
Check if this bounding box is already initialized.
Definition: bbox_3d.cpp:88
bool Inside(const SFVEC3F &aPoint) const
Check if a point is inside this bounding box.
Definition: bbox_3d.cpp:231
void Scale(float aScale)
Scales a bounding box by its center.
Definition: bbox_3d.cpp:182
Definition: ray.h:63
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44