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
f8ba8e10
Commit
f8ba8e10
authored
Aug 22, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store opposite edges in a Map
This way we only have to match triangles with their succesors.
parent
384a4370
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
22 deletions
+30
-22
subdivision.cpp
QTProject/subdivision.cpp
+30
-22
No files found.
QTProject/subdivision.cpp
View file @
f8ba8e10
...
@@ -93,6 +93,26 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
...
@@ -93,6 +93,26 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
}
}
}
}
void
insert_edge
(
QMap
<
Triangle
,
QVector
<
Triangle
::
Edge
>>
&
opposite_edges
,
const
Triangle
&
triangle
,
const
Triangle
::
Edge
&
edge_a
,
const
Triangle
::
Edge
&
edge_b
)
{
QVector
<
Triangle
::
Edge
>
edges
=
opposite_edges
.
value
(
triangle
,
QVector
<
Triangle
::
Edge
>
());
edges
.
resize
(
3
);
switch
(
edge_a
.
name
)
{
case
Triangle
:
:
Edge
::
Name
::
uv
:
edges
[
0
]
=
edge_b
;
break
;
case
Triangle
:
:
Edge
::
Name
::
vw
:
edges
[
1
]
=
edge_b
;
break
;
case
Triangle
:
:
Edge
::
Name
::
wu
:
edges
[
2
]
=
edge_b
;
break
;
default
:
qWarning
()
<<
"got"
<<
edge_a
.
name
<<
"as edge!"
;
break
;
}
opposite_edges
.
insert
(
triangle
,
edges
);
}
/**
/**
* @brief Subdivision::precomputeTables
* @brief Subdivision::precomputeTables
* @param mesh
* @param mesh
...
@@ -123,6 +143,9 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
...
@@ -123,6 +143,9 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
//compute edge table
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
//Format: first two entries: edge vertices. last two entries: distant vertices.
// for each triangle the edges of the neighbor triangles are stored.
// First the edge shared with the triangles uv edge, then vw and wu.
QMap
<
Triangle
,
QVector
<
Triangle
::
Edge
>>
opposite_edges
;
unsigned
int
nib_offset
=
vb
.
length
();
//offset in new index buffer for edge vertices
unsigned
int
nib_offset
=
vb
.
length
();
//offset in new index buffer for edge vertices
for
(
int
i
=
0
;
i
<
triangles
.
length
();
i
++
){
for
(
int
i
=
0
;
i
<
triangles
.
length
();
i
++
){
//schaue alle dreiecke an
//schaue alle dreiecke an
...
@@ -139,43 +162,28 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
...
@@ -139,43 +162,28 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
*/
*/
Triangle
::
Edge
edge_a
,
edge_b
;
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.
for
(
int
j
=
i
+
1
;
j
<
triangles
.
length
();
j
++
){
Triangle
::
Edge
uv
,
vw
,
wu
;
for
(
int
j
=
0
;
j
<
triangles
.
length
();
j
++
){
if
(
j
!=
i
)
{
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge_a
,
edge_b
))
{
if
(
triangle
.
get_shared_edge
(
triangles
[
j
],
edge_a
,
edge_b
))
{
switch
(
edge_a
.
name
)
{
insert_edge
(
opposite_edges
,
triangle
,
edge_a
,
edge_b
);
case
Triangle
:
:
Edge
::
Name
::
uv
:
insert_edge
(
opposite_edges
,
triangles
[
j
],
edge_b
,
edge_a
);
uv
=
edge_b
;
break
;
case
Triangle
:
:
Edge
::
Name
::
vw
:
vw
=
edge_b
;
break
;
case
Triangle
:
:
Edge
::
Name
::
wu
:
wu
=
edge_b
;
break
;
default
:
qWarning
()
<<
"got"
<<
edge_a
.
name
<<
"as edge!"
;
break
;
}
}
}
}
}
}
QVector
<
Triangle
::
Edge
>
opposite
=
opposite_edges
.
value
(
triangle
);
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
uv
.
c
);
tables
.
edge_indices
.
push_back
(
opposite
[
0
]
.
c
);
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
vw
.
c
);
tables
.
edge_indices
.
push_back
(
opposite
[
1
]
.
c
);
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
w_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
u_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
triangle
.
v_idx
());
tables
.
edge_indices
.
push_back
(
wu
.
c
);
tables
.
edge_indices
.
push_back
(
opposite
[
2
]
.
c
);
//add indices to new index buffer
//add indices to new index buffer
tables
.
index_buffer
.
push_back
(
triangle
.
u_idx
());
tables
.
index_buffer
.
push_back
(
triangle
.
u_idx
());
...
...
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