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
7c0f191a
Commit
7c0f191a
authored
Aug 22, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only store one set of vertices in edge struct
parent
19232189
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
90 deletions
+72
-90
subdivision.cpp
QTProject/subdivision.cpp
+24
-23
triangle.cpp
QTProject/triangle.cpp
+40
-46
triangle.h
QTProject/triangle.h
+8
-21
No files found.
QTProject/subdivision.cpp
View file @
7c0f191a
...
...
@@ -148,43 +148,44 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
* - Each edge point will be computed twice. This allows us to implicitly know the adjacent points.
*/
Triangle
::
Shared_Edge
edge
;
Triangle
::
Shared_Edge
uv
,
vw
,
wu
;
Triangle
::
Edge
edge_a
,
edge_b
;
// These will hold the edges of the triangles next to the current one. uv will hold the edge shared with the current triangle's uv edge.
Triangle
::
Edge
uv
,
vw
,
wu
;
for
(
int
j
=
0
;
j
<
triangles
.
length
();
j
++
){
if
(
j
!=
i
)
{
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge
))
{
switch
(
edge
.
edge_a
)
{
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
uv
:
uv
=
edge
;
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge
_a
,
edge_b
))
{
switch
(
edge
_a
.
name
)
{
case
Triangle
:
:
Edge
::
Nam
e
::
uv
:
uv
=
edge
_b
;
break
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
vw
:
vw
=
edge
;
case
Triangle
:
:
Edge
::
Nam
e
::
vw
:
vw
=
edge
_b
;
break
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
wu
:
wu
=
edge
;
case
Triangle
:
:
Edge
::
Nam
e
::
wu
:
wu
=
edge
_b
;
break
;
default
:
qWarning
()
<<
"got"
<<
edge
.
edge_a
<<
"as edge!"
;
qWarning
()
<<
"got"
<<
edge
_a
.
name
<<
"as edge!"
;
break
;
}
}
}
}
tables
.
edge_indices
.
push_back
(
uv
.
a1
);
tables
.
edge_indices
.
push_back
(
uv
.
a2
);
tables
.
edge_indices
.
push_back
(
uv
.
a3
);
tables
.
edge_indices
.
push_back
(
uv
.
b3
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
uv
.
c
);
tables
.
edge_indices
.
push_back
(
vw
.
a1
);
tables
.
edge_indices
.
push_back
(
vw
.
a2
);
tables
.
edge_indices
.
push_back
(
vw
.
a3
);
tables
.
edge_indices
.
push_back
(
vw
.
b3
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
vw
.
c
);
tables
.
edge_indices
.
push_back
(
wu
.
a1
);
tables
.
edge_indices
.
push_back
(
wu
.
a2
);
tables
.
edge_indices
.
push_back
(
wu
.
a3
);
tables
.
edge_indices
.
push_back
(
wu
.
b3
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
wu
.
c
);
//add indices to new index buffer
tables
.
index_buffer
.
push_back
(
x_i
);
...
...
QTProject/triangle.cpp
View file @
7c0f191a
...
...
@@ -2,7 +2,7 @@
#include "triangle.h"
Triangle
::
Shared_Edge
::
Edge
rotate_edge_enum
(
Triangle
::
Shared_Edge
::
Edg
e
edge
);
Triangle
::
Edge
::
Name
rotate_edge_name
(
Triangle
::
Edge
::
Nam
e
edge
);
Triangle
::
Triangle
()
{}
...
...
@@ -44,69 +44,63 @@ int Triangle::w_idx() const {
return
w_
;
}
bool
Triangle
::
get_shared_edge
(
Triangle
other
,
Shared_Edge
&
edge
)
const
{
if
(
get_shared_edge_
(
other
,
edge
))
{
bool
Triangle
::
get_shared_edge
(
Triangle
other
,
Edge
&
edge_a
,
Edge
&
edge_b
)
const
{
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
return
true
;
}
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
edge
.
edge_b
=
rotate_edge_enum
(
rotate_edge_enum
(
edge
.
edge_b
));
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
edge
_b
.
name
=
rotate_edge_name
(
rotate_edge_name
(
edge_b
.
name
));
return
true
;
}
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
edge
.
edge_b
=
rotate_edge_enum
(
edge
.
edge_b
);
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
edge
_b
.
name
=
rotate_edge_name
(
edge_b
.
name
);
return
true
;
}
return
false
;
}
bool
Triangle
::
get_shared_edge_
(
const
Triangle
&
other
,
Shared_Edge
&
edge
)
const
{
bool
Triangle
::
get_shared_edge_
(
const
Triangle
&
other
,
Edge
&
edge_a
,
Edge
&
edge_b
)
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_a
.
name
=
Triangle
::
Edge
::
Name
::
uv
;
edge_a
.
a
=
u_idx
();
edge_a
.
b
=
v_idx
();
edge_a
.
c
=
w_idx
();
edge
.
a1
=
u_idx
();
edge
.
b1
=
other
.
w_idx
();
edge
.
a2
=
v_idx
();
edge
.
b2
=
other
.
u_idx
();
edge
.
a3
=
w_idx
();
edge
.
b3
=
other
.
v_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge_b
.
a
=
other
.
w_idx
();
edge_b
.
b
=
other
.
u_idx
();
edge_b
.
c
=
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
();
edge_a
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge_a
.
a
=
w_idx
();
edge_a
.
b
=
u_idx
();
edge_a
.
c
=
v_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
v_idx
();
edge
.
a3
=
v_idx
();
edge
.
b3
=
other
.
w_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
uv
;
edge_b
.
a
=
other
.
u_idx
();
edge_b
.
b
=
other
.
v_idx
();
edge_b
.
c
=
other
.
w_idx
();
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
.
w_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
u_idx
();
edge_a
.
name
=
Triangle
::
Edge
::
Name
::
vw
;
edge_a
.
a
=
v_idx
();
edge_a
.
b
=
w_idx
();
edge_a
.
c
=
u_idx
();
edge
.
a3
=
u_idx
();
edge
.
b3
=
other
.
v_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge_b
.
a
=
other
.
w_idx
();
edge_b
.
b
=
other
.
u_idx
();
edge_b
.
c
=
other
.
v_idx
();
return
true
;
}
...
...
@@ -155,17 +149,17 @@ void Triangle::rotate_indices() {
w_
=
a
;
}
Triangle
::
Shared_Edge
::
Edge
rotate_edge_enum
(
Triangle
::
Shared_Edge
::
Edg
e
edge
)
{
Triangle
::
Edge
::
Name
rotate_edge_name
(
Triangle
::
Edge
::
Nam
e
edge
)
{
switch
(
edge
)
{
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
uv
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
vw
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
vw
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
wu
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
wu
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
uv
;
case
Triangle
:
:
Edge
::
Nam
e
::
uv
:
return
Triangle
::
Edge
::
Nam
e
::
vw
;
case
Triangle
:
:
Edge
::
Nam
e
::
vw
:
return
Triangle
::
Edge
::
Nam
e
::
wu
;
case
Triangle
:
:
Edge
::
Nam
e
::
wu
:
return
Triangle
::
Edge
::
Nam
e
::
uv
;
default
:
qDebug
()
<<
"Default case should be unreachable"
;
return
Triangle
::
Shared_Edge
::
Edg
e
::
uv
;
return
Triangle
::
Edge
::
Nam
e
::
uv
;
}
}
...
...
QTProject/triangle.h
View file @
7c0f191a
...
...
@@ -8,30 +8,17 @@
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.
*
* edge_a describes which edge of the first triangle is part of the shared edge.
*/
struct
Shared_Edge
{
enum
Edge
{
struct
Edge
{
enum
Name
{
uv
,
vw
,
wu
};
Edge
edge_a
;
Edge
edge_b
;
unsigned
int
a1
;
unsigned
int
b1
;
unsigned
int
a2
;
unsigned
int
b2
;
unsigned
int
a3
;
unsigned
int
b3
;
Name
name
;
unsigned
int
a
;
unsigned
int
b
;
unsigned
int
c
;
};
Triangle
();
...
...
@@ -46,7 +33,7 @@ class Triangle {
int
v_idx
()
const
;
int
w_idx
()
const
;
bool
get_shared_edge
(
Triangle
other
,
Shared_Edge
&
edge
)
const
;
bool
get_shared_edge
(
Triangle
other
,
Edge
&
edge_a
,
Edge
&
edge_b
)
const
;
Triangle
&
operator
=
(
const
Triangle
&
other
);
...
...
@@ -62,7 +49,7 @@ class Triangle {
int
w_
;
void
rotate_indices
();
bool
get_shared_edge_
(
const
Triangle
&
other
,
Shared_Edge
&
edge
)
const
;
bool
get_shared_edge_
(
const
Triangle
&
other
,
Edge
&
edge_a
,
Edge
&
edge_b
)
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