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
960e75ea
Commit
960e75ea
authored
Jun 27, 2016
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vertexIndices: Array of single indices with array with offsets instead of one…
vertexIndices: Array of single indices with array with offsets instead of one array with index-vectors
parent
1360526f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
subdivision.cpp
QTProject/subdivision.cpp
+15
-15
subdivision.h
QTProject/subdivision.h
+2
-1
No files found.
QTProject/subdivision.cpp
View file @
960e75ea
...
@@ -48,12 +48,15 @@ QOpenGLShaderProgram *Subdivision::initEdgeComputeShaderProgram(){
...
@@ -48,12 +48,15 @@ QOpenGLShaderProgram *Subdivision::initEdgeComputeShaderProgram(){
Mesh
*
Subdivision
::
subdivide
(
Mesh
*
mesh
)
{
Mesh
*
Subdivision
::
subdivide
(
Mesh
*
mesh
)
{
QVector
<
QVector
<
unsigned
int
>
>
edgeIndices
;
QVector
<
QVector
<
unsigned
int
>
>
edgeIndices
;
precomputeTables
(
mesh
,
edgeIndices
);
QVector
<
unsigned
int
>
vertexIndices
;
QVector
<
unsigned
int
>
vertexIndicesOffsets
;
precomputeTables
(
mesh
,
edgeIndices
,
vertexIndices
,
vertexIndicesOffsets
);
runShader
(
mesh
,
edgeIndices
);
runShader
(
mesh
,
edgeIndices
);
return
NULL
;
return
NULL
;
}
}
void
Subdivision
::
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
)
{
void
Subdivision
::
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
QVector
<
unsigned
int
>
&
vertexIndices
,
QVector
<
unsigned
int
>
&
vertexIndicesOffsets
)
{
Mesh
::
Node
root
=
mesh
->
getRootNode
();
Mesh
::
Node
root
=
mesh
->
getRootNode
();
int
firstMeshEntryIndex
=
-
1
;
int
firstMeshEntryIndex
=
-
1
;
...
@@ -193,18 +196,17 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
...
@@ -193,18 +196,17 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
}
}
}
}
//TODO save/return edge table
//compute vertex table
//compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices.
//Format: First entry: original vertex. Other entries: adjacent vertices.
QVector
<
QVector
<
unsigned
int
>
>
vertexIndices_base
;
QVector
<
QVector
<
unsigned
int
>
>
duplicates
;
//for debugging
QVector
<
QVector
<
unsigned
int
>
>
duplicates
;
//for debugging
int
offset
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
vb
.
length
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
vb
.
length
();
i
++
){
//hat evtl viel redundanz
//hat evtl viel redundanz
QVector
<
unsigned
int
>
adjacent_indices
;
QVector
<
Vertex
>
adj_v
;
//helfer
QVector
<
Vertex
>
adj_v
;
//helfer
adjacent_indices
.
push_back
(
i
);
vertexIndicesOffsets
.
push_back
(
offset
);
vertexIndices
.
push_back
(
i
);
offset
++
;
Vertex
originalVertex
=
vb
[
i
];
Vertex
originalVertex
=
vb
[
i
];
...
@@ -230,7 +232,7 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
...
@@ -230,7 +232,7 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
Vertex
v1
,
v2
;
//neighbour vertices;
Vertex
v1
,
v2
;
//neighbour vertices;
v1
=
vb
[
i1
];
v1
=
vb
[
i1
];
v2
=
vb
[
i2
];
v2
=
vb
[
i2
];
//check if vertices where already used
//check if vertices where already used
to influence this vertex
//Note: Can't use contain. Contain uses equal (would have to implement equal, but we're only interested in the position here.
//Note: Can't use contain. Contain uses equal (would have to implement equal, but we're only interested in the position here.
bool
found1
=
false
;
bool
found1
=
false
;
bool
found2
=
false
;
bool
found2
=
false
;
...
@@ -240,23 +242,21 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
...
@@ -240,23 +242,21 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
}
}
if
(
!
found1
){
if
(
!
found1
){
adj_v
.
push_back
(
v1
);
adj_v
.
push_back
(
v1
);
adjacent_indices
.
push_back
(
i1
);
vertexIndices
.
push_back
(
i1
);
offset
++
;
}
}
if
(
!
found2
){
if
(
!
found2
){
adj_v
.
push_back
(
v2
);
adj_v
.
push_back
(
v2
);
adjacent_indices
.
push_back
(
i2
);
vertexIndices
.
push_back
(
i2
);
offset
++
;
}
}
//if one adjacent vertex is referenced by multiple different indices, only its first index will appear in the adjacent_indices list.1
//if one adjacent vertex is referenced by multiple different indices, only its first index will appear in the adjacent_indices list.1
}
}
}
}
vertexIndices_base
.
push_back
(
adjacent_indices
);
if
(
!
duplicates
.
contains
(
d
))
duplicates
.
push_back
(
d
);
if
(
!
duplicates
.
contains
(
d
))
duplicates
.
push_back
(
d
);
}
}
qDebug
()
<<
"Done with vertex index table. "
<<
vertexIndices_base
.
length
()
<<
" vertices processed. Table:"
;
qDebug
()
<<
"Done with vertex index table. "
;
for
(
int
i
=
0
;
i
<
vertexIndices_base
.
length
();
i
++
){
qDebug
()
<<
vertexIndices_base
[
i
];
}
qDebug
()
<<
"Duplicates: "
;
qDebug
()
<<
"Duplicates: "
;
for
(
int
i
=
0
;
i
<
duplicates
.
length
();
i
++
){
for
(
int
i
=
0
;
i
<
duplicates
.
length
();
i
++
){
...
...
QTProject/subdivision.h
View file @
960e75ea
...
@@ -20,7 +20,8 @@ private:
...
@@ -20,7 +20,8 @@ private:
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
edgeShader
;
QOpenGLShaderProgram
*
initEdgeComputeShaderProgram
();
QOpenGLShaderProgram
*
initEdgeComputeShaderProgram
();
void
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
);
void
precomputeTables
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices_base
,
QVector
<
unsigned
int
>
&
vertexIndices
,
QVector
<
unsigned
int
>
&
vertexIndicesOffsets
);
void
runShader
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
);
void
runShader
(
Mesh
*
mesh
,
QVector
<
QVector
<
unsigned
int
>
>
&
edgeIndices
);
QVector
<
unsigned
int
>
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
);
QVector
<
unsigned
int
>
fillVector
(
unsigned
int
a
,
unsigned
int
b
,
unsigned
int
c
,
unsigned
int
d
);
...
...
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