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
35struct RAY;
36
37
41struct BBOX_3D
42{
43public:
47 BBOX_3D();
48
54 explicit BBOX_3D( const SFVEC3F& aPbInit );
55
62 BBOX_3D( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
63
64 ~BBOX_3D();
65
66
73 void Set( const SFVEC3F& aPbMin, const SFVEC3F& aPbMax );
74
75 void Set( const BBOX_3D& aBBox );
76
81 void Set( const SFVEC3F& aPoint );
82
88 void Union( const SFVEC3F& aPoint );
89
95 void Union( const BBOX_3D& aBBox );
96
102 void Scale( float aScale );
103
107 void ScaleNextUp();
108
112 void ScaleNextDown();
113
119 bool Intersects( const BBOX_3D& aBBox ) const;
120
126 bool Inside( const SFVEC3F& aPoint ) const;
127
134 bool Inside( const BBOX_3D& aBBox ) const;
135
141 void ApplyTransformation( glm::mat4 aTransformMatrix );
142
148 float Volume() const;
149
155 bool IsInitialized() const;
156
160 void Reset();
161
167 SFVEC3F GetCenter() const;
168
174 float GetCenter( unsigned int aAxis ) const;
175
179 SFVEC3F Offset( const SFVEC3F& p ) const;
180
184 const SFVEC3F GetExtent() const;
185
191 const SFVEC3F& Min() const { return m_min; }
192
198 const SFVEC3F& Max() const { return m_max; }
199
200
204 unsigned int MaxDimension() const;
205
209 float GetMaxDimension() const;
210
214 float SurfaceArea() const;
215
221 bool Intersect( const RAY& aRay, float* t ) const;
222
223 bool Intersect( const RAY& aRay ) const;
224
233 bool Intersect( const RAY& aRay, float* aOutHitt0, float* aOutHitt1 ) const;
234
235private:
238};
239
240#endif // _BBOX_3D_H_
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:42
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:236
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:191
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:237
const SFVEC3F & Max() const
Return the maximum vertex pointer.
Definition: bbox_3d.h:198
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