Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
David Cazier
CGoGN
Commits
45d57d02
Commit
45d57d02
authored
May 07, 2014
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Even/Odd pass traversors
parent
c039fdfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
272 additions
and
3 deletions
+272
-3
Apps/Examples/viewer.cpp
Apps/Examples/viewer.cpp
+84
-2
Apps/Tuto/Traversals/traverse_cells.cpp
Apps/Tuto/Traversals/traverse_cells.cpp
+23
-0
include/Topology/generic/traversor/traversorCell.h
include/Topology/generic/traversor/traversorCell.h
+58
-1
include/Topology/generic/traversor/traversorCell.hpp
include/Topology/generic/traversor/traversorCell.hpp
+107
-0
No files found.
Apps/Examples/viewer.cpp
View file @
45d57d02
...
...
@@ -241,7 +241,7 @@ void Viewer::cb_keyPress(int keycode)
if
(
!
pos2
.
isValid
())
pos2
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"pos2"
)
;
for
(
int
i
=
0
;
i
<
10
;
++
i
)
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
foreach_cell
<
VERTEX
>
(
myMap
,
[
&
]
(
Vertex
d
)
{
...
...
@@ -263,7 +263,46 @@ void Viewer::cb_keyPress(int keycode)
updateGL
();
}
break
;
case
'B'
:
{
Utils
::
Chrono
ch
;
ch
.
start
();
VertexAttribute
<
VEC3
,
MAP_IMPL
>
pos2
=
myMap
.
getAttribute
<
VEC3
,
VERTEX
>
(
"pos2"
)
;
if
(
!
pos2
.
isValid
())
pos2
=
myMap
.
addAttribute
<
VEC3
,
VERTEX
>
(
"pos2"
)
;
foreach_cell_EvenOddd
<
VERTEX
>
(
myMap
,
[
&
]
(
Vertex
d
)
{
pos2
[
d
]
=
VEC3
(
0
,
0
,
0
);
int
nb
=
0
;
foreach_adjacent2
<
FACE
>
(
myMap
,
d
,[
&
](
Vertex
e
)
{
pos2
[
d
]
+=
position
[
e
];
nb
++
;
});
pos2
[
d
]
/=
nb
;
},
[
&
]
(
Vertex
d
)
{
position
[
d
]
=
VEC3
(
0
,
0
,
0
);
int
nb
=
0
;
foreach_adjacent2
<
FACE
>
(
myMap
,
d
,[
&
](
Vertex
e
)
{
position
[
d
]
+=
pos2
[
e
];
nb
++
;
});
position
[
d
]
/=
nb
;
},
3
);
std
::
cout
<<
"Even/Odd "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
Algo
::
Surface
::
Geometry
::
computeNormalVertices
<
PFP
>
(
myMap
,
position
,
normal
)
;
m_positionVBO
->
updateData
(
position
)
;
m_normalVBO
->
updateData
(
normal
)
;
updateGL
();
}
break
;
case
'e'
:
{
...
...
@@ -330,6 +369,49 @@ void Viewer::cb_keyPress(int keycode)
}
break
;
case
'A'
:
{
Utils
::
Chrono
ch
;
ch
.
start
();
TraversorCell
<
MAP
,
VERTEX
>
trav
(
myMap
,
true
);
for
(
unsigned
int
i
=
0
;
i
<
10
;
++
i
)
{
for
(
Cell
<
VERTEX
>
v
=
trav
.
begin
(),
e
=
trav
.
end
();
v
.
dart
!=
e
.
dart
;
v
=
trav
.
next
())
{
// normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap, v, position) ;
normal
[
v
][
0
]
=
0.0
f
;
}
}
std
::
cout
<<
"Timing 10 traversors "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
}
break
;
case
'Z'
:
{
Utils
::
Chrono
ch
;
ch
.
start
();
TraversorCell
<
MAP
,
VERTEX
>
trav
(
myMap
,
true
);
TraversorCellEven
<
MAP
,
VERTEX
>
tr1
(
trav
);
TraversorCellOdd
<
MAP
,
VERTEX
>
tr2
(
trav
);
for
(
unsigned
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
Cell
<
VERTEX
>
v
=
tr1
.
begin
(),
e
=
tr1
.
end
();
v
.
dart
!=
e
.
dart
;
v
=
tr1
.
next
())
{
// normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap, v, position) ;
normal
[
v
][
0
]
=
0.0
f
;
}
for
(
Cell
<
VERTEX
>
v
=
tr2
.
begin
(),
e
=
tr2
.
end
();
v
.
dart
!=
e
.
dart
;
v
=
tr2
.
next
())
{
// normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap, v, position) ;
normal
[
v
][
0
]
=
0.0
f
;
}
}
std
::
cout
<<
"Timing 5 traversors even/odd "
<<
ch
.
elapsed
()
<<
" ms "
<<
std
::
endl
;
}
break
;
default:
...
...
@@ -360,7 +442,7 @@ void Viewer::importMesh(std::string& filename)
position
=
myMap
.
getAttribute
<
PFP
::
VEC3
,
VERTEX
>
(
attrNames
[
0
])
;
}
myMap
.
enableQuickTraversal
<
VERTEX
>
()
;
//
myMap.enableQuickTraversal<VERTEX>() ;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
POINTS
)
;
m_render
->
initPrimitives
<
PFP
>
(
myMap
,
Algo
::
Render
::
GL2
::
LINES
)
;
...
...
Apps/Tuto/Traversals/traverse_cells.cpp
View file @
45d57d02
...
...
@@ -140,5 +140,28 @@ int main()
std
::
cout
<<
"Total="
<<
surf
[
0
]
+
surf
[
1
]
+
surf
[
2
]
+
surf
[
3
]
<<
std
::
endl
;
TraversorV
<
MAP
>
tv0
(
myMap
);
TraversorCellEven
<
MAP
,
VERTEX
>
tv1
(
tv0
);
TraversorCellOdd
<
MAP
,
VERTEX
>
tv2
(
tv0
);
std
::
cout
<<
"PAIR:"
;
for
(
Dart
d
=
tv1
.
begin
();
d
!=
tv1
.
end
();
d
=
tv1
.
next
())
// traverse all vertices (d one dart of each vertex)
std
::
cout
<<
d
<<
" / "
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"IMPPAIR:"
;
for
(
Dart
d
=
tv2
.
begin
();
d
!=
tv2
.
end
();
d
=
tv2
.
next
())
// traverse all vertices (d one dart of each vertex)
std
::
cout
<<
d
<<
" / "
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"PAIR:"
;
for
(
Dart
d
=
tv1
.
begin
();
d
!=
tv1
.
end
();
d
=
tv1
.
next
())
// traverse all vertices (d one dart of each vertex)
std
::
cout
<<
d
<<
" / "
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
"IMPPAIR:"
;
for
(
Dart
d
=
tv2
.
begin
();
d
!=
tv2
.
end
();
d
=
tv2
.
next
())
// traverse all vertices (d one dart of each vertex)
std
::
cout
<<
d
<<
" / "
;
std
::
cout
<<
std
::
endl
;
return
0
;
}
include/Topology/generic/traversor/traversorCell.h
View file @
45d57d02
...
...
@@ -39,7 +39,7 @@ namespace CGoGN
template
<
typename
MAP
,
unsigned
int
ORBIT
>
class
TraversorCell
//: public Traversor<MAP>
{
pr
ivate
:
pr
otected
:
const
MAP
&
m
;
unsigned
int
dimension
;
...
...
@@ -53,6 +53,9 @@ private:
Cell
<
ORBIT
>
current
;
bool
firstTraversal
;
// just for odd/even versions
TraversorCell
(
const
TraversorCell
<
MAP
,
ORBIT
>&
tc
);
public:
TraversorCell
(
const
MAP
&
map
,
bool
forceDartMarker
=
false
,
unsigned
int
thread
=
0
)
;
...
...
@@ -65,10 +68,40 @@ public:
inline
Cell
<
ORBIT
>
next
()
;
inline
void
skip
(
Cell
<
ORBIT
>
c
);
inline
unsigned
int
nbCells
();
}
;
template
<
typename
MAP
,
unsigned
int
ORBIT
>
class
TraversorCellEven
:
public
TraversorCell
<
MAP
,
ORBIT
>
{
public:
TraversorCellEven
(
const
TraversorCell
<
MAP
,
ORBIT
>&
tra
)
:
TraversorCell
<
MAP
,
ORBIT
>
(
tra
)
{}
~
TraversorCellEven
()
{
this
->
cmark
=
NULL
;
this
->
dmark
=
NULL
;
}
inline
Cell
<
ORBIT
>
begin
()
;
}
;
template
<
typename
MAP
,
unsigned
int
ORBIT
>
class
TraversorCellOdd
:
public
TraversorCell
<
MAP
,
ORBIT
>
{
public:
TraversorCellOdd
(
const
TraversorCell
<
MAP
,
ORBIT
>&
tra
)
:
TraversorCell
<
MAP
,
ORBIT
>
(
tra
)
{}
~
TraversorCellOdd
()
{
this
->
cmark
=
NULL
;
this
->
dmark
=
NULL
;
}
inline
Cell
<
ORBIT
>
begin
()
;
inline
Cell
<
ORBIT
>
next
()
;
}
;
/*
* Executes function f on each ORBIT
*/
...
...
@@ -92,10 +125,34 @@ inline void foreach_cell_until(const MAP& map, FUNC f, bool forceDartMarker = fa
break
;
}
template
<
unsigned
int
ORBIT
,
typename
MAP
,
typename
FUNC
,
typename
FUNC2
>
inline
void
foreach_cell_EvenOddd
(
const
MAP
&
map
,
FUNC
f
,
FUNC2
g
,
unsigned
int
nbpasses
=
1
,
bool
forceDartMarker
=
false
,
unsigned
int
thread
=
0
)
{
TraversorCell
<
MAP
,
ORBIT
>
trav
(
map
,
forceDartMarker
,
thread
);
TraversorCellEven
<
MAP
,
VERTEX
>
tr1
(
trav
);
TraversorCellOdd
<
MAP
,
VERTEX
>
tr2
(
trav
);
for
(
unsigned
int
i
=
0
;
i
<
nbpasses
;
++
i
)
{
for
(
Cell
<
ORBIT
>
c
=
trav
.
begin
(),
e
=
trav
.
end
();
c
.
dart
!=
e
.
dart
;
c
=
trav
.
next
())
f
(
c
);
for
(
Cell
<
ORBIT
>
c
=
trav
.
begin
(),
e
=
trav
.
end
();
c
.
dart
!=
e
.
dart
;
c
=
trav
.
next
())
g
(
c
);
}
}
namespace
Parallel
{
template
<
unsigned
int
ORBIT
,
typename
MAP
,
typename
FUNC
>
void
foreach_cell
(
MAP
&
map
,
FUNC
func
,
unsigned
int
nbth
=
0
,
bool
needMarkers
=
true
);
template
<
unsigned
int
ORBIT
,
typename
MAP
,
typename
FUNC_E
,
typename
FUNC_O
>
void
foreach_cell_EO
(
MAP
&
map
,
FUNC_E
funcEven
,
FUNC_O
funcOdd
,
unsigned
int
nbth
=
0
,
bool
needMarkers
=
true
);
}
template
<
typename
MAP
>
...
...
include/Topology/generic/traversor/traversorCell.hpp
View file @
45d57d02
...
...
@@ -54,6 +54,25 @@ TraversorCell<MAP, ORBIT>::TraversorCell(const MAP& map, bool forceDartMarker, u
}
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
unsigned
int
TraversorCell
<
MAP
,
ORBIT
>::
nbCells
()
{
return
m
.
template
getAttributeContainer
<
ORBIT
>().
size
();
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
TraversorCell
<
MAP
,
ORBIT
>::
TraversorCell
(
const
TraversorCell
<
MAP
,
ORBIT
>&
tc
)
:
m
(
tc
.
m
),
dmark
(
tc
.
dmark
),
cmark
(
tc
.
cmark
),
quickTraversal
(
tc
.
quickTraversal
),
current
(
tc
.
current
),
firstTraversal
(
tc
.
firstTraversal
),
dimension
(
tc
.
dimension
)
{
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
TraversorCell
<
MAP
,
ORBIT
>::~
TraversorCell
()
{
...
...
@@ -166,6 +185,94 @@ void TraversorCell<MAP, ORBIT>::skip(Cell<ORBIT> c)
template
<
typename
MAP
,
unsigned
int
ORBIT
>
Cell
<
ORBIT
>
TraversorCellEven
<
MAP
,
ORBIT
>::
begin
()
{
Cell
<
ORBIT
>
c
=
TraversorCell
<
MAP
,
ORBIT
>::
begin
();
this
->
firstTraversal
=
true
;
return
c
;
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
Cell
<
ORBIT
>
TraversorCellOdd
<
MAP
,
ORBIT
>::
begin
()
{
if
(
this
->
quickTraversal
!=
NULL
)
{
this
->
qCurrent
=
this
->
cont
->
begin
()
;
this
->
current
.
dart
=
this
->
quickTraversal
->
operator
[](
this
->
qCurrent
);
}
else
{
this
->
current
.
dart
=
this
->
m
.
begin
()
;
while
(
this
->
current
.
dart
!=
this
->
m
.
end
()
&&
(
this
->
m
.
isBoundaryMarked
(
this
->
dimension
,
this
->
current
.
dart
)
))
this
->
m
.
next
(
this
->
current
.
dart
)
;
if
(
this
->
current
.
dart
==
this
->
m
.
end
())
this
->
current
.
dart
=
NIL
;
else
{
if
(
this
->
dmark
)
this
->
dmark
->
template
unmarkOrbit
<
ORBIT
>(
this
->
current
.
dart
)
;
else
this
->
cmark
->
unmark
(
this
->
current
)
;
}
}
return
this
->
current
;
}
template
<
typename
MAP
,
unsigned
int
ORBIT
>
Cell
<
ORBIT
>
TraversorCellOdd
<
MAP
,
ORBIT
>::
next
()
{
assert
(
this
->
current
.
dart
!=
NIL
);
if
(
this
->
quickTraversal
!=
NULL
)
{
this
->
cont
->
next
(
this
->
qCurrent
)
;
if
(
this
->
qCurrent
!=
this
->
cont
->
end
())
this
->
current
.
dart
=
this
->
quickTraversal
->
operator
[](
this
->
qCurrent
)
;
else
this
->
current
.
dart
=
NIL
;
}
else
{
if
(
this
->
dmark
)
{
bool
ismarked
=
this
->
dmark
->
isMarked
(
this
->
current
.
dart
)
;
while
(
this
->
current
.
dart
!=
NIL
&&
(
!
ismarked
||
this
->
m
.
isBoundaryMarked
(
this
->
dimension
,
this
->
current
.
dart
)))
{
this
->
m
.
next
(
this
->
current
.
dart
)
;
if
(
this
->
current
.
dart
==
this
->
m
.
end
())
this
->
current
.
dart
=
NIL
;
else
ismarked
=
this
->
dmark
->
isMarked
(
this
->
current
.
dart
)
;
}
if
(
this
->
current
.
dart
!=
NIL
)
this
->
dmark
->
template
unmarkOrbit
<
ORBIT
>(
this
->
current
.
dart
)
;
}
else
{
bool
ismarked
=
this
->
cmark
->
isMarked
(
this
->
current
)
;
while
(
this
->
current
.
dart
!=
NIL
&&
(
!
ismarked
||
this
->
m
.
isBoundaryMarked
(
this
->
dimension
,
this
->
current
.
dart
)
))
{
this
->
m
.
next
(
this
->
current
.
dart
)
;
if
(
this
->
current
.
dart
==
this
->
m
.
end
())
this
->
current
.
dart
=
NIL
;
else
ismarked
=
this
->
cmark
->
isMarked
(
this
->
current
)
;
}
if
(
this
->
current
.
dart
!=
NIL
)
this
->
cmark
->
unmark
(
this
->
current
)
;
}
}
return
this
->
current
;
}
namespace
Parallel
{
...
...
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