src/types/boundingbox.h

Sun, 10 Jun 2018 17:17:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 10 Jun 2018 17:17:42 +0300
changeset 1399
f52ea4078f5d
parent 1370
c6d5ba08c62c
permissions
-rw-r--r--

added the disc and disc negative to the circular primitive type

1315
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 /*
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
1326
69a90bd2dba2 Happy new year 2018
Teemu Piippo <teemu@hecknology.net>
parents: 1315
diff changeset
3 * Copyright (C) 2013 - 2018 Teemu Piippo
1315
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 *
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 * (at your option) any later version.
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 *
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 * GNU General Public License for more details.
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 *
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 */
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 #include "vertex.h"
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22 //
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 // Defines a bounding box that encompasses a given set of objects.
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 // vertex0 is the minimum vertex, vertex1 is the maximum vertex.
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 //
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 class BoundingBox
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
27 {
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 public:
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 BoundingBox();
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30
1370
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
31 void consider(const Vertex& vertex);
1315
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 Vertex center() const;
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 bool isEmpty() const;
1370
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
34 double longestMeasure() const;
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
35 void clear();
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
36 const Vertex& minimumVertex() const;
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
37 const Vertex& maximumVertex() const;
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
38 double spaceDiagonal() const;
1315
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 BoundingBox& operator<<(const Vertex& v);
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 private:
1370
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
43 bool storedIsEmpty = true;
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
44 Vertex minimum {inf, inf, inf};
c6d5ba08c62c reworked bounding box
Teemu Piippo <teemu@hecknology.net>
parents: 1326
diff changeset
45 Vertex maximum {-inf, -inf, -inf};
1315
23d48a709ffc moved Vertex and BoundingBox into new code units
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 };

mercurial