Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
Unterteilungsalgorithmen
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kai Westerkamp
Unterteilungsalgorithmen
Commits
6b74dff2
Commit
6b74dff2
authored
Aug 20, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement operator== and operator< in Triangle
Now Triangle can be used as the key of a QMap
parent
f93785b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
+31
-0
triangle.cpp
QTProject/triangle.cpp
+26
-0
triangle.h
QTProject/triangle.h
+5
-0
No files found.
QTProject/triangle.cpp
View file @
6b74dff2
...
...
@@ -50,6 +50,32 @@ Triangle &Triangle::operator=(const Triangle &other) {
return
*
this
;
}
bool
Triangle
::
operator
==
(
const
Triangle
&
other
)
const
{
return
u_
==
other
.
u_
&&
v_
==
other
.
v_
&&
w_
==
other
.
w_
;
}
bool
Triangle
::
operator
<
(
const
Triangle
&
other
)
const
{
if
(
u_
<
other
.
u_
)
{
return
true
;
}
else
if
(
u_
>
other
.
u_
)
{
return
false
;
}
if
(
v_
<
other
.
v_
)
{
return
true
;
}
else
if
(
v_
>
other
.
v_
)
{
return
false
;
}
if
(
w_
<
other
.
w_
)
{
return
true
;
}
else
if
(
w_
>
other
.
w_
)
{
return
false
;
}
return
false
;
}
QDebug
operator
<<
(
QDebug
d
,
const
Triangle
&
triangle
)
{
QDebugStateSaver
saver
(
d
);
d
.
nospace
()
<<
"Triangle("
<<
triangle
.
u_idx
()
<<
", "
<<
triangle
.
v_idx
()
<<
", "
<<
triangle
.
w_idx
()
<<
"; "
<<
triangle
.
u
().
pos
<<
", "
<<
triangle
.
v
().
pos
<<
", "
<<
triangle
.
w
().
pos
<<
")"
;
...
...
QTProject/triangle.h
View file @
6b74dff2
...
...
@@ -22,6 +22,11 @@ class Triangle {
Triangle
&
operator
=
(
const
Triangle
&
other
);
// == and < both ignore the vertex buffer, they only compare indices.
// They are implemented so that Triangle can be used as the key of a QMap.
bool
operator
==
(
const
Triangle
&
other
)
const
;
bool
operator
<
(
const
Triangle
&
other
)
const
;
private
:
QVector
<
Vertex
>
vertex_buffer_
;
int
u_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment