Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CGoGN
CGoGN
Commits
31c9ff1a
Commit
31c9ff1a
authored
Feb 07, 2011
by
Sylvain Thery
Browse files
ajout de la parallelisation:
multithreading des algos parallelisation des foreach
parent
1b96b9f3
Changes
42
Expand all
Hide whitespace changes
Inline
Side-by-side
Apps/Tuto/CMakeLists.txt
View file @
31c9ff1a
...
...
@@ -4,6 +4,8 @@ project(Tutos)
#SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm)
#SET (CMAKE_BUILD_TYPE Debug)
SET
(
CMAKE_BUILD_TYPE Release
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNOTOPOWARNING"
)
...
...
@@ -49,3 +51,8 @@ target_link_libraries( tuto_subdivision
add_executable
(
tp_master tp_master.cpp
)
target_link_libraries
(
tp_master
container topology utils algo
${
COMMON_LIBS
}
)
add_executable
(
tuto_mt tuto_mt.cpp
)
target_link_libraries
(
tuto_mt
# containerD topologyD utilsD algoD ${COMMON_LIBS} boost_thread)
container topology utils algo
${
COMMON_LIBS
}
boost_thread
)
Apps/Tuto/tuto_mt.cpp
0 → 100644
View file @
31c9ff1a
This diff is collapsed.
Click to expand it.
include/Algo/Geometry/area.h
View file @
31c9ff1a
...
...
@@ -41,7 +41,7 @@ template <typename PFP>
typename
PFP
::
REAL
convexFaceArea
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
);
template
<
typename
PFP
>
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
=
SelectorTrue
()
,
unsigned
int
th
=
0
)
;
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TREAL
&
face_area
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
...
...
include/Algo/Geometry/area.hpp
View file @
31c9ff1a
...
...
@@ -68,10 +68,10 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename
}
template
<
typename
PFP
>
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
)
typename
PFP
::
REAL
totalArea
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
const
FunctorSelect
&
select
,
unsigned
int
th
)
{
float
area
=
0.0
f
;
DartMarker
mark
(
map
)
;
DartMarker
mark
(
map
,
th
)
;
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
mark
.
isMarked
(
d
))
...
...
include/Algo/Geometry/inclusion.h
View file @
31c9ff1a
...
...
@@ -46,7 +46,7 @@ namespace Geometry
* @param true if the faces of the volume must be in CCW order (default=true)
*/
template
<
typename
PFP
>
bool
isConvex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
bool
CCW
);
bool
isConvex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
bool
CCW
,
unsigned
int
thread
=
0
);
/**
* test if a point is inside a volume
...
...
include/Algo/Geometry/inclusion.hpp
View file @
31c9ff1a
...
...
@@ -39,12 +39,12 @@ namespace Geometry
{
template
<
typename
PFP
>
bool
isConvex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
bool
CCW
)
bool
isConvex
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
positions
,
bool
CCW
,
unsigned
int
thread
)
{
//get all the dart of the volume
std
::
vector
<
Dart
>
vStore
;
FunctorStore
fs
(
vStore
);
map
.
foreach_dart_of_volume
(
d
,
fs
);
map
.
foreach_dart_of_volume
(
d
,
fs
,
thread
);
bool
convex
=
true
;
...
...
include/Algo/Geometry/normal.h
View file @
31c9ff1a
...
...
@@ -46,10 +46,18 @@ template <typename PFP>
typename
PFP
::
VEC3
vertexNormal
(
typename
PFP
::
MAP
&
map
,
Dart
d
,
const
typename
PFP
::
TVEC3
&
position
);
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_normal
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
,
unsigned
int
thread
=
0
)
;
/**
* compute normals of vertices
* @param map the map on which we work
* @param position the position of vertices attribute handler
* @param normal the normal handler in which the result will be stored
* @param the selector
* @ param th the thread number
*/
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
())
;
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
=
SelectorTrue
()
,
unsigned
int
thread
=
0
)
;
}
// namespace Geometry
...
...
include/Algo/Geometry/normal.hpp
View file @
31c9ff1a
...
...
@@ -95,9 +95,9 @@ typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename P
}
template
<
typename
PFP
>
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_normal
,
const
FunctorSelect
&
select
)
void
computeNormalFaces
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
face_normal
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
CellMarker
marker
(
map
,
FACE_CELL
);
CellMarker
marker
(
map
,
FACE_CELL
,
thread
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
...
...
@@ -109,9 +109,9 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit
}
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
)
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
CellMarker
marker
(
map
,
VERTEX_CELL
);
CellMarker
marker
(
map
,
VERTEX_CELL
,
thread
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
{
if
(
select
(
d
)
&&
!
marker
.
isMarked
(
d
))
...
...
include/Algo/Parallel/parallel_foreach.h
0 → 100644
View file @
31c9ff1a
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
"Topology/generic/functor.h"
#ifndef __PARALLEL_FOREACH__
#define __PARALLEL_FOREACH__
namespace
CGoGN
{
namespace
Algo
{
namespace
Parallel
{
/**
* Traverse orbits of a map in parallel. Use topological marker
* Functor application must be independant
* @param map the map
* @param orbit the orbit (VERTEX_ORBIT/EDGE_ORBIT/FACE_ORBIT/..
* @param func the functor to apply
* @param nbth number of thread to use ((use twice as threads of processor)
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
template
<
typename
PFP
>
void
foreach_orbit
(
typename
PFP
::
MAP
&
map
,
unsigned
int
orbit
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
=
8192
,
const
FunctorSelect
&
good
=
SelectorTrue
());
/**
* Traverse cells of a map in parallel. Use embedding marker
* Functor application must be independant
* @param map the map
* @param orbit the cell (VERTEX_CELL/EDGE_CELL/FACE_CELL/..
* @param func the functor to apply
* @param nbth number of thread to use (use twice as threads of processor)
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
template
<
typename
PFP
>
void
foreach_cell
(
typename
PFP
::
MAP
&
map
,
unsigned
int
cell
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
=
8192
,
const
FunctorSelect
&
good
=
SelectorTrue
());
}
}
// end namespace
}
#include
"Algo/Parallel/parallel_foreach.hpp"
#endif
include/Algo/Parallel/parallel_foreach.hpp
0 → 100644
View file @
31c9ff1a
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include
<boost/thread.hpp>
#include
<boost/thread/barrier.hpp>
namespace
CGoGN
{
namespace
Algo
{
namespace
Parallel
{
class
ThreadFunctor
{
protected:
FunctorType
&
m_functor
;
const
std
::
vector
<
Dart
>&
m_darts
;
boost
::
barrier
&
m_sync1
;
boost
::
barrier
&
m_sync2
;
bool
&
m_finished
;
public:
ThreadFunctor
(
FunctorType
&
func
,
const
std
::
vector
<
Dart
>&
vd
,
boost
::
barrier
&
s1
,
boost
::
barrier
&
s2
,
bool
&
finished
)
:
m_functor
(
func
),
m_darts
(
vd
),
m_sync1
(
s1
),
m_sync2
(
s2
),
m_finished
(
finished
)
{}
void
operator
()()
{
while
(
!
m_finished
)
{
for
(
std
::
vector
<
Dart
>::
const_iterator
it
=
m_darts
.
begin
();
it
!=
m_darts
.
end
();
++
it
)
m_functor
(
*
it
);
m_sync1
.
wait
();
m_sync2
.
wait
();
}
}
};
/**
* Traverse orbits of a map in parallel. Use topological marker
* Functor application must be independant
* @param map the map
* @param orbit the orbit (VERTEX_ORBIT/EDGE_ORBIT/FACE_ORBIT/..
* @param func the functor to apply
* @param nbth number of thread to use ((use twice as threads of processor)
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
template
<
typename
PFP
>
void
foreach_orbit
(
typename
PFP
::
MAP
&
map
,
unsigned
int
orbit
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
,
const
FunctorSelect
&
good
)
{
std
::
vector
<
Dart
>
vd
[
nbth
];
boost
::
thread
*
threads
[
nbth
];
DartMarker
dm
(
map
);
Dart
d
=
map
.
begin
();
// nbth new functions, new thread (with good darts !)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
reserve
(
szbuff
);
// fill each vd buffers with 4096 darts
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
)
&&
(
!
dm
.
isMarked
(
d
)))
{
dm
.
markOrbit
(
orbit
,
d
);
vd
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
boost
::
barrier
sync1
(
nbth
+
1
);
boost
::
barrier
sync2
(
nbth
+
1
);
bool
finished
=
false
;
// lauch threads
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
threads
[
i
]
=
new
boost
::
thread
(
ThreadFunctor
(
func
,
vd
[
i
],
sync1
,
sync2
,
finished
));
// and continue to traverse the map
std
::
vector
<
Dart
>
tempo
[
nbth
];
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
reserve
(
szbuff
);
while
(
d
!=
map
.
end
())
{
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
clear
();
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
)
&&
(
!
dm
.
isMarked
(
d
)))
{
dm
.
markOrbit
(
orbit
,
d
);
tempo
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
sync1
.
wait
();
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
swap
(
tempo
[
i
]);
sync2
.
wait
();
}
sync1
.
wait
();
finished
=
true
;
sync2
.
wait
();
//wait for all theads to be finished
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
threads
[
i
]
->
join
();
delete
threads
[
i
];
}
}
/**
* Traverse cells of a map in parallel. Use embedding marker
* Functor application must be independant
* @param map the map
* @param orbit the cell (VERTEX_CELL/EDGE_CELL/FACE_CELL/..
* @param func the functor to apply
* @param nbth number of thread to use (use twice as threads of processor)
* @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion)
* @param good a selector
*/
template
<
typename
PFP
>
void
foreach_cell
(
typename
PFP
::
MAP
&
map
,
unsigned
int
cell
,
FunctorType
&
func
,
unsigned
int
nbth
,
unsigned
int
szbuff
,
const
FunctorSelect
&
good
)
{
std
::
vector
<
Dart
>
vd
[
nbth
];
boost
::
thread
*
threads
[
nbth
];
CellMarker
cm
(
map
,
cell
);
Dart
d
=
map
.
begin
();
// nbth new functions, new thread (with good darts !)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
reserve
(
szbuff
);
// fill each vd buffers with 4096 darts
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
)
&&
(
!
cm
.
isMarked
(
d
)))
{
cm
.
mark
(
d
);
vd
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
boost
::
barrier
sync1
(
nbth
+
1
);
boost
::
barrier
sync2
(
nbth
+
1
);
bool
finished
=
false
;
// lauch threads
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
threads
[
i
]
=
new
boost
::
thread
(
ThreadFunctor
(
func
,
vd
[
i
],
sync1
,
sync2
,
finished
));
// and continue to traverse the map
std
::
vector
<
Dart
>
tempo
[
nbth
];
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
reserve
(
szbuff
);
while
(
d
!=
map
.
end
())
{
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
tempo
[
i
].
clear
();
unsigned
int
nb
=
0
;
while
((
d
!=
map
.
end
())
&&
(
nb
<
nbth
*
szbuff
)
)
{
if
(
good
(
d
)
&&
(
!
cm
.
isMarked
(
d
)))
{
cm
.
mark
(
d
);
tempo
[
nb
%
nbth
].
push_back
(
d
);
nb
++
;
}
map
.
next
(
d
);
}
sync1
.
wait
();
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
vd
[
i
].
swap
(
tempo
[
i
]);
sync2
.
wait
();
}
sync1
.
wait
();
finished
=
true
;
sync2
.
wait
();
//wait for all theads to be finished
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
{
threads
[
i
]
->
join
();
delete
threads
[
i
];
}
}
}
}
// end namespace
}
include/Algo/Render/vbo_MapRender.h
View file @
31c9ff1a
...
...
@@ -161,31 +161,31 @@ public:
* @param tableIndices the table where indices are stored
*/
template
<
typename
PFP
>
void
initTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
;
void
initTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
initTrianglesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
;
void
initTrianglesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
=
0
)
;
/**
* creation of indices table of lines (optimized order)
* @param tableIndices the table where indices are stored
*/
template
<
typename
PFP
>
void
initLines
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
;
void
initLines
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
=
0
)
;
template
<
typename
PFP
>
void
initLinesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
;
void
initLinesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
=
0
)
;
/**
* creation of indices table of points
* @param tableIndices the table where indices are stored
*/
template
<
typename
PFP
>
void
initPoints
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
;
void
initPoints
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
=
0
)
;
/**
* creation of VBO for flat faces rendering
*/
template
<
typename
PFP
>
void
initFlatTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
);
void
initFlatTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
unsigned
int
thread
=
0
);
/**
* initialization of the VBO indices primitives
...
...
@@ -193,7 +193,7 @@ public:
* @param prim primitive to draw: VBO_TRIANGLES, VBO_LINES
*/
template
<
typename
PFP
>
void
initPrimitives
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
prim
,
bool
optimized
=
true
)
;
void
initPrimitives
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
prim
,
bool
optimized
=
true
,
unsigned
int
thread
=
0
)
;
/**
* initialization of the VBO indices primitives
...
...
include/Algo/Render/vbo_MapRender.hpp
View file @
31c9ff1a
...
...
@@ -141,9 +141,9 @@ inline void MapRender_VBO::addTri(typename PFP::MAP& map, Dart d, std::vector<GL
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
void
MapRender_VBO
::
initTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
)
{
DartMarker
m
(
map
);
DartMarker
m
(
map
,
thread
);
tableIndices
.
reserve
(
4
*
map
.
getNbDarts
()
/
3
);
for
(
Dart
dd
=
map
.
begin
();
dd
!=
map
.
end
();
map
.
next
(
dd
))
...
...
@@ -157,10 +157,10 @@ void MapRender_VBO::initTriangles(typename PFP::MAP& map, const FunctorSelect& g
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initTrianglesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
void
MapRender_VBO
::
initTrianglesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
)
{
#define LIST_SIZE 20
DartMarker
m
(
map
);
DartMarker
m
(
map
,
thread
);
// reserve memory for triangles ( nb indices == nb darts )
// and a little bit more
// if lots of polygonal faces, realloc is done by vector
...
...
@@ -213,9 +213,9 @@ void MapRender_VBO::initTrianglesOptimized(typename PFP::MAP& map, const Functor
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initLines
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
void
MapRender_VBO
::
initLines
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
)
{
DartMarker
m
(
map
);
DartMarker
m
(
map
,
thread
);
tableIndices
.
reserve
(
map
.
getNbDarts
());
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
...
...
@@ -230,10 +230,12 @@ void MapRender_VBO::initLines(typename PFP::MAP& map, const FunctorSelect& good,
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initLinesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
void
MapRender_VBO
::
initLinesOptimized
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
)
{
#define LIST_SIZE 20
DartMarker
m
(
map
);
DartMarker
m
(
map
,
thread
);
// reserve memory for edges indices ( nb indices == nb darts)
tableIndices
.
reserve
(
map
.
getNbDarts
());
...
...
@@ -278,9 +280,9 @@ void MapRender_VBO::initLinesOptimized(typename PFP::MAP& map, const FunctorSele
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initPoints
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
)
void
MapRender_VBO
::
initPoints
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
std
::
vector
<
GLuint
>&
tableIndices
,
unsigned
int
thread
)
{
CellMarker
m
(
map
,
VERTEX_ORBIT
)
;
CellMarker
m
(
map
,
VERTEX_ORBIT
,
thread
)
;
tableIndices
.
reserve
(
map
.
getNbDarts
()
/
5
);
for
(
Dart
d
=
map
.
begin
();
d
!=
map
.
end
();
map
.
next
(
d
))
...
...
@@ -294,7 +296,7 @@ void MapRender_VBO::initPoints(typename PFP::MAP& map, const FunctorSelect& good
}
template
<
typename
PFP
>
void
MapRender_VBO
::
initPrimitives
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
prim
,
bool
optimized
)
void
MapRender_VBO
::
initPrimitives
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
,
int
prim
,
bool
optimized
,
unsigned
int
thread
)
{
std
::
vector
<
GLuint
>
tableIndices
;
...
...
@@ -303,27 +305,27 @@ void MapRender_VBO::initPrimitives(typename PFP::MAP& map, const FunctorSelect&
switch
(
prim
)
{
case
FLAT_TRIANGLES
:
initFlatTriangles
<
PFP
>
(
map
,
good
);
initFlatTriangles
<
PFP
>
(
map
,
good
,
thread
);
break
;
case
TRIANGLES
:
if
(
optimized
)
initTrianglesOptimized
<
PFP
>
(
map
,
good
,
tableIndices
);
initTrianglesOptimized
<
PFP
>
(
map
,
good
,
tableIndices
,
thread
);
else
initTriangles
<
PFP
>
(
map
,
good
,
tableIndices
)
;
initTriangles
<
PFP
>
(
map
,
good
,
tableIndices
,
thread
)
;
m_nbIndicesTri
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
TRIANGLE_INDICES
];
break
;
case
LINES
:
if
(
optimized
)
initLinesOptimized
<
PFP
>
(
map
,
good
,
tableIndices
);
initLinesOptimized
<
PFP
>
(
map
,
good
,
tableIndices
,
thread
);
else
initLines
<
PFP
>
(
map
,
good
,
tableIndices
)
;
initLines
<
PFP
>
(
map
,
good
,
tableIndices
,
thread
)
;
m_nbIndicesLines
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
LINE_INDICES
];
break
;
case
POINTS
:
initPoints
<
PFP
>
(
map
,
good
,
tableIndices
);
initPoints
<
PFP
>
(
map
,
good
,
tableIndices
,
thread
);
m_nbIndicesPoints
=
tableIndices
.
size
();
vbo_ind
=
m_VBOBuffers
[
POINT_INDICES
];
break
;
...
...
@@ -342,7 +344,7 @@ void MapRender_VBO::initPrimitives(typename PFP::MAP& map, const FunctorSelect&
template
<
typename
PFP
>
void
MapRender_VBO
::
initFlatTriangles
(
typename
PFP
::
MAP
&
map
,
const
FunctorSelect
&
good
)