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
Hide 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) {
...
@@ -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.
* - Each edge point will be computed twice. This allows us to implicitly know the adjacent points.
*/
*/
Triangle
::
Shared_Edge
edge
;
Triangle
::
Edge
edge_a
,
edge_b
;
Triangle
::
Shared_Edge
uv
,
vw
,
wu
;
// 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
++
){
for
(
int
j
=
0
;
j
<
triangles
.
length
();
j
++
){
if
(
j
!=
i
)
{
if
(
j
!=
i
)
{
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge
))
{
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge
_a
,
edge_b
))
{
switch
(
edge
.
edge_a
)
{
switch
(
edge
_a
.
name
)
{
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
uv
:
case
Triangle
:
:
Edge
::
Nam
e
::
uv
:
uv
=
edge
;
uv
=
edge
_b
;
break
;
break
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
vw
:
case
Triangle
:
:
Edge
::
Nam
e
::
vw
:
vw
=
edge
;
vw
=
edge
_b
;
break
;
break
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
wu
:
case
Triangle
:
:
Edge
::
Nam
e
::
wu
:
wu
=
edge
;
wu
=
edge
_b
;
break
;
break
;
default
:
default
:
qWarning
()
<<
"got"
<<
edge
.
edge_a
<<
"as edge!"
;
qWarning
()
<<
"got"
<<
edge
_a
.
name
<<
"as edge!"
;
break
;
break
;
}
}
}
}
}
}
}
}
tables
.
edge_indices
.
push_back
(
uv
.
a1
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
uv
.
a2
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
uv
.
a3
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
uv
.
b3
);
tables
.
edge_indices
.
push_back
(
uv
.
c
);
tables
.
edge_indices
.
push_back
(
vw
.
a1
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
vw
.
a2
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
vw
.
a3
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
vw
.
b3
);
tables
.
edge_indices
.
push_back
(
vw
.
c
);
tables
.
edge_indices
.
push_back
(
wu
.
a1
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
()
);
tables
.
edge_indices
.
push_back
(
wu
.
a2
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
()
);
tables
.
edge_indices
.
push_back
(
wu
.
a3
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
()
);
tables
.
edge_indices
.
push_back
(
wu
.
b3
);
tables
.
edge_indices
.
push_back
(
wu
.
c
);
//add indices to new index buffer
//add indices to new index buffer
tables
.
index_buffer
.
push_back
(
x_i
);
tables
.
index_buffer
.
push_back
(
x_i
);
...
...
QTProject/triangle.cpp
View file @
7c0f191a
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include "triangle.h"
#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
()
{}
Triangle
::
Triangle
()
{}
...
@@ -44,69 +44,63 @@ int Triangle::w_idx() const {
...
@@ -44,69 +44,63 @@ int Triangle::w_idx() const {
return
w_
;
return
w_
;
}
}
bool
Triangle
::
get_shared_edge
(
Triangle
other
,
Shared_Edge
&
edge
)
const
{
bool
Triangle
::
get_shared_edge
(
Triangle
other
,
Edge
&
edge_a
,
Edge
&
edge_b
)
const
{
if
(
get_shared_edge_
(
other
,
edge
))
{
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
return
true
;
return
true
;
}
}
other
.
rotate_indices
();
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
edge
.
edge_b
=
rotate_edge_enum
(
rotate_edge_enum
(
edge
.
edge_b
));
edge
_b
.
name
=
rotate_edge_name
(
rotate_edge_name
(
edge_b
.
name
));
return
true
;
return
true
;
}
}
other
.
rotate_indices
();
other
.
rotate_indices
();
if
(
get_shared_edge_
(
other
,
edge
))
{
if
(
get_shared_edge_
(
other
,
edge
_a
,
edge_b
))
{
edge
.
edge_b
=
rotate_edge_enum
(
edge
.
edge_b
);
edge
_b
.
name
=
rotate_edge_name
(
edge_b
.
name
);
return
true
;
return
true
;
}
}
return
false
;
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
(
u
().
samePos
(
other
.
u
()))
{
if
(
v
().
samePos
(
other
.
w
()))
{
if
(
v
().
samePos
(
other
.
w
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
uv
;
edge_a
.
name
=
Triangle
::
Edge
::
Name
::
uv
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge_a
.
a
=
u_idx
();
edge_a
.
b
=
v_idx
();
edge_a
.
c
=
w_idx
();
edge
.
a1
=
u_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge
.
b1
=
other
.
w_idx
();
edge_b
.
a
=
other
.
w_idx
();
edge_b
.
b
=
other
.
u_idx
();
edge
.
a2
=
v_idx
();
edge_b
.
c
=
other
.
v_idx
();
edge
.
b2
=
other
.
u_idx
();
edge
.
a3
=
w_idx
();
edge
.
b3
=
other
.
v_idx
();
return
true
;
return
true
;
}
else
if
(
w
().
samePos
(
other
.
v
()))
{
}
else
if
(
w
().
samePos
(
other
.
v
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge_a
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
uv
;
edge_a
.
a
=
w_idx
();
edge_a
.
b
=
u_idx
();
edge
.
a1
=
u_idx
();
edge_a
.
c
=
v_idx
();
edge
.
b1
=
other
.
u_idx
();
edge
.
a2
=
w_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
uv
;
edge
.
b2
=
other
.
v_idx
();
edge_b
.
a
=
other
.
u_idx
();
edge_b
.
b
=
other
.
v_idx
();
edge
.
a3
=
v_idx
();
edge_b
.
c
=
other
.
w_idx
();
edge
.
b3
=
other
.
w_idx
();
return
true
;
return
true
;
}
}
}
else
if
(
v
().
samePos
(
other
.
u
())
&&
w
().
samePos
(
other
.
w
()))
{
}
else
if
(
v
().
samePos
(
other
.
u
())
&&
w
().
samePos
(
other
.
w
()))
{
edge
.
edge_a
=
Triangle
::
Shared_Edge
::
Edge
::
vw
;
edge_a
.
name
=
Triangle
::
Edge
::
Name
::
vw
;
edge
.
edge_b
=
Triangle
::
Shared_Edge
::
Edge
::
wu
;
edge_a
.
a
=
v_idx
();
edge_a
.
b
=
w_idx
();
edge
.
a1
=
v_idx
();
edge_a
.
c
=
u_idx
();
edge
.
b1
=
other
.
w_idx
();
edge
.
a2
=
w_idx
();
edge
.
b2
=
other
.
u_idx
();
edge
.
a3
=
u_idx
();
edge_b
.
name
=
Triangle
::
Edge
::
Name
::
wu
;
edge
.
b3
=
other
.
v_idx
();
edge_b
.
a
=
other
.
w_idx
();
edge_b
.
b
=
other
.
u_idx
();
edge_b
.
c
=
other
.
v_idx
();
return
true
;
return
true
;
}
}
...
@@ -155,17 +149,17 @@ void Triangle::rotate_indices() {
...
@@ -155,17 +149,17 @@ void Triangle::rotate_indices() {
w_
=
a
;
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
)
{
switch
(
edge
)
{
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
uv
:
case
Triangle
:
:
Edge
::
Nam
e
::
uv
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
vw
;
return
Triangle
::
Edge
::
Nam
e
::
vw
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
vw
:
case
Triangle
:
:
Edge
::
Nam
e
::
vw
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
wu
;
return
Triangle
::
Edge
::
Nam
e
::
wu
;
case
Triangle
:
:
Shared_Edge
::
Edg
e
::
wu
:
case
Triangle
:
:
Edge
::
Nam
e
::
wu
:
return
Triangle
::
Shared_Edge
::
Edg
e
::
uv
;
return
Triangle
::
Edge
::
Nam
e
::
uv
;
default
:
default
:
qDebug
()
<<
"Default case should be unreachable"
;
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 @@
...
@@ -8,30 +8,17 @@
class
Triangle
{
class
Triangle
{
public
:
public
:
/**
struct
Edge
{
* Stores the indices of the shared edge of two triangles as well as the other two indices.
enum
Name
{
*
* 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
,
uv
,
vw
,
vw
,
wu
wu
};
};
Edge
edge_a
;
Name
name
;
Edge
edge_b
;
unsigned
int
a
;
unsigned
int
a1
;
unsigned
int
b
;
unsigned
int
b1
;
unsigned
int
c
;
unsigned
int
a2
;
unsigned
int
b2
;
unsigned
int
a3
;
unsigned
int
b3
;
};
};
Triangle
();
Triangle
();
...
@@ -46,7 +33,7 @@ class Triangle {
...
@@ -46,7 +33,7 @@ class Triangle {
int
v_idx
()
const
;
int
v_idx
()
const
;
int
w_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
);
Triangle
&
operator
=
(
const
Triangle
&
other
);
...
@@ -62,7 +49,7 @@ class Triangle {
...
@@ -62,7 +49,7 @@ class Triangle {
int
w_
;
int
w_
;
void
rotate_indices
();
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
);
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