Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Bastos de Souza Junior
dual-octree
Commits
4defcfe5
Commit
4defcfe5
authored
Sep 12, 2019
by
Samuel Bastos de Souza Junior
Browse files
commit do dia kk
parent
b2c0d894
Changes
3
Hide whitespace changes
Inline
Side-by-side
Octree.cpp
View file @
4defcfe5
...
...
@@ -183,8 +183,24 @@ void Octree::checkVolume(std::vector<std::vector<uint32_t>>& volume)
}
void
Octree
::
generateTree
()
void
Octree
::
generateTree
(
IO
::
Volume
data
)
{
_data
=
data
;
_dataP
=
std
::
vector
<
unsigned
int
>
(
_data
.
data
.
size
());
for
(
unsigned
int
i
=
0
;
i
<
33
;
i
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
33
;
j
++
)
{
for
(
unsigned
int
k
=
0
;
k
<
33
;
k
++
)
{
unsigned
int
index
=
lin
(
i
,
j
,
k
);
unsigned
int
value
=
0
;
if
(
_data
.
data
[
index
]
<
0.5
)
value
=
0
;
else
value
=
1
;
_dataP
[
index
]
=
value
;
}
}
}
createNode
(
1
,
0
);
std
::
cout
<<
_table
.
size
();
return
;
...
...
@@ -213,28 +229,34 @@ void Octree::createNode(uint32_t key, int level)
bool
Octree
::
divideNode
(
uint32_t
key
,
int
level
)
{
// if(level >= 3)
// return false;
//
// return true;
if
(
key
==
1
)
return
true
;
for
(
unsigned
int
i
=
level
;
i
>=
0
;
i
--
)
{
unsigned
int
aux
=
key
>>
(
3
*
level
);
unsigned
int
octant
=
aux
&
7
;
if
(
level
>=
3
)
return
false
;
unsigned
int
x
,
y
,
z
;
unsigned
int
dem
=
pow2
(
i
);
unsigned
int
ci
=
0
,
cj
=
0
,
ck
=
0
;
findCoord
(
key
,
level
,
ci
,
cj
,
ck
);
if
(
hasComplexEdge
(
ci
,
cj
,
ck
,
level
))
return
true
;
else
std
::
cout
<<
"oi"
;
x
=
(
octant
&
1
)
*
32
/
dem
;
y
=
((
octant
&
2
)
>>
1
)
*
32
/
dem
;
z
=
((
octant
&
4
)
>>
2
)
*
32
/
dem
;
}
return
false
;
}
void
Octree
::
translate
(
unsigned
int
octant
,
int
level
,
int
&
x
,
int
&
y
,
int
&
z
)
void
Octree
::
findCoord
(
uint32_t
key
,
int
level
,
unsigned
int
&
ci
,
unsigned
int
&
cj
,
unsigned
int
&
ck
)
{
for
(
unsigned
int
i
=
1
;
i
<=
level
;
i
++
)
{
unsigned
int
aux
=
key
>>
(
3
*
(
i
-
1
));
unsigned
int
octant
=
aux
&
7
;
unsigned
int
dem
=
32
/
(
pow2
(
i
));
ci
+=
(
octant
&
1
)
*
dem
;
cj
+=
((
octant
&
2
)
>>
1
)
*
dem
;
ck
+=
((
octant
&
4
)
>>
2
)
*
dem
;
}
}
unsigned
int
Octree
::
pow2
(
unsigned
int
pot
)
...
...
@@ -243,4 +265,229 @@ unsigned int Octree::pow2(unsigned int pot)
for
(
unsigned
int
i
=
0
;
i
<
pot
;
i
++
)
n
*=
2
;
return
n
;
}
// USA MESMA CONVENÇAO DE ARESTAS DO DMC
bool
Octree
::
hasComplexEdge
(
unsigned
int
ci
,
unsigned
int
cj
,
unsigned
int
ck
,
int
level
)
{
int
change
=
0
;
unsigned
int
limit
=
32
/
(
pow2
(
level
));
unsigned
int
aux
=
_dataP
[
lin
(
ci
,
cj
,
ck
)];
// EDGE 0
for
(
unsigned
int
i
=
ci
+
1
;
i
<
ci
+
limit
;
i
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
i
,
cj
,
ck
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 2
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
+
limit
,
ck
)];
for
(
unsigned
int
i
=
ci
+
1
;
i
<
ci
+
limit
;
i
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
i
,
cj
+
limit
,
ck
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 8
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
,
ck
+
limit
)];
for
(
unsigned
int
i
=
ci
+
1
;
i
<
ci
+
limit
;
i
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
i
,
cj
,
ck
+
limit
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 10
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
+
limit
,
ck
+
limit
)];
for
(
unsigned
int
i
=
ci
+
1
;
i
<
ci
+
limit
;
i
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
i
,
cj
+
limit
,
ck
+
limit
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 3
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
,
ck
)];
for
(
unsigned
int
j
=
cj
+
1
;
j
<
cj
+
limit
;
j
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
,
j
,
ck
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 3
change
=
0
;
aux
=
_dataP
[
lin
(
ci
+
limit
,
cj
,
ck
)];
for
(
unsigned
int
j
=
cj
+
1
;
j
<
cj
+
limit
;
j
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
+
limit
,
j
,
ck
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 11
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
,
ck
+
limit
)];
for
(
unsigned
int
j
=
cj
+
1
;
j
<
cj
+
limit
;
j
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
,
j
,
ck
+
limit
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 9
change
=
0
;
aux
=
_dataP
[
lin
(
ci
+
limit
,
cj
,
ck
+
limit
)];
for
(
unsigned
int
j
=
cj
+
1
;
j
<
cj
+
limit
;
j
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
+
limit
,
j
,
ck
+
limit
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 4
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
,
ck
)];
for
(
unsigned
int
k
=
ck
+
1
;
k
<
ck
+
limit
;
k
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
,
cj
,
k
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 5
change
=
0
;
aux
=
_dataP
[
lin
(
ci
+
limit
,
cj
,
ck
)];
for
(
unsigned
int
k
=
ck
+
1
;
k
<
ck
+
limit
;
k
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
+
limit
,
cj
,
k
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 6
change
=
0
;
aux
=
_dataP
[
lin
(
ci
+
limit
,
cj
+
limit
,
ck
)];
for
(
unsigned
int
k
=
ck
+
1
;
k
<
ck
+
limit
;
k
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
+
limit
,
cj
+
limit
,
k
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
// EDGE 7
change
=
0
;
aux
=
_dataP
[
lin
(
ci
,
cj
+
limit
,
ck
)];
for
(
unsigned
int
k
=
ck
+
1
;
k
<
ck
+
limit
;
k
++
)
{
unsigned
int
current
=
_dataP
[
lin
(
ci
,
cj
+
limit
,
k
)];
if
(
current
!=
aux
)
if
(
change
==
1
)
return
true
;
else
change
++
;
aux
=
current
;
}
return
false
;
}
unsigned
int
Octree
::
lin
(
unsigned
int
const
x
,
unsigned
int
const
y
,
unsigned
int
const
z
)
{
if
(
x
<
0
||
y
<
0
||
z
<
0
)
return
-
1
;
if
(
x
>=
33
||
y
>=
33
||
z
>=
33
)
return
-
1
;
return
x
+
33
*
(
y
+
33
*
z
);
}
void
Octree
::
printData
()
{
for
(
unsigned
int
k
=
0
;
k
<
33
;
k
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
33
;
j
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
33
;
i
++
)
{
unsigned
int
index
=
lin
(
i
,
j
,
k
);
std
::
cout
<<
_dataP
[
index
];
}
std
::
cout
<<
std
::
endl
;
}
std
::
cout
<<
std
::
endl
;
}
}
\ No newline at end of file
Octree.h
View file @
4defcfe5
#pragma once
#include <map>
#include <vector>
#include "IO.h"
class
Octree
{
public:
...
...
@@ -16,14 +18,22 @@ public:
bool
nodeExists
(
uint32_t
key
);
void
checkVolume
(
std
::
vector
<
std
::
vector
<
uint32_t
>>&
volume
);
void
getCenter
(
uint32_t
key
,
float
x
,
float
y
);
void
generateTree
();
void
generateTree
(
IO
::
Volume
data
);
void
createNode
(
uint32_t
key
,
int
level
);
bool
divideNode
(
uint32_t
key
,
int
level
);
void
translate
(
unsigned
int
octant
,
int
level
,
int
&
x
,
int
&
y
,
int
&
z
);
void
findCoord
(
uint32_t
key
,
int
level
,
unsigned
int
&
x
,
unsigned
int
&
y
,
unsigned
int
&
z
);
unsigned
int
pow2
(
unsigned
int
pot
);
bool
hasComplexEdge
(
unsigned
int
ci
,
unsigned
int
cj
,
unsigned
int
ck
,
int
level
);
unsigned
int
lin
(
unsigned
int
const
x
,
unsigned
int
const
y
,
unsigned
int
const
z
);
void
printData
();
private:
int
_depth
;
std
::
map
<
uint32_t
,
int
>
_table
;
std
::
map
<
uint32_t
,
int
>
_vtable
;
IO
::
Volume
_data
;
std
::
vector
<
unsigned
int
>
_dataP
;
};
\ No newline at end of file
main.cpp
View file @
4defcfe5
#include <iostream>
#include "Octree.h"
#include "IO.h"
int
main
()
{
IO
::
Volume
volume
;
IO
::
loadRawFile
(
volume
,
"/home/sam
uel
/CLionProjects/
dual-octree-hom
e/cube.raw"
,
32
,
32
,
32
);
IO
::
loadRawFile
(
volume
,
"/home/sam
bsj
/CLionProjects/
octre
e/cube.raw"
,
32
,
32
,
32
);
IO
::
extrapolateVolume
(
volume
);
Octree
octree
;
octree
.
generateTree
();
//octree.setParameters(2);
//octree.simulateTree();
// std::vector<int8_t> vertices;
// std::vector<int> levels;
// int level;
// octree.leaf2vert(0b01000111, level, vertices, levels);
// vertices.clear();
// octree.vert2leaf(0b01001110, 2, 2, vertices);
octree
.
generateTree
(
volume
);
//octree.printData();
std
::
vector
<
std
::
vector
<
uint32_t
>>
dualVol
;
octree
.
preprocess
();
...
...
Write
Preview
Supports
Markdown
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