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
95d087ee
Commit
95d087ee
authored
Sep 27, 2016
by
Philipp Adolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
85836b9d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
54 deletions
+49
-54
Subdivision.pro
QTProject/Subdivision.pro
+1
-1
subdivision.cpp
QTProject/subdivision.cpp
+46
-53
subdivision.h
QTProject/subdivision.h
+2
-0
No files found.
QTProject/Subdivision.pro
View file @
95d087ee
...
...
@@ -8,7 +8,7 @@ QT += core gui opengl
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
CONFIG
+=
c
++
11
CONFIG
+=
c
++
11
debug
TARGET
=
Subdivision
TEMPLATE
=
app
...
...
QTProject/subdivision.cpp
View file @
95d087ee
...
...
@@ -1040,6 +1040,38 @@ void Subdivision::runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indic
edgeShader
->
release
();
}
QVector3D
Subdivision
::
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
)
{
QVector
<
Vertex
>
surroundingVertex
;
QVectorIterator
<
Triangle
>
extra
(
neighboring_triangles
);
while
(
extra
.
hasNext
())
{
Triangle
extra_triangle
=
extra
.
next
();
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
u
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
u
()))
surroundingVertex
.
push_back
(
extra_triangle
.
u
());
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
v
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
v
()))
surroundingVertex
.
push_back
(
extra_triangle
.
v
());
if
(
!
currentCorner
.
samePos
(
extra_triangle
.
w
())
&&
!
containsVertex
(
surroundingVertex
,
extra_triangle
.
w
()))
surroundingVertex
.
push_back
(
extra_triangle
.
w
());
}
QVector3D
newPos
(
0.0
,
0.0
,
0.0
);
double
n
=
surroundingVertex
.
length
()
+
1
;
qDebug
()
<<
n
;
qDebug
()
<<
currentCorner
;
qDebug
()
<<
surroundingVertex
;
double
a
=
5.0
/
8.0
-
pow
((
3.0
/
8.0
+
2.0
/
8.0
*
cos
(
2.0
*
M_PI
/
n
)),
2.0
);
double
omega
=
3.0
*
n
/
(
8.0
*
a
);
for
(
int
i
=
0
;
i
<
surroundingVertex
.
length
();
i
++
)
{
newPos
+=
surroundingVertex
[
i
].
pos
;
}
newPos
*=
a
/
n
;
newPos
+=
omega
*
a
/
n
*
currentCorner
.
pos
;
return
newPos
;
}
void
Subdivision
::
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
){
result
.
vertex_buffer_irregular
.
resize
(
result
.
vertex_buffer
.
size
());
...
...
@@ -1048,69 +1080,30 @@ void Subdivision::updateIrregularForDraw(const QVector<Triangle> &triangles,QMap
Triangle
triangle
=
it
.
next
();
Triangle
::
Neighbors
ns
=
neighbors
.
value
(
triangle
);
QVector
<
Triangle
>
neighboring_triangles
;
// u
Vertex
currentCorner
=
triangle
.
u
();
neighboring_triangles
=
vertexNeighbors
(
triangle
,
ns
.
uv
,
neighbors
);
QVector
<
Vertex
>
surroundingVertex
;
QVectorIterator
<
Triangle
>
extra
(
neighboring_triangles
);
while
(
extra
.
hasNext
())
{
Triangle
extra_triangle
=
extra
.
next
();
if
(
currentCorner
.
samePos
(
extra_triangle
.
u
())
){
bool
found
=
false
;
for
(
int
i
=
0
;
i
<
surroundingVertex
.
length
()
&&
!
found
;
++
i
)
{
if
(
extra_triangle
.
u
().
samePos
(
surroundingVertex
[
i
])){
found
=
true
;
}
}
if
(
!
found
)
surroundingVertex
.
push_back
(
extra_triangle
.
u
());
}
if
(
currentCorner
.
samePos
(
extra_triangle
.
v
())
)
found
=
false
;
for
(
int
i
=
0
;
i
<
surroundingVertex
.
length
()
&&
!
found
;
++
i
)
{
if
(
extra_triangle
.
v
().
samePos
(
surroundingVertex
[
i
])){
found
=
true
;
}
}
if
(
!
found
)
surroundingVertex
.
push_back
(
extra_triangle
.
v
());
Triangle
extra_triangle
=
extra
.
next
();
if
(
currentCorner
.
samePos
(
extra_triangle
.
w
())
)
found
=
false
;
for
(
int
i
=
0
;
i
<
surroundingVertex
.
length
()
&&
!
found
;
++
i
)
{
if
(
extra_triangle
.
w
().
samePos
(
surroundingVertex
[
i
])){
found
=
true
;
}
}
if
(
!
found
)
surroundingVertex
.
push_back
(
extra_triangle
.
w
());
}
QVector3D
new_u_pos
=
updateIrregularVertexForDraw
(
triangle
.
u
(),
vertexNeighbors
(
triangle
,
ns
.
uv
,
neighbors
));
//v
QVector3D
new_v_pos
=
updateIrregularVertexForDraw
(
triangle
.
v
(),
vertexNeighbors
(
triangle
,
ns
.
vw
,
neighbors
));
//w
neighboring_triangles
+=
vertexNeighbors
(
triangle
,
ns
.
vw
,
neighbors
);
neighboring_triangles
+=
vertexNeighbors
(
triangle
,
ns
.
wu
,
neighbors
);
QVector3D
new_w_pos
=
updateIrregularVertexForDraw
(
triangle
.
w
(),
vertexNeighbors
(
triangle
,
ns
.
wu
,
neighbors
));
result
.
vertex_buffer_irregular
[
triangle
.
u_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
u_idx
());
result
.
vertex_buffer_irregular
[
triangle
.
u_idx
()].
pos
=
new_u_pos
;
result
.
vertex_buffer_irregular
[
triangle
.
v_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
v_idx
());
result
.
vertex_buffer_irregular
[
triangle
.
v_idx
()].
pos
=
new_v_pos
;
result
.
vertex_buffer_irregular
[
triangle
.
w_idx
()]
=
result
.
vertex_buffer
.
at
(
triangle
.
w_idx
());
result
.
vertex_buffer_irregular
[
triangle
.
w_idx
()].
pos
=
new_w_pos
;
}
}
bool
Subdivision
::
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
)
{
for
(
int
i
=
0
;
i
<
vertices
.
length
();
i
++
)
{
if
(
vertex
.
samePos
(
vertices
[
i
]))
{
return
true
;
}
}
return
false
;
}
QTProject/subdivision.h
View file @
95d087ee
...
...
@@ -70,7 +70,9 @@ private:
void
runCopyShader
(
GLuint
size
,
GLuint
vb_in
,
GLuint
vb_out
);
void
runVertexShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
vertex_indices_handle
,
GLuint
vertex_offsets_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
void
runEdgeShader
(
GLuint
size
,
GLuint
vb_handle
,
GLuint
edge_indices_handle
,
GLuint
output_handle
,
GLuint
offset_handle
);
QVector3D
updateIrregularVertexForDraw
(
Vertex
currentCorner
,
QVector
<
Triangle
>
neighboring_triangles
);
void
updateIrregularForDraw
(
const
QVector
<
Triangle
>
&
triangles
,
QMap
<
Triangle
,
Triangle
::
Neighbors
>
&
neighbors
,
Result
&
result
);
bool
containsVertex
(
QVector
<
Vertex
>
&
vertices
,
Vertex
vertex
);
...
...
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