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
5418ded6
Commit
5418ded6
authored
Aug 22, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store which edge was matched in Shared_Edge
parent
130d3a34
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
triangle.cpp
QTProject/triangle.cpp
+36
-5
triangle.h
QTProject/triangle.h
+10
-0
No files found.
QTProject/triangle.cpp
View file @
5418ded6
...
...
@@ -2,6 +2,8 @@
#include "triangle.h"
Triangle
::
Shared_Edge
::
Edge
rotate_edge_enum
(
Triangle
::
Shared_Edge
::
Edge
edge
);
Triangle
::
Triangle
()
{}
Triangle
::
Triangle
(
const
Triangle
&
other
)
{
...
...
@@ -49,27 +51,39 @@ bool Triangle::get_shared_edge(Triangle other, Shared_Edge &edge) const {
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
edge
.
edge_b
=
rotate_edge_enum
(
rotate_edge_enum
(
edge
.
edge_b
));
return
true
;
}
other
.
rotate_indices
();
return
get_shared_edge_
(
other
,
edge
);
if
(
get_shared_edge_
(
other
,
edge
))
{
edge
.
edge_b
=
rotate_edge_enum
(
edge
.
edge_b
);
return
true
;
}
return
false
;
}
bool
Triangle
::
get_shared_edge_
(
const
Triangle
&
other
,
Shared_Edge
&
edge
)
const
{
if
(
u
().
samePos
(
other
.
u
()))
{
if
(
v
().
samePos
(
other
.
w
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
uv
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge
.
a1
=
u_idx
();
edge
.
b1
=
other
.
u
_idx
();
edge
.
b1
=
other
.
w
_idx
();
edge
.
a2
=
v_idx
();
edge
.
b2
=
other
.
w
_idx
();
edge
.
b2
=
other
.
u
_idx
();
edge
.
a3
=
w_idx
();
edge
.
b3
=
other
.
v_idx
();
return
true
;
}
else
if
(
w
().
samePos
(
other
.
v
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
uv
;
edge
.
a1
=
u_idx
();
edge
.
b1
=
other
.
u_idx
();
...
...
@@ -82,11 +96,14 @@ bool Triangle::get_shared_edge_(const Triangle &other, Shared_Edge &edge) const
return
true
;
}
}
else
if
(
v
().
samePos
(
other
.
u
())
&&
w
().
samePos
(
other
.
w
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
vw
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge
.
a1
=
v_idx
();
edge
.
b1
=
other
.
u
_idx
();
edge
.
b1
=
other
.
w
_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
w
_idx
();
edge
.
b2
=
other
.
u
_idx
();
edge
.
a3
=
u_idx
();
edge
.
b3
=
other
.
v_idx
();
...
...
@@ -138,6 +155,20 @@ void Triangle::rotate_indices() {
w_
=
a
;
}
Triangle
::
Shared_Edge
::
Edge
rotate_edge_enum
(
Triangle
::
Shared_Edge
::
Edge
edge
)
{
switch
(
edge
)
{
case
Triangle
:
:
Shared_Edge
::
Edge
::
uv
:
return
Triangle
::
Shared_Edge
::
Edge
::
vw
;
case
Triangle
:
:
Shared_Edge
::
Edge
::
vw
:
return
Triangle
::
Shared_Edge
::
Edge
::
wu
;
case
Triangle
:
:
Shared_Edge
::
Edge
::
wu
:
return
Triangle
::
Shared_Edge
::
Edge
::
uv
;
default
:
qDebug
()
<<
"Default case should be unreachable"
;
return
Triangle
::
Shared_Edge
::
Edge
::
uv
;
}
}
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 @
5418ded6
...
...
@@ -14,8 +14,18 @@ class Triangle {
* 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.
*
* edge_a describes which edge of the first triangle is part of the shared edge.
*/
struct
Shared_Edge
{
enum
Edge
{
uv
,
vw
,
wu
};
Edge
edge_a
;
Edge
edge_b
;
unsigned
int
a1
;
unsigned
int
b1
;
unsigned
int
a2
;
...
...
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