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
130d3a34
Commit
130d3a34
authored
Aug 20, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add method for neighbor detection
parent
6b74dff2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
triangle.cpp
QTProject/triangle.cpp
+62
-0
triangle.h
QTProject/triangle.h
+21
-0
No files found.
QTProject/triangle.cpp
View file @
130d3a34
...
...
@@ -42,6 +42,61 @@ int Triangle::w_idx() const {
return
w_
;
}
bool
Triangle
::
get_shared_edge
(
Triangle
other
,
Shared_Edge
&
edge
)
const
{
if
(
get_shared_edge_
(
other
,
edge
))
{
return
true
;
}
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
return
true
;
}
other
.
rotate_indices
();
return
get_shared_edge_
(
other
,
edge
);
}
bool
Triangle
::
get_shared_edge_
(
const
Triangle
&
other
,
Shared_Edge
&
edge
)
const
{
if
(
u
().
samePos
(
other
.
u
()))
{
if
(
v
().
samePos
(
other
.
w
()))
{
edge
.
a1
=
u_idx
();
edge
.
b1
=
other
.
u_idx
();
edge
.
a2
=
v_idx
();
edge
.
b2
=
other
.
w_idx
();
edge
.
a3
=
w_idx
();
edge
.
b3
=
other
.
v_idx
();
return
true
;
}
else
if
(
w
().
samePos
(
other
.
v
()))
{
edge
.
a1
=
u_idx
();
edge
.
b1
=
other
.
u_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
v_idx
();
edge
.
a3
=
v_idx
();
edge
.
b3
=
other
.
w_idx
();
return
true
;
}
}
else
if
(
v
().
samePos
(
other
.
u
())
&&
w
().
samePos
(
other
.
w
()))
{
edge
.
a1
=
v_idx
();
edge
.
b1
=
other
.
u_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
w_idx
();
edge
.
a3
=
u_idx
();
edge
.
b3
=
other
.
v_idx
();
return
true
;
}
return
false
;
}
Triangle
&
Triangle
::
operator
=
(
const
Triangle
&
other
)
{
this
->
vertex_buffer_
=
other
.
vertex_buffer_
;
this
->
u_
=
other
.
u_
;
...
...
@@ -76,6 +131,13 @@ bool Triangle::operator<(const Triangle &other) const {
return
false
;
}
void
Triangle
::
rotate_indices
()
{
unsigned
int
a
=
u_
;
u_
=
v_
;
v_
=
w_
;
w_
=
a
;
}
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 @
130d3a34
...
...
@@ -8,6 +8,22 @@
class
Triangle
{
public
:
/**
* Stores the indices of the shared edge of two triangles as well as the other two indices.
*
* a_* are the indices of the first triangle, b_* those of the second triangle.
*
* The vertices at a_1 and b_1 are at the same position as are those at a_2 and b_2.
*/
struct
Shared_Edge
{
unsigned
int
a1
;
unsigned
int
b1
;
unsigned
int
a2
;
unsigned
int
b2
;
unsigned
int
a3
;
unsigned
int
b3
;
};
Triangle
();
Triangle
(
const
Triangle
&
other
);
Triangle
(
const
QVector
<
Vertex
>
&
vertex_buffer
,
int
u
,
int
v
,
int
w
);
...
...
@@ -20,6 +36,8 @@ class Triangle {
int
v_idx
()
const
;
int
w_idx
()
const
;
bool
get_shared_edge
(
Triangle
other
,
Shared_Edge
&
edge
)
const
;
Triangle
&
operator
=
(
const
Triangle
&
other
);
// == and < both ignore the vertex buffer, they only compare indices.
...
...
@@ -32,6 +50,9 @@ class Triangle {
int
u_
;
int
v_
;
int
w_
;
void
rotate_indices
();
bool
get_shared_edge_
(
const
Triangle
&
other
,
Shared_Edge
&
edge
)
const
;
};
QDebug
operator
<<
(
QDebug
d
,
const
Triangle
&
triangle
);
...
...
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