Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
David Cazier
CGoGN
Commits
6afbce7f
Commit
6afbce7f
authored
Sep 03, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update MC + some upgrade in parallel algo
parent
4bb1ab67
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
4 deletions
+166
-4
include/Algo/Geometry/area.hpp
include/Algo/Geometry/area.hpp
+84
-0
include/Algo/MC/marchingcube.h
include/Algo/MC/marchingcube.h
+13
-0
include/Algo/MC/marchingcube.hpp
include/Algo/MC/marchingcube.hpp
+58
-2
include/Algo/Parallel/parallel_foreach.hpp
include/Algo/Parallel/parallel_foreach.hpp
+11
-2
No files found.
include/Algo/Geometry/area.hpp
View file @
6afbce7f
...
@@ -158,6 +158,90 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
...
@@ -158,6 +158,90 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
vertex_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
map
,
d
,
position
)
;
vertex_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
map
,
d
,
position
)
;
}
}
namespace
Parallel
{
template
<
typename
PFP
>
class
FunctorConvexFaceArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
FaceAttribute
<
typename
PFP
::
REAL
>&
m_area
;
public:
FunctorConvexFaceArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_area
[
d
]
=
convexFaceArea
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeAreaFaces
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
FaceAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
FACE
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
}
template
<
typename
PFP
>
class
FunctorVertexOneRingArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VertexAttribute
<
typename
PFP
::
REAL
>&
m_area
;
public:
FunctorVertexOneRingArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_area
[
d
]
=
vertexOneRingArea
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeOneRingAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
}
template
<
typename
PFP
>
class
FunctorVertexVoronoiArea
:
public
FunctorMapThreaded
<
typename
PFP
::
MAP
>
{
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
m_position
;
VertexAttribute
<
typename
PFP
::
REAL
>&
m_area
;
public:
FunctorVertexVoronoiArea
<
PFP
>
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
)
:
FunctorMapThreaded
<
typename
PFP
::
MAP
>
(
map
),
m_position
(
position
),
m_area
(
area
)
{
}
void
run
(
Dart
d
,
unsigned
int
threadID
)
{
m_area
[
d
]
=
vertexVoronoiArea
<
PFP
>
(
this
->
m_map
,
d
,
m_position
)
;
}
};
template
<
typename
PFP
>
void
computeVoronoiAreaVertices
(
typename
PFP
::
MAP
&
map
,
const
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
VertexAttribute
<
typename
PFP
::
REAL
>&
area
,
const
FunctorSelect
&
select
,
unsigned
int
nbth
,
unsigned
int
current_thread
)
{
FunctorConvexFaceArea
<
PFP
>
funct
(
map
,
position
,
area
);
Algo
::
Parallel
::
foreach_cell
<
typename
PFP
::
MAP
,
VERTEX
>
(
map
,
funct
,
nbth
,
false
,
select
,
current_thread
);
}
}
}
// namespace Geometry
}
// namespace Geometry
}
// namespace Algo
}
// namespace Algo
...
...
include/Algo/MC/marchingcube.h
View file @
6afbce7f
...
@@ -54,6 +54,13 @@ protected:
...
@@ -54,6 +54,13 @@ protected:
typedef
typename
PFP
::
MAP
L_MAP
;
typedef
typename
PFP
::
MAP
L_MAP
;
typedef
Dart
L_DART
;
typedef
Dart
L_DART
;
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
unsigned
int
m_zbound
;
unsigned
int
m_sliceGroup
;
EdgeAttribute
<
unsigned
long
long
>*
m_zslice
;
unsigned
int
m_currentZSlice
;
#endif
/**
/**
* voxel image
* voxel image
*/
*/
...
@@ -258,6 +265,12 @@ public:
...
@@ -258,6 +265,12 @@ public:
void
removeFacesOfBoundary
(
VertexAttribute
<
unsigned
char
>&
boundVertices
,
unsigned
int
frameWidth
);
void
removeFacesOfBoundary
(
VertexAttribute
<
unsigned
char
>&
boundVertices
,
unsigned
int
frameWidth
);
void
recalPoints
(
const
Geom
::
Vec3f
&
origin
);
void
recalPoints
(
const
Geom
::
Vec3f
&
origin
);
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
void
setZSliceAttrib
(
EdgeAttribute
<
unsigned
long
long
>*
zsatt
,
unsigned
int
zbound
,
unsigned
int
nbZone
);
#endif
};
};
}
// namespace MC
}
// namespace MC
...
...
include/Algo/MC/marchingcube.hpp
View file @
6afbce7f
...
@@ -46,6 +46,11 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(const char* _cName)
...
@@ -46,6 +46,11 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(const char* _cName)
m_fOrigin
=
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
);
m_fOrigin
=
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
);
m_fScal
=
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
);
m_fScal
=
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
);
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
m_currentZSlice
=
0
;
m_zslice
=
NULL
;
#endif
}
}
...
@@ -58,7 +63,13 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(Image<DataType>* img, Windo
...
@@ -58,7 +63,13 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(Image<DataType>* img, Windo
m_fOrigin
(
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
)),
m_fOrigin
(
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
)),
m_fScal
(
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
)),
m_fScal
(
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
)),
m_brem
(
boundRemoved
)
m_brem
(
boundRemoved
)
{}
{
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
m_currentZSlice
=
0
;
m_zslice
=
NULL
;
#endif
}
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
MarchingCube
(
Image
<
DataType
>*
img
,
L_MAP
*
map
,
VertexAttribute
<
VEC3
>&
position
,
Windowing
<
DataType
>
wind
,
bool
boundRemoved
)
:
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
MarchingCube
(
Image
<
DataType
>*
img
,
L_MAP
*
map
,
VertexAttribute
<
VEC3
>&
position
,
Windowing
<
DataType
>
wind
,
bool
boundRemoved
)
:
...
@@ -70,7 +81,12 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(Image<DataType>* img, L_MAP
...
@@ -70,7 +81,12 @@ MarchingCube<DataType, Windowing, PFP>::MarchingCube(Image<DataType>* img, L_MAP
m_fOrigin
(
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
)),
m_fOrigin
(
typename
PFP
::
VEC3
(
0.0
,
0.0
,
0.0
)),
m_fScal
(
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
)),
m_fScal
(
typename
PFP
::
VEC3
(
1.0
,
1.0
,
1.0
)),
m_brem
(
boundRemoved
)
m_brem
(
boundRemoved
)
{}
{
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
m_currentZSlice
=
0
;
m_zslice
=
NULL
;
#endif
}
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
...
@@ -185,6 +201,10 @@ void MarchingCube<DataType, Windowing, PFP>::simpleMeshing()
...
@@ -185,6 +201,10 @@ void MarchingCube<DataType, Windowing, PFP>::simpleMeshing()
lY
++
;
lY
++
;
}
}
lZ
++
;
lZ
++
;
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
m_currentZSlice
++
;
#endif
m_Buffer
->
nextSlice
();
m_Buffer
->
nextSlice
();
// middles slices
// middles slices
...
@@ -218,6 +238,9 @@ void MarchingCube<DataType, Windowing, PFP>::simpleMeshing()
...
@@ -218,6 +238,9 @@ void MarchingCube<DataType, Windowing, PFP>::simpleMeshing()
}
}
lZ
++
;
lZ
++
;
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
m_currentZSlice
++
;
#endif
m_Buffer
->
nextSlice
();
m_Buffer
->
nextSlice
();
}
}
...
@@ -898,14 +921,34 @@ template< typename DataType, template < typename D2 > class Windowing, typename
...
@@ -898,14 +921,34 @@ template< typename DataType, template < typename D2 > class Windowing, typename
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
setNeighbourSimple
(
L_DART
d1
,
L_DART
d2
)
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
setNeighbourSimple
(
L_DART
d1
,
L_DART
d2
)
{
{
if
(
m_map
->
phi2
(
d1
)
!=
d2
)
if
(
m_map
->
phi2
(
d1
)
!=
d2
)
{
m_map
->
sewFaces
(
d1
,
d2
,
false
);
m_map
->
sewFaces
(
d1
,
d2
,
false
);
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
if
(
m_zslice
!=
NULL
)
{
unsigned
int
val
=
(
m_currentZSlice
-
m_zbound
)
/
m_sliceGroup
;
std
::
cout
<<
"ZSLICE="
<<
val
<<
std
::
endl
;
m_zslice
->
operator
[](
d1
)
=
val
;
}
#endif
}
}
}
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
setNeighbour
(
L_DART
d1
,
L_DART
d2
)
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
setNeighbour
(
L_DART
d1
,
L_DART
d2
)
{
{
if
(
m_map
->
phi2
(
d1
)
!=
d2
)
if
(
m_map
->
phi2
(
d1
)
!=
d2
)
{
m_map
->
sewFaces
(
d1
,
d2
,
false
);
m_map
->
sewFaces
(
d1
,
d2
,
false
);
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
if
(
m_zslice
!=
NULL
)
{
unsigned
int
val
=
(
m_currentZSlice
-
m_zbound
)
/
m_sliceGroup
;
std
::
cout
<<
"ZSLICE="
<<
val
<<
std
::
endl
;
m_zslice
->
operator
[](
d1
)
=
val
;
}
#endif
}
}
}
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
...
@@ -1191,6 +1234,19 @@ void MarchingCube<DataType, Windowing, PFP>::recalPoints(const Geom::Vec3f& orig
...
@@ -1191,6 +1234,19 @@ void MarchingCube<DataType, Windowing, PFP>::recalPoints(const Geom::Vec3f& orig
}
}
}
}
#ifdef MC_WIDTH_EDGE_Z_EMBEDED
template
<
typename
DataType
,
template
<
typename
D2
>
class
Windowing
,
typename
PFP
>
void
MarchingCube
<
DataType
,
Windowing
,
PFP
>::
setZSliceAttrib
(
EdgeAttribute
<
unsigned
long
long
>*
zsatt
,
unsigned
int
zbound
,
unsigned
int
nbZone
)
{
m_zslice
=
zsatt
;
m_zbound
=
zbound
;
m_sliceGroup
=
m_Image
->
getWidthZ
()
/
nbZone
;
}
#endif
}
// namespace MC
}
// namespace MC
}
// namespace Algo
}
// namespace Algo
...
...
include/Algo/Parallel/parallel_foreach.hpp
View file @
6afbce7f
...
@@ -163,7 +163,6 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
...
@@ -163,7 +163,6 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
unsigned
int
nbth
=
funcs
.
size
();
unsigned
int
nbth
=
funcs
.
size
();
std
::
vector
<
Dart
>*
vd
=
new
std
::
vector
<
Dart
>
[
nbth
];
std
::
vector
<
Dart
>*
vd
=
new
std
::
vector
<
Dart
>
[
nbth
];
boost
::
thread
**
threads
=
new
boost
::
thread
*
[
nbth
];
// nbth new functions, new thread (with good darts !)
// nbth new functions, new thread (with good darts !)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
...
@@ -243,8 +242,16 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
...
@@ -243,8 +242,16 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
map
.
addThreadMarker
(
nbth
+
1
-
nbth_prec
);
map
.
addThreadMarker
(
nbth
+
1
-
nbth_prec
);
}
}
boost
::
thread
**
threads
=
new
boost
::
thread
*
[
nbth
];
ThreadFunction
<
MAP
>**
tfs
=
new
ThreadFunction
<
MAP
>*
[
nbth
];
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
nbth
;
++
i
)
threads
[
i
]
=
new
boost
::
thread
(
ThreadFunction
<
MAP
>
(
funcs
[
i
],
vd
[
i
],
sync1
,
sync2
,
finished
,
1
+
i
));
{
tfs
[
i
]
=
new
ThreadFunction
<
MAP
>
(
funcs
[
i
],
vd
[
i
],
sync1
,
sync2
,
finished
,
1
+
i
);
threads
[
i
]
=
new
boost
::
thread
(
boost
::
ref
(
*
(
tfs
[
i
])
)
);
}
// threads[i] = new boost::thread(ThreadFunction<MAP>(funcs[i], vd[i],sync1,sync2, finished,1+i));
// and continue to traverse the map
// and continue to traverse the map
std
::
vector
<
Dart
>*
tempo
=
new
std
::
vector
<
Dart
>
[
nbth
];
std
::
vector
<
Dart
>*
tempo
=
new
std
::
vector
<
Dart
>
[
nbth
];
...
@@ -332,7 +339,9 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
...
@@ -332,7 +339,9 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
{
{
threads
[
i
]
->
join
();
threads
[
i
]
->
join
();
delete
threads
[
i
];
delete
threads
[
i
];
delete
tfs
[
i
];
}
}
delete
[]
tfs
;
delete
[]
threads
;
delete
[]
threads
;
delete
[]
vd
;
delete
[]
vd
;
delete
[]
tempo
;
delete
[]
tempo
;
...
...
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