Wed, 05 Mar 2014 18:30:04 +0200
- doxygenified Types.h
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013, 2014 Santeri Piippo |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
641
425b169a82aa
- changed header guards into #pragma once
Santeri Piippo <crimsondusk64@gmail.com>
parents:
629
diff
changeset
|
19 | #pragma once |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QString> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QObject> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QStringList> |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QMetaType> |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
24 | #include "Macros.h" |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | class LDObject; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | class QFile; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | class QTextStream; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | using int8 = qint8; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | using int16 = qint16; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | using int32 = qint32; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | using int64 = qint64; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | using uint8 = quint8; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | using uint16 = quint16; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | using uint32 = quint32; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | using uint64 = quint64; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
39 | template<typename T, typename R> |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
40 | using Pair = std::pair<T, R>; |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | enum Axis |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | X, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | Y, |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | Z |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | // ============================================================================= |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | class LDObject; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | using LDObjectList = QList<LDObject*>; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
54 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
55 | //! \brief A mathematical 3 x 3 matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
56 | //! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | class Matrix |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
60 | //! Constructs a matrix with undetermined values. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | Matrix() {} |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
62 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
63 | //! Constructs a matrix with the given values. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
64 | //! \note \c vals is expected to have exactly 9 elements. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
65 | Matrix (const QList<double>& vals); |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
66 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
67 | //! Constructs a matrix all 9 elements initialized to the same value. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
68 | //! \param fillval the value to initialize the matrix coordinates as |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | Matrix (double fillval); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
70 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
71 | //! Constructs a matrix with a C-array. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
72 | //! \note \c vals is expected to have exactly 9 elements. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | Matrix (double vals[]); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
75 | //! Calculates the matrix's determinant. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
76 | //! \returns the calculated determinant. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | double getDeterminant() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
78 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
79 | //! Multiplies this matrix with \c other |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
80 | //! \param other the matrix to multiply with. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
81 | //! \returns the resulting matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
82 | //! \note a.mult(b) is not equivalent to b.mult(a)! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | Matrix mult (const Matrix& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
84 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
85 | //! Prints the matrix to stdout. |
644
93dcd1a0e4bd
- replaced the fmt/log/dlog/fprint macros in favor of template functions. renamed to format, print, dprint and fprint respectively.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
642
diff
changeset
|
86 | void dump() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
87 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
88 | //! \returns a string representation of the matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | QString toString() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
90 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
91 | //! Zeroes the matrix out. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | void zero(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
93 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
94 | //! Assigns the matrix values to the values of \c other. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
95 | //! \param other the matrix to assign this to. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
96 | //! \returns a reference to self |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | Matrix& operator= (const Matrix& other); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
99 | //! \returns a mutable reference to a value by \c idx |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
100 | inline double& value (int idx) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | return m_vals[idx]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
105 | //! An overload of \c value() for const matrices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
106 | //! \returns a const reference to a value by \c idx |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
107 | inline const double& value (int idx) const |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | return m_vals[idx]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
112 | //! An operator overload for \c mult(). |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
113 | //! \returns the multiplied matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | inline Matrix operator* (const Matrix& other) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | return mult (other); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
119 | //! An operator overload for \c value(). |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
120 | //! \returns a mutable reference to a value by \c idx |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | inline double& operator[] (int idx) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | { |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
123 | return value (idx); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
126 | //! An operator overload for \c value() const. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
127 | //! \returns a const reference to a value by \c idx |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | inline const double& operator[] (int idx) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | { |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
130 | return value (idx); |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
133 | //! \param other the matrix to check against |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
134 | //! \returns whether the two matrices have the same values. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | bool operator== (const Matrix& other) const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | private: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | double m_vals[9]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
141 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
142 | //! \brief A vertex in 3D space |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
143 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
144 | //! Contains a single point in 3D space. Not to be confused with |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
145 | //! LDVertex, which is a vertex used in an LDraw part file. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
146 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
147 | //! This also sees use as a position vector. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
148 | //! |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | class Vertex |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
152 | //! Constructs a zero vertex |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
153 | Vertex() : m_coords({0, 0, 0}) {} |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
154 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
155 | //! Constructs a vertex with the given \c x, \c y and \c z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | Vertex (double x, double y, double z); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
158 | //! \returns the distance from this vertex to \c other |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | double distanceTo (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
160 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
161 | //! \returns the vertex at the midpoint between this and \c other |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | Vertex midpoint (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
163 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
164 | //! Moves this vertex using \param other as a position vector. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | void move (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
166 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
167 | //! Yields a string representation of the vertex. The string returned |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
168 | //! can possibly be mangled. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
169 | //! - As mangled: {1.5, 2.8, 3.14} |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
170 | //! - Without mangling: 1.5 2.8 3.14 |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
171 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
172 | //! The mangled version is suitable for printing to the user, the |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
173 | //! non-mangled one is used when writing the vertex to LDraw files. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
174 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
175 | //! \returns a string representation of this vertex |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
176 | //! \param mangled whether to return a mangled representation or not |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | QString toString (bool mangled) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
178 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
179 | //! Transforms this vertex with \c matr as transformation matrix |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
180 | //! and \c pos as the position column of the 4x4 matrix. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | void transform (const Matrix& matr, const Vertex& pos); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
183 | //! An operator overload for \c move(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | Vertex& operator+= (const Vertex& other); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
185 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
186 | //! An operator overload for \c move(), using a temporary vertex. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
187 | Vertex operator+ (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
188 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
189 | //! Divides all values by \c d. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | Vertex operator/ (const double d) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
191 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
192 | //! Divides all values by \c d. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | Vertex& operator/= (const double d); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
194 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
195 | //! Checks whether this vertex has the same values as \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | bool operator== (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
197 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
198 | //! Checks whether this vertex has different values than \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | bool operator!= (const Vertex& other) const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
200 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
201 | //! \returns a negated version the vertex |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | Vertex operator-() const; |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
203 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
204 | //! \returns whether the vertex has lesser values than \c other. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | int operator< (const Vertex& other) const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
207 | //! An operator overload for \c getCoordinate(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | inline double& operator[] (const Axis ax) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
210 | return getCoordinate ((int) ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
213 | //! An operator overload for \c getCoordinate() const. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | inline const double& operator[] (const Axis ax) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | return getCoordinate ((int) ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
219 | //! An operator overload for \c getCoordinate(). |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | inline double& operator[] (const int ax) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | return getCoordinate (ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
225 | //! An operator overload for \c getCoordinate() const. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | inline const double& operator[] (const int ax) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | return getCoordinate (ax); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
231 | //! \returns a mutable reference for the coordinate designated by \param n. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | inline double& getCoordinate (int n) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | return m_coords[n]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
237 | //! An overload of \c getCoordinate for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
238 | //! \returns a const reference for the coordinate designated by \param n. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | inline const double& getCoordinate (int n) const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | return m_coords[n]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
244 | //! \returns a mutable reference to X. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | inline double& x() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | return m_coords[X]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
250 | //! An overload of \c x() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
251 | //! \returns a const reference to X. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | inline const double& x() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | return m_coords[X]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
257 | //! \returns a mutable reference to Y. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | inline double& y() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | return m_coords[Y]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
261 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
263 | //! An overload of \c y() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
264 | //! \returns a const reference to Y. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | inline const double& y() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | return m_coords[Y]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
270 | //! \returns a mutable reference to Z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | inline double& z() |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | return m_coords[Z]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
276 | //! An overload of \c z() for const vertices. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
277 | //! \returns a const reference to Z. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | inline const double& z() const |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | { |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | return m_coords[Z]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | } |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
283 | private: |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | double m_coords[3]; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
286 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
287 | Q_DECLARE_METATYPE (Vertex) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
288 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
289 | //! |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
290 | //! Defines a bounding box that encompasses a given set of objects. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
291 | //! vertex0 is the minimum vertex, vertex1 is the maximum vertex. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
292 | // |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | class LDBoundingBox |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | { |
642
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
295 | PROPERTY (private, bool, isEmpty, setEmpty, STOCK_WRITE) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
296 | PROPERTY (private, Vertex, vertex0, setVertex0, STOCK_WRITE) |
751a8df42842
- migrated the codebase to use a simpler PROPERTY macro, arrrrrrrrrrrrrrrrrrrrrgh
Santeri Piippo <crimsondusk64@gmail.com>
parents:
641
diff
changeset
|
297 | PROPERTY (private, Vertex, vertex1, setVertex1, STOCK_WRITE) |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
298 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | public: |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
300 | //! Constructs an empty bounding box. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | LDBoundingBox(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
302 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
303 | //! Clears the bounding box |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | void reset(); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
305 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
306 | //! Calculates the bounding box's values from the objects in the current |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
307 | //! document. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
308 | void calculateFromCurrentDocument(); |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
309 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
310 | //! \returns the length of the bounding box on the longest measure. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
311 | double longestMeasurement() const; |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
312 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
313 | //! Calculates the given \param obj to the bounding box, adjusting |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
314 | //! extremas if necessary. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
315 | void calcObject (LDObject* obj); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
316 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
317 | //! Calculates the given \param vertex to the bounding box, adjusting |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
318 | //! extremas if necessary. |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
319 | void calcVertex (const Vertex& vertex); |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
320 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
321 | //! \returns the center of the bounding box. |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
322 | Vertex center() const; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
323 | |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
324 | //! An operator overload for \c calcObject() |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
325 | LDBoundingBox& operator<< (LDObject* obj); |
648
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
326 | |
ed6170728ae4
- doxygenified Types.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
644
diff
changeset
|
327 | //! An operator overload for \c calcVertex() |
629
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | LDBoundingBox& operator<< (const Vertex& v); |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | }; |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | extern const Vertex g_origin; // Vertex at (0, 0, 0) |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
332 | extern const Matrix g_identity; // Identity matrix |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | |
b75c6cce02e2
- refactored filenames
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | static const double pi = 3.14159265358979323846; |