OOFEM 3.0
Loading...
Searching...
No Matches
aabb.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include "aabb.h"
36#include <stdexcept>
37
38namespace oofem {
39
40Vector :: Vector() : Vector(0.0, 0.0, 0.0)
41{
42}
43
44Vector :: Vector(double x, double y, double z) : x(x), y(y), z(z)
45{
46}
47
48double
49Vector :: operator[](int index) const {
50 if (index == 0) return this->x;
51 if (index == 1) return this->y;
52 if (index == 2) return this->z;
53 throw std::out_of_range("Index out of range for Vector");
54}
55
56AABB :: AABB(const Vector& min, const Vector& max)
57{
58 this->min = min;
59 this->max = max;
60}
61
62bool
63AABB :: contains(const Vector& v)
64{
65 return (
66 this->min.x <= v.x
67 &&
68 v.x <= this->max.x
69 &&
70 this->min.y <= v.y
71 &&
72 v.y <= this->max.y
73 &&
74 this->min.z <= v.z
75 &&
76 v.z <= this->max.z
77 );
78}
79
80bool
81AABB :: contains(double x, double y, double z)
82{
83 return this->contains(Vector(x, y, z));
84}
85
86void
87AABB :: merge(double x, double y, double z)
88{
89 this->merge(Vector(x, y, z));
90}
91
92void
93AABB :: merge(const Vector& v)
94{
95 if (v.x < this->min.x) this->min.x = v.x;
96 if (v.y < this->min.y) this->min.y = v.y;
97 if (v.z < this->min.z) this->min.z = v.z;
98 if (v.x > this->max.x) this->max.x = v.x;
99 if (v.y > this->max.y) this->max.y = v.y;
100 if (v.z > this->max.z) this->max.z = v.z;
101}
102
103} // end namespace oofem
bool contains(CONTTYPE &cont, const T &t)
Definition CSG.h:1107
Vector min
Definition aabb.h:67
void merge(const Vector &v)
Expands the bounding box to include a given point.
Definition aabb.C:93
Vector max
Definition aabb.h:68
double z
Definition aabb.h:42
double x
Definition aabb.h:42
double y
Definition aabb.h:42

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011